Search in sources :

Example 36 with ResourceLoader

use of org.springframework.core.io.ResourceLoader in project webapp by elimu-ai.

the class EPubChapterExtractionHelperTest method testExtractChapterReferencesFromTableOfContentsFile_STORYWEAVER.

@Test
public void testExtractChapterReferencesFromTableOfContentsFile_STORYWEAVER() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubChapterExtractionHelper.class);
    Resource resource = resourceLoader.getResource("ben-sw-11791-ghumkature-bhim.epub_toc.ncx");
    File ncxFile = resource.getFile();
    logger.debug("ncxFile: " + ncxFile);
    List<String> chapterReferences = EPubChapterExtractionHelper.extractChapterReferencesFromTableOfContentsFileNcx(ncxFile);
    assertThat(chapterReferences.size(), is(10));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Test(org.junit.Test)

Example 37 with ResourceLoader

use of org.springframework.core.io.ResourceLoader in project webapp by elimu-ai.

the class EPubChapterExtractionHelperTest method testExtractChapterReferencesFromTableOfContentsFile_GLOBAL_DIGITAL_LIBRARY.

@Test
public void testExtractChapterReferencesFromTableOfContentsFile_GLOBAL_DIGITAL_LIBRARY() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubChapterExtractionHelper.class);
    Resource resource = resourceLoader.getResource("ben-gdl-761.epub_toc.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    List<String> chapterReferences = EPubChapterExtractionHelper.extractChapterReferencesFromTableOfContentsFile(xhtmlFile);
    assertThat(chapterReferences.size(), is(12));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Test(org.junit.Test)

Example 38 with ResourceLoader

use of org.springframework.core.io.ResourceLoader in project webapp by elimu-ai.

the class EPubMetadataExtractionHelperTest method testExtractTitleFromOpfFile_FIL_STORYWEAVER_105391.

@Test
public void testExtractTitleFromOpfFile_FIL_STORYWEAVER_105391() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubMetadataExtractionHelper.class);
    Resource resource = resourceLoader.getResource("fil-sw-105391-tayo-ay-magbilang.epub_package.opf");
    File opfFile = resource.getFile();
    logger.debug("opfFile: " + opfFile);
    String title = EPubMetadataExtractionHelper.extractTitleFromOpfFile(opfFile);
    assertThat(title, is("Tayo ay Magbilang!"));
    String description = EPubMetadataExtractionHelper.extractDescriptionFromOpfFile(opfFile);
    assertThat(description, is(nullValue()));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Test(org.junit.Test)

Example 39 with ResourceLoader

use of org.springframework.core.io.ResourceLoader in project webapp by elimu-ai.

the class EPubMetadataExtractionHelperTest method testExtractTitleFromOpfFile_FIL_LETS_READ_ASIA_0acfe340.

@Test
public void testExtractTitleFromOpfFile_FIL_LETS_READ_ASIA_0acfe340() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubMetadataExtractionHelper.class);
    Resource resource = resourceLoader.getResource("fil-lra-0acfe340-6116-4f8a-a45d-c925c8a1fd0e.epub_content.opf");
    File opfFile = resource.getFile();
    logger.debug("opfFile: " + opfFile);
    String title = EPubMetadataExtractionHelper.extractTitleFromOpfFile(opfFile);
    assertThat(title, is("Hindi na Ako natatakot!"));
    String description = EPubMetadataExtractionHelper.extractDescriptionFromOpfFile(opfFile);
    assertThat(description, is("Ang batang si Marah,  mag-isang lumabas sa dilim.  Matatakot kaya siya?"));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Test(org.junit.Test)

Example 40 with ResourceLoader

use of org.springframework.core.io.ResourceLoader in project webapp by elimu-ai.

the class EPubMetadataExtractionHelperTest method testExtractTitleFromOpfFile_FIL_LETS_READ_ASIA_627f64f8.

@Test
public void testExtractTitleFromOpfFile_FIL_LETS_READ_ASIA_627f64f8() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubMetadataExtractionHelper.class);
    Resource resource = resourceLoader.getResource("fil-lra-627f64f8-a002-4c0f-8bb6-3701ce5fcf19.epub_content.opf");
    File opfFile = resource.getFile();
    logger.debug("opfFile: " + opfFile);
    String title = EPubMetadataExtractionHelper.extractTitleFromOpfFile(opfFile);
    assertThat(title, is("Si Pusa at si Aso at ang Sumbrero"));
    String description = EPubMetadataExtractionHelper.extractDescriptionFromOpfFile(opfFile);
    assertThat(description, is("Mayroong mga bagong sumbrero sina Pusa at Aso! Ngunit ano ang kanilang gagawin pagkatapos tangayin ng malakas  na hangin ang kani-kaniyang sumbrero sa tubig? Sana, mayroon silang kaibigan na nauuhaw."));
}
Also used : ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) Resource(org.springframework.core.io.Resource) File(java.io.File) Test(org.junit.Test)

Aggregations

ResourceLoader (org.springframework.core.io.ResourceLoader)90 Resource (org.springframework.core.io.Resource)51 Test (org.junit.Test)35 ClassRelativeResourceLoader (org.springframework.core.io.ClassRelativeResourceLoader)34 File (java.io.File)33 DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)26 Test (org.junit.jupiter.api.Test)15 IOException (java.io.IOException)9 Environment (org.springframework.core.env.Environment)9 ByteArrayResource (org.springframework.core.io.ByteArrayResource)7 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)6 FileSystemResource (org.springframework.core.io.FileSystemResource)6 HashMap (java.util.HashMap)5 Configuration (freemarker.template.Configuration)4 Template (freemarker.template.Template)4 InputStream (java.io.InputStream)4 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)4 InputStreamReader (java.io.InputStreamReader)3 Properties (java.util.Properties)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3