Skip to content

Commit

Permalink
Fail with a better error message if database connection can't be made…
Browse files Browse the repository at this point in the history
… during test.
  • Loading branch information
chenson42 committed Apr 25, 2008
1 parent 81a1f55 commit 6aefb56
Showing 1 changed file with 12 additions and 12 deletions.
Expand Up @@ -36,7 +36,6 @@
import org.jumpmind.symmetric.common.TestConstants;
import org.jumpmind.symmetric.db.DbTriggerTest;
import org.jumpmind.symmetric.load.DataLoaderTest;
import org.testng.Assert;
import org.testng.annotations.Factory;

/**
Expand Down Expand Up @@ -81,13 +80,14 @@ public Object[] createTests() throws Exception {
return tests2Run.toArray(new Object[tests2Run.size()]);
}

public List<? extends AbstractTest> createIntegrationTests(String clientDatabaseType, String rootDatabaseType)
throws Exception {
public List<? extends AbstractTest> createIntegrationTests(String clientDatabaseType,
String rootDatabaseType) throws Exception {
List<AbstractIntegrationTest> tests2Run = new ArrayList<AbstractIntegrationTest>();
File clientFile = writeTempPropertiesFileFor(clientDatabaseType, DatabaseRole.CLIENT);
File rootFile = writeTempPropertiesFileFor(rootDatabaseType, DatabaseRole.ROOT);
addAbstractIntegrationTests(clientFile, rootFile, tests2Run);

if (clientFile != null && rootFile != null) {
addAbstractIntegrationTests(clientFile, rootFile, tests2Run);
}
return tests2Run;
}

Expand Down Expand Up @@ -162,11 +162,11 @@ protected static File writeTempPropertiesFileFor(String databaseType, DatabaseRo
newProperties.setProperty("symmetric.runtime.external.id",
databaseRole == DatabaseRole.ROOT ? TestConstants.TEST_ROOT_EXTERNAL_ID
: TestConstants.TEST_CLIENT_EXTERNAL_ID);
newProperties
.setProperty("symmetric.runtime.my.url", "internal://" + databaseRole.name().toLowerCase());
newProperties.setProperty("symmetric.runtime.my.url", "internal://"
+ databaseRole.name().toLowerCase());
newProperties.setProperty("symmetric.runtime.registration.url",
databaseRole == DatabaseRole.CLIENT ? ("internal://" + DatabaseRole.ROOT.name().toLowerCase())
: "");
databaseRole == DatabaseRole.CLIENT ? ("internal://" + DatabaseRole.ROOT.name()
.toLowerCase()) : "");
newProperties.setProperty("symmetric.runtime.engine.name", databaseRole.name().toLowerCase());

File propertiesFile = File.createTempFile("symmetric-test.", ".properties");
Expand All @@ -177,7 +177,7 @@ protected static File writeTempPropertiesFileFor(String databaseType, DatabaseRo
return propertiesFile;

} else {
Assert.fail();
logger.error("Could not find a valid connection for " + databaseType);
return null;
}
} catch (RuntimeException ex) {
Expand All @@ -196,8 +196,8 @@ private static boolean isConnectionValid(Properties properties) throws Exception
c.close();
return true;
} catch (Exception ex) {
logger.error("Could not connect to the test database using the url: " + properties.getProperty("db.url")
+ ". ", ex);
logger.error("Could not connect to the test database using the url: "
+ properties.getProperty("db.url") + ". ", ex);
return false;
}
}
Expand Down

0 comments on commit 6aefb56

Please sign in to comment.