publicclassSearchTest{ @Test publicvoidtestSearch(){ try { String pageContent = "There are certain queer times and occasions " + "in this strange mixed affair we call life when a man " + "takes this whole universe for a vast practical joke, " + "though the wit thereof he but dimly discerns, and more " + "than suspects that the joke is at nobody's expense but " + "his own."; byte[] bytes = pageContent.getBytes(); ByteArrayInputStream stream = new ByteArrayInputStream(bytes); // search Search search = new Search(stream, "practical joke", "1"); Search.LOGGER.setLevel(Level.OFF); search.setSurroundingCharacterCount(10); search.execute(); assertFalse(search.errored()); List<Match> matches = search.getMatches(); assertThat(matches, is(notNullValue())); assertTrue(matches.size() >= 1); Match match = matches.get(0); assertThat(match.searchString, equalTo("practical joke")); assertThat(match.surroundingContext, equalTo("or a vast practical joke, though t")); stream.close();
publicclassSearchTest{ privatestaticfinal String A_TITLE = "1"; @Test publicvoidtestSearch()throws IOException { String pageContent = "There are certain queer times and occasions " + "in this strange mixed affair we call life when a man " + "takes this whole universe for a vast practical joke, " + "though the wit thereof he but dimly discerns, and more " + "than suspects that the joke is at nobody's expense but " + "his own."; byte[] bytes = pageContent.getBytes(); ByteArrayInputStream stream = new ByteArrayInputStream(bytes); ...
@Test publicvoidtestSearch()throws IOException { InputStream stream = streamOn("There are certain queer times and occasions " + "in this strange mixed affair we call life when a man " + "takes this whole universe for a vast practical joke, " + "though the wit thereof he but dimly discerns, and more " + "than suspects that the joke is at nobody's expense but " + "his own."); ... }