more tidy up of derby usage in tests to ensure proper cleanup; ci failures

This commit is contained in:
gtully 2015-05-19 11:44:11 +01:00
parent 2536c03125
commit 17f4f349f3
6 changed files with 14 additions and 12 deletions

View File

@ -112,6 +112,7 @@ public abstract class LockableServiceSupport extends ServiceSupport implements L
}
if (locker != null) {
getLocker().stop();
locker = null;
}
}
ThreadPoolUtils.shutdown(clockDaemon);

View File

@ -1040,7 +1040,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
} else if (command.isBrokerInfo()) {
futureLocalBrokerInfo.set((BrokerInfo) command);
} else if (command.isShutdownInfo()) {
LOG.info("{} Shutting down", configuration.getBrokerName());
LOG.info("{} Shutting down {}", configuration.getBrokerName(), configuration.getName());
stop();
} else if (command.getClass() == ConnectionError.class) {
ConnectionError ce = (ConnectionError) command;

View File

@ -98,11 +98,16 @@ abstract public class DataSourceServiceSupport extends LockableServiceSupport {
final EmbeddedDataSource ds = new EmbeddedDataSource();
ds.setDatabaseName("derbydb");
ds.setCreateDatabase("create");
try {
ds.getConnection().close();
} catch (SQLException ignored) {
}
return ds;
}
public static void shutdownDefaultDataSource(DataSource dataSource) {
final EmbeddedDataSource ds = (EmbeddedDataSource) dataSource;
ds.setCreateDatabase("shutdown");
ds.setShutdownDatabase("shutdown");
try {
ds.getConnection();

View File

@ -60,11 +60,9 @@ public class AMQ4351Test extends BrokerTestSupport {
broker.setOfflineDurableSubscriberTaskSchedule(500);
broker.setOfflineDurableSubscriberTimeout(2000); // lets delete durable subs much faster.
System.setProperty("derby.system.home", new File(IOHelper.getDefaultDataDirectory()).getCanonicalPath());
JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
jdbc.deleteAllMessages();
broker.setPersistenceAdapter(jdbc);
broker.setDeleteAllMessagesOnStartup(true);
return broker;
}

View File

@ -20,6 +20,7 @@ import java.io.File;
import junit.framework.Test;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.store.jdbc.DataSourceServiceSupport;
import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
import org.apache.activemq.util.IOHelper;
import org.apache.derby.jdbc.EmbeddedDataSource;
@ -67,13 +68,7 @@ public class JdbcXARecoveryBrokerTest extends XARecoveryBrokerTest {
private void stopDerby() {
LOG.info("STOPPING DB!@!!!!");
final EmbeddedDataSource ds = dataSource;
try {
ds.setShutdownDatabase("shutdown");
ds.getConnection();
} catch (Exception ignored) {
}
DataSourceServiceSupport.shutdownDefaultDataSource(dataSource);
}
public static Test suite() {

View File

@ -56,7 +56,7 @@ public class RecoverExpiredMessagesTest extends BrokerRestartTestSupport {
addCombinationValues("queuePendingPolicy", new PendingQueueMessageStoragePolicy[] {new FilePendingQueueMessageStoragePolicy(), new VMPendingQueueMessageStoragePolicy()});
PersistenceAdapter[] persistenceAdapters = new PersistenceAdapter[] {
new KahaDBPersistenceAdapter(),
new JDBCPersistenceAdapter(JDBCPersistenceAdapter.createDataSource(IOHelper.getDefaultDataDirectory()), new OpenWireFormat())
new JDBCPersistenceAdapter()
};
for (PersistenceAdapter adapter : persistenceAdapters) {
adapter.setDirectory(new File(IOHelper.getDefaultDataDirectory()));
@ -134,6 +134,9 @@ public class RecoverExpiredMessagesTest extends BrokerRestartTestSupport {
@Override
protected void configureBroker(BrokerService broker) throws Exception {
super.configureBroker(broker);
if (persistenceAdapter instanceof JDBCPersistenceAdapter) {
((JDBCPersistenceAdapter) persistenceAdapter).setLockDataSource(null);
}
broker.setPersistenceAdapter(persistenceAdapter);
}