EMMA Coverage Report (generated Tue Aug 23 05:57:12 CDT 2011)
[all classes][felix.test]

COVERAGE SUMMARY FOR SOURCE FILE [IOHDFSTest.java]

nameclass, %method, %block, %line, %
IOHDFSTest.java100% (1/1)100% (21/21)94%  (1804/1911)83%  (271.1/325)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IOHDFSTest100% (1/1)100% (21/21)94%  (1804/1911)83%  (271.1/325)
setUp (): void 100% (1/1)92%  (83/90)91%  (30/33)
xmlNoMatchTest (): void 100% (1/1)93%  (66/71)79%  (11/14)
checkEvidence (String []): void 100% (1/1)93%  (123/132)83%  (20/24)
commentTest (): void 100% (1/1)94%  (78/83)79%  (11/14)
importTest (): void 100% (1/1)94%  (78/83)79%  (11/14)
importTestXML (): void 100% (1/1)94%  (78/83)79%  (11/14)
initTest (): void 100% (1/1)94%  (78/83)79%  (11/14)
initTestXML (): void 100% (1/1)94%  (78/83)79%  (11/14)
localTest (): void 100% (1/1)94%  (78/83)79%  (11/14)
printTest (): void 100% (1/1)94%  (78/83)79%  (11/14)
repeatTest (): void 100% (1/1)94%  (78/83)79%  (11/14)
simpleTest (): void 100% (1/1)94%  (78/83)79%  (11/14)
simpleTestXML (): void 100% (1/1)94%  (78/83)79%  (11/14)
comboTest2 (): void 100% (1/1)94%  (137/145)85%  (17.8/21)
comboTest1 (): void 100% (1/1)95%  (145/153)85%  (18.8/22)
checkOutput (String, String []): void 100% (1/1)95%  (82/86)92%  (12/13)
comboTest3 (): void 100% (1/1)96%  (181/189)88%  (22.8/26)
comboTest4 (): void 100% (1/1)96%  (202/210)89%  (25.8/29)
IOHDFSTest (): void 100% (1/1)100% (3/3)100% (1/1)
reduceTest (): void 100% (1/1)100% (1/1)100% (1/1)
reduceTestXML (): void 100% (1/1)100% (1/1)100% (1/1)

