Search in sources :

Example 31 with ClassRelativeResourceLoader

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

the class EPubMetadataExtractionHelperTest method testExtractCoverImageReferenceFromOpfFile_FIL_GLOBAL_DIGITAL_LIBRARY_761.

@Test
public void testExtractCoverImageReferenceFromOpfFile_FIL_GLOBAL_DIGITAL_LIBRARY_761() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubMetadataExtractionHelper.class);
    Resource resource = resourceLoader.getResource("ben-gdl-761.epub_book.opf");
    File opfFile = resource.getFile();
    logger.debug("opfFile: " + opfFile);
    String coverImageReference = EPubMetadataExtractionHelper.extractCoverImageReferenceFromOpfFile(opfFile);
    assertThat(coverImageReference, is("99e3d3af620881991813482fb602a1f6.jpg"));
}
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 32 with ClassRelativeResourceLoader

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

the class EPubMetadataExtractionHelperTest method testExtractCoverImageReferenceFromOpfFile_FIL_LETS_READ_ASIA_0acfe340.

@Test
public void testExtractCoverImageReferenceFromOpfFile_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 coverImageReference = EPubMetadataExtractionHelper.extractCoverImageReferenceFromOpfFile(opfFile);
    assertThat(coverImageReference, is("coverImage.jpeg"));
}
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 33 with ClassRelativeResourceLoader

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

the class EPubMetadataExtractionHelperTest method testExtractTitleFromOpfFile_BEN_GLOBAL_DIGITAL_LIBRARY.

@Test
public void testExtractTitleFromOpfFile_BEN_GLOBAL_DIGITAL_LIBRARY() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubMetadataExtractionHelper.class);
    Resource resource = resourceLoader.getResource("ben-gdl-761.epub_book.opf");
    File opfFile = resource.getFile();
    logger.debug("opfFile: " + opfFile);
    String title = EPubMetadataExtractionHelper.extractTitleFromOpfFile(opfFile);
    assertThat(title, is("উৎসব"));
    String description = EPubMetadataExtractionHelper.extractDescriptionFromOpfFile(opfFile);
    assertThat(description, is("পোশাক উৎসবের বর্ণ, শব্দ, গন্ধ ও অনুভূতি উপভোগ করো।"));
}
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 34 with ClassRelativeResourceLoader

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

the class EPubImageExtractionHelperTest method testExtractImageReferenceFromChapterFile_FIL_LRA_faa0d66e.

@Test
public void testExtractImageReferenceFromChapterFile_FIL_LRA_faa0d66e() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubImageExtractionHelper.class);
    Resource resource = resourceLoader.getResource("fil-lra-faa0d66e-564f-4d72-a1d3-ec46fb754205.epub_Page_3.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    String imageReference = EPubImageExtractionHelper.extractImageReferenceFromChapterFile(xhtmlFile);
    assertThat(imageReference, is("image_3.jpg"));
}
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 35 with ClassRelativeResourceLoader

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

the class EPubImageExtractionHelperTest method testExtractImageReferenceFromChapterFile_BEN_SW_11791.

@Test
public void testExtractImageReferenceFromChapterFile_BEN_SW_11791() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubImageExtractionHelper.class);
    Resource resource = resourceLoader.getResource("ben-sw-11791-ghumkature-bhim.epub_2.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    String imageReference = EPubImageExtractionHelper.extractImageReferenceFromChapterFile(xhtmlFile);
    assertThat(imageReference, is("image_2.jpg"));
}
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

ClassRelativeResourceLoader (org.springframework.core.io.ClassRelativeResourceLoader)41 Resource (org.springframework.core.io.Resource)34 ResourceLoader (org.springframework.core.io.ResourceLoader)34 Test (org.junit.Test)33 File (java.io.File)32 Before (org.junit.Before)5 StreamSource (javax.xml.transform.stream.StreamSource)4 ResourceLoaderURIResolver (org.apereo.portal.xml.ResourceLoaderURIResolver)4 SimpleTransformErrorListener (org.springframework.util.xml.SimpleTransformErrorListener)4 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 MessagingException (javax.mail.MessagingException)2 MimeMessage (javax.mail.internet.MimeMessage)2 JavaMailSenderImpl (org.springframework.mail.javamail.JavaMailSenderImpl)2 MimeMessageHelper (org.springframework.mail.javamail.MimeMessageHelper)2 XMLEventReader (javax.xml.stream.XMLEventReader)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1