Search in sources :

Example 6 with ClassRelativeResourceLoader

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

the class EPubImageExtractionHelperTest method testExtractImageReferenceFromChapterFile_BEN_GDL_761.

@Test
public void testExtractImageReferenceFromChapterFile_BEN_GDL_761() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubImageExtractionHelper.class);
    Resource resource = resourceLoader.getResource("ben-gdl-761.epub_chapter-2.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    String imageReference = EPubImageExtractionHelper.extractImageReferenceFromChapterFile(xhtmlFile);
    assertThat(imageReference, is("1e8e58cc7d627a7896737cfb3eba8270.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 7 with ClassRelativeResourceLoader

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

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_SWA_GDL_30.

@Test
public void testExtractParagraphsFromChapterFile_SWA_GDL_30() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("swa-gdl-30.epub_chapter-2.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
    assertThat(storyBookParagraphs.size(), is(1));
    assertThat(storyBookParagraphs.get(0), is("Kuku na Jongoo walikuwa marafiki."));
}
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 8 with ClassRelativeResourceLoader

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

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_FIL_LRA_7f877260_ch4.

@Test
public void testExtractParagraphsFromChapterFile_FIL_LRA_7f877260_ch4() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("fil-lra-7f877260-ec7c-4970-b6e2-2ee41231d96d.epub_Page_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("Ano kaya kung kaya kang palundagin ng jelly beans nang napakataas?"));
    assertThat(storyBookParagraphs.get(1), is("Maari kang makarating sa paaralan sa isang malaking hakbang."));
}
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 9 with ClassRelativeResourceLoader

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

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_HIN_SW_99651_ch3.

@Test
public void testExtractParagraphsFromChapterFile_HIN_SW_99651_ch3() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("hin-sw-99651-hamare-mitra-kon-hai.epub_3.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("हमारा सबसे अच्छा मित्र है पक्षी!"));
    assertThat(storyBookParagraphs.get(1), 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 10 with ClassRelativeResourceLoader

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

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_HIN_GDL_1296.

@Test
public void testExtractParagraphsFromChapterFile_HIN_GDL_1296() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("hin-gdl-1296.epub_chapter-2.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
    assertThat(storyBookParagraphs.size(), is(1));
    assertThat(storyBookParagraphs.get(0), 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)

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