diff --git a/symmetric/pom.xml b/symmetric/pom.xml
index f25d4e90bd..da66e39b4f 100644
--- a/symmetric/pom.xml
+++ b/symmetric/pom.xml
@@ -399,7 +399,7 @@
org.testng
testng
- 5.5
+ 5.6
jdk15
test
diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/db/SqlTemplate.java b/symmetric/src/main/java/org/jumpmind/symmetric/db/SqlTemplate.java
index 14feae719e..3c4d708c89 100644
--- a/symmetric/src/main/java/org/jumpmind/symmetric/db/SqlTemplate.java
+++ b/symmetric/src/main/java/org/jumpmind/symmetric/db/SqlTemplate.java
@@ -195,29 +195,31 @@ private String replaceTemplateVariables(IDbDialect dialect, DataEventType dml, T
}
private String eval(boolean condition, String prop, String ddl) {
- String ifStmt = "$(if:" + prop + ")";
- String elseStmt = "$(else:" + prop + ")";
- String endStmt = "$(end:" + prop + ")";
- int ifIndex = ddl.indexOf(ifStmt);
- if (ifIndex >= 0) {
- int endIndex = ddl.indexOf(endStmt);
- if (endIndex >= 0) {
- String onTrue = ddl.substring(ifIndex + ifStmt.length(), endIndex);
- String onFalse = "";
- int elseIndex = onTrue.indexOf(elseStmt);
- if (elseIndex >= 0) {
- onFalse = onTrue.substring(elseIndex + elseStmt.length());
- onTrue = onTrue.substring(0, elseIndex);
- }
+ if (ddl != null) {
+ String ifStmt = "$(if:" + prop + ")";
+ String elseStmt = "$(else:" + prop + ")";
+ String endStmt = "$(end:" + prop + ")";
+ int ifIndex = ddl.indexOf(ifStmt);
+ if (ifIndex >= 0) {
+ int endIndex = ddl.indexOf(endStmt);
+ if (endIndex >= 0) {
+ String onTrue = ddl.substring(ifIndex + ifStmt.length(), endIndex);
+ String onFalse = "";
+ int elseIndex = onTrue.indexOf(elseStmt);
+ if (elseIndex >= 0) {
+ onFalse = onTrue.substring(elseIndex + elseStmt.length());
+ onTrue = onTrue.substring(0, elseIndex);
+ }
+
+ if (condition) {
+ ddl = ddl.substring(0, ifIndex) + onTrue + ddl.substring(endIndex + endStmt.length());
+ } else {
+ ddl = ddl.substring(0, ifIndex) + onFalse + ddl.substring(endIndex + endStmt.length());
+ }
- if (condition) {
- ddl = ddl.substring(0, ifIndex) + onTrue + ddl.substring(endIndex + endStmt.length());
} else {
- ddl = ddl.substring(0, ifIndex) + onFalse + ddl.substring(endIndex + endStmt.length());
+ throw new IllegalStateException(ifStmt + " has to have a " + endStmt);
}
-
- } else {
- throw new IllegalStateException(ifStmt + " has to have a " + endStmt);
}
}
return ddl;
diff --git a/symmetric/src/shortcuts/Symmetric Compile and Package Only.launch b/symmetric/src/shortcuts/Symmetric Compile and Package Only.launch
index 255553ae00..2d0bd7d2c0 100644
--- a/symmetric/src/shortcuts/Symmetric Compile and Package Only.launch
+++ b/symmetric/src/shortcuts/Symmetric Compile and Package Only.launch
@@ -6,6 +6,6 @@
-
+
diff --git a/symmetric/src/test/java/org/jumpmind/symmetric/AbstractIntegrationTest.java b/symmetric/src/test/java/org/jumpmind/symmetric/AbstractIntegrationTest.java
index c2295a3eba..681c8b0268 100644
--- a/symmetric/src/test/java/org/jumpmind/symmetric/AbstractIntegrationTest.java
+++ b/symmetric/src/test/java/org/jumpmind/symmetric/AbstractIntegrationTest.java
@@ -19,6 +19,10 @@ abstract public class AbstractIntegrationTest extends AbstractTest {
private SymmetricEngine rootEngine;
+ private String clientDatabaseType;
+
+ private String rootDatabaseType;
+
protected SymmetricEngine getClientEngine() {
if (this.clientEngine == null) {
this.clientEngine = createEngine(getClientFile());
@@ -26,18 +30,23 @@ protected SymmetricEngine getClientEngine() {
}
return this.clientEngine;
}
-
+
protected String getRootDatabaseName() {
- IDbDialect dialect = (IDbDialect)getRootEngine().getApplicationContext().getBean(Constants.DB_DIALECT);
- return dialect.getName().toLowerCase();
+ if (rootDatabaseType == null) {
+ IDbDialect dialect = (IDbDialect) getRootEngine().getApplicationContext().getBean(Constants.DB_DIALECT);
+ rootDatabaseType = dialect.getName().toLowerCase();
+ }
+ return rootDatabaseType;
}
protected String getClientDatabaseName() {
- IDbDialect dialect = (IDbDialect)getClientEngine().getApplicationContext().getBean(Constants.DB_DIALECT);
- return dialect.getName().toLowerCase();
+ if (clientDatabaseType == null) {
+ IDbDialect dialect = (IDbDialect) getClientEngine().getApplicationContext().getBean(Constants.DB_DIALECT);
+ clientDatabaseType = dialect.getName().toLowerCase();
+ }
+ return clientDatabaseType;
}
-
protected SymmetricEngine getRootEngine() {
if (this.rootEngine == null) {
this.rootEngine = createEngine(getRootFile());
@@ -49,7 +58,7 @@ protected SymmetricEngine getRootEngine() {
}
return this.rootEngine;
}
-
+
File getClientFile() {
Properties properties = MultiDatabaseTestFactory.getTestProperties();
String[] databaseTypes = StringUtils.split(properties.getProperty("test.client"), ",");
@@ -61,5 +70,13 @@ File getRootFile() {
String[] databaseTypes = StringUtils.split(properties.getProperty("test.root"), ",");
return MultiDatabaseTestFactory.writeTempPropertiesFileFor(databaseTypes[0], DatabaseRole.ROOT);
- }
+ }
+
+ public void setClientDatabaseType(String clientDatabaseType) {
+ this.clientDatabaseType = clientDatabaseType;
+ }
+
+ public void setRootDatabaseType(String rootDatabaseType) {
+ this.rootDatabaseType = rootDatabaseType;
+ }
}
diff --git a/symmetric/src/test/java/org/jumpmind/symmetric/IntegrationTest.java b/symmetric/src/test/java/org/jumpmind/symmetric/IntegrationTest.java
index b4e3f2eb8e..d05ba35076 100644
--- a/symmetric/src/test/java/org/jumpmind/symmetric/IntegrationTest.java
+++ b/symmetric/src/test/java/org/jumpmind/symmetric/IntegrationTest.java
@@ -19,20 +19,16 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.testng.Assert;
import org.testng.ITest;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
-@Test(sequential=true)
public class IntegrationTest extends AbstractIntegrationTest implements ITest {
private JdbcTemplate rootJdbcTemplate;
private JdbcTemplate clientJdbcTemplate;
- // TODO: move this data access somewhere else
static final String insertOrderHeaderSql = "insert into test_order_header (order_id, customer_id, status, deliver_date) values(?,?,?,?)";
-
+
static final String updateOrderHeaderStatusSql = "update test_order_header set status = ? where order_id = ?";
static final String selectOrderHeaderSql = "select order_id, customer_id, status, deliver_date from test_order_header where order_id = ?";
@@ -40,36 +36,47 @@ public class IntegrationTest extends AbstractIntegrationTest implements ITest {
static final String insertOrderDetailSql = "insert into test_order_detail (order_id, line_number, item_type, item_id, quantity, price) values(?,?,?,?,?,?)";
static final String insertCustomerSql = "insert into test_customer (customer_id, name, is_active, address, city, state, zip, entry_time, notes, icon) values(?,?,?,?,?,?,?,?,?,?)";
-
+
static final String insertTestTriggerTableSql = "insert into test_triggers_table (string_one_value, string_two_value) values(?,?)";
-
+
static final String updateTestTriggerTableSql = "update test_triggers_table set string_one_value=?";
static final byte[] BINARY_DATA = new byte[] { 0x01, 0x02, 0x03 };
-
+
public String getTestName() {
return "Test from " + getRootDatabaseName() + " to " + getClientDatabaseName();
}
-
- @BeforeTest(groups="continuous")
- public void init() {
+
+ @Test(testName = "Integration Test", groups = "continuous", timeOut = 60000)
+ public void testLifecycle() throws Exception {
+ init();
+ register();
+ testSyncToClient();
+ testSyncToRootAutoGeneratedPrimaryKey();
+ testSyncToRoot();
+ testSyncInsertCondition();
+ testSyncUpdateCondition();
+ testIgnoreNodeChannel();
+ testPurge();
+ testHeartbeat();
+
+ }
+
+ protected void init() {
BeanFactory rootBeanFactory = getRootEngine().getApplicationContext();
rootJdbcTemplate = new JdbcTemplate((DataSource) rootBeanFactory.getBean(Constants.DATA_SOURCE));
BeanFactory clientBeanFactory = getClientEngine().getApplicationContext();
clientJdbcTemplate = new JdbcTemplate((DataSource) clientBeanFactory.getBean(Constants.DATA_SOURCE));
-
}
-
- @Test(groups="continuous", timeOut=60000)
- public void testRegistration() {
+
+ protected void register() {
getRootEngine().openRegistration(TestConstants.TEST_CLIENT_NODE_GROUP, TestConstants.TEST_CLIENT_EXTERNAL_ID);
getClientEngine().start();
Assert.assertTrue(getClientEngine().isRegistered(), "The client did not register.");
}
- @Test(groups="continuous",dependsOnMethods="testRegistration")
- public void testSyncToClient() {
+ protected void testSyncToClient() {
// test pulling no data
getClientEngine().pull();
@@ -89,31 +96,25 @@ public void testSyncToClient() {
}
- @Test
- public void testRejectedRegistration() {
-
- }
-
- @Test(groups="continuous",dependsOnMethods = "testSyncToClient")
- public void testSyncToRootAutoGeneratedPrimaryKey() {
+ protected void testSyncToRootAutoGeneratedPrimaryKey() {
final String NEW_VALUE = "unique new value one value";
clientJdbcTemplate.update(insertTestTriggerTableSql, new Object[] { "value one", "value \" two" });
getClientEngine().push();
clientJdbcTemplate.update(updateTestTriggerTableSql, new Object[] { NEW_VALUE });
getClientEngine().push();
- Assert.assertEquals(rootJdbcTemplate.queryForInt("select count(*) from test_triggers_table where string_one_value=?", new Object[] {NEW_VALUE}), 1, "The update on test_triggers_table did not work.");
+ Assert.assertEquals(rootJdbcTemplate.queryForInt(
+ "select count(*) from test_triggers_table where string_one_value=?", new Object[] { NEW_VALUE }), 1,
+ "The update on test_triggers_table did not work.");
}
- @Test(groups="continuous",dependsOnMethods = "testSyncToClient")
- public void testSyncToRoot() throws ParseException {
+ protected void testSyncToRoot() throws ParseException {
Date date = DateUtils.parseDate("2007-01-03", new String[] { "yyyy-MM-dd" });
clientJdbcTemplate.update(insertOrderHeaderSql, new Object[] { "10", 100, null, date });
clientJdbcTemplate.update(insertOrderDetailSql, new Object[] { "10", 1, "STK", "110000065", 3, 3.33 });
getClientEngine().push();
}
- @Test(groups="continuous",dependsOnMethods="testSyncToRoot")
- public void testSyncInsertCondition() throws ParseException {
+ protected void testSyncInsertCondition() throws ParseException {
// Should not sync when status = null
Date date = DateUtils.parseDate("2007-01-02", new String[] { "yyyy-MM-dd" });
rootJdbcTemplate.update(insertOrderHeaderSql, new Object[] { "11", 100, null, date });
@@ -136,8 +137,7 @@ public void testSyncInsertCondition() throws ParseException {
}
@SuppressWarnings("unchecked")
- @Test(groups="continuous",dependsOnMethods="testSyncToRoot")
- public void testSyncUpdateCondition() {
+ protected void testSyncUpdateCondition() {
rootJdbcTemplate.update(updateOrderHeaderStatusSql, new Object[] { null, "1" });
getClientEngine().pull();
Assert.assertEquals(clientJdbcTemplate.queryForList(selectOrderHeaderSql, new Object[] { "1" }).size(), 0,
@@ -153,8 +153,7 @@ public void testSyncUpdateCondition() {
}
@SuppressWarnings("unchecked")
- @Test(groups="continuous",dependsOnMethods = "testSyncUpdateCondition")
- public void testIgnoreNodeChannel() {
+ protected void testIgnoreNodeChannel() {
INodeService nodeService = (INodeService) getRootEngine().getApplicationContext().getBean("nodeService");
nodeService.ignoreNodeChannelForExternalId(true, TestConstants.TEST_CHANNEL_ID,
TestConstants.TEST_ROOT_NODE_GROUP, TestConstants.TEST_ROOT_EXTERNAL_ID);
@@ -168,9 +167,7 @@ public void testIgnoreNodeChannel() {
}
- @Test(groups="continuous",dependsOnMethods = { "testSyncUpdateCondition", "testSyncInsertCondition",
- "testSyncToRoot", "testSyncToClient" })
- public void testPurge() throws Exception {
+ protected void testPurge() throws Exception {
Thread.sleep(1000);
getRootEngine().purge();
getClientEngine().purge();
@@ -182,8 +179,7 @@ public void testPurge() throws Exception {
}
- @Test(groups="continuous", dependsOnMethods="testRegistration")
- public void testHeartbeat() throws Exception {
+ protected void testHeartbeat() throws Exception {
long ts = System.currentTimeMillis();
Thread.sleep(1000);
getClientEngine().heartbeat();
@@ -194,41 +190,31 @@ public void testHeartbeat() throws Exception {
"The client node was not sync'd to the root as expected.");
}
- @Test
- public void testMultipleChannels() {
+ protected void testMultipleChannels() {
}
- @Test
- public void testChannelInError() {
+ protected void testChannelInError() {
}
- @Test
- public void testTableSyncConfigChangeForRoot() {
+ protected void testTableSyncConfigChangeForRoot() {
}
- @Test
- public void testTableSyncConfigChangeForClient() {
+ protected void testTableSyncConfigChangeForClient() {
}
- @Test
- public void testDataChangeTableChangeDataChangeThenSync() {
+ protected void testDataChangeTableChangeDataChangeThenSync() {
}
- @Test
- public void testTransactionalCommit() {
+ protected void testTransactionalCommit() {
}
- @Test
- public void testTransactionalCommitPastBatchBoundary() {
+ protected void testTransactionalCommitPastBatchBoundary() {
}
- @Test
- public void testSyncingGlobalParametersFromRoot() {
-
+ protected void testSyncingGlobalParametersFromRoot() {
}
- @AfterClass()
- public void tearDown() {
+ protected void testRejectedRegistration() {
}
}
diff --git a/symmetric/src/test/java/org/jumpmind/symmetric/MultiDatabaseTestFactory.java b/symmetric/src/test/java/org/jumpmind/symmetric/MultiDatabaseTestFactory.java
index 13d86407cd..9e9b2d4a8f 100644
--- a/symmetric/src/test/java/org/jumpmind/symmetric/MultiDatabaseTestFactory.java
+++ b/symmetric/src/test/java/org/jumpmind/symmetric/MultiDatabaseTestFactory.java
@@ -38,6 +38,7 @@
import org.jumpmind.symmetric.common.TestConstants;
import org.jumpmind.symmetric.db.DbTriggerTest;
import org.jumpmind.symmetric.load.DataLoaderTest;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Factory;
/**
@@ -51,27 +52,40 @@ enum DatabaseRole {
CLIENT, ROOT
};
- @Factory
- public Object[] createTests() throws Exception {
- List