1   package de.fu_berlin.ties.text;
2   
3   import junit.framework.TestCase;
4   // JUnitDoclet begin import
5   import java.io.StringReader;
6   
7   import de.fu_berlin.ties.TiesConfiguration;
8   import de.fu_berlin.ties.classify.Classifier;
9   import de.fu_berlin.ties.classify.feature.FeatureVector;
10  import de.fu_berlin.ties.text.FieldTokenizingExtractor;
11  // JUnitDoclet end import
12  
13  /***
14  * Generated by JUnitDoclet, a tool provided by
15  * ObjectFab GmbH under LGPL.
16  * Please see www.junitdoclet.org, www.gnu.org
17  * and www.objectfab.de for informations about
18  * the tool, the licence and the authors.
19  */
20  
21  
22  public class FieldTokenizingExtractorTest
23  // JUnitDoclet begin extends_implements
24  extends TestCase
25  // JUnitDoclet end extends_implements
26  {
27    // JUnitDoclet begin class
28    FieldTokenizingExtractor fieldtokenizingextractor = null;
29    private final static String INPUT =
30        "From my to you\nDelivered-To: netnoteinc\r\n"
31        + "  Indented line with\r\n \r\n obsolete whitespace folding\n"
32        + "  Not-a-Header: indented\n\nMain body\nNot-a-Header: body content";
33    private final static String FLAT_OUTPUT =
34        "From_my From_to From_you Delivered-To:_netnoteinc"
35        + " Delivered-To:_Indented Delivered-To:_line Delivered-To:_with"
36        + " Delivered-To:_obsolete Delivered-To:_whitespace Delivered-To:_folding"
37        + " Delivered-To:_Not-a-Header: Delivered-To:_indented _Main _body "
38        + "_Not-a-Header: _body _content";
39    // JUnitDoclet end class
40    
41    public FieldTokenizingExtractorTest(String name) {
42      // JUnitDoclet begin method FieldTokenizingExtractorTest
43      super(name);
44      // JUnitDoclet end method FieldTokenizingExtractorTest
45    }
46    
47    public de.fu_berlin.ties.text.FieldTokenizingExtractor createInstance() throws Exception {
48      // JUnitDoclet begin method testcase.createInstance
49      return new FieldTokenizingExtractor(TiesConfiguration.CONF,
50              Classifier.CONFIG_CLASSIFIER);
51      // JUnitDoclet end method testcase.createInstance
52    }
53    
54    protected void setUp() throws Exception {
55      // JUnitDoclet begin method testcase.setUp
56      super.setUp();
57      fieldtokenizingextractor = createInstance();
58      // JUnitDoclet end method testcase.setUp
59    }
60    
61    protected void tearDown() throws Exception {
62      // JUnitDoclet begin method testcase.tearDown
63      fieldtokenizingextractor = null;
64      super.tearDown();
65      // JUnitDoclet end method testcase.tearDown
66    }
67    
68    public void testBuildFeatures() throws Exception {
69      // JUnitDoclet begin method buildFeatures
70        final FeatureVector features = fieldtokenizingextractor.buildFeatures(
71                new StringReader(INPUT));
72        final String flatFeatures = features.flatten().toString();
73        assertEquals(TextUtils.normalize(flatFeatures),
74                TextUtils.normalize(FLAT_OUTPUT));
75      // JUnitDoclet end method buildFeatures
76    }
77    
78    
79    
80    /***
81    * JUnitDoclet moves marker to this method, if there is not match
82    * for them in the regenerated code and if the marker is not empty.
83    * This way, no test gets lost when regenerating after renaming.
84    * Method testVault is supposed to be empty.
85    */
86    public void testVault() throws Exception {
87      // JUnitDoclet begin method testcase.testVault
88      // JUnitDoclet end method testcase.testVault
89    }
90    
91    public static void main(String[] args) {
92      // JUnitDoclet begin method testcase.main
93      junit.textui.TestRunner.run(FieldTokenizingExtractorTest.class);
94      // JUnitDoclet end method testcase.main
95    }
96  }