EMMA Coverage Report (generated Sat Aug 20 11:00:51 CDT 2011)
[all classes][felix.test]

COVERAGE SUMMARY FOR SOURCE FILE [IOHDFSTest.java]

nameclass, %method, %block, %line, %
IOHDFSTest.java100% (1/1)90%  (19/21)86%  (1803/2099)77%  (269.1/351)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IOHDFSTest100% (1/1)90%  (19/21)86%  (1803/2099)77%  (269.1/351)
reduceTest (): void 0%   (0/1)0%   (0/95)0%   (0/14)
reduceTestXML (): void 0%   (0/1)0%   (0/95)0%   (0/14)
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)
comboTest3 (): void 100% (1/1)96%  (181/189)88%  (22.8/26)
comboTest4 (): void 100% (1/1)96%  (202/210)89%  (25.8/29)
checkOutput (String, String []): void 100% (1/1)97%  (83/86)92%  (12/13)
IOHDFSTest (): void 100% (1/1)100% (3/3)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                try {
265                        String output = "test/felix/output/out.txt_IOHDFSTest_reduceTest";
266                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-reduce", "-o", output, 
267                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
268                                        "felix_test", "-local"};
269                        
270                        FelixConfig.overrideID();
271                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
272                        new Felix().run(options);
273                        
274                        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." };
275                        checkEvidence(expect);
276                        checkOutput(output, expect);
277                } catch(InterruptedException e) {
278                        e.printStackTrace();
279                        assertTrue(false);
280                }
281        }
282 
283        /**
284         * Simple smoke test with an XML file.
285         */
286        @Test
287        public void simpleTestXML() {
288                try {
289                        String output = "test/felix/output/out.txt_IOHDFSTest_simpleTestXML";
290                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-simple-xml,test/felix/io_test/prog.mln-hdfs", "-o", output, 
291                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
292                                        "felix_test", "-local"};
293                        
294                        FelixConfig.overrideID();
295                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
296                        new Felix().run(options);
297                        
298                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
299                        checkEvidence(expect);
300                        checkOutput(output, expect);
301                } catch(InterruptedException e) {
302                        e.printStackTrace();
303                        assertTrue(false);
304                }
305        }
306        
307        /**
308         * Test using @MAPINIT with with an XML file.
309         */
310        @Test
311        public void initTestXML() {
312                try {
313                        String output = "test/felix/output/out.txt_IOHDFSTest_initTestXML";
314                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-init-xml,test/felix/io_test/prog.mln-hdfs", "-o", output, 
315                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
316                                        "felix_test", "-local"};
317                        
318                        FelixConfig.overrideID();
319                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
320                        new Felix().run(options);
321                        
322                        String[] expect = { "headThis is a test.", "headThis is another sentence.", "headThis is the end."};
323                        checkEvidence(expect);
324                        checkOutput(output, expect);
325                } catch(InterruptedException e) {
326                        e.printStackTrace();
327                        assertTrue(false);
328                }
329        }
330        
331        /**
332         * Test using an import statement with an XML file.
333         */
334        @Test
335        public void importTestXML() {
336                try {
337                        String output = "test/felix/output/out.txt_IOHDFSTest_importTestXML";
338                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-import-xml,test/felix/io_test/prog.mln-hdfs", "-o", output, 
339                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
340                                        "felix_test", "-local"};
341                        
342                        FelixConfig.overrideID();
343                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
344                        new Felix().run(options);
345                        
346                        String[] expect = { "This is a test", "This is another sentence", "This is the end"};
347                        checkEvidence(expect);
348                        checkOutput(output, expect);
349                } catch(InterruptedException e) {
350                        e.printStackTrace();
351                        assertTrue(false);
352                }
353        }
354        
355        /**
356         * Test using a custom @REDUCE method with an XML file.
357         */
358        @Test
359        public void reduceTestXML() {
360                try {
361                        String output = "test/felix/output/out.txt_IOHDFSTest_reduceTestXML";
362                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-reduce-xml", "-o", output, 
363                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
364                                        "felix_test", "-local"};
365                        
366                        FelixConfig.overrideID();
367                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
368                        new Felix().run(options);
369                        
370                        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." };
371                        checkEvidence(expect);
372                        checkOutput(output, expect);
373                } catch(InterruptedException e) {
374                        e.printStackTrace();
375                        assertTrue(false);
376                }
377        }
378        
379        /**
380         * Test using -local option.
381         */
382        @Test
383        public void localTest() {
384                try {
385                        String output = "test/felix/output/out.txt_IOHDFSTest_localTest";
386                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-local,test/felix/io_test/prog.mln-hdfs", "-o", output, 
387                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
388                                        "felix_test", "-local"};
389                        
390                        FelixConfig.overrideID();
391                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
392                        new Felix().run(options);
393                        
394                        // TODO: check table for features
395                        
396                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
397                        checkEvidence(expect);
398                        checkOutput(output, expect);
399                } catch(InterruptedException e) {
400                        e.printStackTrace();
401                        assertTrue(false);
402                }
403        }
404        
405        /**
406         * Combo test using evidence generated with Blah Blah and evidence from a file.
407         */
408        @Test
409        public void comboTest1() {
410                try {
411                        String output = "test/felix/output/out.txt_IOHDFSTest_comboTest1";
412                        String[] args = {"-e", "test/felix/io_test/evid.db", "-i", 
413                                        "test/felix/io_test/prog.mln-hdfs-combo1,test/felix/io_test/prog.mln-hdfs", "-o", output, 
414                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
415                                        "felix_test", "-q", "fact", "-local"};
416                        
417                        FelixConfig.overrideID();
418                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
419                        new Felix().run(options);
420                        
421                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
422                        checkEvidence(expect);
423 
424                        ArrayList<String> lines = FileMan.getLines(output);
425                        assertTrue(lines.size() == 5);
426                        for(int i = 0; i < lines.size(); i++) {
427                                assertTrue(lines.get(i).equals("long(\"This is a test.\")") || 
428                                                lines.get(i).equals("long(\"This is another sentence.\")") ||
429                                                lines.get(i).equals("long(\"This is the end.\")") ||
430                                                lines.get(i).equals("fact(\"1\", \"2\")") || 
431                                                lines.get(i).equals("fact(\"4\", \"5\")"));
432                        }
433 
434                } catch(InterruptedException e) {
435                        e.printStackTrace();
436                        assertTrue(false);
437                }
438        }
439 
440        /**
441         * Combo test using evidence generated with Blah Blah and evidence from a database table.
442         */
443        @Test
444        public void comboTest2() {
445                        try {
446                        String output = "test/felix/output/out.txt_IOHDFSTest_comboTest2";
447                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-combo2,test/felix/io_test/prog.mln-hdfs", "-o", output, 
448                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
449                                        "felix_test", "-q", "fact", "-local"};
450                        
451                        FelixConfig.overrideID();
452                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
453                        new Felix().run(options);
454                        
455                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
456                        checkEvidence(expect);
457                        
458                        ArrayList<String> lines = FileMan.getLines(output);
459                        assertTrue(lines.size() == 5);
460                        for(int i = 0; i < lines.size(); i++) {
461                                assertTrue(lines.get(i).equals("long(\"This is a test.\")") || 
462                                                lines.get(i).equals("long(\"This is another sentence.\")") ||
463                                                lines.get(i).equals("long(\"This is the end.\")") ||
464                                                lines.get(i).equals("fact(\"11\", \"12\")") || 
465                                                lines.get(i).equals("fact(\"14\", \"15\")"));
466                        }
467 
468                } catch(InterruptedException e) {
469                        e.printStackTrace();
470                        assertTrue(false);
471                }
472        }
473 
474        /**
475         * Combo test using evidence generated with Blah Blah, evidence from a file, and evidence from a database table.
476         */
477        @Test
478        public void comboTest3() {
479                try {
480                        String output = "test/felix/output/out.txt_IOHDFSTest_comboTest3";
481                        String[] args = {"-e", "test/felix/io_test/evid.db", "-i", 
482                                        "test/felix/io_test/prog.mln-hdfs-combo3,test/felix/io_test/prog.mln-hdfs", "-o", output, 
483                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
484                                        "felix_test", "-q", "fact", "-local"};
485                        
486                        FelixConfig.overrideID();
487                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
488                        new Felix().run(options);
489                        
490                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
491                        checkEvidence(expect);
492                        
493                        ArrayList<String> lines = FileMan.getLines(output);
494                        System.out.println("size: " + lines.size());
495                        assertTrue(lines.size() == 7);
496                        for(int i = 0; i < lines.size(); i++) {
497                                System.out.println("line: " + lines.get(i));
498                                assertTrue(lines.get(i).equals("long(\"This is a test.\")") || 
499                                                lines.get(i).equals("long(\"This is another sentence.\")") ||
500                                                lines.get(i).equals("long(\"This is the end.\")") ||
501                                                lines.get(i).equals("fact(\"1\", \"2\")") || 
502                                                lines.get(i).equals("fact(\"4\", \"5\")") ||
503                                                lines.get(i).equals("fact(\"11\", \"12\")") || 
504                                                lines.get(i).equals("fact(\"14\", \"15\")"));
505 
506                        }
507 
508                } catch(InterruptedException e) {
509                        e.printStackTrace();
510                        assertTrue(false);
511                }
512        }
513 
514        /**
515         * 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.
516         */
517        @Test
518        public void comboTest4() {
519                try {
520                        String output = "test/felix/output/out.txt_IOHDFSTest_comboTest4";
521                        String[] args = {"-e", "test/felix/io_test/evid.db", "-i", 
522                                        "test/felix/io_test/prog.mln-hdfs-combo4,test/felix/io_test/prog.mln-hdfs", "-o", output, 
523                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
524                                        "felix_test", "-q", "fact,long2", "-local"};
525                        
526                        FelixConfig.overrideID();
527                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
528                        new Felix().run(options);
529                        
530                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
531                        checkEvidence(expect);
532                        
533                        ArrayList<String> lines = FileMan.getLines(output);
534                        System.out.println("size: " + lines.size());
535                        assertTrue(lines.size() == 10);
536                        for(int i = 0; i < lines.size(); i++) {
537                                System.out.println("line: " + lines.get(i));
538                                assertTrue(lines.get(i).equals("long(\"This is a test.\")") || 
539                                                lines.get(i).equals("long(\"This is another sentence.\")") ||
540                                                lines.get(i).equals("long(\"This is the end.\")") ||
541                                                lines.get(i).equals("long2(\"This is a test.\")") || 
542                                                lines.get(i).equals("long2(\"This is another sentence.\")") ||
543                                                lines.get(i).equals("long2(\"This is the end.\")") ||
544                                                lines.get(i).equals("fact(\"1\", \"2\")") || 
545                                                lines.get(i).equals("fact(\"4\", \"5\")") ||
546                                                lines.get(i).equals("fact(\"11\", \"12\")") || 
547                                                lines.get(i).equals("fact(\"14\", \"15\")"));
548 
549                        }
550 
551                } catch(InterruptedException e) {
552                        e.printStackTrace();
553                        assertTrue(false);
554                }
555        }
556 
557        /**
558         * Test re-running with a feature that is already extracted.
559         */
560        @Test
561        public void repeatTest() {
562                try {
563                        String output = "test/felix/output/out.txt_IOHDFSTest_repeatTest";
564                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-simple,test/felix/io_test/prog.mln-hdfs", "-o", output, 
565                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
566                                        "felix_test", "-local"};
567                        
568                        FelixConfig.overrideID();
569                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
570                        new Felix().run(options);
571                        
572                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end." };
573                        checkEvidence(expect);
574                        checkOutput(output, expect);
575                        
576                        // TODO: check that feature is not re-extracted somehow?
577 
578                } catch(InterruptedException e) {
579                        e.printStackTrace();
580                        assertTrue(false);
581                }
582        }
583 
584// NOTE: bad test, XML is case sensitive
585//        @Test
586//        public void xmlCaseTest() {
587//                try {
588//                        String output = "test/felix/output/out.txt_IOHDFSTest_xmlCaseTest";
589//                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-xml-case,test/felix/io_test/prog.mln-hdfs", "-o", output, 
590//                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
591//                                        "felix_test", "-local"};
592//                        
593//                        FelixConfig.overrideID();
594//                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
595//                        new Felix().run(options);
596//                        
597//                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end." };
598//                        checkEvidence(expect);
599//                        checkOutput(output, expect);
600//                } catch(InterruptedException e) {
601//                        e.printStackTrace();
602//                        assertTrue(false);
603//                }
604//        }
605        
606        /**
607         * Test using an XML file with no matching tags.
608         */
609        @Test
610        public void xmlNoMatchTest() {
611                try {
612                        String output = "test/felix/output/out.txt_IOHDFSTest_xmlNoMatchTest";
613                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-xml-no-match,test/felix/io_test/prog.mln-hdfs", "-o", output, 
614                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
615                                        "felix_test", "-local"};
616                        
617                        FelixConfig.overrideID();
618                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
619                        new Felix().run(options);
620                        
621                        String[] expect = { };
622                        checkEvidence(expect);
623                        checkOutput(output, expect);
624                } catch(InterruptedException e) {
625                        e.printStackTrace();
626                        assertTrue(false);
627                }
628        }
629 
630        /**
631         * Test the use of python comments.
632         */
633        @Test
634        public void commentTest() {
635                try {
636                        String output = "test/felix/output/out.txt_IOHDFSTest_commentTest";
637                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-comment,test/felix/io_test/prog.mln-hdfs", "-o", output, 
638                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
639                                        "felix_test", "-local"};
640                        
641                        FelixConfig.overrideID();
642                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
643                        new Felix().run(options);
644                        
645                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
646                        checkEvidence(expect);
647                        checkOutput(output, expect);
648 
649                } catch(InterruptedException e) {
650                        e.printStackTrace();
651                        assertTrue(false);
652                }
653        }
654        
655        /**
656         * Test the use of python print statements.
657         */
658        @Test
659        public void printTest() {
660                try {
661                        String output = "test/felix/output/out.txt_IOHDFSTest_printTest";
662                        String[] args = {"-i", "test/felix/io_test/prog.mln-hdfs-print,test/felix/io_test/prog.mln-hdfs", "-o", output, 
663                                        "-queryFile", "test/felix/io_test/query.db-hdfs", "-keepData", "-auxSchema",
664                                        "felix_test", "-local"};
665                        
666                        FelixConfig.overrideID();
667                        FelixCommandOptions options = FelixUIMan.parseCommand(args);
668                        new Felix().run(options);
669                        
670                        String[] expect = { "This is a test.", "This is another sentence.", "This is the end."};
671                        checkEvidence(expect);
672                        checkOutput(output, expect);
673                        
674                        // TODO: check if print statements actually printed to console?
675 
676                } catch(InterruptedException e) {
677                        e.printStackTrace();
678                        assertTrue(false);
679                }
680        }
681 
682 
683}

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