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 java.io.BufferedReader;
17  import java.io.IOException;
18  import java.io.StringReader;
19  import java.util.List;
20  
21  import ch.qos.logback.classic.corpus.TextFileUtil;
22  import org.junit.jupiter.api.Test;
23  
24  import static org.junit.jupiter.api.Assertions.assertEquals;
25  
26  public class TextFileUtilTest {
27  
28      @Test
29      public void smoke() throws IOException {
30          String s = "When on board H.M.S. 'Beagle,' as naturalist, I was much struck with\r\n"
31                  + "certain facts in the distribution of the inhabitants of South America,\r\n"
32                  + "and in the geological relations of the present to the past inhabitants\r\n" + "of that continent.";
33  
34          StringReader sr = new StringReader(s);
35          BufferedReader br = new BufferedReader(sr);
36          List<String> wordList = TextFileUtil.toWords(br);
37          assertEquals(38, wordList.size());
38          assertEquals("When", wordList.get(0));
39          assertEquals("'Beagle,'", wordList.get(4));
40          assertEquals("of", wordList.get(17));
41  
42      }
43  }