mirror of https://github.com/apache/activemq.git
added a helper class so that system properties can be used to overload the default prefix for auto-created data directories. Also patched the test cases to use a relative to target/ directory for easier cleaning
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@511947 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
611ecd2a01
commit
9583b5fc9f
|
@ -181,6 +181,14 @@
|
|||
<childDelegation>false</childDelegation>
|
||||
<useFile>true</useFile>
|
||||
<argLine>-Xmx512M</argLine>
|
||||
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>org.apache.activemq.default.directory.prefix</name>
|
||||
<value>target/</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
|
||||
<includes>
|
||||
<include>**/*Test.*</include>
|
||||
</includes>
|
||||
|
|
|
@ -73,6 +73,7 @@ import org.apache.activemq.security.SecurityContext;
|
|||
import org.apache.activemq.store.DefaultPersistenceAdapterFactory;
|
||||
import org.apache.activemq.store.PersistenceAdapter;
|
||||
import org.apache.activemq.store.PersistenceAdapterFactory;
|
||||
import org.apache.activemq.store.jdbc.DataSourceSupport;
|
||||
import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
|
||||
import org.apache.activemq.thread.TaskRunnerFactory;
|
||||
import org.apache.activemq.transport.TransportFactory;
|
||||
|
@ -82,6 +83,7 @@ import org.apache.activemq.util.IOExceptionSupport;
|
|||
import org.apache.activemq.util.JMXSupport;
|
||||
import org.apache.activemq.util.ServiceStopper;
|
||||
import org.apache.activemq.util.URISupport;
|
||||
import org.apache.activemq.util.IOHelper;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -553,7 +555,7 @@ public class BrokerService implements Service, Serializable {
|
|||
|
||||
public File getDataDirectory() {
|
||||
if (dataDirectory == null) {
|
||||
dataDirectory = new File(new File("activemq-data"), getBrokerName()
|
||||
dataDirectory = new File(new File(IOHelper.getDefaultDataDirectory()), getBrokerName()
|
||||
.replaceAll("[^a-zA-Z0-9\\.\\_\\-]", "_"));
|
||||
}
|
||||
return dataDirectory;
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.activemq.store.jdbc.Statements;
|
|||
import org.apache.activemq.store.journal.JournalPersistenceAdapter;
|
||||
import org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter;
|
||||
import org.apache.activemq.thread.TaskRunnerFactory;
|
||||
import org.apache.activemq.util.IOHelper;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class DefaultPersistenceAdapterFactory extends DataSourceSupport implemen
|
|||
// if( useQuickJournal ) {
|
||||
// return new QuickJournalPersistenceAdapter(getJournal(), jdbcPersistenceAdapter, getTaskRunnerFactory());
|
||||
// } else {
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("amqstore"));
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File(IOHelper.getDefaultStoreDirectory()));
|
||||
return new JournalPersistenceAdapter(getJournal(), jdbcPersistenceAdapter, getTaskRunnerFactory());
|
||||
//return new JournalPersistenceAdapter(getJournal(), adaptor, getTaskRunnerFactory());
|
||||
// }
|
||||
|
|
|
@ -62,6 +62,7 @@ import org.apache.activemq.thread.TaskRunner;
|
|||
import org.apache.activemq.thread.TaskRunnerFactory;
|
||||
import org.apache.activemq.util.ByteSequence;
|
||||
import org.apache.activemq.util.IOExceptionSupport;
|
||||
import org.apache.activemq.util.IOHelper;
|
||||
import org.apache.activemq.wireformat.WireFormat;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -105,7 +106,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener
|
|||
|
||||
private Runnable periodicCleanupTask;
|
||||
private boolean deleteAllMessages;
|
||||
private File directory = new File("activemq-data/quick");
|
||||
private File directory = new File(IOHelper.getDefaultDataDirectory() + "/quick");
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.activemq.store.jdbc;
|
||||
|
||||
import org.apache.derby.jdbc.EmbeddedDataSource;
|
||||
import org.apache.activemq.util.IOHelper;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
@ -32,7 +33,7 @@ import java.io.IOException;
|
|||
*/
|
||||
public class DataSourceSupport {
|
||||
|
||||
private String dataDirectory = "activemq-data";
|
||||
private String dataDirectory = IOHelper.getDefaultDataDirectory();
|
||||
private File dataDirectoryFile;
|
||||
private DataSource dataSource;
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ import org.apache.activemq.thread.TaskRunner;
|
|||
import org.apache.activemq.thread.TaskRunnerFactory;
|
||||
import org.apache.activemq.util.ByteSequence;
|
||||
import org.apache.activemq.util.IOExceptionSupport;
|
||||
import org.apache.activemq.util.IOHelper;
|
||||
import org.apache.activemq.wireformat.WireFormat;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -104,7 +105,7 @@ public class QuickPersistenceAdapter implements PersistenceAdapter, UsageListene
|
|||
|
||||
private Runnable periodicCleanupTask;
|
||||
private boolean deleteAllMessages;
|
||||
private File directory = new File("activemq-data/quick");
|
||||
private File directory = new File(IOHelper.getDefaultDataDirectory() + "/quick");
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "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.apache.activemq.util;
|
||||
|
||||
/**
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class IOHelper {
|
||||
|
||||
public static String getDefaultDataDirectory() {
|
||||
return getDefaultDirectoryPrefix() + "activemq-data";
|
||||
}
|
||||
|
||||
public static String getDefaultStoreDirectory() {
|
||||
return getDefaultDirectoryPrefix() + "amqstore";
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows a system property to be used to overload the default data directory
|
||||
* which can be useful for forcing the test cases to use a target/ prefix
|
||||
*/
|
||||
public static String getDefaultDirectoryPrefix() {
|
||||
try {
|
||||
return System.getProperty("org.apache.activemq.default.directory.prefix", "");
|
||||
}
|
||||
catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,7 +39,7 @@ public class TransactedTopicMasterSlaveTest extends JmsTopicTransactionTest{
|
|||
// this will create the main (or master broker)
|
||||
broker=createBroker();
|
||||
broker.start();
|
||||
KahaPersistenceAdapter adaptor=new KahaPersistenceAdapter(new File("activemq-data/slave"));
|
||||
KahaPersistenceAdapter adaptor=new KahaPersistenceAdapter(new File("target/test-amq-data/slave"));
|
||||
slave = new BrokerService();
|
||||
slave.setBrokerName("slave");
|
||||
slave.setPersistenceAdapter(adaptor);
|
||||
|
@ -66,7 +66,7 @@ public class TransactedTopicMasterSlaveTest extends JmsTopicTransactionTest{
|
|||
protected BrokerService createBroker() throws Exception,URISyntaxException{
|
||||
BrokerService broker=new BrokerService();
|
||||
broker.setBrokerName("master");
|
||||
KahaPersistenceAdapter adaptor=new KahaPersistenceAdapter(new File("activemq-data/master"));
|
||||
KahaPersistenceAdapter adaptor=new KahaPersistenceAdapter(new File("target/test-amq-data/master"));
|
||||
broker.setPersistenceAdapter(adaptor);
|
||||
broker.addConnector("tcp://localhost:62001");
|
||||
broker.setDeleteAllMessagesOnStartup(true);
|
||||
|
|
|
@ -32,7 +32,7 @@ public class KahaCursorDurableTest extends CursorDurableTest{
|
|||
|
||||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("activemq-data/durableTest"));
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("target/test-amq-data/durableTest"));
|
||||
answer.setPersistenceAdapter(adaptor);
|
||||
answer.addConnector(bindAddress);
|
||||
answer.setDeleteAllMessagesOnStartup(true);
|
||||
|
|
|
@ -35,7 +35,7 @@ public class KahaQueueStoreTest extends CursorQueueStoreTest{
|
|||
|
||||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("activemq-data/durableTest"));
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("target/test-amq-data/durableTest"));
|
||||
answer.setPersistenceAdapter(adaptor);
|
||||
PolicyEntry policy = new PolicyEntry();
|
||||
policy.setPendingQueuePolicy(new StorePendingQueueMessageStoragePolicy());
|
||||
|
|
|
@ -84,7 +84,7 @@ public class JmsDurableTopicSlowReceiveTest extends JmsTopicSendReceiveTest{
|
|||
}
|
||||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
//KahaPersistenceAdapter adapter=new KahaPersistenceAdapter(new File("activemq-data/durableTest"));
|
||||
//KahaPersistenceAdapter adapter=new KahaPersistenceAdapter(new File("target/test-amq-data/durableTest"));
|
||||
//JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
|
||||
// answer.setPersistenceAdapter(adapter);
|
||||
answer.setDeleteAllMessagesOnStartup(true);
|
||||
|
|
|
@ -20,6 +20,7 @@ import junit.framework.TestCase;
|
|||
import org.apache.activemq.kaha.Store;
|
||||
import org.apache.activemq.kaha.impl.index.IndexItem;
|
||||
import org.apache.activemq.kaha.impl.index.IndexManager;
|
||||
import org.apache.activemq.util.IOHelper;
|
||||
|
||||
/**
|
||||
* Test a HashIndex
|
||||
|
@ -39,7 +40,7 @@ public class HashTest extends TestCase{
|
|||
*/
|
||||
protected void setUp() throws Exception{
|
||||
super.setUp();
|
||||
directory=new File("activemq-data");
|
||||
directory=new File(IOHelper.getDefaultDataDirectory());
|
||||
directory.mkdirs();
|
||||
indexManager=new IndexManager(directory,"im-hash-test","rw",null);
|
||||
this.hashIndex=new HashIndex(directory,"testHash",indexManager);
|
||||
|
|
|
@ -26,7 +26,7 @@ public class AMQStoreDurableTopicTest extends SimpleDurableTopicTest{
|
|||
|
||||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
File dataFileDir=new File("activemq-data/perfTest/amqdb");
|
||||
File dataFileDir=new File("target/test-amq-data/perfTest/amqdb");
|
||||
AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter();
|
||||
adaptor.setDirectory(dataFileDir);
|
||||
answer.setPersistenceAdapter(adaptor);
|
||||
|
|
|
@ -29,7 +29,7 @@ public class AMQStoreQueueTest extends SimpleQueueTest{
|
|||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
|
||||
File dataFileDir = new File("activemq-data/perfTest/amq");
|
||||
File dataFileDir = new File("target/test-amq-data/perfTest/amq");
|
||||
|
||||
AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter();
|
||||
adaptor.setDirectory(dataFileDir);
|
||||
|
|
|
@ -31,7 +31,7 @@ public class JournalKahaDurableTopicTest extends SimpleDurableTopicTest {
|
|||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
|
||||
File dataFileDir = new File("activemq-data/perfTest");
|
||||
File dataFileDir = new File("target/test-amq-data/perfTest");
|
||||
File journalDir = new File(dataFileDir, "journal").getCanonicalFile();
|
||||
JournalImpl journal = new JournalImpl(journalDir, 3, 1024*1024*20);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class JournalKahaQueueTest extends SimpleQueueTest{
|
|||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
|
||||
File dataFileDir = new File("activemq-data/perfTest");
|
||||
File dataFileDir = new File("target/test-amq-data/perfTest");
|
||||
File journalDir = new File(dataFileDir, "journal").getCanonicalFile();
|
||||
JournalImpl journal = new JournalImpl(journalDir, 3, 1024*1024*20);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class KahaDurableTopicTest extends SimpleDurableTopicTest {
|
|||
*/
|
||||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("activemq-data/perfTest"));
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("target/test-amq-data/perfTest"));
|
||||
answer.setPersistenceAdapter(adaptor);
|
||||
answer.addConnector(bindAddress);
|
||||
answer.setDeleteAllMessagesOnStartup(true);
|
||||
|
|
|
@ -30,7 +30,7 @@ public class KahaQueueTest extends SimpleQueueTest{
|
|||
|
||||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("activemq-data/perfTest"));
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("target/test-amq-data/perfTest"));
|
||||
answer.setPersistenceAdapter(adaptor);
|
||||
answer.addConnector(bindAddress);
|
||||
answer.setDeleteAllMessagesOnStartup(true);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class QueueConnectionMemoryTest extends SimpleQueueTest{
|
|||
}
|
||||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("activemq-data/perfTest"));
|
||||
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter(new File("target/test-amq-data/perfTest"));
|
||||
answer.setPersistenceAdapter(adaptor);
|
||||
answer.addConnector(bindAddress);
|
||||
answer.setDeleteAllMessagesOnStartup(true);
|
||||
|
|
|
@ -25,7 +25,7 @@ public class QuickStoreDurableTopicTest extends SimpleDurableTopicTest{
|
|||
|
||||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
File dataFileDir=new File("activemq-data/perfTest");
|
||||
File dataFileDir=new File("target/test-amq-data/perfTest");
|
||||
QuickPersistenceAdapter adaptor=new QuickPersistenceAdapter();
|
||||
adaptor.setDirectory(dataFileDir);
|
||||
answer.setPersistenceAdapter(adaptor);
|
||||
|
|
|
@ -29,7 +29,7 @@ public class QuickStoreQueueTest extends SimpleQueueTest{
|
|||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
|
||||
File dataFileDir = new File("activemq-data/perfTest");
|
||||
File dataFileDir = new File("target/test-amq-data/perfTest");
|
||||
|
||||
QuickPersistenceAdapter adaptor = new QuickPersistenceAdapter();
|
||||
adaptor.setDirectory(dataFileDir);
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RapidStoreQueueTest extends SimpleQueueTest{
|
|||
|
||||
protected void configureBroker(BrokerService answer) throws Exception{
|
||||
|
||||
File dataFileDir = new File("activemq-data/perfTest");
|
||||
File dataFileDir = new File("target/test-amq-data/perfTest");
|
||||
File journalDir = new File(dataFileDir, "journal").getCanonicalFile();
|
||||
JournalImpl journal = new JournalImpl(journalDir, 3, 1024*1024*20);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.activemq.usecases;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.util.IOHelper;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -45,7 +46,7 @@ public final class PublishOnQueueConsumedMessageInTransactionTest extends TestCa
|
|||
private List messages = createConcurrentList();
|
||||
private final Object lock = new Object();
|
||||
private String[] data;
|
||||
private String DATAFILE_ROOT = "activemq-data";
|
||||
private String DATAFILE_ROOT = IOHelper.getDefaultDataDirectory();
|
||||
private int messageCount = 3;
|
||||
private String url = "vm://localhost";
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<transportConnector uri="tcp://localhost:61616"/>
|
||||
</transportConnectors>
|
||||
<persistenceAdapter>
|
||||
<kahaPersistenceAdapter dir = "activemq-data"/>
|
||||
<kahaPersistenceAdapter dir = "target/activemq-data"/>
|
||||
</persistenceAdapter>
|
||||
</broker>
|
||||
|
||||
|
|
Loading…
Reference in New Issue