-
Notifications
You must be signed in to change notification settings - Fork 27
/
RestfulDatabaseMetaDataTest.java
1112 lines (930 loc) · 37 KB
/
RestfulDatabaseMetaDataTest.java
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package com.taosdata.jdbc.rs;
import com.taosdata.jdbc.TSDBDriver;
import com.taosdata.jdbc.utils.SpecifyAddress;
import com.taosdata.jdbc.utils.StringUtils;
import org.junit.*;
import java.sql.*;
import java.util.Properties;
public class RestfulDatabaseMetaDataTest {
private static final String host = "127.0.0.1";
private static String url;
private static Connection connection;
private static RestfulDatabaseMetaData metaData;
private static final String dbName = "log_test";
@Test
public void unwrap() throws SQLException {
RestfulDatabaseMetaData unwrap = metaData.unwrap(RestfulDatabaseMetaData.class);
Assert.assertNotNull(unwrap);
}
@Test
public void isWrapperFor() throws SQLException {
Assert.assertTrue(metaData.isWrapperFor(RestfulDatabaseMetaData.class));
}
@Test
public void allProceduresAreCallable() throws SQLException {
Assert.assertFalse(metaData.allProceduresAreCallable());
}
@Test
public void allTablesAreSelectable() throws SQLException {
Assert.assertFalse(metaData.allTablesAreSelectable());
}
@Test
public void getURL() throws SQLException {
Assert.assertEquals(url, metaData.getURL());
}
@Test
public void getUserName() throws SQLException {
Assert.assertEquals("root", metaData.getUserName());
}
@Test
public void isReadOnly() throws SQLException {
Assert.assertFalse(metaData.isReadOnly());
}
@Test
public void nullsAreSortedHigh() throws SQLException {
Assert.assertFalse(metaData.nullsAreSortedHigh());
}
@Test
public void nullsAreSortedLow() throws SQLException {
Assert.assertTrue(metaData.nullsAreSortedLow());
}
@Test
public void nullsAreSortedAtStart() throws SQLException {
Assert.assertTrue(metaData.nullsAreSortedAtStart());
}
@Test
public void nullsAreSortedAtEnd() throws SQLException {
Assert.assertFalse(metaData.nullsAreSortedAtEnd());
}
@Test
public void getDatabaseProductName() throws SQLException {
Assert.assertEquals("TDengine", metaData.getDatabaseProductName());
}
/**
* don't have other method to obtain server version,so just check patterns
*
* @throws SQLException
*/
@Test
public void getDatabaseProductVersion() throws SQLException {
String version = metaData.getDatabaseProductVersion();
Assert.assertNotNull(version);
String[] array = version.split("\\.");
Assert.assertNotNull(array);
Assert.assertTrue(array.length == 5 || array.length == 4);
}
@Test
public void getDriverName() throws SQLException {
Assert.assertEquals("com.taosdata.jdbc.rs.RestfulDriver", metaData.getDriverName());
}
@Test
public void usesLocalFiles() throws SQLException {
Assert.assertFalse(metaData.usesLocalFiles());
}
@Test
public void usesLocalFilePerTable() throws SQLException {
Assert.assertFalse(metaData.usesLocalFilePerTable());
}
@Test
public void supportsMixedCaseIdentifiers() throws SQLException {
Assert.assertFalse(metaData.supportsMixedCaseIdentifiers());
}
@Test
public void storesUpperCaseIdentifiers() throws SQLException {
Assert.assertFalse(metaData.storesUpperCaseIdentifiers());
}
@Test
public void storesLowerCaseIdentifiers() throws SQLException {
Assert.assertTrue(metaData.storesLowerCaseIdentifiers());
}
@Test
public void storesMixedCaseIdentifiers() throws SQLException {
Assert.assertFalse(metaData.storesMixedCaseIdentifiers());
}
@Test
public void supportsMixedCaseQuotedIdentifiers() throws SQLException {
Assert.assertFalse(metaData.supportsMixedCaseQuotedIdentifiers());
}
@Test
public void storesUpperCaseQuotedIdentifiers() throws SQLException {
Assert.assertFalse(metaData.storesUpperCaseQuotedIdentifiers());
}
@Test
public void storesLowerCaseQuotedIdentifiers() throws SQLException {
Assert.assertFalse(metaData.storesLowerCaseQuotedIdentifiers());
}
@Test
public void storesMixedCaseQuotedIdentifiers() throws SQLException {
Assert.assertFalse(metaData.storesMixedCaseQuotedIdentifiers());
}
@Test
public void getIdentifierQuoteString() throws SQLException {
Assert.assertEquals(" ", metaData.getIdentifierQuoteString());
}
@Test
public void getSQLKeywords() throws SQLException {
Assert.assertEquals(null, metaData.getSQLKeywords());
}
@Test
public void getNumericFunctions() throws SQLException {
Assert.assertEquals(null, metaData.getNumericFunctions());
}
@Test
public void getStringFunctions() throws SQLException {
Assert.assertEquals(null, metaData.getStringFunctions());
}
@Test
public void getSystemFunctions() throws SQLException {
Assert.assertEquals(null, metaData.getSystemFunctions());
}
@Test
public void getTimeDateFunctions() throws SQLException {
Assert.assertEquals(null, metaData.getTimeDateFunctions());
}
@Test
public void getSearchStringEscape() throws SQLException {
Assert.assertEquals(null, metaData.getSearchStringEscape());
}
@Test
public void getExtraNameCharacters() throws SQLException {
Assert.assertEquals(null, metaData.getExtraNameCharacters());
}
@Test
public void supportsAlterTableWithAddColumn() throws SQLException {
Assert.assertTrue(metaData.supportsAlterTableWithAddColumn());
}
@Test
public void supportsAlterTableWithDropColumn() throws SQLException {
Assert.assertTrue(metaData.supportsAlterTableWithDropColumn());
}
@Test
public void supportsColumnAliasing() throws SQLException {
Assert.assertTrue(metaData.supportsColumnAliasing());
}
@Test
public void nullPlusNonNullIsNull() throws SQLException {
Assert.assertFalse(metaData.nullPlusNonNullIsNull());
}
@Test
public void supportsConvert() throws SQLException {
Assert.assertFalse(metaData.supportsConvert());
}
@Test
public void testSupportsConvert() throws SQLException {
Assert.assertFalse(metaData.supportsConvert(1, 1));
}
@Test
public void supportsTableCorrelationNames() throws SQLException {
Assert.assertFalse(metaData.supportsTableCorrelationNames());
}
@Test
public void supportsDifferentTableCorrelationNames() throws SQLException {
Assert.assertFalse(metaData.supportsDifferentTableCorrelationNames());
}
@Test
public void supportsExpressionsInOrderBy() throws SQLException {
Assert.assertFalse(metaData.supportsExpressionsInOrderBy());
}
@Test
public void supportsOrderByUnrelated() throws SQLException {
Assert.assertFalse(metaData.supportsOrderByUnrelated());
}
@Test
public void supportsGroupBy() throws SQLException {
Assert.assertTrue(metaData.supportsGroupBy());
}
@Test
public void supportsGroupByUnrelated() throws SQLException {
Assert.assertFalse(metaData.supportsGroupByUnrelated());
}
@Test
public void supportsGroupByBeyondSelect() throws SQLException {
Assert.assertFalse(metaData.supportsGroupByBeyondSelect());
}
@Test
public void supportsLikeEscapeClause() throws SQLException {
Assert.assertFalse(metaData.supportsLikeEscapeClause());
}
@Test
public void supportsMultipleResultSets() throws SQLException {
Assert.assertFalse(metaData.supportsMultipleResultSets());
}
@Test
public void supportsMultipleTransactions() throws SQLException {
Assert.assertFalse(metaData.supportsMultipleTransactions());
}
@Test
public void supportsNonNullableColumns() throws SQLException {
Assert.assertFalse(metaData.supportsNonNullableColumns());
}
@Test
public void supportsMinimumSQLGrammar() throws SQLException {
Assert.assertFalse(metaData.supportsMinimumSQLGrammar());
}
@Test
public void supportsCoreSQLGrammar() throws SQLException {
Assert.assertFalse(metaData.supportsCoreSQLGrammar());
}
@Test
public void supportsExtendedSQLGrammar() throws SQLException {
Assert.assertFalse(metaData.supportsExtendedSQLGrammar());
}
@Test
public void supportsANSI92EntryLevelSQL() throws SQLException {
Assert.assertFalse(metaData.supportsANSI92EntryLevelSQL());
}
@Test
public void supportsANSI92IntermediateSQL() throws SQLException {
Assert.assertFalse(metaData.supportsANSI92IntermediateSQL());
}
@Test
public void supportsANSI92FullSQL() throws SQLException {
Assert.assertFalse(metaData.supportsANSI92FullSQL());
}
@Test
public void supportsIntegrityEnhancementFacility() throws SQLException {
Assert.assertFalse(metaData.supportsIntegrityEnhancementFacility());
}
@Test
public void supportsOuterJoins() throws SQLException {
Assert.assertFalse(metaData.supportsOuterJoins());
}
@Test
public void supportsFullOuterJoins() throws SQLException {
Assert.assertFalse(metaData.supportsFullOuterJoins());
}
@Test
public void supportsLimitedOuterJoins() throws SQLException {
Assert.assertFalse(metaData.supportsLimitedOuterJoins());
}
@Test
public void getSchemaTerm() throws SQLException {
Assert.assertNull(metaData.getSchemaTerm());
}
@Test
public void getProcedureTerm() throws SQLException {
Assert.assertNull(metaData.getProcedureTerm());
}
@Test
public void getCatalogTerm() throws SQLException {
Assert.assertEquals("database", metaData.getCatalogTerm());
}
@Test
public void isCatalogAtStart() throws SQLException {
Assert.assertTrue(metaData.isCatalogAtStart());
}
@Test
public void getCatalogSeparator() throws SQLException {
Assert.assertEquals(".", metaData.getCatalogSeparator());
}
@Test
public void supportsSchemasInDataManipulation() throws SQLException {
Assert.assertFalse(metaData.supportsSchemasInDataManipulation());
}
@Test
public void supportsSchemasInProcedureCalls() throws SQLException {
Assert.assertFalse(metaData.supportsSchemasInProcedureCalls());
}
@Test
public void supportsSchemasInTableDefinitions() throws SQLException {
Assert.assertFalse(metaData.supportsSchemasInTableDefinitions());
}
@Test
public void supportsSchemasInIndexDefinitions() throws SQLException {
Assert.assertFalse(metaData.supportsSchemasInIndexDefinitions());
}
@Test
public void supportsSchemasInPrivilegeDefinitions() throws SQLException {
Assert.assertFalse(metaData.supportsSchemasInPrivilegeDefinitions());
}
@Test
public void supportsCatalogsInDataManipulation() throws SQLException {
Assert.assertTrue(metaData.supportsCatalogsInDataManipulation());
}
@Test
public void supportsCatalogsInProcedureCalls() throws SQLException {
Assert.assertFalse(metaData.supportsCatalogsInProcedureCalls());
}
@Test
public void supportsCatalogsInTableDefinitions() throws SQLException {
Assert.assertFalse(metaData.supportsCatalogsInTableDefinitions());
}
@Test
public void supportsCatalogsInIndexDefinitions() throws SQLException {
Assert.assertFalse(metaData.supportsCatalogsInIndexDefinitions());
}
@Test
public void supportsCatalogsInPrivilegeDefinitions() throws SQLException {
Assert.assertFalse(metaData.supportsCatalogsInPrivilegeDefinitions());
}
@Test
public void supportsPositionedDelete() throws SQLException {
Assert.assertFalse(metaData.supportsPositionedDelete());
}
@Test
public void supportsPositionedUpdate() throws SQLException {
Assert.assertFalse(metaData.supportsPositionedUpdate());
}
@Test
public void supportsSelectForUpdate() throws SQLException {
Assert.assertFalse(metaData.supportsSelectForUpdate());
}
@Test
public void supportsStoredProcedures() throws SQLException {
Assert.assertFalse(metaData.supportsStoredProcedures());
}
@Test
public void supportsSubqueriesInComparisons() throws SQLException {
Assert.assertFalse(metaData.supportsSubqueriesInComparisons());
}
@Test
public void supportsSubqueriesInExists() throws SQLException {
Assert.assertFalse(metaData.supportsSubqueriesInExists());
}
@Test
public void supportsSubqueriesInIns() throws SQLException {
Assert.assertFalse(metaData.supportsSubqueriesInIns());
}
@Test
public void supportsSubqueriesInQuantifieds() throws SQLException {
Assert.assertFalse(metaData.supportsSubqueriesInQuantifieds());
}
@Test
public void supportsCorrelatedSubqueries() throws SQLException {
Assert.assertFalse(metaData.supportsCorrelatedSubqueries());
}
@Test
public void supportsUnion() throws SQLException {
Assert.assertFalse(metaData.supportsUnion());
}
@Test
public void supportsUnionAll() throws SQLException {
Assert.assertFalse(metaData.supportsUnionAll());
}
@Test
public void supportsOpenCursorsAcrossCommit() throws SQLException {
Assert.assertFalse(metaData.supportsOpenCursorsAcrossCommit());
}
@Test
public void supportsOpenCursorsAcrossRollback() throws SQLException {
Assert.assertFalse(metaData.supportsOpenCursorsAcrossRollback());
}
@Test
public void supportsOpenStatementsAcrossCommit() throws SQLException {
Assert.assertFalse(metaData.supportsOpenStatementsAcrossCommit());
}
@Test
public void supportsOpenStatementsAcrossRollback() throws SQLException {
Assert.assertFalse(metaData.supportsOpenStatementsAcrossRollback());
}
@Test
public void getMaxBinaryLiteralLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxBinaryLiteralLength());
}
@Test
public void getMaxCharLiteralLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxCharLiteralLength());
}
@Test
public void getMaxColumnNameLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxColumnNameLength());
}
@Test
public void getMaxColumnsInGroupBy() throws SQLException {
Assert.assertEquals(0, metaData.getMaxColumnsInGroupBy());
}
@Test
public void getMaxColumnsInIndex() throws SQLException {
Assert.assertEquals(0, metaData.getMaxColumnsInIndex());
}
@Test
public void getMaxColumnsInOrderBy() throws SQLException {
Assert.assertEquals(0, metaData.getMaxColumnsInOrderBy());
}
@Test
public void getMaxColumnsInSelect() throws SQLException {
Assert.assertEquals(0, metaData.getMaxColumnsInSelect());
}
@Test
public void getMaxColumnsInTable() throws SQLException {
Assert.assertEquals(0, metaData.getMaxColumnsInTable());
}
@Test
public void getMaxConnections() throws SQLException {
Assert.assertEquals(0, metaData.getMaxConnections());
}
@Test
public void getMaxCursorNameLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxCursorNameLength());
}
@Test
public void getMaxIndexLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxIndexLength());
}
@Test
public void getMaxSchemaNameLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxSchemaNameLength());
}
@Test
public void getMaxProcedureNameLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxProcedureNameLength());
}
@Test
public void getMaxCatalogNameLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxCatalogNameLength());
}
@Test
public void getMaxRowSize() throws SQLException {
Assert.assertEquals(0, metaData.getMaxRowSize());
}
@Test
public void doesMaxRowSizeIncludeBlobs() throws SQLException {
Assert.assertFalse(metaData.doesMaxRowSizeIncludeBlobs());
}
@Test
public void getMaxStatementLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxStatementLength());
}
@Test
public void getMaxStatements() throws SQLException {
Assert.assertEquals(0, metaData.getMaxStatements());
}
@Test
public void getMaxTableNameLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxTableNameLength());
}
@Test
public void getMaxTablesInSelect() throws SQLException {
Assert.assertEquals(0, metaData.getMaxTablesInSelect());
}
@Test
public void getMaxUserNameLength() throws SQLException {
Assert.assertEquals(0, metaData.getMaxUserNameLength());
}
@Test
public void getDefaultTransactionIsolation() throws SQLException {
Assert.assertEquals(Connection.TRANSACTION_NONE, metaData.getDefaultTransactionIsolation());
}
@Test
public void supportsTransactions() throws SQLException {
Assert.assertFalse(metaData.supportsTransactions());
}
@Test
public void supportsTransactionIsolationLevel() throws SQLException {
Assert.assertTrue(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_NONE));
Assert.assertFalse(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED));
Assert.assertFalse(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED));
Assert.assertFalse(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ));
Assert.assertFalse(metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_SERIALIZABLE));
}
@Test
public void supportsDataDefinitionAndDataManipulationTransactions() throws SQLException {
Assert.assertFalse(metaData.supportsDataDefinitionAndDataManipulationTransactions());
}
@Test
public void supportsDataManipulationTransactionsOnly() throws SQLException {
Assert.assertFalse(metaData.supportsDataManipulationTransactionsOnly());
}
@Test
public void dataDefinitionCausesTransactionCommit() throws SQLException {
Assert.assertFalse(metaData.dataDefinitionCausesTransactionCommit());
}
@Test
public void dataDefinitionIgnoredInTransactions() throws SQLException {
Assert.assertFalse(metaData.dataDefinitionIgnoredInTransactions());
}
@Test
public void getProcedures() throws SQLException {
Assert.assertNull(metaData.getProcedures("*", "*", "*"));
}
@Test
public void getProcedureColumns() throws SQLException {
Assert.assertNull(metaData.getProcedureColumns("*", "*", "*", "*"));
}
@Test
public void getTables() throws SQLException {
ResultSet rs = metaData.getTables(dbName, "", null, null);
ResultSetMetaData meta = rs.getMetaData();
Assert.assertNotNull(rs);
rs.next();
{
// TABLE_CAT
Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1));
Assert.assertEquals(dbName, rs.getString(1));
Assert.assertEquals(dbName, rs.getString("TABLE_CAT"));
// TABLE_SCHEM
Assert.assertEquals("TABLE_SCHEM", meta.getColumnLabel(2));
Assert.assertEquals(null, rs.getString(2));
Assert.assertEquals(null, rs.getString("TABLE_SCHEM"));
// TABLE_NAME
Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3));
Assert.assertNotNull(rs.getString(3));
Assert.assertNotNull(rs.getString("TABLE_NAME"));
// TABLE_TYPE
Assert.assertEquals("TABLE_TYPE", meta.getColumnLabel(4));
Assert.assertEquals("TABLE", rs.getString(4));
Assert.assertEquals("TABLE", rs.getString("TABLE_TYPE"));
// REMARKS
Assert.assertEquals("REMARKS", meta.getColumnLabel(5));
Assert.assertEquals("", rs.getString(5));
Assert.assertEquals("", rs.getString("REMARKS"));
}
}
@Test
public void getSchemas() throws SQLException {
Assert.assertNotNull(metaData.getSchemas());
}
@Test
public void getCatalogs() throws SQLException {
ResultSet rs = metaData.getCatalogs();
ResultSetMetaData meta = rs.getMetaData();
rs.next();
{
// TABLE_CAT
Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1));
Assert.assertNotNull(rs.getString(1));
Assert.assertNotNull(rs.getString("TABLE_CAT"));
}
}
@Test
public void getTableTypes() throws SQLException {
ResultSet tableTypes = metaData.getTableTypes();
tableTypes.next();
// tableTypes: table
{
Assert.assertEquals("TABLE", tableTypes.getString(1));
Assert.assertEquals("TABLE", tableTypes.getString("TABLE_TYPE"));
}
tableTypes.next();
// tableTypes: stable
{
Assert.assertEquals("STABLE", tableTypes.getString(1));
Assert.assertEquals("STABLE", tableTypes.getString("TABLE_TYPE"));
}
}
@Test
public void getColumns() throws SQLException {
// when
ResultSet columns = metaData.getColumns(dbName, "", "dn", "");
// then
ResultSetMetaData meta = columns.getMetaData();
columns.next();
// column: 1
{
// TABLE_CAT
Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1));
Assert.assertEquals(dbName, columns.getString(1));
Assert.assertEquals(dbName, columns.getString("TABLE_CAT"));
// TABLE_NAME
Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3));
Assert.assertEquals("dn", columns.getString(3));
Assert.assertEquals("dn", columns.getString("TABLE_NAME"));
// COLUMN_NAME
Assert.assertEquals("COLUMN_NAME", meta.getColumnLabel(4));
Assert.assertEquals("ts", columns.getString(4));
Assert.assertEquals("ts", columns.getString("COLUMN_NAME"));
// DATA_TYPE
Assert.assertEquals("DATA_TYPE", meta.getColumnLabel(5));
Assert.assertEquals(Types.TIMESTAMP, columns.getInt(5));
Assert.assertEquals(Types.TIMESTAMP, columns.getInt("DATA_TYPE"));
// TYPE_NAME
Assert.assertEquals("TYPE_NAME", meta.getColumnLabel(6));
Assert.assertEquals("TIMESTAMP", columns.getString(6));
Assert.assertEquals("TIMESTAMP", columns.getString("TYPE_NAME"));
// COLUMN_SIZE
Assert.assertEquals("COLUMN_SIZE", meta.getColumnLabel(7));
Assert.assertEquals(26, columns.getInt(7));
Assert.assertEquals(26, columns.getInt("COLUMN_SIZE"));
// DECIMAL_DIGITS
Assert.assertEquals("DECIMAL_DIGITS", meta.getColumnLabel(9));
Assert.assertEquals(0, columns.getInt(9));
Assert.assertEquals(0, columns.getInt("DECIMAL_DIGITS"));
Assert.assertEquals(null, columns.getString(9));
Assert.assertEquals(null, columns.getString("DECIMAL_DIGITS"));
// NUM_PREC_RADIX
Assert.assertEquals("NUM_PREC_RADIX", meta.getColumnLabel(10));
Assert.assertEquals(10, columns.getInt(10));
Assert.assertEquals(10, columns.getInt("NUM_PREC_RADIX"));
// NULLABLE
Assert.assertEquals("NULLABLE", meta.getColumnLabel(11));
Assert.assertEquals(DatabaseMetaData.columnNoNulls, columns.getInt(11));
Assert.assertEquals(DatabaseMetaData.columnNoNulls, columns.getInt("NULLABLE"));
// REMARKS
Assert.assertEquals("REMARKS", meta.getColumnLabel(12));
Assert.assertEquals(null, columns.getString(12));
Assert.assertEquals(null, columns.getString("REMARKS"));
}
columns.next();
// column: 2
{
// TABLE_CAT
Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1));
Assert.assertEquals(dbName, columns.getString(1));
Assert.assertEquals(dbName, columns.getString("TABLE_CAT"));
// TABLE_NAME
Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3));
Assert.assertEquals("dn", columns.getString(3));
Assert.assertEquals("dn", columns.getString("TABLE_NAME"));
// COLUMN_NAME
Assert.assertEquals("COLUMN_NAME", meta.getColumnLabel(4));
Assert.assertEquals("cpu_taosd", columns.getString(4));
Assert.assertEquals("cpu_taosd", columns.getString("COLUMN_NAME"));
// DATA_TYPE
Assert.assertEquals("DATA_TYPE", meta.getColumnLabel(5));
Assert.assertEquals(Types.FLOAT, columns.getInt(5));
Assert.assertEquals(Types.FLOAT, columns.getInt("DATA_TYPE"));
// TYPE_NAME
Assert.assertEquals("TYPE_NAME", meta.getColumnLabel(6));
Assert.assertEquals("FLOAT", columns.getString(6));
Assert.assertEquals("FLOAT", columns.getString("TYPE_NAME"));
// COLUMN_SIZE
Assert.assertEquals("COLUMN_SIZE", meta.getColumnLabel(7));
Assert.assertEquals(12, columns.getInt(7));
Assert.assertEquals(12, columns.getInt("COLUMN_SIZE"));
// DECIMAL_DIGITS
Assert.assertEquals("DECIMAL_DIGITS", meta.getColumnLabel(9));
Assert.assertEquals(5, columns.getInt(9));
Assert.assertEquals(5, columns.getInt("DECIMAL_DIGITS"));
// NUM_PREC_RADIX
Assert.assertEquals("NUM_PREC_RADIX", meta.getColumnLabel(10));
Assert.assertEquals(10, columns.getInt(10));
Assert.assertEquals(10, columns.getInt("NUM_PREC_RADIX"));
// NULLABLE
Assert.assertEquals("NULLABLE", meta.getColumnLabel(11));
Assert.assertEquals(DatabaseMetaData.columnNullable, columns.getInt(11));
Assert.assertEquals(DatabaseMetaData.columnNullable, columns.getInt("NULLABLE"));
// REMARKS
Assert.assertEquals("REMARKS", meta.getColumnLabel(12));
Assert.assertEquals(null, columns.getString(12));
}
}
@Test
public void getColumnPrivileges() throws SQLException {
Assert.assertNotNull(metaData.getColumnPrivileges("", "", "", ""));
}
@Test
public void getTablePrivileges() throws SQLException {
Assert.assertNotNull(metaData.getTablePrivileges("", "", ""));
}
@Test
public void getBestRowIdentifier() throws SQLException {
Assert.assertNotNull(metaData.getBestRowIdentifier("", "", "", 0, false));
}
@Test
public void getVersionColumns() throws SQLException {
Assert.assertNotNull(metaData.getVersionColumns("", "", ""));
}
@Test
public void getPrimaryKeys() throws SQLException {
ResultSet rs = metaData.getPrimaryKeys(dbName, "", "dn1");
ResultSetMetaData meta = rs.getMetaData();
rs.next();
{
// TABLE_CAT
Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1));
Assert.assertEquals(dbName, rs.getString(1));
Assert.assertEquals(dbName, rs.getString("TABLE_CAT"));
// TABLE_SCHEM
Assert.assertEquals("TABLE_SCHEM", meta.getColumnLabel(2));
Assert.assertEquals(null, rs.getString(2));
Assert.assertEquals(null, rs.getString("TABLE_SCHEM"));
// TABLE_NAME
Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3));
Assert.assertEquals("dn1", rs.getString(3));
Assert.assertEquals("dn1", rs.getString("TABLE_NAME"));
// COLUMN_NAME
Assert.assertEquals("COLUMN_NAME", meta.getColumnLabel(4));
Assert.assertEquals("ts", rs.getString(4));
Assert.assertEquals("ts", rs.getString("COLUMN_NAME"));
// KEY_SEQ
Assert.assertEquals("KEY_SEQ", meta.getColumnLabel(5));
Assert.assertEquals(1, rs.getShort(5));
Assert.assertEquals(1, rs.getShort("KEY_SEQ"));
// DATA_TYPE
Assert.assertEquals("PK_NAME", meta.getColumnLabel(6));
Assert.assertEquals("ts", rs.getString(6));
Assert.assertEquals("ts", rs.getString("PK_NAME"));
}
}
@Test
public void getImportedKeys() throws SQLException {
Assert.assertNotNull(metaData.getImportedKeys("", "", ""));
}
@Test
public void getExportedKeys() throws SQLException {
Assert.assertNotNull(metaData.getExportedKeys("", "", ""));
}
@Test
public void getCrossReference() throws SQLException {
Assert.assertNotNull(metaData.getCrossReference("", "", "", "", "", ""));
}
@Test
public void getTypeInfo() throws SQLException {
Assert.assertNotNull(metaData.getTypeInfo());
}
@Test
public void getIndexInfo() throws SQLException {
Assert.assertNotNull(metaData.getIndexInfo("", "", "", false, false));
}
@Test
public void supportsResultSetType() throws SQLException {
Assert.assertFalse(metaData.supportsResultSetType(0));
}
@Test
public void supportsResultSetConcurrency() throws SQLException {
Assert.assertFalse(metaData.supportsResultSetConcurrency(0, 0));
}
@Test
public void ownUpdatesAreVisible() throws SQLException {
Assert.assertFalse(metaData.ownUpdatesAreVisible(0));
}
@Test
public void ownDeletesAreVisible() throws SQLException {
Assert.assertFalse(metaData.ownDeletesAreVisible(0));
}
@Test
public void ownInsertsAreVisible() throws SQLException {
Assert.assertFalse(metaData.ownInsertsAreVisible(0));
}
@Test
public void othersUpdatesAreVisible() throws SQLException {
Assert.assertFalse(metaData.othersUpdatesAreVisible(0));
}
@Test
public void othersDeletesAreVisible() throws SQLException {
Assert.assertFalse(metaData.othersDeletesAreVisible(0));
}
@Test
public void othersInsertsAreVisible() throws SQLException {
Assert.assertFalse(metaData.othersInsertsAreVisible(0));
}
@Test
public void updatesAreDetected() throws SQLException {
Assert.assertFalse(metaData.updatesAreDetected(0));
}
@Test
public void deletesAreDetected() throws SQLException {
Assert.assertFalse(metaData.deletesAreDetected(0));
}
@Test
public void insertsAreDetected() throws SQLException {
Assert.assertFalse(metaData.insertsAreDetected(0));
}
@Test
public void supportsBatchUpdates() throws SQLException {
Assert.assertFalse(metaData.supportsBatchUpdates());
}
@Test
public void getUDTs() throws SQLException {
Assert.assertNotNull(metaData.getUDTs("", "", "", null));
}
@Test
public void getConnection() throws SQLException {
Assert.assertNotNull(metaData.getConnection());
}
@Test
public void supportsSavepoints() throws SQLException {
Assert.assertFalse(metaData.supportsSavepoints());
}
@Test
public void supportsNamedParameters() throws SQLException {
Assert.assertFalse(metaData.supportsNamedParameters());
}
@Test
public void supportsMultipleOpenResults() throws SQLException {
Assert.assertFalse(metaData.supportsMultipleOpenResults());
}
@Test
public void supportsGetGeneratedKeys() throws SQLException {
Assert.assertFalse(metaData.supportsGetGeneratedKeys());
}
@Test
public void getSuperTypes() throws SQLException {
Assert.assertNotNull(metaData.getSuperTypes("", "", ""));
}
@Test
public void getSuperTables() throws SQLException {
ResultSet rs = metaData.getSuperTables(dbName, "", "dn1");
ResultSetMetaData meta = rs.getMetaData();
rs.next();
{
// TABLE_CAT
Assert.assertEquals("TABLE_CAT", meta.getColumnLabel(1));
Assert.assertEquals(dbName, rs.getString(1));
Assert.assertEquals(dbName, rs.getString("TABLE_CAT"));
// TABLE_CAT
Assert.assertEquals("TABLE_SCHEM", meta.getColumnLabel(2));
Assert.assertEquals(null, rs.getString(2));
Assert.assertEquals(null, rs.getString("TABLE_SCHEM"));
// TABLE_CAT
Assert.assertEquals("TABLE_NAME", meta.getColumnLabel(3));
Assert.assertEquals("dn1", rs.getString(3));
Assert.assertEquals("dn1", rs.getString("TABLE_NAME"));
// TABLE_CAT
Assert.assertEquals("SUPERTABLE_NAME", meta.getColumnLabel(4));
Assert.assertEquals("dn", rs.getString(4));
Assert.assertEquals("dn", rs.getString("SUPERTABLE_NAME"));
}
}
@Test
public void getAttributes() throws SQLException {
Assert.assertNotNull(metaData.getAttributes("", "", "", ""));
}
@Test
public void supportsResultSetHoldability() throws SQLException {
Assert.assertTrue(metaData.supportsResultSetHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT));
Assert.assertFalse(metaData.supportsResultSetHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT));
}