View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.classic.corpusTest;
15  
16  import static org.junit.Assert.*;
17  
18  import java.io.BufferedReader;
19  import java.io.IOException;
20  import java.io.StringReader;
21  import java.util.List;
22  
23  import org.junit.Test;
24  
25  import ch.qos.logback.classic.corpus.TextFileUtil;
26  
27  public class TextFileUtilTest {
28  
29      @Test
30      public void smoke() throws IOException {
31          String s = "When on board H.M.S. 'Beagle,' as naturalist, I was much struck with\r\n"
32                          + "certain facts in the distribution of the inhabitants of South America,\r\n"
33                          + "and in the geological relations of the present to the past inhabitants\r\n" + "of that continent.";
34  
35          StringReader sr = new StringReader(s);
36          BufferedReader br = new BufferedReader(sr);
37          List<String> wordList = TextFileUtil.toWords(br);
38          assertEquals(38, wordList.size());
39          assertEquals("When", wordList.get(0));
40          assertEquals("'Beagle,'", wordList.get(4));
41          assertEquals("of", wordList.get(17));
42  
43      }
44  }