1 package de.fu_berlin.ties.text;
2
3 import junit.framework.TestCase;
4
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
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
24 extends TestCase
25
26 {
27
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
40
41 public FieldTokenizingExtractorTest(String name) {
42
43 super(name);
44
45 }
46
47 public de.fu_berlin.ties.text.FieldTokenizingExtractor createInstance() throws Exception {
48
49 return new FieldTokenizingExtractor(TiesConfiguration.CONF,
50 Classifier.CONFIG_CLASSIFIER);
51
52 }
53
54 protected void setUp() throws Exception {
55
56 super.setUp();
57 fieldtokenizingextractor = createInstance();
58
59 }
60
61 protected void tearDown() throws Exception {
62
63 fieldtokenizingextractor = null;
64 super.tearDown();
65
66 }
67
68 public void testBuildFeatures() throws Exception {
69
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
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
88
89 }
90
91 public static void main(String[] args) {
92
93 junit.textui.TestRunner.run(FieldTokenizingExtractorTest.class);
94
95 }
96 }