Skip to content

Commit

Permalink
Test not working, trying a different attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffery-Wasty committed Aug 18, 2023
1 parent 3394474 commit bbbd879
Showing 1 changed file with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,38 +356,34 @@ public void testDBSchemasForDashedCatalogNameWithPattern() throws SQLException {
@Tag(Constants.xAzureSQLDB)
public void testDBSchemasForSchemaPatternWithWildcards() throws SQLException {
UUID id = UUID.randomUUID();
String testCatalog = "catalog" + id;
String[] schemas = {"some_schema", "some%schema", "some[schema"};
String[] schemaPatterns = {"some\\_schema", "some\\%schema", "some\\[schema"};
String testCatalog = "dash-catalog" + id;
String testSchema = "some_schema" + id;

try (Connection conn = getConnection(); Statement stmt = conn.createStatement()) {
TestUtils.dropDatabaseIfExists(testCatalog, connectionString);
stmt.execute(String.format("CREATE DATABASE [%s]", testCatalog));
stmt.execute(String.format("USE [%s]", testCatalog));
stmt.execute(String.format("CREATE SCHEMA [%s]", testSchema));

for (int i = 0; i < schemas.length; ++i) {
stmt.execute(String.format("CREATE SCHEMA [%s]", schemas[i]));

try (ResultSet rs = conn.getMetaData().getSchemas(testCatalog, schemaPatterns[i])) {

MessageFormat schemaEmptyFormat = new MessageFormat(TestResource.getResource("R_nameEmpty"));
Object[] schemaMsgArgs = {schemas[i]};
Object[] catalogMsgArgs = {testCatalog};
try (ResultSet rs = conn.getMetaData().getSchemas(testCatalog, "some\\_%")) {

boolean hasResults = false;
while (rs.next()) {
hasResults = true;
String schemaName = rs.getString(1);
String catalogName = rs.getString(2);
assertTrue(!StringUtils.isEmpty(schemaName), schemaEmptyFormat.format(schemaMsgArgs));
assertTrue(!StringUtils.isEmpty(catalogName), schemaEmptyFormat.format(catalogMsgArgs));
assertEquals(schemaName, schemaMsgArgs[0]);
assertEquals(catalogName, catalogMsgArgs[0]);
}
MessageFormat schemaEmptyFormat = new MessageFormat(TestResource.getResource("R_nameEmpty"));
Object[] schemaMsgArgs = {testSchema};
Object[] catalogMsgArgs = {testCatalog};

MessageFormat atLeastOneFoundFormat = new MessageFormat(TestResource.getResource("R_atLeastOneFound"));
assertTrue(hasResults, atLeastOneFoundFormat.format(schemaMsgArgs));
boolean hasResults = false;
while (rs.next()) {
hasResults = true;
String schemaName = rs.getString(1);
String catalogName = rs.getString(2);
assertTrue(!StringUtils.isEmpty(schemaName), schemaEmptyFormat.format(schemaMsgArgs));
assertTrue(!StringUtils.isEmpty(catalogName), schemaEmptyFormat.format(catalogMsgArgs));
assertEquals(schemaName, schemaMsgArgs[0]);
assertEquals(catalogName, catalogMsgArgs[0]);
}

MessageFormat atLeastOneFoundFormat = new MessageFormat(TestResource.getResource("R_atLeastOneFound"));
assertTrue(hasResults, atLeastOneFoundFormat.format(schemaMsgArgs));
}
} catch (Exception e) {
fail(TestResource.getResource("R_unexpectedErrorMessage") + e.getMessage());
Expand Down

0 comments on commit bbbd879

Please sign in to comment.