1package felix.test;
2 
3import static org.junit.Assert.*;
4 
5import java.sql.ResultSet;
6import java.sql.SQLException;
7import java.util.ArrayList;
8 
9import org.junit.BeforeClass;
10import org.junit.Test;
11 
12import tuffy.db.RDB;
13import tuffy.util.Config;
14import tuffy.util.FileMan;
15import tuffy.util.UIMan;
16 
17import felix.main.Felix;
18import felix.parser.FelixCommandOptions;
19import felix.util.FelixConfig;
20import felix.util.FelixUIMan;
21 
22/**
23 * Test for generating evidence through the Blah Blah feature extraction language.
24 * @author Josh Slauson
25 *
26 */
27public class IOHDFSTest {
28 
29        /*
30 
31        NOTE: these tests assume files hdfs://d-02.cs.wisc.edu:9000/temp/test.txt, hdfs://d-02.cs.wisc.edu:9000/temp/test.xml exist
32         
33        test.txt contents:
34                This is a test.
35                This is another sentence.
36                This is the end.
37        
38         test.xml contents:
39                <DOC>
40                <HEADLINE>
41                This is the headline.
42                </HEADLINE>
43                <POST>
44                This is a test.
45                </POST>
46                <POST>
47                This is another sentence.
48                </POST>
49                <POST>
50                This is the end.
51                </POST>
52                </DOC>
53 
54         */
55 
56        // TODO: fix "Failed to connect to PostgreSQL! FATAL: sorry, too many clients already"
57        // maybe do init db, db.close() between tests?
58 
59        // TODO: run tests without "-local"
60        
61        public static RDB db;
62        
63        /**
64         * Perform required setup for this test.
65         */
66        @BeforeClass
67        public static final void setUp() {
68                // delete existing output files
69                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_simpleTest");
70                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_initTest");
71                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_importTest");
72                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_reduceTest");
73                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_simpleTestXML");
74                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_initTestXML");
75                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_importTestXML");
76                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_reduceTestXML");
77                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_localTest");
78                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_comboTest1");
79                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_comboTest2");
80                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_comboTest3");
81                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_comboTest4");
82                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_repeatTest");
83                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_xmlNoMatchTest");
84                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_commentTest");
85                FileMan.removeFile("test/felix/output/out.txt_IOHDFSTest_printTest");
86 
87 
88                FelixConfig.overrideID();
89                
90                UIMan.parseConfigFile(Config.path_conf);
91                
92                if(FelixConfig.evidDBSchema != null){
93                        FelixConfig.db_schema = FelixConfig.evidDBSchema;
94                }
95 
96                db = RDB.getRDBbyConfig();
97                db.schema = FelixConfig.db_schema;
98                db.resetSchema(FelixConfig.db_schema);
99                
100                if(!db.isSchemaExists("felix_test")) {
101                        String query = "CREATE SCHEMA felix_test";
102                        db.execute(query);
103                }
104 
105                db.dropTable("felix_test.evid");
106                String query = "CREATE TABLE felix_test.evid (truth boolean, prior integer, a1 text, b2 text)";
107                db.execute(query);
108                
109                query = "INSERT INTO felix_test.evid VALUES (true, 0, 11, 12), (true, 0, 14, 15)";
110                db.execute(query);                
111        }
112        
113        /**
114         * Check if evidence was correctly loaded into a database table.
115         * @param expect
116         */
117        public void checkEvidence(String[] expect) {
118                // Check if evidence table exists
119                db = RDB.getRDBbyConfig(FelixConfig.db_schema);
120                long count = db.countTuples("felix_test._fe_raw_length");
121                System.out.println("Checking evidence count: " + count + " = " + expect.length + "?");
122                assertTrue(count == expect.length);
123                
124                // Check evidence table contents
125                String query = "SELECT * FROM felix_test._fe_raw_length";
126                ResultSet rs = db.query(query);
127                
128                try {
129                        while(rs != null && rs.next()) {
130                                String text = rs.getString("text1");
131                                String len = rs.getString("len2");
132                                
133                                System.out.println("Checking evidence contents: " + text + " (" + len + ")");
134                                
135                                boolean match = false;
136                                for(int i = 0; i < expect.length; i++) {
137                                        if(text.equals(expect[i])) {
138                                                System.out.println("\tChecking evience length: " + len + " = " + expect[i].length() + "?");
139                                                assertTrue(len.equals("" + expect[i].length()));
140                                                match = true;
141                                        }
142                                }
143                                if(!match) {
144                                        System.out.println("\tNo match");
145                                }
146                                assertTrue(match);
147                        }
148                        
149                        db.close();
150                        
151                } catch (SQLException e) {
152                        // TODO Auto-generated catch block
153                        e.printStackTrace();
154                        assertTrue(false);
155                }
156 
157        }
158 
159        /**
160         * Checks if output file contains expected results.
161         * @param output
162         * @param expect
163         */
164        public void checkOutput(String output, String[] expect) {
165                ArrayList<String> lines = FileMan.getLines(output);
166                System.out.println("Checking output size: " + lines.size() + " = " + expect.length + "?");
167                assertTrue(lines.size() == expect.length);
168                
169                for(int i = 0; i < lines.size(); i++) {
170                        System.out.println("Checking output: " + lines.get(i));
171 
172                        boolean match = false;
173                        for(int j = 0; j < expect.length; j++) {
174                                if(lines.get(i).equals("long(\"" + expect[j] + "\")")) {
175                                        match = true;
176                                }
177                        }
178                        if(!match) {
179                                System.out.println("\tNo match");
180                        }
181                        assertTrue(match);
182                }
183 
184        }
185 
186        /**
187         * Simple smoke test.
188         */
189        @Test
190        public void simpleTest() {
191                try {
192                        String output = "test/felix/output/out.txt_IOHDFSTest_simpleTest";
193                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-simple,test/felix/io_test/prog.mln-hdfs", "-o", output, 
194                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
195                                        "felix_test", "-local"};
196                        
197                        FelixConfig.overrideID();
198                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
199                        new Felix().run(options);
200                        
201                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
202                        checkEvidence(expect);
203                        checkOutput(output, expect);
204 
205                } catch(InterruptedException e) {
206                        e.printStackTrace();
207                        assertTrue(false);
208                }
209        }
210 
211        /**
212         * Test using @MAPINIT.
213         */
214        @Test
215        public void initTest() {
216                try {
217                        String output = "test/felix/output/out.txt_IOHDFSTest_initTest";
218                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-init,test/felix/io_test/prog.mln-hdfs", "-o", output, 
219                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
220                                        "felix_test", "-local"};
221                        
222                        FelixConfig.overrideID();
223                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
224                        new Felix().run(options);
225                        
226                        String[] expect = { "headThis is a test.", "headThis is another sentence.", "headThis is the end."};
227                        checkEvidence(expect);
228                        checkOutput(output, expect);
229                } catch(InterruptedException e) {
230                        e.printStackTrace();
231                        assertTrue(false);
232                }
233        }
234        
235        /**
236         * Test using an import statement.
237         */
238        @Test
239        public void importTest() {
240                try {
241                        String output = "test/felix/output/out.txt_IOHDFSTest_importTest";
242                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-import,test/felix/io_test/prog.mln-hdfs", "-o", output, 
243                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
244                                        "felix_test", "-local"};
245                        
246                        FelixConfig.overrideID();
247                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
248                        new Felix().run(options);
249                        
250                        String[] expect = { "This is a test", "This is another sentence", "This is the end"};
251                        checkEvidence(expect);
252                        checkOutput(output, expect);
253                } catch(InterruptedException e) {
254                        e.printStackTrace();
255                        assertTrue(false);
256                }
257        }
258        
259        /**
260         * Test using a custom @REDUCE method.
261         */
262        @Test
263        public void reduceTest() {
264                /*
265                try {
266                        String output = "test/felix/output/out.txt_IOHDFSTest_reduceTest";
267                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-reduce", "-o", output, 
268                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
269                                        "felix_test", "-local"};
270                        
271                        FelixConfig.overrideID();
272                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
273                        new Felix().run(options);
274                        
275                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end.", "This is a test.", "This is another sentence.", "This is the end." };
276                        checkEvidence(expect);
277                        checkOutput(output, expect);
278                } catch(InterruptedException e) {
279                        e.printStackTrace();
280                        assertTrue(false);
281                }
282                */
283        }
284 
285        /**
286         * Simple smoke test with an XML file.
287         */
288        @Test
289        public void simpleTestXML() {
290                try {
291                        String output = "test/felix/output/out.txt_IOHDFSTest_simpleTestXML";
292                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-simple-xml,test/felix/io_test/prog.mln-hdfs", "-o", output, 
293                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
294                                        "felix_test", "-local"};
295                        
296                        FelixConfig.overrideID();
297                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
298                        new Felix().run(options);
299                        
300                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
301                        checkEvidence(expect);
302                        checkOutput(output, expect);
303                } catch(InterruptedException e) {
304                        e.printStackTrace();
305                        assertTrue(false);
306                }
307        }
308        
309        /**
310         * Test using @MAPINIT with with an XML file.
311         */
312        @Test
313        public void initTestXML() {
314                try {
315                        String output = "test/felix/output/out.txt_IOHDFSTest_initTestXML";
316                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-init-xml,test/felix/io_test/prog.mln-hdfs", "-o", output, 
317                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
318                                        "felix_test", "-local"};
319                        
320                        FelixConfig.overrideID();
321                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
322                        new Felix().run(options);
323                        
324                        String[] expect = { "headThis is a test.", "headThis is another sentence.", "headThis is the end."};
325                        checkEvidence(expect);
326                        checkOutput(output, expect);
327                } catch(InterruptedException e) {
328                        e.printStackTrace();
329                        assertTrue(false);
330                }
331        }
332        
333        /**
334         * Test using an import statement with an XML file.
335         */
336        @Test
337        public void importTestXML() {
338                try {
339                        String output = "test/felix/output/out.txt_IOHDFSTest_importTestXML";
340                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-import-xml,test/felix/io_test/prog.mln-hdfs", "-o", output, 
341                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
342                                        "felix_test", "-local"};
343                        
344                        FelixConfig.overrideID();
345                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
346                        new Felix().run(options);
347                        
348                        String[] expect = { "This is a test", "This is another sentence", "This is the end"};
349                        checkEvidence(expect);
350                        checkOutput(output, expect);
351                } catch(InterruptedException e) {
352                        e.printStackTrace();
353                        assertTrue(false);
354                }
355        }
356        
357        /**
358         * Test using a custom @REDUCE method with an XML file.
359         */
360        @Test
361        public void reduceTestXML() {
362                /*
363                try {
364                        String output = "test/felix/output/out.txt_IOHDFSTest_reduceTestXML";
365                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-reduce-xml", "-o", output, 
366                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
367                                        "felix_test", "-local"};
368                        
369                        FelixConfig.overrideID();
370                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
371                        new Felix().run(options);
372                        
373                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end.", "This is a test.", "This is another sentence.", "This is the end." };
374                        checkEvidence(expect);
375                        checkOutput(output, expect);
376                } catch(InterruptedException e) {
377                        e.printStackTrace();
378                        assertTrue(false);
379                }
380                */
381        }
382        
383        /**
384         * Test using -local option.
385         */
386        @Test
387        public void localTest() {
388                try {
389                        String output = "test/felix/output/out.txt_IOHDFSTest_localTest";
390                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-local,test/felix/io_test/prog.mln-hdfs", "-o", output, 
391                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
392                                        "felix_test", "-local"};
393                        
394                        FelixConfig.overrideID();
395                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
396                        new Felix().run(options);
397                        
398                        // TODO: check table for features
399                        
400                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
401                        checkEvidence(expect);
402                        checkOutput(output, expect);
403                } catch(InterruptedException e) {
404                        e.printStackTrace();
405                        assertTrue(false);
406                }
407        }
408        
409        /**
410         * Combo test using evidence generated with Blah Blah and evidence from a file.
411         */
412        @Test
413        public void comboTest1() {
414                try {
415                        String output = "test/felix/output/out.txt_IOHDFSTest_comboTest1";
416                        String[] args = {"-e", "test/felix/io_test/evid.db", "-i", 
417                                        "test/felix/io_test/prog.mln-hdfs-combo1,test/felix/io_test/prog.mln-hdfs", "-o", output, 
418                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
419                                        "felix_test", "-q", "fact", "-local"};
420                        
421                        FelixConfig.overrideID();
422                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
423                        new Felix().run(options);
424                        
425                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
426                        checkEvidence(expect);
427 
428                        ArrayList<String> lines = FileMan.getLines(output);
429                        assertTrue(lines.size() == 5);
430                        for(int i = 0; i < lines.size(); i++) {
431                                assertTrue(lines.get(i).equals("long(\"This is a test.\")") || 
432                                                lines.get(i).equals("long(\"This is another sentence.\")") ||
433                                                lines.get(i).equals("long(\"This is the end.\")") ||
434                                                lines.get(i).equals("fact(\"1\", \"2\")") || 
435                                                lines.get(i).equals("fact(\"4\", \"5\")"));
436                        }
437 
438                } catch(InterruptedException e) {
439                        e.printStackTrace();
440                        assertTrue(false);
441                }
442        }
443 
444        /**
445         * Combo test using evidence generated with Blah Blah and evidence from a database table.
446         */
447        @Test
448        public void comboTest2() {
449                        try {
450                        String output = "test/felix/output/out.txt_IOHDFSTest_comboTest2";
451                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-combo2,test/felix/io_test/prog.mln-hdfs", "-o", output, 
452                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
453                                        "felix_test", "-q", "fact", "-local"};
454                        
455                        FelixConfig.overrideID();
456                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
457                        new Felix().run(options);
458                        
459                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
460                        checkEvidence(expect);
461                        
462                        ArrayList<String> lines = FileMan.getLines(output);
463                        assertTrue(lines.size() == 5);
464                        for(int i = 0; i < lines.size(); i++) {
465                                assertTrue(lines.get(i).equals("long(\"This is a test.\")") || 
466                                                lines.get(i).equals("long(\"This is another sentence.\")") ||
467                                                lines.get(i).equals("long(\"This is the end.\")") ||
468                                                lines.get(i).equals("fact(\"11\", \"12\")") || 
469                                                lines.get(i).equals("fact(\"14\", \"15\")"));
470                        }
471 
472                } catch(InterruptedException e) {
473                        e.printStackTrace();
474                        assertTrue(false);
475                }
476        }
477 
478        /**
479         * Combo test using evidence generated with Blah Blah, evidence from a file, and evidence from a database table.
480         */
481        @Test
482        public void comboTest3() {
483                try {
484                        String output = "test/felix/output/out.txt_IOHDFSTest_comboTest3";
485                        String[] args = {"-e", "test/felix/io_test/evid.db", "-i", 
486                                        "test/felix/io_test/prog.mln-hdfs-combo3,test/felix/io_test/prog.mln-hdfs", "-o", output, 
487                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
488                                        "felix_test", "-q", "fact", "-local"};
489                        
490                        FelixConfig.overrideID();
491                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
492                        new Felix().run(options);
493                        
494                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
495                        checkEvidence(expect);
496                        
497                        ArrayList<String> lines = FileMan.getLines(output);
498                        System.out.println("size: " + lines.size());
499                        assertTrue(lines.size() == 7);
500                        for(int i = 0; i < lines.size(); i++) {
501                                System.out.println("line: " + lines.get(i));
502                                assertTrue(lines.get(i).equals("long(\"This is a test.\")") || 
503                                                lines.get(i).equals("long(\"This is another sentence.\")") ||
504                                                lines.get(i).equals("long(\"This is the end.\")") ||
505                                                lines.get(i).equals("fact(\"1\", \"2\")") || 
506                                                lines.get(i).equals("fact(\"4\", \"5\")") ||
507                                                lines.get(i).equals("fact(\"11\", \"12\")") || 
508                                                lines.get(i).equals("fact(\"14\", \"15\")"));
509 
510                        }
511 
512                } catch(InterruptedException e) {
513                        e.printStackTrace();
514                        assertTrue(false);
515                }
516        }
517 
518        /**
519         * Combo test using evidence generated with Blah Blah for a text file and a XML file, evidence from a file, and evidence from a database table.
520         */
521        @Test
522        public void comboTest4() {
523                try {
524                        String output = "test/felix/output/out.txt_IOHDFSTest_comboTest4";
525                        String[] args = {"-e", "test/felix/io_test/evid.db", "-i", 
526                                        "test/felix/io_test/prog.mln-hdfs-combo4,test/felix/io_test/prog.mln-hdfs", "-o", output, 
527                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
528                                        "felix_test", "-q", "fact,long2", "-local"};
529                        
530                        FelixConfig.overrideID();
531                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
532                        new Felix().run(options);
533                        
534                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
535                        checkEvidence(expect);
536                        
537                        ArrayList<String> lines = FileMan.getLines(output);
538                        System.out.println("size: " + lines.size());
539                        assertTrue(lines.size() == 10);
540                        for(int i = 0; i < lines.size(); i++) {
541                                System.out.println("line: " + lines.get(i));
542                                assertTrue(lines.get(i).equals("long(\"This is a test.\")") || 
543                                                lines.get(i).equals("long(\"This is another sentence.\")") ||
544                                                lines.get(i).equals("long(\"This is the end.\")") ||
545                                                lines.get(i).equals("long2(\"This is a test.\")") || 
546                                                lines.get(i).equals("long2(\"This is another sentence.\")") ||
547                                                lines.get(i).equals("long2(\"This is the end.\")") ||
548                                                lines.get(i).equals("fact(\"1\", \"2\")") || 
549                                                lines.get(i).equals("fact(\"4\", \"5\")") ||
550                                                lines.get(i).equals("fact(\"11\", \"12\")") || 
551                                                lines.get(i).equals("fact(\"14\", \"15\")"));
552 
553                        }
554 
555                } catch(InterruptedException e) {
556                        e.printStackTrace();
557                        assertTrue(false);
558                }
559        }
560 
561        /**
562         * Test re-running with a feature that is already extracted.
563         */
564        @Test
565        public void repeatTest() {
566                try {
567                        String output = "test/felix/output/out.txt_IOHDFSTest_repeatTest";
568                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-simple,test/felix/io_test/prog.mln-hdfs", "-o", output, 
569                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
570                                        "felix_test", "-local"};
571                        
572                        FelixConfig.overrideID();
573                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
574                        new Felix().run(options);
575                        
576                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end." };
577                        checkEvidence(expect);
578                        checkOutput(output, expect);
579                        
580                        // TODO: check that feature is not re-extracted somehow?
581 
582                } catch(InterruptedException e) {
583                        e.printStackTrace();
584                        assertTrue(false);
585                }
586        }
587 
588// NOTE: bad test, XML is case sensitive
589//        @Test
590//        public void xmlCaseTest() {
591//                try {
592//                        String output = "test/felix/output/out.txt_IOHDFSTest_xmlCaseTest";
593//                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-xml-case,test/felix/io_test/prog.mln-hdfs", "-o", output, 
594//                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
595//                                        "felix_test", "-local"};
596//                        
597//                        FelixConfig.overrideID();
598//                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
599//                        new Felix().run(options);
600//                        
601//                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end." };
602//                        checkEvidence(expect);
603//                        checkOutput(output, expect);
604//                } catch(InterruptedException e) {
605//                        e.printStackTrace();
606//                        assertTrue(false);
607//                }
608//        }
609        
610        /**
611         * Test using an XML file with no matching tags.
612         */
613        @Test
614        public void xmlNoMatchTest() {
615                try {
616                        String output = "test/felix/output/out.txt_IOHDFSTest_xmlNoMatchTest";
617                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-xml-no-match,test/felix/io_test/prog.mln-hdfs", "-o", output, 
618                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
619                                        "felix_test", "-local"};
620                        
621                        FelixConfig.overrideID();
622                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
623                        new Felix().run(options);
624                        
625                        String[] expect = { };
626                        checkEvidence(expect);
627                        checkOutput(output, expect);
628                } catch(InterruptedException e) {
629                        e.printStackTrace();
630                        assertTrue(false);
631                }
632        }
633 
634        /**
635         * Test the use of python comments.
636         */
637        @Test
638        public void commentTest() {
639                try {
640                        String output = "test/felix/output/out.txt_IOHDFSTest_commentTest";
641                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-comment,test/felix/io_test/prog.mln-hdfs", "-o", output, 
642                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
643                                        "felix_test", "-local"};
644                        
645                        FelixConfig.overrideID();
646                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
647                        new Felix().run(options);
648                        
649                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
650                        checkEvidence(expect);
651                        checkOutput(output, expect);
652 
653                } catch(InterruptedException e) {
654                        e.printStackTrace();
655                        assertTrue(false);
656                }
657        }
658        
659        /**
660         * Test the use of python print statements.
661         */
662        @Test
663        public void printTest() {
664                try {
665                        String output = "test/felix/output/out.txt_IOHDFSTest_printTest";
666                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-print,test/felix/io_test/prog.mln-hdfs", "-o", output, 
667                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
668                                        "felix_test", "-local"};
669                        
670                        FelixConfig.overrideID();
671                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
672                        new Felix().run(options);
673                        
674                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
675                        checkEvidence(expect);
676                        checkOutput(output, expect);
677                        
678                        // TODO: check if print statements actually printed to console?
679 
680                } catch(InterruptedException e) {
681                        e.printStackTrace();
682                        assertTrue(false);
683                }
684        }
685 
686 
687}

[all classes][felix.test]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov