Skip to content

Commit

Permalink
dev checkin. more unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Feb 15, 2012
1 parent bcf3ec8 commit dc87cac
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 62 deletions.
Expand Up @@ -52,9 +52,9 @@ public void testExtractConfigurationStandalone() throws Exception {
dataExtractorService.extractConfigurationStandalone(TestConstants.TEST_CLIENT_NODE, writer);
String content = writer.getBuffer().toString();
assertNumberOfLinesThatStartWith(24, "table,", content, false, true);
assertNumberOfLinesThatStartWith(14, "columns,", content);
assertNumberOfLinesThatStartWith(14, "keys,", content);
assertNumberOfLinesThatStartWith(14, "sql,", content);
assertNumberOfLinesThatStartWith(15, "columns,", content);
assertNumberOfLinesThatStartWith(15, "keys,", content);
assertNumberOfLinesThatStartWith(15, "sql,", content);
assertNumberOfLinesThatStartWith(0, "update,", content);
assertNumberOfLinesThatStartWith(66, "insert,", content, false, true);
assertNumberOfLinesThatStartWith(1, "commit,-9999", content);
Expand Down
Expand Up @@ -11,6 +11,7 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
Expand Down Expand Up @@ -78,6 +79,10 @@ public <T> ISqlReadCursor<T> queryForCursor(String sql, ISqlRowMapper<T> mapper,
Object[] values, int[] types) {
return new JdbcSqlReadCursor<T>(this, mapper, sql, values, types);
}

public static void main(String[] args) {
System.out.println(Timestamp.class.isAssignableFrom(Date.class));
}

public <T> T queryForObject(final String sql, final Class<T> clazz, final Object... args) {
return execute(new IConnectionCallback<T>() {
Expand All @@ -92,9 +97,9 @@ public T execute(Connection con) throws SQLException {
JdbcUtils.setValues(ps, expandArgs(sql, args));
rs = ps.executeQuery();
if (rs.next()) {
if (clazz.isAssignableFrom(Date.class)) {
if (Date.class.isAssignableFrom(clazz)) {
result = (T) rs.getTimestamp(1);
} else if (clazz.isAssignableFrom(String.class)) {
} else if (String.class.isAssignableFrom(clazz)) {
result = (T) rs.getString(1);
} else {
result = (T) rs.getObject(1);
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.jumpmind.symmetric.service.IOutgoingBatchService;
import org.jumpmind.symmetric.service.IParameterService;
import org.jumpmind.symmetric.statistic.IStatisticManager;
import org.jumpmind.symmetric.util.AppUtils;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -846,7 +847,7 @@ public void syncUpdateWithEmptyKey() {
}
}

//@Test(timeout = 120000)
@Test(timeout = 120000)
public void testPurge() throws Exception {
logTestRunning();

Expand Down Expand Up @@ -905,7 +906,7 @@ public void testPurge() throws Exception {
purgeRetentionMinues);
}

@Test//(timeout = 120000)
@Test(timeout = 120000)
public void testHeartbeat() throws Exception {
logTestRunning();
final String checkHeartbeatSql = "select heartbeat_time from sym_node where external_id='"
Expand Down Expand Up @@ -934,61 +935,55 @@ public void testHeartbeat() throws Exception {
clientHeartbeatTimeAfter, rootHeartbeatTimeAfter);
}

// @Test(timeout = 120000)
// public void testVirtualTransactionId() {
// logTestRunning();
// getServer().getSqlTemplate().update("insert into test_very_long_table_name_1234 values('42')");
// if (getRootDbDialect().isTransactionIdOverrideSupported()) {
// assertEquals(
// getServer().getSqlTemplate().queryForObject(
// "select transaction_id from sym_data where data_id in (select max(data_id) from sym_data)",
// String.class), "42", "The hardcoded transaction id was not found.");
// Assert.assertEquals(getServer().getSqlTemplate()
// .update("delete from test_very_long_table_name_1234 where id='42'"), 1);
// assertEquals(
// getServer().getSqlTemplate().queryForObject(
// "select transaction_id from sym_data where data_id in (select max(data_id) from sym_data)",
// String.class), "42", "The hardcoded transaction id was not found.");
// }
// }
//
// @Test(timeout = 120000)
// public void testCaseSensitiveTableNames() {
// logTestRunning();
// String rquote =
// getRootDbDialect().getPlatform().isDelimitedIdentifierModeOn() ?
// getRootDbDialect()
// .getPlatform().getPlatformInfo().getDelimiterToken()
// : "";
// String cquote =
// getClientDbDialect().getPlatform().isDelimitedIdentifierModeOn() ?
// getClientDbDialect()
// .getPlatform().getPlatformInfo().getDelimiterToken()
// : "";
// getServer().getSqlTemplate().update("insert into " + rquote +
// "TEST_ALL_CAPS" +
// rquote
// + " values(1, 'HELLO')");
// clientPull();
// assertEquals(
// getClient().getSqlTemplate().queryForInt("select count(*) from " + cquote
// +
// "TEST_ALL_CAPS"
// + cquote + " where " + cquote + "ALL_CAPS_ID" + cquote + " = 1"), 1,
// "Table name in all caps was not synced");
// getServer().getSqlTemplate().update("insert into " + rquote +
// "Test_Mixed_Case" +
// rquote
// + " values(1, 'Hello')");
// clientPull();
// assertEquals(
// getClient().getSqlTemplate().queryForInt("select count(*) from " + cquote
// +
// "Test_Mixed_Case"
// + cquote + " where " + cquote + "Mixed_Case_Id" + cquote + " = 1"), 1,
// "Table name in mixed case was not synced");
// }
//
@Test(timeout = 120000)
public void testVirtualTransactionId() {
logTestRunning();
getServer().getSqlTemplate().update(
"insert into test_very_long_table_name_1234 values('42')");
if (getServer().getSymmetricDialect().isTransactionIdOverrideSupported()) {
Assert.assertEquals(
"The hardcoded transaction id was not found.",
"42",
getServer()
.getSqlTemplate()
.queryForObject(
"select transaction_id from sym_data where data_id in (select max(data_id) from sym_data)",
String.class));
Assert.assertEquals(
1,
getServer().getSqlTemplate().update(
"delete from test_very_long_table_name_1234 where id='42'"));
Assert.assertEquals(
"The hardcoded transaction id was not found.",
"42",
getServer()
.getSqlTemplate()
.queryForObject(
"select transaction_id from sym_data where data_id in (select max(data_id) from sym_data)",
String.class));
}
}

@Test(timeout = 120000)
public void testCaseSensitiveTableNames() {
logTestRunning();
String rquote = getServer().getSymmetricDialect().getPlatform().getPlatformInfo()
.getDelimiterToken();
String cquote = getClient().getSymmetricDialect().getPlatform().getPlatformInfo()
.getDelimiterToken();
getServer().getSqlTemplate().update(
"insert into " + rquote + "Test_Mixed_Case" + rquote + " values(?,?)", 1, "Hello");
while (clientPull()) {
AppUtils.sleep(1000);
}
Assert.assertEquals(
"Table name in mixed case was not synced",
1,
getClient().getSqlTemplate().queryForInt(
"select count(*) from " + cquote + "Test_Mixed_Case" + cquote + " where "
+ cquote + "Mixed_Case_Id" + cquote + " = 1"));
}

// @Test(timeout = 120000)
// public void testSyncShellCommand() throws Exception {
// logTestRunning();
Expand Down

0 comments on commit dc87cac

Please sign in to comment.