Skip to content

Commit

Permalink
fixed several more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Dec 26, 2011
1 parent 9087154 commit cce3ffe
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 60 deletions.
2 changes: 1 addition & 1 deletion symmetric/symmetric-server/pom.xml
Expand Up @@ -96,7 +96,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
<scope>provided</scope>
</dependency>
<!-- Spring Framework -->
<dependency>
Expand Down
Expand Up @@ -37,7 +37,7 @@
import org.junit.Before;
import org.junit.Test;

public class XmlPublisherFilterTest {
public class XmlPublisherFilterUnitTest {

private static final String TABLE_TEST = "TEST_XML_PUBLISHER";

Expand All @@ -47,7 +47,7 @@ public class XmlPublisherFilterTest {

private Table table;

public XmlPublisherFilterTest() throws Exception {
public XmlPublisherFilterUnitTest() throws Exception {
super();
}

Expand Down
Expand Up @@ -718,7 +718,7 @@ public void testColumnMatchOnNull() {

resetBatches();

update(TEST_TABLE_1, "Not Routed");
insert(TEST_TABLE_1, "Not Routed");

Assert.assertEquals(
0,
Expand All @@ -736,7 +736,7 @@ public void testColumnMatchOnNull() {

resetBatches();

update(TEST_TABLE_1, null);
insert(TEST_TABLE_1, null);

Assert.assertEquals(
0,
Expand Down Expand Up @@ -768,7 +768,7 @@ public void testColumnMatchOnNotNull() {

resetBatches();

update(TEST_TABLE_1, "Not Routed");
insert(TEST_TABLE_1, "Not Routed");

Assert.assertEquals(
0,
Expand All @@ -786,7 +786,7 @@ public void testColumnMatchOnNotNull() {

resetBatches();

update(TEST_TABLE_1, null);
insert(TEST_TABLE_1, null);

Assert.assertEquals(
0,
Expand Down Expand Up @@ -1426,7 +1426,6 @@ protected void insert(final String tableName, final int count, boolean transacti
dialect.disableSyncTriggers(transaction, node2disable);
}
for (int i = 0; i < count; i++) {
update(tableName, routingVarcharFieldValue);
transaction.execute(
String.format("insert into %s (ROUTING_VARCHAR) values(?)", tableName),
routingVarcharFieldValue);
Expand Down Expand Up @@ -1457,9 +1456,8 @@ protected long getLatestDataId() {
return getJdbcTemplate().queryForObject("select max(data_id) from sym_data", Long.class);
}

protected void update(String tableName, String value) {
getJdbcTemplate().update(
String.format("insert into %s (ROUTING_VARCHAR) values(?)", tableName), value);
protected void insert(String tableName, String value) {
insert(tableName, 1, true, null, value);
}

protected void execute(final String sql, final String node2disable) {
Expand Down
Expand Up @@ -393,18 +393,24 @@ protected static int[] filterTypes(int[] types, IDbDialect dbDialect) {
}

public static int insert(Object[] values, IDbDialect dbDialect, boolean disableTriggers) {
int count = -1;
IDatabasePlatform platform = dbDialect.getPlatform();
ISqlTransaction transaction = platform.getSqlTemplate().startSqlTransaction();
if (disableTriggers) {
dbDialect.disableSyncTriggers(transaction);
}
int count = transaction.execute(INSERT, filterValues(values, dbDialect),
filterTypes(INSERT_TYPES, dbDialect));
if (disableTriggers) {
dbDialect.enableSyncTriggers(transaction);
try {
if (disableTriggers) {
dbDialect.disableSyncTriggers(transaction);
}
count = transaction.execute(INSERT, filterValues(values, dbDialect));
if (disableTriggers) {
dbDialect.enableSyncTriggers(transaction);
}
transaction.commit();
} catch (RuntimeException ex) {
transaction.rollback();
throw ex;
} finally {
transaction.close();
}
transaction.commit();
transaction.close();
return count;
}

Expand Down
Expand Up @@ -16,15 +16,15 @@
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License. */

package org.jumpmind.symmetric.test;

* under the License.
*/

package org.jumpmind.symmetric.test;

import java.util.Collection;

import org.jumpmind.symmetric.config.ParameterFilterTest;
import org.jumpmind.symmetric.extract.DataExtractorTest;
import org.jumpmind.symmetric.integrate.XmlPublisherFilterTest;
import org.jumpmind.symmetric.service.impl.AcknowledgeServiceTest;
import org.jumpmind.symmetric.service.impl.ClusterServiceTest;
import org.jumpmind.symmetric.service.impl.DataExtractorServiceTest;
Expand All @@ -43,38 +43,39 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(ParameterizedSuite.class)
@SuiteClasses( { TriggerRouterServiceTest.class, DataExtractorTest.class,
ParameterFilterTest.class, RouterServiceTest.class, CrossCatalogSyncTest.class, FunkyDataTypesTest.class,
NodeConcurrencyFilterTest.class, AcknowledgeServiceTest.class, ClusterServiceTest.class,
DataExtractorServiceTest.class, DataLoaderServiceTest.class, NodeServiceTest.class,
OutgoingBatchServiceTest.class, ParameterServiceTest.class, PurgeServiceTest.class,
RegistrationServiceTest.class, StatisticServiceTest.class, XmlPublisherFilterTest.class,
DataServiceTest.class, CleanupTest.class })
public class DatabaseTestSuite {

String database;
public static final String DEFAULT_TEST_PREFIX = "test";

public DatabaseTestSuite() throws Exception {
}
public void init(String database) {
this.database = database;
}
@Parameters
public static Collection<String[]> lookupDatabases() {
return TestSetupUtil.lookupDatabases(DEFAULT_TEST_PREFIX);
}

@Test

@RunWith(ParameterizedSuite.class)
@SuiteClasses({ TriggerRouterServiceTest.class, DataExtractorTest.class, ParameterFilterTest.class,
RouterServiceTest.class, CrossCatalogSyncTest.class, FunkyDataTypesTest.class,
NodeConcurrencyFilterTest.class, AcknowledgeServiceTest.class, ClusterServiceTest.class,
DataExtractorServiceTest.class, DataLoaderServiceTest.class, NodeServiceTest.class,
OutgoingBatchServiceTest.class, ParameterServiceTest.class, PurgeServiceTest.class,
RegistrationServiceTest.class, StatisticServiceTest.class, DataServiceTest.class,
CleanupTest.class })
public class DatabaseTestSuite {

String database;

public static final String DEFAULT_TEST_PREFIX = "test";

public DatabaseTestSuite() throws Exception {
}

public void init(String database) {
this.database = database;
}

@Parameters
public static Collection<String[]> lookupDatabases() {
return TestSetupUtil.lookupDatabases(DEFAULT_TEST_PREFIX);
}

@Test
public void setup() throws Exception {
TestSetupUtil.cleanup();
AbstractDatabaseTest.standalone = false;
TestSetupUtil.setup(DEFAULT_TEST_PREFIX, TestConstants.TEST_CONTINUOUS_SETUP_SCRIPT, null, database);
}

TestSetupUtil.cleanup();
AbstractDatabaseTest.standalone = false;
TestSetupUtil.setup(DEFAULT_TEST_PREFIX, TestConstants.TEST_CONTINUOUS_SETUP_SCRIPT, null,
database);
}

}
6 changes: 4 additions & 2 deletions symmetric/symmetric-server/src/test/resources/log4j.xml
Expand Up @@ -13,13 +13,15 @@
<priority value="INFO" />
</category>

<category name="org.jumpmind.symmetric.io">
<!--
<category name="org.jumpmind.symmetric.io.data.writer">
<priority value="DEBUG" />
</category>
<category name="org.jumpmind.db.sql.jdbc">
<priority value="DEBUG" />
</category>
</category>
-->

<category name="org.jumpmind.symmetric.ddlutils">
<priority value="WARN" />
Expand Down

0 comments on commit cce3ffe

Please sign in to comment.