Skip to content

Commit 5767fc5

Browse files
committed
Fix for tests in MetaDataTest using conflicting table names.
Change-Id: I789d8c2297aa52997eb0853e9aeb6cb669a088df
1 parent 3394bf6 commit 5767fc5

1 file changed

Lines changed: 43 additions & 43 deletions

File tree

src/test/java/testsuite/simple/MetaDataTest.java

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,11 @@ public void testGetPrimaryKeys() throws SQLException {
468468

469469
if (dbMapsToSchema) {
470470
String dbPattern = testConn.getSchema().substring(0, testConn.getSchema().length() - 1) + "%";
471-
this.rs = dbmd.getPrimaryKeys("", dbPattern, "multikey"); //metaData.getIndexInfo(null, dbPattern, "t1", false, true);
471+
this.rs = dbmd.getPrimaryKeys("", dbPattern, "multikey");
472472
assertFalse(this.rs.next(), "Schema pattern " + dbPattern + " should not be recognized.");
473473
} else {
474474
String dbPattern = testConn.getCatalog().substring(0, testConn.getCatalog().length() - 1) + "%";
475-
this.rs = dbmd.getPrimaryKeys(dbPattern, null, "multikey"); //metaData.getIndexInfo(dbPattern, null, "t1", false, true);
475+
this.rs = dbmd.getPrimaryKeys(dbPattern, null, "multikey");
476476
assertFalse(this.rs.next(), "Catalog pattern " + dbPattern + " should not be recognized.");
477477
}
478478

@@ -687,10 +687,10 @@ private void checkBitOrBooleanType(boolean usingBit) throws SQLException {
687687

688688
@Test
689689
public void testResultSetMetaDataMethods() throws Exception {
690-
createTable("t1",
690+
createTable("testResultSetMetaDataMethods",
691691
"(c1 char(1) CHARACTER SET latin7 COLLATE latin7_general_cs, c2 char(10) CHARACTER SET latin7 COLLATE latin7_general_ci, g1 GEOMETRY)");
692692

693-
this.rs = this.stmt.executeQuery("SELECT c1 as QQQ, c2, g1 FROM t1");
693+
this.rs = this.stmt.executeQuery("SELECT c1 as QQQ, c2, g1 FROM testResultSetMetaDataMethods");
694694

695695
assertThrows(SQLException.class, "Column index out of range.", new Callable<Void>() {
696696

@@ -732,7 +732,7 @@ public Void call() throws Exception {
732732
props.setProperty(PropertyKey.useOldAliasMetadataBehavior.getKeyName(), "true");
733733
Connection con = getConnectionWithProps(props);
734734

735-
this.rs = con.createStatement().executeQuery("SELECT c1 as QQQ, g1 FROM t1");
735+
this.rs = con.createStatement().executeQuery("SELECT c1 as QQQ, g1 FROM testResultSetMetaDataMethods");
736736
assertEquals("QQQ", this.rs.getMetaData().getColumnLabel(1));
737737
assertEquals("QQQ", this.rs.getMetaData().getColumnName(1));
738738
}
@@ -744,7 +744,7 @@ public Void call() throws Exception {
744744
*/
745745
@Test
746746
public void testGetPrimaryKeysUsingInfoShcema() throws Exception {
747-
createTable("t1", "(c1 int(1) primary key)");
747+
createTable("testGetPrimaryKeysUsingInfoShcema", "(c1 int(1) primary key)");
748748
Properties props = new Properties();
749749
props.setProperty(PropertyKey.sslMode.getKeyName(), "DISABLED");
750750
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
@@ -753,9 +753,9 @@ public void testGetPrimaryKeysUsingInfoShcema() throws Exception {
753753
try {
754754
conn1 = getConnectionWithProps(props);
755755
DatabaseMetaData metaData = conn1.getMetaData();
756-
this.rs = metaData.getPrimaryKeys(null, null, "t1");
756+
this.rs = metaData.getPrimaryKeys(null, null, "testGetPrimaryKeysUsingInfoShcema");
757757
this.rs.next();
758-
assertEquals("t1", this.rs.getString("TABLE_NAME"));
758+
assertEquals("testGetPrimaryKeysUsingInfoShcema", this.rs.getString("TABLE_NAME"));
759759
assertEquals("c1", this.rs.getString("COLUMN_NAME"));
760760
} finally {
761761
if (conn1 != null) {
@@ -766,8 +766,8 @@ public void testGetPrimaryKeysUsingInfoShcema() throws Exception {
766766

767767
@Test
768768
public void testGetIndexInfo() throws Exception {
769-
createTable("t1", "(c1 int(1))");
770-
this.stmt.executeUpdate("CREATE INDEX index1 ON t1 (c1)");
769+
createTable("testGetIndexInfo", "(c1 int(1))");
770+
this.stmt.executeUpdate("CREATE INDEX index1 ON testGetIndexInfo (c1)");
771771

772772
Properties props = new Properties();
773773
props.setProperty(PropertyKey.sslMode.getKeyName(), "DISABLED");
@@ -785,16 +785,16 @@ public void testGetIndexInfo() throws Exception {
785785

786786
if (dbMapsToSchema) {
787787
String dbPattern = testConn.getSchema().substring(0, testConn.getSchema().length() - 1) + "%";
788-
this.rs = metaData.getIndexInfo(null, dbPattern, "t1", false, true);
788+
this.rs = metaData.getIndexInfo(null, dbPattern, "testGetIndexInfo", false, true);
789789
assertFalse(this.rs.next(), "Schema pattern " + dbPattern + " should not be recognized.");
790790
} else {
791791
String dbPattern = testConn.getCatalog().substring(0, testConn.getCatalog().length() - 1) + "%";
792-
this.rs = metaData.getIndexInfo(dbPattern, null, "t1", false, true);
792+
this.rs = metaData.getIndexInfo(dbPattern, null, "testGetIndexInfo", false, true);
793793
assertFalse(this.rs.next(), "Catalog pattern " + dbPattern + " should not be recognized.");
794794
}
795795

796-
this.rs = dbMapsToSchema ? metaData.getIndexInfo(null, testConn.getCatalog(), "t1", false, true)
797-
: metaData.getIndexInfo(testConn.getCatalog(), null, "t1", false, true);
796+
this.rs = dbMapsToSchema ? metaData.getIndexInfo(null, testConn.getCatalog(), "testGetIndexInfo", false, true)
797+
: metaData.getIndexInfo(testConn.getCatalog(), null, "testGetIndexInfo", false, true);
798798
this.rs.next();
799799
if (dbMapsToSchema) {
800800
assertEquals("def", this.rs.getString("TABLE_CAT"));
@@ -803,7 +803,7 @@ public void testGetIndexInfo() throws Exception {
803803
assertEquals(lowerCaseIds ? this.dbName.toLowerCase() : this.dbName, this.rs.getString("TABLE_CAT"));
804804
assertNull(this.rs.getString("TABLE_SCHEM"));
805805
}
806-
assertEquals("t1", this.rs.getString("TABLE_NAME"));
806+
assertEquals("testGetIndexInfo", this.rs.getString("TABLE_NAME"));
807807
assertTrue(this.rs.getBoolean("NON_UNIQUE"));
808808
assertNull(this.rs.getString("INDEX_QUALIFIER"));
809809
assertEquals("index1", this.rs.getString("INDEX_NAME"));
@@ -831,7 +831,7 @@ public void testGetIndexInfo() throws Exception {
831831
*/
832832
@Test
833833
public void testGetColumns() throws Exception {
834-
createTable("t1", "(c1 char(1))");
834+
createTable("testGetColumns", "(c1 char(1))");
835835
Properties props = new Properties();
836836
props.setProperty(PropertyKey.sslMode.getKeyName(), "DISABLED");
837837
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
@@ -846,7 +846,7 @@ public void testGetColumns() throws Exception {
846846
testConn = getConnectionWithProps(props);
847847
DatabaseMetaData metaData = testConn.getMetaData();
848848
boolean lowerCaseIds = metaData.storesLowerCaseIdentifiers();
849-
this.rs = metaData.getColumns(null, null, "t1", null);
849+
this.rs = metaData.getColumns(null, null, "testGetColumns", null);
850850
this.rs.next();
851851

852852
if (dbMapsToSchema) {
@@ -857,18 +857,18 @@ public void testGetColumns() throws Exception {
857857
assertNull(this.rs.getString("TABLE_SCHEM"));
858858
}
859859

860-
assertEquals("t1", this.rs.getString("TABLE_NAME"));
860+
assertEquals("testGetColumns", this.rs.getString("TABLE_NAME"));
861861
assertEquals("c1", this.rs.getString("COLUMN_NAME"));
862862
assertEquals("CHAR", this.rs.getString("TYPE_NAME"));
863863
assertEquals("1", this.rs.getString("COLUMN_SIZE"));
864864

865865
if (dbMapsToSchema) {
866866
String dbPattern = testConn.getSchema().substring(0, testConn.getSchema().length() - 1) + "%";
867-
this.rs = metaData.getColumns(null, dbPattern, "t1", null);
867+
this.rs = metaData.getColumns(null, dbPattern, "testGetColumns", null);
868868
assertTrue(this.rs.next(), "Schema pattern " + dbPattern + " should be recognized.");
869869
} else {
870870
String dbPattern = testConn.getCatalog().substring(0, testConn.getCatalog().length() - 1) + "%";
871-
this.rs = metaData.getColumns(dbPattern, null, "t1", null);
871+
this.rs = metaData.getColumns(dbPattern, null, "testGetColumns", null);
872872
assertFalse(this.rs.next(), "Catalog pattern " + dbPattern + " should not be recognized.");
873873
}
874874

@@ -888,12 +888,12 @@ public void testGetColumns() throws Exception {
888888
*/
889889
@Test
890890
public void testGetTablesUsingInfoSchema() throws Exception {
891-
createTable("`t1-1`", "(c1 char(1))");
892-
createTable("`t1-2`", "(c1 char(1))");
893-
createTable("`t2`", "(c1 char(1))");
891+
createTable("`testGetTablesUsingInfoSchema1-1`", "(c1 char(1))");
892+
createTable("`testGetTablesUsingInfoSchema1-2`", "(c1 char(1))");
893+
createTable("`testGetTablesUsingInfoSchema2`", "(c1 char(1))");
894894
Set<String> tableNames = new HashSet<>();
895-
tableNames.add("t1-1");
896-
tableNames.add("t1-2");
895+
tableNames.add("testGetTablesUsingInfoSchema1-1");
896+
tableNames.add("testGetTablesUsingInfoSchema1-2");
897897
Properties props = new Properties();
898898
props.setProperty(PropertyKey.sslMode.getKeyName(), "DISABLED");
899899
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
@@ -903,7 +903,7 @@ public void testGetTablesUsingInfoSchema() throws Exception {
903903
conn1 = getConnectionWithProps(props);
904904
DatabaseMetaData metaData = conn1.getMetaData();
905905
// pattern matching for table name
906-
this.rs = metaData.getTables(this.dbName, null, "t1-_", null);
906+
this.rs = metaData.getTables(this.dbName, null, "testGetTablesUsingInfoSchema1-_", null);
907907
while (this.rs.next()) {
908908
assertTrue(tableNames.remove(this.rs.getString("TABLE_NAME")));
909909
}
@@ -917,9 +917,9 @@ public void testGetTablesUsingInfoSchema() throws Exception {
917917

918918
@Test
919919
public void testGetTables() throws Exception {
920-
createTable("`t1-1`", "(c1 char(1)) COMMENT 'table1'");
921-
createTable("`t1-2`", "(c1 char(1))");
922-
createTable("`t2`", "(c1 char(1))");
920+
createTable("`testGetTables1-1`", "(c1 char(1)) COMMENT 'table1'");
921+
createTable("`testGetTables1-2`", "(c1 char(1))");
922+
createTable("`testGetTables2`", "(c1 char(1))");
923923

924924
Properties props = new Properties();
925925
props.setProperty(PropertyKey.sslMode.getKeyName(), "DISABLED");
@@ -934,22 +934,22 @@ public void testGetTables() throws Exception {
934934
testConn = getConnectionWithProps(props);
935935
DatabaseMetaData metaData = testConn.getMetaData();
936936

937-
this.rs = metaData.getTables(null, null, "t1-_", null);
937+
this.rs = metaData.getTables(null, null, "testGetTables1-_", null);
938938
testGetTables_checkResult(useIS, dbMapsToSchema);
939939

940-
this.rs = metaData.getTables(null, this.dbName.substring(0, 3) + "%", "t1-_", null);
940+
this.rs = metaData.getTables(null, this.dbName.substring(0, 3) + "%", "testGetTables1-_", null);
941941
testGetTables_checkResult(useIS, dbMapsToSchema);
942942

943-
this.rs = metaData.getTables(this.dbName, null, "t1-_", null);
943+
this.rs = metaData.getTables(this.dbName, null, "testGetTables1-_", null);
944944
testGetTables_checkResult(useIS, dbMapsToSchema);
945945

946946
if (dbMapsToSchema) {
947947
String dbPattern = testConn.getSchema().substring(0, testConn.getSchema().length() - 1) + "%";
948-
this.rs = metaData.getTables(null, dbPattern, "t1-_", null);
948+
this.rs = metaData.getTables(null, dbPattern, "testGetTables1-_", null);
949949
assertTrue(this.rs.next(), "Schema pattern " + dbPattern + " should be recognized.");
950950
} else {
951951
String dbPattern = testConn.getCatalog().substring(0, testConn.getCatalog().length() - 1) + "%";
952-
this.rs = metaData.getTables(dbPattern, null, "t1-_", null);
952+
this.rs = metaData.getTables(dbPattern, null, "testGetTables1-_", null);
953953
assertFalse(this.rs.next(), "Catalog pattern " + dbPattern + " should not be recognized.");
954954
}
955955
} finally {
@@ -972,7 +972,7 @@ private void testGetTables_checkResult(boolean useIS, boolean dbMapsToSchema) th
972972
assertEquals(runningOnWindows ? this.dbName.toLowerCase() : this.dbName, this.rs.getString("TABLE_CAT"));
973973
assertNull(this.rs.getString("TABLE_SCHEM"));
974974
}
975-
assertEquals("t1-1", this.rs.getString("TABLE_NAME"));
975+
assertEquals("testGetTables1-1", this.rs.getString("TABLE_NAME"));
976976
assertEquals("TABLE", this.rs.getString("TABLE_TYPE"));
977977
assertEquals(useIS ? "table1" : "", this.rs.getString("REMARKS")); // Table comment is available only with I_S
978978
assertNull(this.rs.getString("TYPE_CAT"));
@@ -989,7 +989,7 @@ private void testGetTables_checkResult(boolean useIS, boolean dbMapsToSchema) th
989989
assertEquals(runningOnWindows ? this.dbName.toLowerCase() : this.dbName, this.rs.getString("TABLE_CAT"));
990990
assertNull(this.rs.getString("TABLE_SCHEM"));
991991
}
992-
assertEquals("t1-2", this.rs.getString("TABLE_NAME"));
992+
assertEquals("testGetTables1-2", this.rs.getString("TABLE_NAME"));
993993
assertEquals("TABLE", this.rs.getString("TABLE_TYPE"));
994994
assertEquals("", this.rs.getString("REMARKS"));
995995
assertNull(this.rs.getString("TYPE_CAT"));
@@ -1030,7 +1030,7 @@ public void testGetColumnPrivileges() throws Exception {
10301030
try {
10311031
testConn = getConnectionWithProps(props);
10321032
testStmt = testConn.createStatement();
1033-
createTable("t1", "(c1 int)");
1033+
createTable("testGetColumnPrivileges", "(c1 int)");
10341034
this.rs = testStmt.executeQuery("SELECT CURRENT_USER()");
10351035
this.rs.next();
10361036
String user = this.rs.getString(1);
@@ -1040,7 +1040,7 @@ public void testGetColumnPrivileges() throws Exception {
10401040
userHostQuoted = "'" + userHost.get(0) + "'@'" + userHost.get(1) + "'";
10411041

10421042
try {
1043-
testStmt.executeUpdate("GRANT update (c1) on t1 to " + userHostQuoted);
1043+
testStmt.executeUpdate("GRANT update (c1) on testGetColumnPrivileges to " + userHostQuoted);
10441044
grantFailed = false;
10451045
} catch (SQLException sqlEx) {
10461046
fail("This testcase needs to be run with a URL that allows the user to issue GRANTs "
@@ -1051,7 +1051,7 @@ public void testGetColumnPrivileges() throws Exception {
10511051
if (!grantFailed) {
10521052
DatabaseMetaData metaData = testConn.getMetaData();
10531053
boolean lowerCaseIds = metaData.storesLowerCaseIdentifiers();
1054-
this.rs = metaData.getColumnPrivileges(null, null, "t1", null);
1054+
this.rs = metaData.getColumnPrivileges(null, null, "testGetColumnPrivileges", null);
10551055
this.rs.next();
10561056
if (dbMapsToSchema) {
10571057
assertEquals("def", this.rs.getString("TABLE_CAT"));
@@ -1060,25 +1060,25 @@ public void testGetColumnPrivileges() throws Exception {
10601060
assertEquals(lowerCaseIds ? this.dbName.toLowerCase() : this.dbName, this.rs.getString("TABLE_CAT"));
10611061
assertNull(this.rs.getString("TABLE_SCHEM"));
10621062
}
1063-
assertEquals("t1", this.rs.getString("TABLE_NAME"));
1063+
assertEquals("testGetColumnPrivileges", this.rs.getString("TABLE_NAME"));
10641064
assertEquals("c1", this.rs.getString("COLUMN_NAME"));
10651065
assertEquals(useIS ? userHostQuoted : userHost.get(0) + "@" + userHost.get(1), this.rs.getString("GRANTEE"));
10661066
assertEquals("UPDATE", this.rs.getString("PRIVILEGE"));
10671067

10681068
if (dbMapsToSchema) {
10691069
String dbPattern = testConn.getSchema().substring(0, testConn.getSchema().length() - 1) + "%";
1070-
this.rs = metaData.getColumnPrivileges(null, dbPattern, "t1", null);
1070+
this.rs = metaData.getColumnPrivileges(null, dbPattern, "testGetColumnPrivileges", null);
10711071
assertFalse(this.rs.next(), "Schema pattern " + dbPattern + " should not be recognized.");
10721072
} else {
10731073
String dbPattern = testConn.getCatalog().substring(0, testConn.getCatalog().length() - 1) + "%";
1074-
this.rs = metaData.getColumnPrivileges(dbPattern, null, "t1", null);
1074+
this.rs = metaData.getColumnPrivileges(dbPattern, null, "testGetColumnPrivileges", null);
10751075
assertFalse(this.rs.next(), "Catalog pattern " + dbPattern + " should not be recognized.");
10761076
}
10771077
}
10781078
} finally {
10791079
if (testStmt != null) {
10801080
if (!grantFailed) {
1081-
testStmt.executeUpdate("REVOKE UPDATE (c1) ON t1 FROM " + userHostQuoted);
1081+
testStmt.executeUpdate("REVOKE UPDATE (c1) ON testGetColumnPrivileges FROM " + userHostQuoted);
10821082
}
10831083
testStmt.close();
10841084
}

0 commit comments

Comments
 (0)