tidy up some jdbc directory usage - move into target

This commit is contained in:
gtully 2015-02-09 12:29:52 +00:00
parent 01d0155149
commit c6837acefe
6 changed files with 38 additions and 8 deletions

View File

@ -196,6 +196,7 @@ public abstract class TestSupport extends CombinationTestSupport {
break;
}
broker.setPersistenceAdapter(adapter);
adapter.setDirectory(broker.getBrokerDataDirectory());
return adapter;
}

View File

@ -20,12 +20,14 @@ import junit.framework.Test;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
import org.apache.activemq.util.IOHelper;
import org.apache.derby.jdbc.EmbeddedDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jms.Connection;
import javax.jms.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@ -58,6 +60,8 @@ 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();
EmbeddedDataSource dataSource = new EmbeddedDataSource();
dataSource.setDatabaseName("derbyDb");

View File

@ -16,10 +16,12 @@
*/
package org.apache.activemq.broker;
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.JDBCPersistenceAdapter;
import org.apache.activemq.util.IOHelper;
import org.apache.derby.jdbc.EmbeddedDataSource;
import org.apache.derby.jdbc.EmbeddedXADataSource;
@ -29,6 +31,7 @@ public class JdbcXARecoveryBrokerTest extends XARecoveryBrokerTest {
@Override
protected void setUp() throws Exception {
System.setProperty("derby.system.home", new File(IOHelper.getDefaultDataDirectory()).getCanonicalPath());
dataSource = new EmbeddedXADataSource();
dataSource.setDatabaseName("derbyDb");
dataSource.setCreateDatabase("create");

View File

@ -17,6 +17,7 @@
package org.apache.activemq.bugs;
import java.io.File;
import java.net.URI;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -55,11 +56,13 @@ import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.network.ConditionalNetworkBridgeFilterFactory;
import org.apache.activemq.network.NetworkConnector;
import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
import org.apache.activemq.util.IOHelper;
import org.apache.activemq.util.IntrospectionSupport;
import org.apache.activemq.util.Wait;
import org.apache.derby.jdbc.EmbeddedDataSource;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -125,6 +128,11 @@ public class AMQ4952Test {
return Arrays.asList(new Object[][] { { Boolean.TRUE }, { Boolean.FALSE } });
}
@BeforeClass
public static void dbHomeSysProp() throws Exception {
System.setProperty("derby.system.home", new File(IOHelper.getDefaultDataDirectory()).getCanonicalPath());
}
@Test
public void testConsumerBrokerRestart() throws Exception {

View File

@ -16,6 +16,7 @@
*/
package org.apache.activemq.store.jdbc;
import java.io.File;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
@ -24,23 +25,28 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.jms.Connection;
import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.util.IOHelper;
import org.apache.activemq.util.LeaseLockerIOExceptionHandler;
import org.apache.activemq.util.Wait;
import org.apache.derby.jdbc.EmbeddedDataSource;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
/**
* Test to see if the JDBCExceptionIOHandler will restart the transport connectors correctly after
* the underlying DB has been stopped and restarted
*
* see AMQ-4575
*/
public class JDBCIOExceptionHandlerTest extends TestCase {
public class JDBCIOExceptionHandlerTest {
private static final Logger LOG = LoggerFactory.getLogger(JDBCIOExceptionHandlerTest.class);
private static final String TRANSPORT_URL = "tcp://0.0.0.0:0";
@ -50,6 +56,11 @@ public class JDBCIOExceptionHandlerTest extends TestCase {
private ReconnectingEmbeddedDataSource dataSource;
private BrokerService broker;
@Before
public void dbHomeSysProp() throws Exception {
System.setProperty("derby.system.home", new File(IOHelper.getDefaultDataDirectory()).getCanonicalPath());
}
protected BrokerService createBroker(boolean withJMX) throws Exception {
return createBroker("localhost", withJMX, true, true);
}
@ -94,6 +105,7 @@ public class JDBCIOExceptionHandlerTest extends TestCase {
/*
* run test without JMX enabled
*/
@Test
public void testRecoverWithOutJMX() throws Exception {
recoverFromDisconnectDB(false);
}
@ -101,14 +113,17 @@ public class JDBCIOExceptionHandlerTest extends TestCase {
/*
* run test with JMX enabled
*/
@Test
public void testRecoverWithJMX() throws Exception {
recoverFromDisconnectDB(true);
}
@Test
public void testSlaveStoppedLease() throws Exception {
testSlaveStopped(true);
}
@Test
public void testSlaveStoppedDefault() throws Exception {
testSlaveStopped(false);
}

View File

@ -23,22 +23,21 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.region.cursors.NegativeQueueTest;
import org.apache.derby.jdbc.EmbeddedDataSource;
public class JDBCNegativeQueueTest extends NegativeQueueTest {
EmbeddedDataSource dataSource;
DataSource dataSource;
protected void configureBroker(BrokerService answer) throws Exception {
super.configureBroker(answer);
JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
dataSource = new EmbeddedDataSource();
dataSource.setDatabaseName("derbyDb");
dataSource.setCreateDatabase("create");
jdbc.setDataSource(dataSource);
jdbc.setDataSource(dataSource);
answer.setPersistenceAdapter(jdbc);
dataSource = jdbc.getDataSource();
}
protected void tearDown() throws Exception {