From 8b5bf2f1bf00c62a063650238dea54bea9699acf Mon Sep 17 00:00:00 2001 From: lilgreenbird Date: Mon, 20 Jul 2020 16:02:39 -0700 Subject: [PATCH] Test | Cleanup before running tests (#1387) --- azure-pipelines.yml | 6 +++--- .../DatabaseMetaDataForeignKeyTest.java | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index de93bfaa8..3681ace57 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,7 +38,7 @@ jobs: displayName: 'Maven build jre14' inputs: mavenPomFile: 'pom.xml' - goals: 'clean -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pjre14 -DuserNTLM=$(userNTLM) -DpasswordNTLM=$(passwordNTLM) -DdomainNTLM=$(domainNTLM) -DexcludedGroups=$(Ex_Groups) -Dpkcs12_truststore_password=$(pkcs12_truststore_password) -Dpkcs12_truststore=$(pkcs12_truststore.secureFilePath) + goals: 'clean dependency:purge-local-repository -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pjre14 -DuserNTLM=$(userNTLM) -DpasswordNTLM=$(passwordNTLM) -DdomainNTLM=$(domainNTLM) -DexcludedGroups=$(Ex_Groups) -Dpkcs12_truststore_password=$(pkcs12_truststore_password) -Dpkcs12_truststore=$(pkcs12_truststore.secureFilePath) -DapplicationClientID=$(applicationClientID) -DapplicationKey=$(applicationKey) -DkeyID=$(keyID) -DwindowsKeyPath=$(windowsKeyPath) -DenclaveAttestationUrl=$(enclaveAttestationUrl) -DenclaveAttestationProtocol=$(enclaveAttestationProtocol) -DenclaveServer=$(enclaveServer)' testResultsFiles: '**/TEST-*.xml' testRunTitle: 'Maven build jre14' @@ -48,7 +48,7 @@ jobs: displayName: 'Maven build jre11' inputs: mavenPomFile: 'pom.xml' - goals: 'clean -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pjre11 -DuserNTLM=$(userNTLM) -DpasswordNTLM=$(passwordNTLM) -DdomainNTLM=$(domainNTLM) -DexcludedGroups=$(Ex_Groups) -Dpkcs12_truststore_password=$(pkcs12_truststore_password) -Dpkcs12_truststore=$(pkcs12_truststore.secureFilePath) + goals: 'clean dependency:purge-local-repository -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pjre11 -DuserNTLM=$(userNTLM) -DpasswordNTLM=$(passwordNTLM) -DdomainNTLM=$(domainNTLM) -DexcludedGroups=$(Ex_Groups) -Dpkcs12_truststore_password=$(pkcs12_truststore_password) -Dpkcs12_truststore=$(pkcs12_truststore.secureFilePath) -DapplicationClientID=$(applicationClientID) -DapplicationKey=$(applicationKey) -DkeyID=$(keyID) -DwindowsKeyPath=$(windowsKeyPath) -DenclaveAttestationUrl=$(enclaveAttestationUrl) -DenclaveAttestationProtocol=$(enclaveAttestationProtocol) -DenclaveServer=$(enclaveServer)' testResultsFiles: '**/TEST-*.xml' testRunTitle: 'Maven build jre11' @@ -58,7 +58,7 @@ jobs: displayName: 'Maven build jre8' inputs: mavenPomFile: 'pom.xml' - goals: 'clean -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pjre8 -DuserNTLM=$(userNTLM) -DpasswordNTLM=$(passwordNTLM) -DdomainNTLM=$(domainNTLM) -DexcludedGroups=$(Ex_Groups) -Dpkcs12_truststore_password=$(pkcs12_truststore_password) -Dpkcs12_truststore=$(pkcs12_truststore.secureFilePath) + goals: 'clean dependency:purge-local-repository -Dmssql_jdbc_test_connection_properties=jdbc:sqlserver://$(Target_SQL)$(server_domain);$(database);$(user);$(password); install -Pjre8 -DuserNTLM=$(userNTLM) -DpasswordNTLM=$(passwordNTLM) -DdomainNTLM=$(domainNTLM) -DexcludedGroups=$(Ex_Groups) -Dpkcs12_truststore_password=$(pkcs12_truststore_password) -Dpkcs12_truststore=$(pkcs12_truststore.secureFilePath) -DapplicationClientID=$(applicationClientID) -DapplicationKey=$(applicationKey) -DkeyID=$(keyID) -DwindowsKeyPath=$(windowsKeyPath) -DenclaveAttestationUrl=$(enclaveAttestationUrl) -DenclaveAttestationProtocol=$(enclaveAttestationProtocol) -DenclaveServer=$(enclaveServer)' testResultsFiles: '**/TEST-*.xml' testRunTitle: 'Maven build jre8' diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/databasemetadata/DatabaseMetaDataForeignKeyTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/databasemetadata/DatabaseMetaDataForeignKeyTest.java index 1c5f48bb3..4f725c307 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/databasemetadata/DatabaseMetaDataForeignKeyTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/databasemetadata/DatabaseMetaDataForeignKeyTest.java @@ -53,16 +53,12 @@ public class DatabaseMetaDataForeignKeyTest extends AbstractTest { @BeforeAll public static void setupVariation() throws SQLException { + cleanup(); + try (Connection conn = getConnection(); Statement stmt = conn.createStatement()) { catalog = conn.getCatalog(); schema = conn.getSchema(); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table1), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table2), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table3), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table4), stmt); - TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table5), stmt); - stmt.execute("Create table " + AbstractSQLGenerator.escapeIdentifier(table2) + " (c21 int NOT NULL PRIMARY KEY)"); @@ -111,6 +107,10 @@ public static void setupVariation() throws SQLException { @AfterAll public static void terminateVariation() throws SQLException { + cleanup(); + } + + private static void cleanup() { try (Statement stmt = connection.createStatement()) { TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table1), stmt); TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(table2), stmt); @@ -126,7 +126,6 @@ public static void terminateVariation() throws SQLException { TestUtils.dropTableIfExists(AbstractSQLGenerator.escapeIdentifier(PKTable1), stmt); TestUtils.dropSchemaIfExists(anotherSchema, stmt); - } catch (Exception e) { fail(TestResource.getResource("R_unexpectedErrorMessage") + e.getMessage()); }