Skip to content

Commit 1a993a8

Browse files
SNOW-1050447: Cleanup schemas in testGetProcedureColumnsWildcards (#1641)
1 parent 99ce7d4 commit 1a993a8

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java

+23-14
Original file line numberDiff line numberDiff line change
@@ -389,27 +389,36 @@ public void testGetFunctionSqlInjectionProtection() throws Throwable {
389389
* @throws SQLException
390390
*/
391391
@Test
392-
public void testGetProcedureColumnsWildcards() throws SQLException {
392+
public void testGetProcedureColumnsWildcards() throws Exception {
393393
try (Connection con = getConnection();
394394
Statement statement = con.createStatement()) {
395395
String database = con.getCatalog();
396396
String schemaPrefix =
397397
TestUtil.GENERATED_SCHEMA_PREFIX + SnowflakeUtil.randomAlphaNumeric(5).toUpperCase();
398398
String schema1 = schemaPrefix + "SCH1";
399399
String schema2 = schemaPrefix + "SCH2";
400-
// Create 2 schemas, each with the same stored procedure declared in them
401-
statement.execute("create or replace schema " + schema1);
402-
statement.execute(TEST_PROC);
403-
statement.execute("create or replace schema " + schema2);
404-
statement.execute(TEST_PROC);
405-
DatabaseMetaData metaData = con.getMetaData();
406-
try (ResultSet rs =
407-
metaData.getProcedureColumns(database, schemaPrefix + "SCH_", "TESTPROC", "PARAM1")) {
408-
// Assert 4 rows returned for the param PARAM1 that's present in each of the 2 identical
409-
// stored procs in different schemas. A result row is returned for each procedure, making
410-
// the total rowcount 4
411-
assertEquals(4, getSizeOfResultSet(rs));
412-
}
400+
TestUtil.withSchema(
401+
statement,
402+
schema1,
403+
() -> {
404+
statement.execute(TEST_PROC);
405+
TestUtil.withSchema(
406+
statement,
407+
schema2,
408+
() -> {
409+
statement.execute(TEST_PROC);
410+
// Create 2 schemas, each with the same stored procedure declared in them
411+
DatabaseMetaData metaData = con.getMetaData();
412+
try (ResultSet rs =
413+
metaData.getProcedureColumns(
414+
database, schemaPrefix + "SCH_", "TESTPROC", "PARAM1")) {
415+
// Assert 4 rows returned for the param PARAM1 that's present in each of the 2
416+
// identical stored procs in different schemas. A result row is returned for
417+
// each procedure, making the total rowcount 4
418+
assertEquals(4, getSizeOfResultSet(rs));
419+
}
420+
});
421+
});
413422
}
414423
}
415424

0 commit comments

Comments
 (0)