@Test
  public void testFindCorrectNumberOfHits() throws Exception {
    ByteArrayInputStream inputText = new ByteArrayInputStream(text.getBytes("UTF-8"));

    FinderResult result = finder.find(inputText, search2);

    assertEquals("Number of hits", 2, result.numberOfHits);
  }
  @Test
  public void testSearchStringFoundListener() throws Exception {
    ByteArrayInputStream inputText = new ByteArrayInputStream(text.getBytes("UTF-8"));

    final FinderStatusListener listener = context.mock(FinderStatusListener.class);
    finder.setStatusListener(listener);

    context.checking(
        new Expectations() {
          {
            exactly(2).of(listener).searchStringFound(with(any(Position.class)));
            ignoring(listener).progressUpdate(with(any(Long.class)));
          }
        });

    finder.find(inputText, search2);
  }
  @Test
  public void testMultipleHitsInOneLine() throws Exception {
    ByteArrayInputStream inputText = new ByteArrayInputStream(text.getBytes("UTF-8"));

    FinderResult result = finder.find(inputText, search3);

    assertEquals("Number of hits in one line", 2, result.numberOfHits);
  }
  @Test
  public void testCorrectSizeOfHitsList() throws Exception {
    ByteArrayInputStream inputText = new ByteArrayInputStream(text.getBytes("UTF-8"));

    FinderResult result = finder.find(inputText, search2);

    assertEquals("Size of hits list", 2, result.hits.size());
  }
  @Test
  public void testCorrectHitPositions() throws Exception {
    ByteArrayInputStream inputText = new ByteArrayInputStream(text.getBytes("UTF-8"));

    FinderResult result = finder.find(inputText, search2);

    assertThat(result.hits.get(0), equalTo(new Position(1, 22)));
    assertThat(result.hits.get(1), equalTo(new Position(2, 14)));
  }
  @Test
  public void testSimpleSearch() throws Exception {

    ByteArrayInputStream inputText = new ByteArrayInputStream(text.getBytes("UTF-8"));

    FinderResult result = finder.find(inputText, search1);

    assertEquals("Search string found", true, result.found);
  }