List of usage examples for org.springframework.util StringUtils countOccurrencesOf
public static int countOccurrencesOf(String str, String sub)
From source file:com.googlecode.flyway.core.dbsupport.postgresql.PostgreSQLSqlScript.java
@Override protected boolean endsWithOpenMultilineStringLiteral(String statement) { int numQuotes = StringUtils.countOccurrencesOf(statement, "'"); return (numQuotes % 2) != 0; }
From source file:org.zilverline.extractors.TestHTMLExtractor.java
public void testExtractInfo() { HTMLExtractor hex = new HTMLExtractor(); File file = new File("test\\data\\test.html"); // File file = new File("d:\\books\\problems\\manual_fr.htm2"); ParsedFileInfo pfi = hex.extractInfo(file); assertNotNull(pfi);//from w w w .j ava 2 s . c om assertEquals("HTML", pfi.getType()); assertTrue(pfi.getSize() > 0); log.debug("Summary: " + pfi.getSummary()); assertEquals("HTML title", pfi.getTitle()); char[] text = new char[pfi.getSummary().length()]; try { assertTrue(pfi.getReader().read(text) > 0); log.debug("Content with length of summary: " + new String(text)); } catch (IOException e) { fail(e.getMessage()); } assertTrue(pfi.getSummary().length() > 0); // assertTrue(new String(text).startsWith(pfi.getSummary())); assertTrue(StringUtils.countOccurrencesOf(pfi.getSummary(), "test") > 0); }
From source file:org.zilverline.extractors.TestTextExtractor.java
public void testGetContentAsInputStream() { try {/*ww w.j a va 2s.c om*/ TextExtractor tex = new TextExtractor(); InputStream is = new FileInputStream("test\\data\\readme"); String txt = tex.getContent(is); assertNotNull(txt); log.debug(txt); assertTrue(txt.length() > 0); assertTrue(txt.startsWith("Dit is een test in een TEXT document.")); assertTrue(StringUtils.countOccurrencesOf(txt, "test") > 0); } catch (FileNotFoundException e) { fail(e.getMessage()); } }
From source file:org.zilverline.extractors.TestRTFExtractor.java
public void testGetContentAsInputStream() { try {// w w w .j a v a2s. c om RTFExtractor tex = new RTFExtractor(); InputStream is = new FileInputStream("test\\data\\test.rtf"); String txt = tex.getContent(is); assertNotNull(txt); log.debug(txt.trim()); assertTrue(txt.length() > 0); assertTrue(txt.trim().startsWith("This is a sample of some RTF text.")); assertTrue(StringUtils.countOccurrencesOf(txt, "underlined") > 0); } catch (FileNotFoundException e) { fail(e.getMessage()); } }
From source file:org.zilverline.extractors.TestPDFExtractor.java
public void testGetContentAsInputStream() { try {//from w ww . j av a 2 s . c o m PDFExtractor tex = new PDFExtractor(); InputStream is = new FileInputStream("test\\data\\test.pdf"); String txt = tex.getContent(is); assertNotNull(txt); log.debug(txt.trim()); assertTrue(txt.length() > 0); assertTrue(txt.trim().startsWith("Dit is een test in een PDF document.")); assertTrue(StringUtils.countOccurrencesOf(txt, "test") > 0); } catch (FileNotFoundException e) { fail(e.getMessage()); } }
From source file:org.zilverline.extractors.TestWordExtractor.java
public void testGetContentAsInputStream() { try {//from www. ja va 2s .c o m WordExtractor tex = new WordExtractor(); InputStream is = new FileInputStream("test\\data\\test.doc"); String txt = tex.getContent(is); assertNotNull(txt); log.debug(txt.trim()); assertTrue(txt.length() > 0); assertTrue(txt.trim().startsWith("Dit is een test in een WORD document.")); assertTrue(StringUtils.countOccurrencesOf(txt, "test") > 0); } catch (FileNotFoundException e) { fail(e.getMessage()); } }
From source file:org.zilverline.extractors.TestPowerPointExtractor.java
public void testGetContentAsInputStream() { try {// ww w . j av a 2 s. c o m PowerPointExtractor tex = new PowerPointExtractor(); InputStream is = new FileInputStream("test\\data\\test.ppt"); String txt = tex.getContent(is); assertNotNull(txt); log.debug(txt.trim()); assertTrue(txt.length() > 0); assertTrue(txt.trim().startsWith("Test Dit is een test in een powerpoint document.")); assertTrue(StringUtils.countOccurrencesOf(txt, "test") > 0); } catch (FileNotFoundException e) { fail(e.getMessage()); } }
From source file:org.zilverline.extractors.TestExcelExtractor.java
public void testGetContentAsInputStream() { try {//from ww w. j a v a2 s .co m ExcelExtractor tex = new ExcelExtractor(); InputStream is = new FileInputStream("test\\data\\test.xls"); String txt = tex.getContent(is); assertNotNull(txt); log.debug(txt.trim()); assertTrue(txt.length() > 0); assertTrue(txt.trim().startsWith("2.0 1.0 zilverline test")); assertTrue(StringUtils.countOccurrencesOf(txt, "test") > 0); } catch (FileNotFoundException e) { fail(e.getMessage()); } }
From source file:org.zilverline.extractors.TestHTMLExtractor.java
public void testGetContentAsInputStream() { try {//from w w w .ja va 2 s. c o m HTMLExtractor tex = new HTMLExtractor(); InputStream is = new FileInputStream("test\\data\\test.html"); String txt = tex.getContent(is); assertNotNull(txt); log.debug(txt.trim()); assertTrue(txt.length() > 0); assertTrue(txt.trim().endsWith("Dit is een test in een HTML document.")); assertTrue(StringUtils.countOccurrencesOf(txt, "test") > 0); } catch (FileNotFoundException e) { fail(e.getMessage()); } }