Search in sources :

Example 36 with ClassRelativeResourceLoader

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

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_HIN_SW_10145_ch4.

@Test
public void testExtractParagraphsFromChapterFile_HIN_SW_10145_ch4() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("hin-sw-10145-ek-sau-saintisvan-paer.epub_4.xhtml");
    File xhtmlFile = resource.getFile();
    logger.debug("xhtmlFile: " + xhtmlFile);
    List<String> storyBookParagraphs = EPubParagraphExtractionHelper.extractParagraphsFromChapterFile(xhtmlFile);
    assertThat(storyBookParagraphs.size(), is(3));
    assertThat(storyBookParagraphs.get(0), is("एक गोजर एक बड़े से भूरे पत्ते के भीतर"));
    assertThat(storyBookParagraphs.get(1), is("ख़ुमारी में दुबकी हुई थी।"));
    assertThat(storyBookParagraphs.get(2), 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 37 with ClassRelativeResourceLoader

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

the class EPubParagraphExtractionHelperTest method testExtractParagraphsFromChapterFile_BEN_GDL_761.

@Test
public void testExtractParagraphsFromChapterFile_BEN_GDL_761() throws IOException {
    ResourceLoader resourceLoader = new ClassRelativeResourceLoader(EPubParagraphExtractionHelper.class);
    Resource resource = resourceLoader.getResource("ben-gdl-761.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)

Example 38 with ClassRelativeResourceLoader

use of org.springframework.core.io.ClassRelativeResourceLoader 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!"));
}
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 ClassRelativeResourceLoader

use of org.springframework.core.io.ClassRelativeResourceLoader 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!"));
}
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 ClassRelativeResourceLoader

use of org.springframework.core.io.ClassRelativeResourceLoader in project uPortal by Jasig.

the class XalanAuthorizationHelperTest method setup.

@Before
public void setup() throws Exception {
    final ResourceLoaderURIResolver resolver = new ResourceLoaderURIResolver(new ClassRelativeResourceLoader(getClass()));
    this.tFactory = TransformerFactory.newInstance();
    this.tFactory.setURIResolver(resolver);
    this.tFactory.setErrorListener(new SimpleTransformErrorListener(LogFactory.getLog(getClass())));
    this.xmlSource = new StreamSource(this.getClass().getResourceAsStream("test.xml"));
}
Also used : ResourceLoaderURIResolver(org.apereo.portal.xml.ResourceLoaderURIResolver) ClassRelativeResourceLoader(org.springframework.core.io.ClassRelativeResourceLoader) SimpleTransformErrorListener(org.springframework.util.xml.SimpleTransformErrorListener) StreamSource(javax.xml.transform.stream.StreamSource) Before(org.junit.Before)

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