use of org.springframework.core.io.ResourceLoader in project webapp by elimu-ai.
the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_ENG_GDL_1855_ch4.
@Test
public void testExtractParagraphsFromChapterFile_ENG_GDL_1855_ch4() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
Resource resource = resourceLoader.getResource("eng-gdl-1855.epub_chapter-4.xhtml");
File xhtmlFile = resource.getFile();
logger.debug("xhtmlFile: " + xhtmlFile);
List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
assertThat(storyBookParagraphs.size(), is(2));
assertThat(storyBookParagraphs.get(0), is("Some wild cats have spots."));
assertThat(storyBookParagraphs.get(1), is("Like the leopard and the leopard cat!"));
}
use of org.springframework.core.io.ResourceLoader in project webapp by elimu-ai.
the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_ENG_GDL_1855.
@Test
public void testExtractParagraphsFromChapterFile_ENG_GDL_1855() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
Resource resource = resourceLoader.getResource("eng-gdl-1855.epub_chapter-2.xhtml");
File xhtmlFile = resource.getFile();
logger.debug("xhtmlFile: " + xhtmlFile);
List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
assertThat(storyBookParagraphs.size(), is(2));
assertThat(storyBookParagraphs.get(0), is("Some wild cats have stripes."));
assertThat(storyBookParagraphs.get(1), is("Like the tiger!"));
}
use of org.springframework.core.io.ResourceLoader in project jbehave-core by jbehave.
the class SpringApplicationContextFactory method createApplicationContext.
/**
* Creates a configurable application context from the resources provided.
* The context will be an instance of
* {@link AnnotationConfigApplicationContext}, if the resources are
* annotated class names, or {@link GenericApplicationContext} otherwise.
*
* @return A ConfigurableApplicationContext
*/
public ConfigurableApplicationContext createApplicationContext() {
try {
// first try to create annotation config application context
Class<?>[] annotatedClasses = new Class<?>[resources.length];
for (int i = 0; i < resources.length; i++) {
annotatedClasses[i] = this.classLoader.loadClass(resources[i]);
}
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(annotatedClasses);
context.setParent(parent);
context.setClassLoader(classLoader);
return context;
} catch (ClassNotFoundException e) {
// create generic application context
GenericApplicationContext context = new GenericApplicationContext(parent);
context.setClassLoader(classLoader);
ResourceLoader resourceLoader = new DefaultResourceLoader(classLoader);
context.setResourceLoader(resourceLoader);
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
for (String resource : resources) {
reader.loadBeanDefinitions(resourceLoader.getResource(resource));
}
context.refresh();
return context;
}
}
use of org.springframework.core.io.ResourceLoader in project syndesis by syndesisio.
the class DataManagerTest method setup.
@Before
public void setup() {
cacheManager = new LRUCacheManager(100);
EncryptionComponent encryptionComponent = new EncryptionComponent(null);
ResourceLoader resourceLoader = new DefaultResourceLoader();
// Create Data Manager
dataManager = new DataManager(cacheManager, Collections.emptyList(), null, encryptionComponent, resourceLoader);
dataManager.init();
dataManager.resetDeploymentData();
}
use of org.springframework.core.io.ResourceLoader in project syndesis by syndesisio.
the class MetricsCollectorTest method before.
@Before
public void before() throws IOException, ParseException {
JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=PostgreSQL");
DBI dbi = new DBI(ds);
this.jsondb = new SqlJsonDB(dbi, null, Arrays.asList(new Index("/pair", "key")));
try {
this.jsondb.dropTables();
} catch (Exception e) {
}
this.jsondb.createTables();
jsondbRM = new JsonDBRawMetrics(jsondb);
load();
CacheManager cacheManager = new LRUCacheManager(100);
EncryptionComponent encryptionComponent = new EncryptionComponent(null);
ResourceLoader resourceLoader = new DefaultResourceLoader();
// Create Data Manager
dataManager = new DataManager(cacheManager, Collections.emptyList(), null, encryptionComponent, resourceLoader);
intMH = new IntegrationMetricsHandler(dataManager);
}
Aggregations