1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 package name.angoca.zemucan.core.lexical.impl;
30
31 import name.angoca.zemucan.AbstractZemucanException;
32 import name.angoca.zemucan.grammarReader.api.GrammarReaderController;
33 import name.angoca.zemucan.interfaze.model.ReturnOptions;
34 import name.angoca.zemucan.tools.Constants;
35 import name.angoca.zemucan.tools.configurator.Configurator;
36 import name.angoca.zemucan.tools.test.RandomTestRunner;
37
38 import org.junit.AfterClass;
39 import org.junit.Assert;
40 import org.junit.BeforeClass;
41 import org.junit.Test;
42 import org.junit.runner.RunWith;
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 @RunWith(RandomTestRunner.class)
64 public final class ImplementationLexicalAnalyzerRealGrammarTest {
65
66
67
68
69
70
71
72 @BeforeClass
73 public static void setUpBeforeClass() throws AbstractZemucanException {
74 System.setProperty(Constants.ZEMUCAN_CONF_XML_PROPERTY,
75 "sa_conf-test-realGrammar.xml");
76 Configurator.getInstance().setProperty(
77 Constants.GRAMMAR_READER_NAME_PROPERTY,
78 Configurator.GRAMMAR_READER_NAME_VALUE);
79
80
81 ImplementationLexicalAnalyzer.getInstance();
82 }
83
84
85
86
87 @AfterClass
88 public static void tearDownAfterClass() {
89
90 ImplementationLexicalAnalyzer.destroyInstance();
91
92
93 Configurator.destroyInstance();
94 GrammarReaderController.destroyInstance();
95 System.clearProperty(Constants.ZEMUCAN_CONF_XML_PROPERTY);
96 }
97
98
99
100
101 public ImplementationLexicalAnalyzerRealGrammarTest() {
102
103 }
104
105
106
107
108
109
110
111 @Test
112 public void test1() throws AbstractZemucanException {
113 final String cmdIn = "";
114
115 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
116 .analyzePhrase(cmdIn);
117
118 final String actual = ret.getPhrase();
119
120 final String expected = "";
121
122 final int actualOptionsSize = ret.getOptions().length;
123 final int actualPhrasesSize = ret.getPhrases().length;
124 Assert.assertEquals("phrase '" + cmdIn + "'", expected, actual);
125
126 Assert.assertEquals("options '" + cmdIn + "'", 8, actualOptionsSize);
127
128 Assert.assertEquals("phrases '" + cmdIn + "'", 0, actualPhrasesSize);
129 }
130
131
132
133
134
135
136
137 @Test
138 public void test10() throws AbstractZemucanException {
139 final String cmdIn = "db2 create";
140
141 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
142 .analyzePhrase(cmdIn);
143
144 final String actual = ret.getPhrase();
145
146 final String expected = "db2 create table";
147
148 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
149
150 Assert.assertTrue("options: '" + cmdIn + "'",
151 ret.getOptions().length == 2);
152 Assert.assertTrue("phrases: '" + cmdIn + "'",
153 ret.getPhrases().length == 0);
154 }
155
156
157
158
159
160
161
162 @Test
163 public void test10a() throws AbstractZemucanException {
164 final String cmdIn = " db2 create";
165
166 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
167 .analyzePhrase(cmdIn);
168
169 final String actual = ret.getPhrase();
170
171 final String expected = "db2 create table";
172
173 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
174
175 Assert.assertTrue("options: '" + cmdIn + "'",
176 ret.getOptions().length == 2);
177 Assert.assertTrue("phrases: '" + cmdIn + "'",
178 ret.getPhrases().length == 0);
179 }
180
181
182
183
184
185
186
187 @Test
188 public void test11() throws AbstractZemucanException {
189 final String cmdIn = "db2 create ";
190
191 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
192 .analyzePhrase(cmdIn);
193
194 final String actual = ret.getPhrase();
195
196 final String expected = "db2 create table";
197
198 final int actualOptionsSize = ret.getOptions().length;
199 final int actualPhrasesSize = ret.getPhrases().length;
200 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
201
202 Assert.assertEquals("options: '" + cmdIn + "'", 2, actualOptionsSize);
203
204 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
205 }
206
207
208
209
210
211
212
213 @Test
214 public void test12() throws AbstractZemucanException {
215 final String cmdIn = "db2 create t";
216
217 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
218 .analyzePhrase(cmdIn);
219
220 final String actual = ret.getPhrase();
221
222 final String expected = "db2 create table";
223
224 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
225 Assert.assertTrue("options: '" + cmdIn + "'",
226 ret.getOptions().length == 0);
227 Assert.assertTrue("phrases: '" + cmdIn + "'",
228 ret.getPhrases().length == 2);
229 }
230
231
232
233
234
235
236
237 @Test
238 public void test13() throws AbstractZemucanException {
239 final String cmdIn = "db2 create tables";
240
241 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
242 .analyzePhrase(cmdIn);
243
244 final String actual = ret.getPhrase();
245
246 final String expected = "db2 create tablespace";
247
248 final int actualOptionsSize = ret.getOptions().length;
249 final int actualPhrasesSize = ret.getPhrases().length;
250 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
251 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
252 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
253 }
254
255
256
257
258
259
260
261 @Test
262 public void test14() throws AbstractZemucanException {
263 final String cmdIn = "db2 create tablespace";
264
265 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
266 .analyzePhrase(cmdIn);
267
268 final String actual = ret.getPhrase();
269
270 final String expected = "db2 create tablespace";
271
272 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
273 Assert.assertTrue("options: '" + cmdIn + "'",
274 ret.getOptions().length == 0);
275 Assert.assertTrue("phrases: '" + cmdIn + "'",
276 ret.getPhrases().length == 0);
277 }
278
279
280
281
282
283
284
285 @Test
286 public void test15() throws AbstractZemucanException {
287 final String cmdIn = "db2 create ta";
288
289 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
290 .analyzePhrase(cmdIn);
291
292 final String actual = ret.getPhrase();
293
294 final String expected = "db2 create table";
295
296 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
297 Assert.assertTrue("options: '" + cmdIn + "'",
298 ret.getOptions().length == 0);
299 Assert.assertTrue("phrases: '" + cmdIn + "'",
300 ret.getPhrases().length == 2);
301 }
302
303
304
305
306
307
308
309 @Test
310 public void test16() throws AbstractZemucanException {
311 final String cmdIn = "db2 create table";
312
313 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
314 .analyzePhrase(cmdIn);
315
316 final String actual = ret.getPhrase();
317
318 final String expected = "db2 create table";
319
320 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
321
322 Assert.assertTrue("options: '" + cmdIn + "'",
323 ret.getOptions().length == 1);
324 Assert.assertTrue("phrases: '" + cmdIn + "'",
325 ret.getPhrases().length == 1);
326 }
327
328
329
330
331
332
333
334 @Test
335 public void test17() throws AbstractZemucanException {
336 final String cmdIn = "db2 create table ";
337
338 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
339 .analyzePhrase(cmdIn);
340
341 final String actual = ret.getPhrase();
342
343 final String expected = "db2 create table ";
344
345 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
346
347 Assert.assertTrue("options: '" + cmdIn + "'",
348 ret.getOptions().length == 1);
349 Assert.assertTrue("phrases: '" + cmdIn + "'",
350 ret.getPhrases().length == 0);
351 }
352
353
354
355
356
357
358
359 @Test
360 public void test18() throws AbstractZemucanException {
361 final String cmdIn = "db2 create table t1";
362
363 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
364 .analyzePhrase(cmdIn);
365
366 final String actual = ret.getPhrase();
367
368 final String expected = "db2 create table t1 (";
369
370 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
371 Assert.assertTrue("options: '" + cmdIn + "'",
372 ret.getOptions().length == 0);
373 Assert.assertTrue("phrases: '" + cmdIn + "'",
374 ret.getPhrases().length == 0);
375 }
376
377
378
379
380
381
382
383 @Test
384 public void test19() throws AbstractZemucanException {
385 final String cmdIn = "db2 create table t1 ";
386
387 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
388 .analyzePhrase(cmdIn);
389
390 final String actual = ret.getPhrase();
391
392 final String expected = "db2 create table t1 (";
393
394 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
395 Assert.assertTrue("options: '" + cmdIn + "'",
396 ret.getOptions().length == 0);
397 Assert.assertTrue("phrases: '" + cmdIn + "'",
398 ret.getPhrases().length == 0);
399 }
400
401
402
403
404
405
406
407 @Test
408 public void test2() throws AbstractZemucanException {
409 final String cmdIn = "d";
410
411 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
412 .analyzePhrase(cmdIn);
413
414 final String actual = ret.getPhrase();
415
416 final String expected = "db2";
417
418 final int actualOptionsSize = ret.getOptions().length;
419 final int actualPhrasesSize = ret.getPhrases().length;
420 Assert.assertEquals("phrase '" + cmdIn + "'", expected, actual);
421
422 Assert.assertEquals("options '" + cmdIn + "'", 0, actualOptionsSize);
423
424 Assert.assertEquals("phrases '" + cmdIn + "'", 5, actualPhrasesSize);
425 }
426
427
428
429
430
431
432
433 @Test
434 public void test20() throws AbstractZemucanException {
435 final String cmdIn = "db2 create table t1 (";
436
437 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
438 .analyzePhrase(cmdIn);
439
440 final String actual = ret.getPhrase();
441
442 final String expected = "db2 create table t1 ( ";
443
444 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
445 Assert.assertTrue("options: '" + cmdIn + "'",
446 ret.getOptions().length == 1);
447 Assert.assertTrue("phrases: '" + cmdIn + "'",
448 ret.getPhrases().length == 0);
449 }
450
451
452
453
454
455
456
457 @Test
458 public void test21() throws AbstractZemucanException {
459 final String cmdIn = "db2 create table t1(";
460
461 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
462 .analyzePhrase(cmdIn);
463
464 final String actual = ret.getPhrase();
465
466 final String expected = "db2 create table t1( ";
467
468 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
469
470 Assert.assertTrue("options: '" + cmdIn + "'",
471 ret.getOptions().length == 1);
472 Assert.assertTrue("phrases: '" + cmdIn + "'",
473 ret.getPhrases().length == 0);
474 }
475
476
477
478
479
480
481
482 @Test
483 public void test22() throws AbstractZemucanException {
484 final String cmdIn = "db2 create table t1 (c1";
485
486 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
487 .analyzePhrase(cmdIn);
488
489 final String actual = ret.getPhrase();
490
491 final String expected = "db2 create table t1 (c1 ";
492
493 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
494
495 Assert.assertTrue("options: '" + cmdIn + "'",
496 ret.getOptions().length == 2);
497 Assert.assertTrue("phrases: '" + cmdIn + "'",
498 ret.getPhrases().length == 0);
499 }
500
501
502
503
504
505
506
507 @Test
508 public void test23() throws AbstractZemucanException {
509 final String cmdIn = "db2 create table t1( c1";
510
511 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
512 .analyzePhrase(cmdIn);
513
514 final String actual = ret.getPhrase();
515
516 final String expected = "db2 create table t1( c1 ";
517
518 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
519
520 Assert.assertTrue("options: '" + cmdIn + "'",
521 ret.getOptions().length == 2);
522 Assert.assertTrue("phrases: '" + cmdIn + "'",
523 ret.getPhrases().length == 0);
524 }
525
526
527
528
529
530
531
532 @Test
533 public void test24() throws AbstractZemucanException {
534 final String cmdIn = "db2 create table t1 ( c1 int )";
535
536 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
537 .analyzePhrase(cmdIn);
538
539 final String actual = ret.getPhrase();
540
541 final String expected = "db2 create table t1 ( c1 int )";
542
543 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
544 Assert.assertTrue("options: '" + cmdIn + "'",
545 ret.getOptions().length == 0);
546 Assert.assertTrue("phrases: '" + cmdIn + "'",
547 ret.getPhrases().length == 0);
548 }
549
550
551
552
553
554
555
556 @Test
557 public void test25() throws AbstractZemucanException {
558 final String cmdIn = " db2";
559
560 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
561 .analyzePhrase(cmdIn);
562
563 final String actual = ret.getPhrase();
564
565 final String expected = "db2";
566
567 final int actualOptionsSize = ret.getOptions().length;
568 final int actualPhrasesSize = ret.getPhrases().length;
569 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
570
571 Assert.assertEquals("options: '" + cmdIn + "'", 3, actualOptionsSize);
572
573 Assert.assertEquals("phrases: '" + cmdIn + "'", 4, actualPhrasesSize);
574 }
575
576
577
578
579
580
581
582 @Test
583 public void test25a() throws AbstractZemucanException {
584 final String cmdIn = " db2";
585
586 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
587 .analyzePhrase(cmdIn);
588
589 final String actual = ret.getPhrase();
590
591 final String expected = "db2";
592
593 final int actualOptionsSize = ret.getOptions().length;
594 final int actualPhrasesSize = ret.getPhrases().length;
595 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
596
597 Assert.assertEquals("options: '" + cmdIn + "'", 3, actualOptionsSize);
598
599 Assert.assertEquals("phrases: '" + cmdIn + "'", 4, actualPhrasesSize);
600 }
601
602
603
604
605
606
607
608 @Test
609 public void test26() throws AbstractZemucanException {
610 final String cmdIn = "DB";
611
612 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
613 .analyzePhrase(cmdIn);
614
615 final String actual = ret.getPhrase();
616
617 final String expected = "db2";
618
619 final int actualOptionsSize = ret.getOptions().length;
620 final int actualPhrasesSize = ret.getPhrases().length;
621 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
622
623 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
624
625 Assert.assertEquals("phrases: '" + cmdIn + "'", 5, actualPhrasesSize);
626 }
627
628
629
630
631
632
633
634 @Test
635 public void test26a() throws AbstractZemucanException {
636 final String cmdIn = " DB";
637
638 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
639 .analyzePhrase(cmdIn);
640
641 final String actual = ret.getPhrase();
642
643 final String expected = "db2";
644
645 final int actualOptionsSize = ret.getOptions().length;
646 final int actualPhrasesSize = ret.getPhrases().length;
647 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
648
649 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
650
651 Assert.assertEquals("phrases: '" + cmdIn + "'", 5, actualPhrasesSize);
652 }
653
654
655
656
657
658
659
660 @Test
661 public void test27() throws AbstractZemucanException {
662 final String cmdIn = "DB2 CREA";
663
664 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
665 .analyzePhrase(cmdIn);
666
667 final String actual = ret.getPhrase();
668
669 final String expected = "DB2 create";
670
671 final int actualOptionsSize = ret.getOptions().length;
672 final int actualPhrasesSize = ret.getPhrases().length;
673 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
674 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
675 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
676 }
677
678
679
680
681
682
683
684 @Test
685 public void test27A() throws AbstractZemucanException {
686 final String cmdIn = " DB2 CREA";
687
688 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
689 .analyzePhrase(cmdIn);
690
691 final String actual = ret.getPhrase();
692
693 final String expected = "DB2 create";
694
695 final int actualOptionsSize = ret.getOptions().length;
696 final int actualPhrasesSize = ret.getPhrases().length;
697 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
698 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
699 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
700 }
701
702
703
704
705
706
707
708 @Test
709 public void test3() throws AbstractZemucanException {
710 final String cmdIn = "db";
711
712 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
713 .analyzePhrase(cmdIn);
714
715 final String actual = ret.getPhrase();
716
717 final String expected = "db2";
718
719 final int actualOptionsSize = ret.getOptions().length;
720 final int actualPhrasesSize = ret.getPhrases().length;
721 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
722
723 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
724
725 Assert.assertEquals("phrases: '" + cmdIn + "'", 5, actualPhrasesSize);
726 }
727
728
729
730
731
732
733
734 @Test
735 public void test4() throws AbstractZemucanException {
736 final String cmdIn = "db2";
737
738 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
739 .analyzePhrase(cmdIn);
740
741 final String actual = ret.getPhrase();
742
743 final String expected = "db2";
744
745 final int actualOptionsSize = ret.getOptions().length;
746 final int actualPhrasesSize = ret.getPhrases().length;
747 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
748
749 Assert.assertEquals("options: '" + cmdIn + "'", 3, actualOptionsSize);
750
751 Assert.assertEquals("phrases: '" + cmdIn + "'", 4, actualPhrasesSize);
752 }
753
754
755
756
757
758
759
760 @Test
761 public void test5() throws AbstractZemucanException {
762 final String cmdIn = "db2 ";
763
764 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
765 .analyzePhrase(cmdIn);
766
767 final String actual = ret.getPhrase();
768
769 final String expected = "db2 ";
770
771 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
772
773 Assert.assertTrue("options: '" + cmdIn + "'",
774 ret.getOptions().length == 3);
775 Assert.assertTrue("phrases: '" + cmdIn + "'",
776 ret.getPhrases().length == 0);
777 }
778
779
780
781
782
783
784
785 @Test
786 public void test5a() throws AbstractZemucanException {
787 final String cmdIn = "db2 ";
788
789 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
790 .analyzePhrase(cmdIn);
791
792 final String actual = ret.getPhrase();
793
794 final String expected = "db2 ";
795
796 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
797
798 Assert.assertTrue("options: '" + cmdIn + "'",
799 ret.getOptions().length == 3);
800 Assert.assertTrue("phrases: '" + cmdIn + "'",
801 ret.getPhrases().length == 0);
802 }
803
804
805
806
807
808
809
810 @Test
811 public void test6() throws AbstractZemucanException {
812 final String cmdIn = "db2 a";
813
814 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
815 .analyzePhrase(cmdIn);
816
817 final String actual = ret.getPhrase();
818
819 final String expected = "db2 attach";
820
821 final int actualOptionsSize = ret.getOptions().length;
822 final int actualPhrasesSize = ret.getPhrases().length;
823 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
824 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
825 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
826 }
827
828
829
830
831
832
833
834 @Test
835 public void test6a() throws AbstractZemucanException {
836 final String cmdIn = "db2 c";
837
838 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
839 .analyzePhrase(cmdIn);
840
841 final String actual = ret.getPhrase();
842
843 final String expected = "db2 c";
844
845 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
846 Assert.assertTrue("options: '" + cmdIn + "'",
847 ret.getOptions().length == 0);
848 Assert.assertTrue("phrases: '" + cmdIn + "'",
849 ret.getPhrases().length == 2);
850 }
851
852
853
854
855
856
857
858
859
860
861 @Test
862 public void test7() throws AbstractZemucanException {
863 final String cmdIn = "db2 cr";
864
865 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
866 .analyzePhrase(cmdIn);
867
868 final String actual = ret.getPhrase();
869
870 final String expected = "db2 create";
871
872 final int actualOptionsSize = ret.getOptions().length;
873 final int actualPhrasesSize = ret.getPhrases().length;
874 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
875 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
876 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
877 }
878
879
880
881
882
883
884
885 @Test
886 public void test8() throws AbstractZemucanException {
887 final String cmdIn = "db2 crea";
888
889 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
890 .analyzePhrase(cmdIn);
891
892 final String actual = ret.getPhrase();
893
894 final String expected = "db2 create";
895
896 final int actualOptionsSize = ret.getOptions().length;
897 final int actualPhrasesSize = ret.getPhrases().length;
898 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
899 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
900 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
901 }
902
903
904
905
906
907
908
909 @Test
910 public void test8a() throws AbstractZemucanException {
911 final String cmdIn = " db2 crea";
912
913 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
914 .analyzePhrase(cmdIn);
915
916 final String actual = ret.getPhrase();
917
918 final String expected = "db2 create";
919
920 final int actualOptionsSize = ret.getOptions().length;
921 final int actualPhrasesSize = ret.getPhrases().length;
922 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
923 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
924 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
925 }
926
927
928
929
930
931
932
933 @Test
934 public void test9() throws AbstractZemucanException {
935 final String cmdIn = "db2 crea ";
936
937 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
938 .analyzePhrase(cmdIn);
939
940 final String actual = ret.getPhrase();
941
942 final String expected = "db2 crea ";
943
944 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
945 Assert.assertTrue("options: '" + cmdIn + "'",
946 ret.getOptions().length == 0);
947 Assert.assertTrue("phrases: '" + cmdIn + "'",
948 ret.getPhrases().length == 0);
949 }
950
951
952
953
954
955
956 @Test
957 public void testCase1() throws AbstractZemucanException {
958 final String cmdIn = "db2";
959
960 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
961 .analyzePhrase(cmdIn);
962
963 final String actual = ret.getPhrase();
964
965 final String expected = "db2";
966
967 final int actualOptionsSize = ret.getOptions().length;
968 final int actualPhrasesSize = ret.getPhrases().length;
969 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
970
971 Assert.assertEquals("options: '" + cmdIn + "'", 3, actualOptionsSize);
972
973 Assert.assertEquals("phrases: '" + cmdIn + "'", 4, actualPhrasesSize);
974 }
975
976
977
978
979
980
981
982
983 public void testCase2() throws AbstractZemucanException {
984 final String cmdIn = "???";
985
986 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
987 .analyzePhrase(cmdIn);
988
989 final String actual = ret.getPhrase();
990
991 final String expected = "???";
992
993 final int actualOptionsSize = ret.getOptions().length;
994 final int actualPhrasesSize = ret.getPhrases().length;
995 Assert.assertEquals("phrase: '" + cmdIn + "' TODO", expected, actual);
996
997 Assert.assertEquals("options: '" + cmdIn + "' TODO", -1,
998 actualOptionsSize);
999
1000 Assert.assertEquals("phrases: '" + cmdIn + "' TODO", -1,
1001 actualPhrasesSize);
1002 }
1003
1004
1005
1006
1007
1008
1009 @Test
1010 public void testCase3() throws AbstractZemucanException {
1011 final String cmdIn = "db2 c";
1012
1013 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
1014 .analyzePhrase(cmdIn);
1015
1016 final String actual = ret.getPhrase();
1017
1018 final String expected = "db2 c";
1019
1020 final int actualOptionsSize = ret.getOptions().length;
1021 final int actualPhrasesSize = ret.getPhrases().length;
1022 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
1023 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
1024 Assert.assertEquals("phrases: '" + cmdIn + "'", 2, actualPhrasesSize);
1025 }
1026
1027
1028
1029
1030
1031
1032 @Test
1033 public void testCase4() throws AbstractZemucanException {
1034 final String cmdIn = "db2fm";
1035
1036 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
1037 .analyzePhrase(cmdIn);
1038
1039 final String actual = ret.getPhrase();
1040
1041 final String expected = "db2fm";
1042
1043 final int actualOptionsSize = ret.getOptions().length;
1044 final int actualPhrasesSize = ret.getPhrases().length;
1045 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
1046
1047 Assert.assertEquals("options: '" + cmdIn + "'", 2, actualOptionsSize);
1048
1049 Assert.assertEquals("phrases: '" + cmdIn + "'", 1, actualPhrasesSize);
1050 }
1051
1052
1053
1054
1055
1056
1057 @Test
1058 public void testCase5() throws AbstractZemucanException {
1059 final String cmdIn = "db2 create table";
1060
1061 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
1062 .analyzePhrase(cmdIn);
1063
1064 final String actual = ret.getPhrase();
1065
1066 final String expected = "db2 create table";
1067
1068 final int actualOptionsSize = ret.getOptions().length;
1069 final int actualPhrasesSize = ret.getPhrases().length;
1070 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
1071 Assert.assertEquals("options: '" + cmdIn + "'", 1, actualOptionsSize);
1072 Assert.assertEquals("phrases: '" + cmdIn + "'", 1, actualPhrasesSize);
1073 }
1074
1075
1076
1077
1078
1079
1080 @Test
1081 public void testCase6() throws AbstractZemucanException {
1082 final String cmdIn = "db2 create tables";
1083
1084 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
1085 .analyzePhrase(cmdIn);
1086
1087 final String actual = ret.getPhrase();
1088
1089 final String expected = "db2 create tablespace";
1090
1091 final int actualOptionsSize = ret.getOptions().length;
1092 final int actualPhrasesSize = ret.getPhrases().length;
1093 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
1094 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
1095
1096 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
1097 }
1098
1099
1100
1101
1102
1103
1104 @Test
1105 public void testCase7() throws AbstractZemucanException {
1106 final String cmdIn = "db2 create";
1107
1108 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
1109 .analyzePhrase(cmdIn);
1110
1111 final String actual = ret.getPhrase();
1112
1113 final String expected = "db2 create table";
1114
1115 final int actualOptionsSize = ret.getOptions().length;
1116 final int actualPhrasesSize = ret.getPhrases().length;
1117 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
1118 Assert.assertEquals("options: '" + cmdIn + "'", 2, actualOptionsSize);
1119 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
1120 }
1121
1122
1123
1124
1125
1126
1127 @Test
1128 public void testCase8() throws AbstractZemucanException {
1129 final String cmdIn = "db2 create table ";
1130
1131 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
1132 .analyzePhrase(cmdIn);
1133
1134 final String actual = ret.getPhrase();
1135
1136 final String expected = "db2 create table ";
1137
1138 final int actualOptionsSize = ret.getOptions().length;
1139 final int actualPhrasesSize = ret.getPhrases().length;
1140 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
1141 Assert.assertEquals("options: '" + cmdIn + "'", 1, actualOptionsSize);
1142 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
1143 }
1144
1145
1146
1147
1148
1149
1150
1151 @Test
1152 public void testCase9() throws AbstractZemucanException {
1153 final String cmdIn = "db2 create tablespace";
1154
1155 final ReturnOptions ret = ImplementationLexicalAnalyzer.getInstance()
1156 .analyzePhrase(cmdIn);
1157
1158 final String actual = ret.getPhrase();
1159
1160 final String expected = "db2 create tablespace";
1161
1162 final int actualOptionsSize = ret.getOptions().length;
1163 final int actualPhrasesSize = ret.getPhrases().length;
1164 Assert.assertEquals("phrase: '" + cmdIn + "'", expected, actual);
1165 Assert.assertEquals("options: '" + cmdIn + "'", 0, actualOptionsSize);
1166 Assert.assertEquals("phrases: '" + cmdIn + "'", 0, actualPhrasesSize);
1167 }
1168 }