Here are the examples of the java api org.springframework.context.ApplicationContext.getResource() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
112 Examples
19
View Source File : RedisAutoConfig.java
License : Apache License 2.0
Project Creator : yanghaiji
License : Apache License 2.0
Project Creator : yanghaiji
private InputStream getConfigStream() throws IOException {
Resource resource = ctx.getResource(redissonProperties.getConfig());
InputStream is = resource.getInputStream();
return is;
}
19
View Source File : SpringContextUtil.java
License : Apache License 2.0
Project Creator : Xiao-Y
License : Apache License 2.0
Project Creator : Xiao-Y
/**
* 获取指定资源
*
* @param name
* @return org.springframework.core.io.Resource
* @author billow
* @date 2019/8/11 12:05
*/
public static Resource getResource(String name) {
checkApplicationContext();
return applicationContext.getResource(name);
}
19
View Source File : RedissonAutoConfiguration.java
License : Apache License 2.0
Project Creator : tiankong0310
License : Apache License 2.0
Project Creator : tiankong0310
/**
* 自定义redission配置
*
* @return
* @throws IOException
*/
private InputStream getConfigStream() throws IOException {
org.springframework.core.io.Resource resource = ctx.getResource(redissonProperties.getConfig());
InputStream is = resource.getInputStream();
return is;
}
19
View Source File : FrontendController.java
License : Apache License 2.0
Project Creator : saturnism
License : Apache License 2.0
Project Creator : saturnism
// ".+" is necessary to capture URI with filename extension
@GetMapping("/image/{filename:.+}")
public ResponseEnreplacedy<Resource> file(@PathVariable String filename) {
String bucket = "gs://" + projectIdProvider.getProjectId();
// Use "gs://" URI to construct a Spring Resource object
Resource image = context.getResource(bucket + "/" + filename);
// Send it back to the client
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.IMAGE_JPEG);
return new ResponseEnreplacedy<>(image, headers, HttpStatus.OK);
}
19
View Source File : EmailTemplateContent.java
License : GNU Affero General Public License v3.0
Project Creator : kamax-matrix
License : GNU Affero General Public License v3.0
Project Creator : kamax-matrix
private Resource get(String path) {
return app.getResource(path);
}
19
View Source File : NGBRegistrationUtils.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
public String resolveFilePath(String filename) throws IOException {
context.getResource("clreplacedpath:templates");
return resource.getFile().getAbsolutePath() + filename;
}
19
View Source File : AbstractManagerTest.java
License : Apache License 2.0
Project Creator : epam
License : Apache License 2.0
Project Creator : epam
public File getTestFile(String path) throws IOException {
return context.getResource(TEMPLATES_PATH + path).getFile();
}
19
View Source File : ApplicationUtils.java
License : Apache License 2.0
Project Creator : alibaba
License : Apache License 2.0
Project Creator : alibaba
public static Resource getResource(String location) {
return applicationContext.getResource(location);
}
18
View Source File : ClasspathReportProvider.java
License : Apache License 2.0
Project Creator : youseries
License : Apache License 2.0
Project Creator : youseries
@Override
public InputStream loadReport(String file) {
Resource resource = applicationContext.getResource(file);
try {
return resource.getInputStream();
} catch (IOException e) {
String newFileName = null;
if (file.startsWith("clreplacedpath:")) {
newFileName = "clreplacedpath*:" + file.substring(10, file.length());
} else if (file.startsWith("clreplacedpath*:")) {
newFileName = "clreplacedpath:" + file.substring(11, file.length());
}
if (newFileName != null) {
try {
return applicationContext.getResource(file).getInputStream();
} catch (IOException ex) {
throw new ReportException(e);
}
}
throw new ReportException(e);
}
}
18
View Source File : DefaultImageProvider.java
License : Apache License 2.0
Project Creator : youseries
License : Apache License 2.0
Project Creator : youseries
@Override
public InputStream getImage(String path) {
try {
if (path.startsWith(ResourceUtils.CLreplacedPATH_URL_PREFIX) || path.startsWith("/WEB-INF")) {
return applicationContext.getResource(path).getInputStream();
} else {
path = baseWebPath + path;
return new FileInputStream(path);
}
} catch (IOException e) {
throw new ReportComputeException(e);
}
}
18
View Source File : XMapSpringUtil.java
License : Apache License 2.0
Project Creator : sofastack
License : Apache License 2.0
Project Creator : sofastack
/**
* Get spring object
* @param type type
* @param beanName bean name
* @param applicationContext application context
* @return spring object
*/
public static Object getSpringObject(Clreplaced type, String beanName, ApplicationContext applicationContext) {
if (type == Resource.clreplaced) {
return applicationContext.getResource(beanName);
} else {
return applicationContext.getBean(beanName, type);
}
}
18
View Source File : SpringResourceService.java
License : Apache License 2.0
Project Creator : hekate-io
License : Apache License 2.0
Project Creator : hekate-io
@Override
public InputStream load(String path) throws ResourceLoadingException {
try {
return ctx.getResource(path).getInputStream();
} catch (IOException e) {
throw new ResourceLoadingException("Failed to load resource [path=" + path + ']', e);
}
}
18
View Source File : VcfManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private void testRegisterInvalidFile(String path, String expectedMessage) throws IOException {
String errorMessage = "";
try {
Resource resource = context.getResource(path);
FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
request.setPath(resource.getFile().getAbsolutePath());
request.setReferenceId(referenceId);
vcfManager.registerVcfFile(request);
} catch (TribbleException | IllegalArgumentException | replacedertionError e) {
errorMessage = e.getMessage();
}
// check that we received an appropriate message
replacedert.replacedertTrue(errorMessage.contains(expectedMessage));
}
18
View Source File : VcfManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
/*@After
public void clear() throws IOException {
String contentsDir = fileManager.getBaseDirPath();
File file = new File(contentsDir);
if (file.exists() && file.isDirectory()) {
FileUtils.deleteDirectory(file);
}
}*/
private String readFile(String filename) throws IOException {
Resource resource = context.getResource("clreplacedpath:externaldb//data//" + filename);
String pathStr = resource.getFile().getPath();
return new String(Files.readAllBytes(Paths.get(pathStr)), Charset.defaultCharset());
}
18
View Source File : VcfManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private VcfFile testSave(String filePath) throws IOException, InterruptedException {
Resource resource = context.getResource(filePath);
return registerVcf(resource, referenceId, vcfManager, PRETTY_NAME);
}
18
View Source File : ProjectManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private VcfFile addVcfFile(String name, String path) throws IOException {
Resource resource = context.getResource(path);
FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
request.setReferenceId(referenceId);
request.setName(name);
request.setPath(resource.getFile().getAbsolutePath());
return vcfManager.registerVcfFile(request);
}
18
View Source File : MafManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private void testRegisterInvalidFile(String path, String expectedMessage) throws IOException {
String errorMessage = "";
try {
Resource resource = context.getResource(path);
IndexedFileRegistrationRequest request = new IndexedFileRegistrationRequest();
request.setPath(resource.getFile().getAbsolutePath());
request.setReferenceId(referenceId);
mafManager.registerMafFile(request);
} catch (TribbleException | IllegalArgumentException | replacedertionError e) {
errorMessage = e.getMessage();
}
// check that we received an appropriate message
replacedert.replacedertTrue(errorMessage.contains(expectedMessage));
}
18
View Source File : GffManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private String readFile(String filename) throws IOException {
Resource resource = context.getResource("clreplacedpath:externaldb//data//" + filename);
String pathStr = resource.getFile().getPath();
return new String(Files.readAllBytes(Paths.get(pathStr)), Charset.defaultCharset());
}
18
View Source File : UniprotDataManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private String readFile(String filename) throws IOException {
Resource resource = context.getResource("clreplacedpath:externaldb//data//" + filename);
String pathStr = resource.getFile().getPath();
String content = new String(Files.readAllBytes(Paths.get(pathStr)), Charset.defaultCharset());
return content;
}
18
View Source File : BlatSearchManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private String readMockedResponse() throws IOException {
Resource resource = context.getResource("clreplacedpath:blat//data//testResponse.html");
String pathStr = resource.getFile().getPath();
return new String(Files.readAllBytes(Paths.get(pathStr)), Charset.defaultCharset());
}
18
View Source File : UrlTestingUtils.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
public static Server getFileServer(ApplicationContext context) {
Resource resource = context.getResource("clreplacedpath:templates");
Server server = new Server(UrlTestingUtils.TEST_FILE_SERVER_PORT);
server.setHandler(new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String uri = baseRequest.getRequestURI();
LOGGER.info(uri);
File file = new File(resource.getFile().getAbsolutePath() + uri);
MultipartFileSender fileSender = MultipartFileSender.fromFile(file);
try {
fileSender.with(request).with(response).serveResource();
} catch (IOException e) {
e.printStackTrace();
}
}
});
return server;
}
18
View Source File : SPIDIntegrationService.java
License : GNU Affero General Public License v3.0
Project Creator : consiglionazionaledellericerche
License : GNU Affero General Public License v3.0
Project Creator : consiglionazionaledellericerche
public KeyStore getKeyStore() {
KeyStore ks = null;
char[] preplacedword = idpConfiguration.getSpidProperties().getKeystore().getPreplacedword().toCharArray();
// Get Default Instance of KeyStore
try {
ks = KeyStore.getInstance(KeyStore.getDefaultType());
} catch (KeyStoreException e) {
LOGGER.error("Error while Intializing Keystore", e);
}
final Resource resource = appContext.getResource(idpConfiguration.getSpidProperties().getKeystore().getPath());
// Load KeyStore from input stream
try (InputStream keystoreInputStream = resource.getInputStream()) {
ks.load(keystoreInputStream, preplacedword);
} catch (NoSuchAlgorithmException | CertificateException | IOException e) {
LOGGER.error("Failed to Load the KeyStore:: ", e);
}
return ks;
}
18
View Source File : SpringKeyResourceLoader.java
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
License : GNU Lesser General Public License v3.0
Project Creator : Alfresco
/**
* Helper method to switch between application context resource loading or
* simpler current clreplacedloader resource loading.
*/
private InputStream getSafeInputStream(String location) {
try {
final InputStream is;
if (applicationContext != null) {
Resource resource = applicationContext.getResource(location);
if (resource.exists()) {
is = new BufferedInputStream(resource.getInputStream());
} else {
// Fall back to conventional loading
File file = ResourceUtils.getFile(location);
if (file.exists()) {
is = new BufferedInputStream(new FileInputStream(file));
} else {
is = null;
}
}
} else {
// Load conventionally (i.e. we are in a unit test)
File file = ResourceUtils.getFile(location);
if (file.exists()) {
is = new BufferedInputStream(new FileInputStream(file));
} else {
is = null;
}
}
return is;
} catch (IOException e) {
return null;
}
}
17
View Source File : FileResourceProvider.java
License : Apache License 2.0
Project Creator : youseries
License : Apache License 2.0
Project Creator : youseries
@Override
public Resource provide(String path, String version) {
try {
InputStream inputStream = applicationContext.getResource(path).getInputStream();
String content = IOUtils.toString(inputStream, "utf-8");
IOUtils.closeQuietly(inputStream);
return new Resource(content, path);
} catch (IOException e) {
throw new RuleException(e);
}
}
17
View Source File : ResourceHttpRequestHandler.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private void resolveResourceLocations() {
if (CollectionUtils.isEmpty(this.locationValues)) {
return;
} else if (!CollectionUtils.isEmpty(this.locations)) {
throw new IllegalArgumentException("Please set either Resource-based \"locations\" or " + "String-based \"locationValues\", but not both.");
}
ApplicationContext applicationContext = obtainApplicationContext();
for (String location : this.locationValues) {
if (this.embeddedValueResolver != null) {
String resolvedLocation = this.embeddedValueResolver.resolveStringValue(location);
if (resolvedLocation == null) {
throw new IllegalArgumentException("Location resolved to null: " + location);
}
location = resolvedLocation;
}
Charset charset = null;
location = location.trim();
if (location.startsWith(URL_RESOURCE_CHARSET_PREFIX)) {
int endIndex = location.indexOf(']', URL_RESOURCE_CHARSET_PREFIX.length());
if (endIndex == -1) {
throw new IllegalArgumentException("Invalid charset syntax in location: " + location);
}
String value = location.substring(URL_RESOURCE_CHARSET_PREFIX.length(), endIndex);
charset = Charset.forName(value);
location = location.substring(endIndex + 1);
}
Resource resource = applicationContext.getResource(location);
this.locations.add(resource);
if (charset != null) {
if (!(resource instanceof UrlResource)) {
throw new IllegalArgumentException("Unexpected charset for non-UrlResource: " + resource);
}
this.locationCharsets.put(resource, charset);
}
}
}
17
View Source File : FileContextUtil.java
License : Apache License 2.0
Project Creator : Nepxion
License : Apache License 2.0
Project Creator : Nepxion
public static File getFile(ApplicationContext applicationContext, String path) {
if (StringUtils.isEmpty(path)) {
throw new IllegalArgumentException("File path isn't set");
}
LOG.info("File path is {}", path);
try {
String filePath = applicationContext.getEnvironment().resolvePlaceholders(path);
return applicationContext.getResource(filePath).getFile();
} catch (Exception e) {
LOG.warn("File [{}] isn't found or invalid, ignore to load...", path);
}
return null;
}
17
View Source File : FileContextUtil.java
License : Apache License 2.0
Project Creator : Nepxion
License : Apache License 2.0
Project Creator : Nepxion
public static InputStream getInputStream(ApplicationContext applicationContext, String path) {
if (StringUtils.isEmpty(path)) {
throw new IllegalArgumentException("File path isn't set");
}
LOG.info("File path is {}", path);
try {
String filePath = applicationContext.getEnvironment().resolvePlaceholders(path);
return applicationContext.getResource(filePath).getInputStream();
} catch (Exception e) {
LOG.warn("File [{}] isn't found or invalid, ignore to load...", path);
}
return null;
}
17
View Source File : OptionsMetadata.java
License : GNU General Public License v3.0
Project Creator : MoeraOrg
License : GNU General Public License v3.0
Project Creator : MoeraOrg
@PostConstruct
public void init() throws IOException {
types = applicationContext.getBeansWithAnnotation(OptionType.clreplaced).values().stream().filter(bean -> bean instanceof OptionTypeBase).map(bean -> (OptionTypeBase) bean).collect(Collectors.toMap(OptionTypeBase::getTypeName, Function.idenreplacedy()));
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
List<OptionDescriptor> data = mapper.readValue(applicationContext.getResource("clreplacedpath:options.yaml").getInputStream(), new TypeReference<>() {
});
descriptors = data.stream().collect(Collectors.toMap(OptionDescriptor::getName, Function.idenreplacedy()));
typeModifiers = data.stream().filter(desc -> desc.getModifiers() != null).filter(desc -> types.get(desc.getType()) != null).collect(Collectors.toMap(OptionDescriptor::getName, desc -> types.get(desc.getType()).parseTypeModifiers(desc.getModifiers())));
}
17
View Source File : SpringBootProvider.java
License : MIT License
Project Creator : limberest
License : MIT License
Project Creator : limberest
@Override
public String loadResource(String path) throws IOException {
Resource res = appContext.getResource("clreplacedpath:" + path);
if (res == null)
return null;
try (InputStream is = res.getInputStream()) {
if (is == null)
return null;
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int bytesRead;
byte[] data = new byte[1024];
while ((bytesRead = is.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, bytesRead);
}
buffer.flush();
return new String(buffer.toByteArray());
}
}
17
View Source File : AbstractExtendedApplicationContextInitializer.java
License : Apache License 2.0
Project Creator : igloo-project
License : Apache License 2.0
Project Creator : igloo-project
/**
* <p>Map a location to the corresponding resource. If resource is not readable, either throw an exception or
* ignore the location. Ignored locations map to null.</p>
*
* <p>If you map a collection, you need to filter null values after mapping.</p>
*/
private static Function2<String, Resource> resourceFromLocation(ApplicationContext applicationContext, boolean throwErrorIfNotReadable) {
return location -> {
String resolvedLocation = applicationContext.getEnvironment().resolveRequiredPlaceholders(location);
if (applicationContext.getResource(resolvedLocation).isReadable()) {
LOGGER.debug("Configuration {} detected and added", location);
return applicationContext.getResource(resolvedLocation);
} else if (throwErrorIfNotReadable) {
throw new IllegalStateException(String.format("Configuration %s does not exist or is not readable", location));
} else {
LOGGER.warn("Configuration {} not readable; ignored", location);
return null;
}
};
}
17
View Source File : DocumentParser_basic_Test.java
License : MIT License
Project Creator : graphql-java-generator
License : MIT License
Project Creator : graphql-java-generator
@Test
@Execution(ExecutionMode.CONCURRENT)
void test_parseOneDoreplacedent_basic() {
// Preparation
Resource resource = ctx.getResource("/basic.graphqls");
doc = parser.parseDoreplacedent(graphqlTestHelper.readSchema(resource));
// Go, go, go
doreplacedentParser.parseOneDoreplacedent(doc);
// Verification
int nbClreplacedes = (doreplacedentParser.getQueryType() == null ? 0 : 1) + (doreplacedentParser.getSubscriptionType() == null ? 0 : 1) + (doreplacedentParser.getMutationType() == null ? 0 : 1) + doreplacedentParser.getObjectTypes().size() + doreplacedentParser.getEnumTypes().size() + doreplacedentParser.getInterfaceTypes().size();
replacedertEquals(2, nbClreplacedes);
}
17
View Source File : OpenApiServiceImpl.java
License : Apache License 2.0
Project Creator : gemini-projects
License : Apache License 2.0
Project Creator : gemini-projects
private void createDefaultServiceInfoResource(File serviceInfoResource) throws IOException {
Resource defaultInfoService = context.getResource(SERVICE_INFO_DEFAULT_RESOURCE);
serviceInfoResource.getParentFile().mkdirs();
Files.copy(defaultInfoService.getInputStream(), serviceInfoResource.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
17
View Source File : WigProcessorTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private boolean testRegisterInvalidFile(String path) throws IOException {
try {
Resource resource = context.getResource(path);
IndexedFileRegistrationRequest request = new IndexedFileRegistrationRequest();
request.setPath(resource.getFile().getAbsolutePath());
request.setReferenceId(testReference.getId());
wigManager.registerWigFile(request);
} catch (IllegalArgumentException | replacedertionError e) {
return true;
}
return false;
}
17
View Source File : MafManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testRegisterExtraChromosome() throws IOException, InterruptedException, NoSuchAlgorithmException {
Resource resource = context.getResource("clreplacedpath:templates/invalid/extra_chr.maf");
IndexedFileRegistrationRequest request = new IndexedFileRegistrationRequest();
request.setPath(resource.getFile().getAbsolutePath());
request.setReferenceId(referenceId);
MafFile mafFile = mafManager.registerMafFile(request);
// check that name is not reserved
replacedert.replacedertTrue(mafFile != null);
}
17
View Source File : GffManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.clreplaced)
public void testRegisterGffFail() throws IOException, FeatureIndexException, InterruptedException, NoSuchAlgorithmException {
Resource resource = context.getResource("clreplacedpath:templates/Felis_catus.Felis_catus_6.2.81.gtf");
FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
request.setReferenceId(referenceId);
request.setPath(resource.getFile().getAbsolutePath());
boolean failed = true;
try {
gffManager.registerGeneFile(request);
} catch (TribbleException.MalformedFeatureFile e) {
failed = false;
}
replacedert.replacedertFalse("Not failed on unsorted file", failed);
/*Resource fakeIndex = context.getResource("clreplacedpath:templates/fake_gtf_index.tbi");
request.setIndexPath(fakeIndex.getFile().getAbsolutePath());
failed = true;
try {
gffManager.registerGeneFile(request);
} catch (Exception e) {
failed = false;
}
replacedert.replacedertFalse("Not failed on unsorted file", failed);*/
}
17
View Source File : GffManagerUnitTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
@Before
public void setup() throws IOException {
MockitoAnnotations.initMocks(this);
Resource resource = context.getResource("clreplacedpath:templates/genes_sorted.gtf");
try (AbstractFeatureReader<GeneFeature, LineIterator> reader = AbstractEnhancedFeatureReader.getFeatureReader(resource.getFile().getAbsolutePath(), new GffCodec(GffCodec.GffType.GTF), false, indexCache)) {
featureList = reader.iterator().toList();
}
}
17
View Source File : TestContextConfiguration3.java
License : Apache License 2.0
Project Creator : andrehertwig
License : Apache License 2.0
Project Creator : andrehertwig
@Bean(name = QuartzSchedulerAutoConfiguration.QUARTZ_PROPERTIES_BEAN_NAME)
public Properties quartzProperties(@Autowired ApplicationContext applicationContext, @Autowired QuartzSchedulerProperties properties) throws IOException {
System.out.println("my overridden quartz.properties loading");
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(applicationContext.getResource("clreplacedpath:overriddenQuartzScheduler.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
16
View Source File : BerkeleyAccessorFactory.java
License : Apache License 2.0
Project Creator : HongZhaoHua
License : Apache License 2.0
Project Creator : HongZhaoHua
@Override
public BerkeleyAccessor getObject() {
if (accessor == null) {
Resource resource = applicationContext.getResource(properties);
Properties properties = new Properties();
try {
properties.load(resource.getInputStream());
} catch (IOException exception) {
throw new IllegalArgumentException("无法获取配置文件[" + properties + "]");
}
accessor = new BerkeleyAccessor(clreplacedes, directory, properties, readOnly, writeDelay, temporary, versionKeep);
}
return accessor;
}
16
View Source File : ResourceSchemaStringProvider.java
License : MIT License
Project Creator : graphql-java-generator
License : MIT License
Project Creator : graphql-java-generator
public List<org.springframework.core.io.Resource> schemas() throws IOException {
String fullPathPattern;
if (configuration.getSchemaFilePattern().startsWith("clreplacedpath:")) {
// We take the file pattern as is
fullPathPattern = configuration.getSchemaFilePattern();
} else {
if (configuration.getPluginLogger().isDebugEnabled()) {
configuration.getPluginLogger().debug("Before getCanonicalPath(" + configuration.getSchemaFileFolder() + ")");
configuration.getSchemaFileFolder().getCanonicalPath();
}
fullPathPattern = "file:///" + configuration.getSchemaFileFolder().getCanonicalPath() + ((configuration.getSchemaFilePattern().startsWith("/") || (configuration.getSchemaFilePattern().startsWith("\\"))) ? "" : "/") + configuration.getSchemaFilePattern();
}
// Let's look for the GraphQL schema files
List<org.springframework.core.io.Resource> ret = new ArrayList<>(Arrays.asList(applicationContext.getResources(fullPathPattern)));
// A little debug may be useful
if (configuration.getPluginLogger().isDebugEnabled() && ret.size() > 0) {
configuration.getPluginLogger().debug("The GraphQL schema file found are: ");
for (Resource schema : ret) {
configuration.getPluginLogger().debug(" * " + schema.getURI().toString());
}
}
// We musts have found at least one schema
if (ret.size() == 0) {
throw new RuntimeException("No GraphQL schema found (the searched file pattern is: '" + configuration.getSchemaFilePattern() + "')");
}
// In client mode, we need to read the introspection schema
if (configuration instanceof GenerateCodeCommonConfiguration && ((GenerateCodeCommonConfiguration) configuration).getMode().equals(PluginMode.client)) {
org.springframework.core.io.Resource introspection = applicationContext.getResource(INTROSPECTION_SCHEMA);
if (!introspection.exists()) {
throw new IOException("The introspection GraphQL schema doesn't exist (" + INTROSPECTION_SCHEMA + ")");
}
ret.add(introspection);
}
return ret;
}
16
View Source File : TestAbstractFeatureReader.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
@Test
public void testIndexedGZIPVCF() throws IOException {
String vcfPath = "clreplacedpath:templates/test.vcf";
String testPath = context.getResource(vcfPath).getFile().getAbsolutePath();
VCFCodec codec = new VCFCodec();
try (TribbleIndexedFeatureReader<VariantContext, LineIterator> featureReader = new TribbleIndexedFeatureReader<>(testPath, codec, false, indexCache)) {
final CloseableTribbleIterator<VariantContext> localIterator = featureReader.iterator();
int count = 0;
for (final Feature feature : featureReader.iterator()) {
localIterator.next();
replacedertNotNull(feature);
count++;
}
replacedertEquals(count, 5);
}
}
16
View Source File : DiskBasedListTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
@Test
public void serialisationTest() throws IOException, ClreplacedNotFoundException {
Resource resource = context.getResource("clreplacedpath:templates/samples.vcf");
List<VcfIndexEntry> writtenEntries = new ArrayList<>();
List<VcfIndexEntry> diskBasedList = new DiskBasedList<VcfIndexEntry>(MAX_IN_MEMORY_ITEMS_COUNT).adaptToList();
try (FeatureReader<VariantContext> reader = AbstractFeatureReader.getFeatureReader(resource.getFile().getAbsolutePath(), new VCFCodec(), false, indexCache)) {
for (VariantContext variantContext : reader.iterator()) {
VcfIndexEntry vcfIndexEntry = createTestEntry(variantContext);
writtenEntries.add(vcfIndexEntry);
diskBasedList.add(vcfIndexEntry);
}
}
for (int i = 0; i < 3; i++) {
replacedertLists(writtenEntries, diskBasedList);
}
}
16
View Source File : VcfManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.clreplaced)
public void testRegisterFile() throws IOException {
Resource resource = context.getResource(CLreplacedPATH_TEMPLATES_FELIS_CATUS_VCF);
FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
request.setReferenceId(referenceId);
request.setPath(resource.getFile().getAbsolutePath());
VcfFile vcfFile = vcfManager.registerVcfFile(request);
replacedert.replacedertNotNull(vcfFile);
replacedert.replacedertNotNull(vcfFile.getId());
Track<Variation> trackResult = testLoad(vcfFile, 1D, true);
replacedert.replacedertFalse(trackResult.getBlocks().isEmpty());
VcfFile filesByReference = vcfFileManager.load(vcfFile.getId());
replacedert.replacedertNotNull(filesByReference);
}
16
View Source File : ProteinSequenceManagerIntegrationTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private Reference prepareReference(final String fileName) throws IOException {
Resource resource = context.getResource(fileName);
ReferenceRegistrationRequest registerReferenceRequest = new ReferenceRegistrationRequest();
registerReferenceRequest.setName("A1");
registerReferenceRequest.setPath(resource.getFile().getPath());
return referenceManager.registerGenome(registerReferenceRequest);
}
16
View Source File : GffManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testDeleteGeneWithIndex() throws IOException, InterruptedException, FeatureIndexException, NoSuchAlgorithmException, GeneReadingException {
Resource resource = context.getResource(GENES_SORTED_GTF_PATH);
FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
request.setReferenceId(referenceId);
request.setPath(resource.getFile().getAbsolutePath());
GeneFile geneFile = gffManager.registerGeneFile(request);
replacedert.replacedertNotNull(geneFile);
replacedert.replacedertNotNull(geneFile.getId());
try {
referenceGenomeManager.updateReferenceAnnotationFile(referenceId, geneFile.getBioDataItemId(), false);
geneFileManager.delete(geneFile);
// expected exception
} catch (IllegalArgumentException e) {
// remove file correctly as expected
referenceGenomeManager.updateReferenceAnnotationFile(referenceId, geneFile.getBioDataItemId(), true);
geneFileManager.delete(geneFile);
}
}
16
View Source File : BedManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private void testRegisterInvalidBed(String path, String expectedMessage) throws IOException {
String errorMessage = "";
try {
Resource resource = context.getResource(path);
IndexedFileRegistrationRequest request = new IndexedFileRegistrationRequest();
request.setPath(resource.getFile().getAbsolutePath());
request.setReferenceId(referenceId);
bedManager.registerBed(request);
} catch (TribbleException | IllegalArgumentException | replacedertionError e) {
errorMessage = e.getMessage();
}
// check that we received an appropriate message
replacedert.replacedertTrue(errorMessage.contains(expectedMessage));
}
16
View Source File : BamManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
private void registerFileWithoutSOTag(String path) throws IOException {
Resource resource = context.getResource(path);
IndexedFileRegistrationRequest request = new IndexedFileRegistrationRequest();
request.setPath(resource.getFile().getAbsolutePath());
request.setIndexPath(resource.getFile().getAbsolutePath() + BAI_EXTENSION);
request.setName(TEST_NSAME);
request.setReferenceId(testReference.getId());
request.setType(BiologicalDataItemResourceType.FILE);
bamManager.registerBam(request);
}
15
View Source File : StaticImageProcessor.java
License : Apache License 2.0
Project Creator : youseries
License : Apache License 2.0
Project Creator : youseries
@Override
public InputStream getImage(String path) {
Collection<ImageProvider> imageProviders = Utils.getImageProviders();
ImageProvider targetImageProvider = null;
for (ImageProvider provider : imageProviders) {
if (provider.support(path)) {
targetImageProvider = provider;
break;
}
}
if (targetImageProvider == null) {
throw new ReportComputeException("Unsupport image path :" + path);
}
try {
InputStream inputStream = targetImageProvider.getImage(path);
return inputStream;
} catch (Exception ex) {
ApplicationContext applicationContext = Utils.getApplicationContext();
log.warning("Image [" + path + "] not exist,use default picture.");
String imageNotExistPath = "clreplacedpath:com/bstek/ureport/image/image-not-exist.jpg";
try {
return applicationContext.getResource(imageNotExistPath).getInputStream();
} catch (IOException e1) {
throw new ReportComputeException(e1);
}
}
}
15
View Source File : SpringEncoderTests.java
License : Apache License 2.0
Project Creator : spring-cloud
License : Apache License 2.0
Project Creator : spring-cloud
@Test
public void testNoCharsetForBinaryFiles() {
Encoder encoder = context.getInstance("test", Encoder.clreplaced);
replacedertThat(encoder).isNotNull();
RequestTemplate request = new RequestTemplate();
request.header(CONTENT_TYPE, APPLICATION_OCTET_STREAM_VALUE);
Resource resource = applicationContext.getResource("clreplacedpath:dummy.pdf");
encoder.encode(resource, Resource.clreplaced, request);
replacedertThat(request.requestBody().getEncoding()).isEmpty();
}
15
View Source File : IntegrationTestMain.java
License : Apache License 2.0
Project Creator : gemini-projects
License : Apache License 2.0
Project Creator : gemini-projects
private void eraseDatabase(Statement statement) throws SQLException, IOException {
logger.info("Initialization: deleting schema");
Resource resource = applicationContext.getResource("clreplacedpath:erasePublicSchema");
String eraseDBSql = StreamUtils.copyToString(resource.getInputStream(), StandardCharsets.UTF_8);
int i = statement.executeUpdate(eraseDBSql);
logger.info("Initialization: deleting schema - qrs: " + i);
}
15
View Source File : GffManagerTest.java
License : MIT License
Project Creator : epam
License : MIT License
Project Creator : epam
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testLoadExonsInTrack() throws IOException, FeatureIndexException, InterruptedException, NoSuchAlgorithmException {
Resource resource = context.getResource(GENES_SORTED_GTF_PATH);
FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
request.setReferenceId(referenceId);
request.setPath(resource.getFile().getAbsolutePath());
GeneFile geneFile = gffManager.registerGeneFile(request);
replacedert.replacedertNotNull(geneFile);
replacedert.replacedertNotNull(geneFile.getId());
List<Block> exons = gffManager.loadExonsInViewPort(geneFile.getId(), testChromosome.getId(), TEST_CENTER_POSITION, TEST_VIEW_PORT_SIZE, TEST_INTRON_LENGTH);
List<Block> exons2 = gffManager.loadExonsInTrack(geneFile.getId(), testChromosome.getId(), exons.get(0).getStartIndex(), exons.get(exons.size() - 1).getEndIndex(), TEST_INTRON_LENGTH);
replacedert.replacedertFalse(exons2.isEmpty());
replacedert.replacedertEquals(exons.size(), exons2.size());
for (int i = 0; i < exons2.size(); i++) {
replacedert.replacedertEquals(exons.get(i).getStartIndex(), exons2.get(i).getStartIndex());
replacedert.replacedertEquals(exons.get(i).getEndIndex(), exons2.get(i).getEndIndex());
}
testOverlapping(exons2);
}
See More Examples