Skip to content

Commit

Permalink
Refactored some test stuff. Removed unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed May 27, 2010
1 parent 8bc958d commit d259c43
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 25 deletions.
Expand Up @@ -85,7 +85,6 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCallback;
import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
import org.springframework.jdbc.support.lob.LobHandler;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
Expand Down Expand Up @@ -119,8 +118,6 @@ abstract public class AbstractDbDialect implements IDbDialect {

protected SqlTemplate sqlTemplate;

protected SQLErrorCodeSQLExceptionTranslator sqlErrorTranslator;

private Map<Integer, String> _defaultSizes;

protected IParameterService parameterService;
Expand Down Expand Up @@ -215,7 +212,6 @@ public void init(Platform pf) {
log.info("DbDialectInUse", this.getClass().getName());
this.jdbcTemplate = new JdbcTemplate(pf.getDataSource());
this.platform = pf;
this.sqlErrorTranslator = new SQLErrorCodeSQLExceptionTranslator(pf.getDataSource());
this.identifierQuoteString = "\"";
jdbcTemplate.execute(new ConnectionCallback<Object>() {
public Object doInConnection(Connection c) throws SQLException, DataAccessException {
Expand Down Expand Up @@ -1280,10 +1276,6 @@ public void setSqlTemplate(SqlTemplate sqlTemplate) {
this.sqlTemplate = sqlTemplate;
}

public SQLErrorCodeSQLExceptionTranslator getSqlErrorTranslator() {
return sqlErrorTranslator;
}

public void setTablePrefix(String tablePrefix) {
this.tablePrefix = tablePrefix;
}
Expand Down
Expand Up @@ -37,7 +37,6 @@
import org.jumpmind.symmetric.model.TriggerRouter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCallback;
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
import org.springframework.jdbc.support.lob.LobHandler;

public interface IDbDialect {
Expand Down Expand Up @@ -161,8 +160,6 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
*/
public void purge();

public SQLErrorCodeSQLExceptionTranslator getSqlErrorTranslator();

public void disableSyncTriggers();

public void disableSyncTriggers(String nodeId);
Expand Down
Expand Up @@ -35,7 +35,6 @@
import org.jumpmind.symmetric.ext.INodeGroupTestDataLoaderFilter;
import org.jumpmind.symmetric.ext.ITestDataLoaderFilter;
import org.jumpmind.symmetric.load.AbstractDataLoaderTest;
import org.jumpmind.symmetric.load.csv.CsvLoader;
import org.jumpmind.symmetric.model.IncomingBatch;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.service.IParameterService;
Expand All @@ -54,13 +53,6 @@ public DataLoaderServiceTest() throws Exception {
super();
}

protected Level setLoggingLevelForTest(Level level) {
Level old = Logger.getLogger(DataLoaderService.class).getLevel();
Logger.getLogger(DataLoaderService.class).setLevel(level);
Logger.getLogger(CsvLoader.class).setLevel(level);
return old;
}

@Test
public void testIncomingBatch() throws Exception {
String[] insertValues = new String[TEST_COLUMNS.length];
Expand Down
Expand Up @@ -41,7 +41,7 @@
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.transaction.support.TransactionTemplate;

public class AbstractDatabaseTest {
public class AbstractDatabaseTest extends AbstractTest {

protected Log logger = LogFactory.getLog(getClass());

Expand All @@ -52,6 +52,11 @@ public class AbstractDatabaseTest {
public void init(String database) {
this.database = database;
}

@Override
protected String printDatabases() {
return getDatabase();
}

public AbstractDatabaseTest() throws Exception {
if (standalone) {
Expand Down
Expand Up @@ -31,7 +31,7 @@
import org.junit.Before;
import org.springframework.jdbc.core.JdbcTemplate;

public class AbstractIntegrationTest {
public class AbstractIntegrationTest extends AbstractTest {

protected final Log logger = LogFactory.getLog(getClass());

Expand Down Expand Up @@ -63,10 +63,10 @@ public AbstractIntegrationTest() throws Exception {
throw e;
}
}

protected void logTestRunning() {
logger.info("Running " + new Exception().getStackTrace()[1].getMethodName() + ". "
+ printRootAndClientDatabases());
@Override
protected String printDatabases() {
return printRootAndClientDatabases();
}

protected ISymmetricEngine getRootEngine() {
Expand Down
@@ -0,0 +1,26 @@
package org.jumpmind.symmetric.test;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jumpmind.symmetric.load.csv.CsvLoader;
import org.jumpmind.symmetric.service.impl.DataLoaderService;
import org.jumpmind.symmetric.service.impl.RouterService;

abstract public class AbstractTest {

protected Level setLoggingLevelForTest(Level level) {
Level old = Logger.getLogger(getClass()).getLevel();
Logger.getLogger(DataLoaderService.class).setLevel(level);
Logger.getLogger(RouterService.class).setLevel(level);
Logger.getLogger(CsvLoader.class).setLevel(level);
return old;
}

protected void logTestRunning() {
Logger.getLogger(getClass()).info("Running " + new Exception().getStackTrace()[1].getMethodName() + ". "
+ printDatabases());
}

abstract protected String printDatabases();

}
Expand Up @@ -35,6 +35,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.ddlutils.model.Table;
import org.apache.log4j.Level;
import org.jumpmind.symmetric.common.Constants;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.db.IDbDialect;
Expand Down Expand Up @@ -940,6 +941,7 @@ public void testSyncShellCommand() throws Exception {
@Test(timeout = 120000)
public void testSyncShellCommandError() throws Exception {
logTestRunning();
Level old = setLoggingLevelForTest(Level.OFF);
IDataService rootDataService = AppUtils.find(Constants.DATA_SERVICE, getRootEngine());
IOutgoingBatchService rootOutgoingBatchService = AppUtils.find(Constants.OUTGOING_BATCH_SERVICE,
getRootEngine());
Expand All @@ -951,6 +953,7 @@ public void testSyncShellCommandError() throws Exception {
Assert.assertEquals(1, batches.countBatches(true));
Assert.assertFalse(testFlag);
rootOutgoingBatchService.markAllAsSentForNode(TestConstants.TEST_CLIENT_NODE);
setLoggingLevelForTest(old);
}

/**
Expand Down

0 comments on commit d259c43

Please sign in to comment.