1 package org.melati.poem.test.throwing;
2
3 import java.sql.Connection;
4 import java.sql.PreparedStatement;
5 import java.sql.ResultSet;
6 import java.sql.Statement;
7
8 import org.melati.poem.Database;
9 import org.melati.poem.DatabaseInitialisationPoemException;
10 import org.melati.poem.ExecutingSQLPoemException;
11 import org.melati.poem.FieldContentsPoemException;
12 import org.melati.poem.GroupCapability;
13 import org.melati.poem.PoemDatabaseFactory;
14 import org.melati.poem.SQLSeriousPoemException;
15 import org.melati.poem.SimplePrepareFailedPoemException;
16 import org.melati.poem.SimpleRetrievalFailedPoemException;
17 import org.melati.poem.Column.LoadException;
18 import org.melati.poem.dbms.test.sql.Thrower;
19
20
21
22
23
24
25 public class TableTest extends org.melati.poem.test.TableTest {
26
27 public TableTest(String arg0) {
28 super(arg0);
29 }
30
31 protected void setUp() throws Exception {
32 PoemDatabaseFactory.removeDatabase(getDatabaseName());
33 super.setUp();
34 assertEquals("org.melati.poem.dbms.test.HsqldbThrower",getDb().getDbms().getClass().getName());
35 }
36
37 protected void tearDown() throws Exception {
38 try {
39 super.tearDown();
40 } finally {
41 PoemDatabaseFactory.removeDatabase(getDatabaseName());
42 }
43 }
44
45 public Database getDatabase(String name) {
46 maxTrans = 8;
47 Database db = PoemDatabaseFactory.getDatabase(name,
48 "jdbc:hsqldb:mem:" + name,
49 "sa",
50 "",
51 "org.melati.poem.PoemDatabase",
52 "org.melati.poem.dbms.test.HsqldbThrower",
53 false,
54 false,
55 false, maxTrans);
56 return db;
57 }
58
59 public void test_getColumn() {
60
61
62 }
63
64 public void test_newPersistent() {
65
66
67 }
68
69 public void testAddColumnAndCommitBigDecimal() {
70
71
72 }
73
74 public void testAddColumnAndCommitBinary() {
75
76
77 }
78
79 public void testAddColumnAndCommitBoolean() {
80
81
82 }
83
84 public void testAddColumnAndCommitDate() {
85
86
87 }
88
89 public void testAddColumnAndCommitDeleted() throws Exception {
90
91
92 }
93
94 public void testAddColumnAndCommitDisplaylevel() {
95
96
97 }
98
99 public void testAddColumnAndCommitDouble() {
100
101
102 }
103
104 public void testAddColumnAndCommitInteger() {
105
106
107 }
108
109 public void testAddColumnAndCommitIntegrityfix() {
110
111
112 }
113
114 public void testAddColumnAndCommitLong() {
115
116
117 }
118
119 public void testAddColumnAndCommitNullableInteger() {
120
121
122 }
123
124 public void testAddColumnAndCommitPassword() {
125
126
127 }
128
129 public void testAddColumnAndCommitSearchability() {
130
131
132 }
133
134 public void testAddColumnAndCommitString() {
135
136
137 }
138
139 public void testAddColumnAndCommitTimestamp() {
140
141
142 }
143
144 public void testAddColumnAndCommitTroid() {
145
146
147 }
148
149 public void testAddColumnAndCommitType() {
150
151
152 }
153
154 public void testAddListener() {
155
156
157 }
158
159 public void testAppendWhereClause() {
160
161
162 }
163
164 public void testCachedCountPersistent() {
165
166 }
167
168 public void testCachedCountPersistentBooleanBoolean() {
169
170
171 }
172
173 public void testCachedCountString() {
174
175
176 }
177
178 public void testCachedCountStringBoolean() {
179
180
181 }
182
183 public void testCachedCountStringBooleanBoolean() {
184
185
186 }
187
188 public void testCachedExists() {
189
190
191 }
192
193 public void testCachedSelection() {
194
195
196 }
197
198 public void testCachedSelectionField() {
199
200
201 }
202
203 public void testCachedSelectionType() {
204
205
206 }
207
208 public void testCanDeleteColumn() {
209
210
211 }
212
213 public void testCanReadColumn() {
214
215
216 }
217
218 public void testCanSelectColumn() {
219
220
221 }
222
223 public void testCanWriteColumn() {
224
225
226 }
227
228 public void testCnfWhereClauseEnumeration() {
229
230
231 }
232
233 public void testCnfWhereClauseEnumerationBooleanBoolean() {
234
235
236 }
237
238 public void testColumns() {
239
240
241 }
242
243 public void testColumnWithColumnInfoID() {
244
245
246 }
247
248 public void testCount() {
249 Thrower.startThrowing(Connection.class, "createStatement");
250 try {
251 super.testCount();
252 fail("Should have bombed");
253 } catch (ExecutingSQLPoemException e) {
254 assertEquals("Connection bombed", e.innermostException().getMessage());
255 } finally {
256 Thrower.stopThrowing(Connection.class, "createStatement");
257 }
258 }
259
260 public void testCountSQLString() {
261
262
263 }
264
265 public void testCountSQLStringStringBooleanBoolean() {
266
267
268 }
269
270 public void testCountString() {
271
272
273 }
274
275 public void testCountStringBoolean() {
276
277
278 }
279
280 public void testCountStringBooleanBoolean() {
281
282
283 }
284
285 public void testCreateInitialiser() {
286
287
288 }
289
290 public void testCreatePersistent() {
291
292
293 }
294
295 public void testCreateTableInfo() {
296
297
298 }
299
300 public void testDbModifyStructure() {
301
302
303 }
304
305 public void testDefaultCacheLimit() {
306
307
308 }
309
310 public void testDefaultCategory() {
311
312
313 }
314
315 public void testDefaultDescription() {
316
317
318 }
319
320 public void testDefaultDisplayName() {
321
322
323 }
324
325 public void testDefaultDisplayOrder() {
326
327
328 }
329
330 public void testDefaultOrderByClause() {
331
332
333 }
334
335 public void testDefaultRememberAllTroids() {
336
337
338 }
339
340 public void testDefineColumnColumn() {
341
342
343 }
344
345 public void testDefineColumnColumnBoolean() {
346
347
348 }
349
350 public void testDelete_unsafe() {
351
352
353 }
354
355 public void testDelete() {
356
357
358 }
359
360 public void testDeletedColumn() {
361
362
363 }
364
365 public void testDisplayColumn() {
366
367
368 }
369
370 public void testDisplayColumns() {
371
372
373 }
374
375 public void testDisplayColumnsCount() {
376
377
378 }
379
380 public void testDump() {
381
382
383 }
384
385 public void testDumpCacheAnalysis() {
386
387
388 }
389
390 public void testEqualsObject() {
391
392
393 }
394
395 public void testExistsPersistent() {
396
397
398 }
399
400 public void testExistsString() {
401
402
403 }
404
405 public void testExtrasCount() {
406
407
408 }
409
410 public void testFirstSelection() {
411
412
413 }
414
415 public void testGetCacheInfo() {
416
417
418 }
419
420 public void testGetCanCreate() {
421
422
423 }
424
425 public void testGetCategory() {
426
427
428 }
429
430 public void testGetColumn() {
431
432
433 }
434
435 public void testGetColumnsCount() {
436
437
438 }
439
440 public void testGetDatabase() {
441
442
443 }
444
445 public void testGetDefaultCanDelete() {
446
447
448 }
449
450 public void testGetDefaultCanRead() {
451
452
453 }
454
455 public void testGetDefaultCanWrite() {
456
457
458 }
459
460 public void testGetDescription() {
461
462
463 }
464
465 public void testGetDetailDisplayColumns() {
466
467
468 }
469
470 public void testGetDetailDisplayColumnsCount() {
471
472
473 }
474
475 public void testGetDisplayName() {
476
477
478 }
479
480 public void testGetInfo() {
481
482
483 }
484
485 public void testGetName() {
486
487
488 }
489
490 public void testGetObjectInt() {
491 getDb().uncache();
492 Thrower.startThrowing(ResultSet.class, "next");
493 Thrower.startThrowing(ResultSet.class, "close");
494 try {
495 super.testGetObjectInt();
496 fail("Should have blown up");
497 } catch (SimpleRetrievalFailedPoemException e) {
498 assertEquals("ResultSet bombed", e.innermostException().getMessage());
499 } finally {
500 Thrower.stopThrowing(ResultSet.class, "next");
501 Thrower.stopThrowing(ResultSet.class, "close");
502 }
503 getDb().uncache();
504 Thrower.startThrowing(ResultSet.class, "getInt");
505 try {
506 super.testGetObjectInt();
507 fail("Should have blown up");
508 } catch (LoadException e) {
509 assertEquals("ResultSet bombed", e.innermostException().getMessage());
510 } finally {
511 Thrower.stopThrowing(ResultSet.class, "getInt");
512 }
513
514 getDb().getGroupTable().invalidateTransactionStuffs();
515 Thrower.startThrowingAfter(Connection.class,"prepareStatement", 2);
516 try {
517 super.testGetObjectInt();
518 fail("Should have blown up");
519 } catch (SimplePrepareFailedPoemException e) {
520 e.printStackTrace();
521 assertEquals("Connection bombed", e.innermostException().getMessage());
522 } finally {
523 Thrower.stopThrowing(Connection.class, "prepareStatement");
524 }
525
526 }
527
528 public void testGetObjectInteger() {
529
530
531 }
532
533 public void testGetRecordDisplayColumns() {
534
535
536 }
537
538 public void testGetRecordDisplayColumnsCount() {
539
540
541 }
542
543 public void testGetSearchCriterionColumns() {
544
545
546 }
547
548 public void testGetSearchCriterionColumnsCount() {
549
550
551 }
552
553 public void testGetSummaryDisplayColumns() {
554
555
556 }
557
558 public void testGetSummaryDisplayColumnsCount() {
559
560
561 }
562
563 public void testGetTableInfo() {
564
565
566 }
567
568 public void testHashCode() {
569
570
571 }
572
573 public void testInit() {
574
575
576 }
577
578 public void testLoad() {
579
580
581 }
582
583 public void testNewPersistent() {
584
585
586 }
587
588 public void testNotifyColumnInfo() {
589
590
591 }
592
593 public void testNotifyTouched() {
594
595
596 }
597
598 public void testPostInitialise() {
599
600
601 }
602
603 public void testPrimaryCriterionColumn() {
604
605
606 }
607
608 public void testQuotedName() {
609
610
611 }
612
613 public void testReadLock() {
614
615
616 }
617
618 public void testReferencesToPersistent() {
619
620
621 }
622
623 public void testReferencesToTable() {
624
625
626 }
627
628 public void testRememberAllTroids() {
629
630
631 }
632
633 public void testSelection() {
634
635
636 }
637
638 public void testSelectionPersistent() {
639
640
641 }
642
643 public void testSelectionPersistentString() {
644
645
646 }
647
648 public void testSelectionPersistentStringBooleanBoolean() {
649
650
651 }
652
653
654
655
656
657
658 public void testSelectionSQLStringStringBoolean() {
659
660
661 }
662
663
664
665
666
667 public void testSelectionSQLStringStringStringBooleanBoolean() {
668
669
670 }
671
672
673
674
675
676 public void testSelectionString() {
677
678
679 }
680
681
682
683
684
685 public void testSelectionStringStringBoolean() {
686
687
688 }
689
690
691
692
693
694
695 public void testSerial() {
696
697
698 }
699
700
701
702
703
704 public void testSetCacheLimit() {
705
706
707 }
708
709
710
711
712
713 public void testSetDisplayColumn() {
714
715
716 }
717
718
719
720
721
722 public void testSetSearchColumn() {
723
724
725 }
726
727
728
729
730
731 public void testSetTableInfo() {
732
733
734 }
735
736
737
738
739
740 public void testTable() {
741
742
743 }
744
745
746
747
748
749 public void testTableInfoID() {
750
751
752 }
753
754
755
756
757
758 public void testToString() {
759
760
761 }
762
763
764
765
766
767 public void testTrimCache() {
768
769
770 }
771
772
773
774
775
776 public void testTroidColumn() {
777
778
779 }
780
781
782
783
784
785 public void testTroidFor() {
786
787
788 }
789
790
791
792
793
794 public void testTroidSelectionPersistentStringBooleanBooleanPoemTransaction() {
795
796
797 }
798
799
800
801
802
803 public void testTroidSelectionStringStringBoolean() {
804 Thrower.startThrowing(Connection.class, "createStatement");
805 try {
806 super.testTroidSelectionStringStringBoolean();
807 fail("Should have bombed");
808 } catch (ExecutingSQLPoemException e) {
809 assertEquals("Connection bombed", e.innermostException().getMessage());
810 } finally {
811 Thrower.stopThrowing(Connection.class, "createStatement");
812 }
813 }
814
815
816
817
818
819 public void testTroidSelectionStringStringBooleanPoemTransaction() {
820
821
822 }
823
824
825
826
827
828 public void testUncacheContents() {
829
830
831 }
832
833
834
835
836
837 public void testUnifyWithColumnInfo() {
838
839
840 }
841
842
843
844
845
846 public void testUnifyWithDB() {
847
848
849 }
850
851
852
853
854
855 public void testWhereClausePersistent() {
856
857
858 }
859
860
861
862
863
864 public void testWhereClausePersistentBooleanBoolean() {
865
866
867 }
868
869
870
871
872 public void testWriteDown() {
873 Thrower.startThrowing(PreparedStatement.class, "setInt");
874 try {
875 super.testWriteDown();
876 fail("Should have blown up");
877 } catch (FieldContentsPoemException e) {
878 assertEquals("PreparedStatement bombed", e.innermostException().getMessage());
879 } finally {
880 Thrower.stopThrowing(PreparedStatement.class, "setInt");
881 }
882
883 }
884
885
886
887
888 public void testWriteDown2() {
889 Thrower.startThrowing(PreparedStatement.class, "executeUpdate");
890 try {
891 super.testWriteDown();
892 fail("Should have blown up");
893 } catch (ExecutingSQLPoemException e) {
894 assertEquals("PreparedStatement bombed", e.innermostException().getMessage());
895 } finally {
896 Thrower.stopThrowing(PreparedStatement.class, "executeUpdate");
897 }
898 }
899
900
901
902
903 public void testWriteDown3() {
904 Thrower.startThrowingAfter(PreparedStatement.class,"setInt", 1);
905 try {
906 super.testWriteDown();
907 fail("Should have blown up");
908 } catch (SQLSeriousPoemException e) {
909 assertEquals("PreparedStatement bombed", e.innermostException().getMessage());
910 } finally {
911 Thrower.stopThrowing(PreparedStatement.class, "setInt");
912 }
913 }
914
915
916
917
918 public void testWriteDownInsert() {
919 Thrower.startThrowing(Connection.class, "prepareStatement");
920 try {
921 getDb().getGroupCapabilityTable().invalidateTransactionStuffs();
922 GroupCapability g = (GroupCapability)getDb().getGroupCapabilityTable().newPersistent();
923 g.setGroup_unsafe(new Integer(0));
924 g.setCapability_unsafe(new Integer(0));
925 g.makePersistent();
926 fail("Should have blown up");
927 } catch (SimplePrepareFailedPoemException e) {
928 assertEquals("Connection bombed", e.innermostException().getMessage());
929 } finally {
930 Thrower.stopThrowing(Connection.class, "prepareStatement");
931 }
932 }
933
934
935
936
937 public void testWriteDownModify() {
938 Thrower.startThrowingAfter(Connection.class,"prepareStatement", 1);
939 getDb().getUserTable().invalidateTransactionStuffs();
940 try {
941 super.testWriteDown();
942 fail("Should have blown up");
943 } catch (SimplePrepareFailedPoemException e) {
944 assertEquals("Connection bombed", e.innermostException().getMessage());
945 } finally {
946 Thrower.stopThrowing(Connection.class, "prepareStatement");
947 }
948 }
949
950
951
952
953 public void testWriteDown5() {
954 Thrower.startThrowing(PreparedStatement.class, "executeUpdate");
955 try {
956 getDb().getGroupCapabilityTable().invalidateTransactionStuffs();
957 GroupCapability g = (GroupCapability)getDb().getGroupCapabilityTable().newPersistent();
958 g.setGroup_unsafe(new Integer(0));
959 g.setCapability_unsafe(new Integer(0));
960 g.makePersistent();
961 fail("Should have blown up");
962 } catch (ExecutingSQLPoemException e) {
963 assertEquals("PreparedStatement bombed", e.innermostException().getMessage());
964 } finally {
965 Thrower.stopThrowing(PreparedStatement.class, "executeUpdate");
966 }
967 }
968
969
970
971
972 public void testWriteDownDelete() {
973 GroupCapability g = (GroupCapability)getDb().getGroupCapabilityTable().newPersistent();
974 g.setGroup_unsafe(new Integer(0));
975 g.setCapability_unsafe(new Integer(0));
976 g.makePersistent();
977 Thrower.startThrowing(Statement.class, "executeUpdate");
978 getDb().getGroupCapabilityTable().invalidateTransactionStuffs();
979 try {
980 g.delete();
981 fail("Should have blown up");
982 } catch (ExecutingSQLPoemException e) {
983 assertEquals("Statement bombed", e.innermostException().getMessage());
984 } finally {
985 Thrower.stopThrowing(Statement.class, "executeUpdate");
986 g.delete();
987 }
988 }
989
990
991
992
993 public void testNextTroidBombs() {
994 Thrower.startThrowing(Statement.class, "close");
995 PoemDatabaseFactory.removeDatabase("melatijunit");
996 try {
997 getDb();
998 fail("Should have blown up");
999 } catch (DatabaseInitialisationPoemException e) {
1000 e.printStackTrace();
1001 assertEquals("Statement bombed", e.innermostException().getMessage());
1002 } finally {
1003 Thrower.stopThrowing(Statement.class, "close");
1004 }
1005 }
1006 }