Add some basic testing of the Kaha persistence adaptor

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@391053 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2006-04-03 14:15:17 +00:00
parent ff6a6e834e
commit 1ffd9f88a9
8 changed files with 217 additions and 6 deletions

View File

@ -0,0 +1,67 @@
/**
*
* Copyright 2005-2006 The Apache Software Foundation
*
* Licensed 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.broker.store;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.jms.BytesMessage;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import junit.framework.Test;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.JmsTestSupport;
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.ProgressPrinter;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.xbean.BrokerFactoryBean;
import org.springframework.core.io.ClassPathResource;
/**
*
* @version $Revision$
*/
public class KahaLoadTester extends LoadTester {
protected BrokerService createBroker() throws Exception {
BrokerFactoryBean brokerFactory=new BrokerFactoryBean(new ClassPathResource("org/apache/activemq/broker/store/kahabroker.xml"));
brokerFactory.afterPropertiesSet();
BrokerService broker = brokerFactory.getBroker();
broker.setDeleteAllMessagesOnStartup(true);
return broker;
}
public static Test suite() {
return suite(KahaLoadTester.class);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
}

View File

@ -0,0 +1,59 @@
/**
*
* Copyright 2005-2006 The Apache Software Foundation
*
* Licensed 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.broker.store;
import java.io.File;
import junit.framework.Test;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.RecoveryBrokerTest;
import org.apache.activemq.store.kahadaptor.KahaPersistentAdaptor;
import org.apache.activemq.xbean.BrokerFactoryBean;
import org.springframework.core.io.ClassPathResource;
/**
* Used to verify that recovery works correctly against
*
* @version $Revision$
*/
public class KahaRecoveryBrokerTest extends RecoveryBrokerTest {
protected BrokerService createBroker() throws Exception {
BrokerService broker = createRestartedBroker();
broker.setDeleteAllMessagesOnStartup(true);
return broker;
}
protected BrokerService createRestartedBroker() throws Exception {
BrokerService broker = new BrokerService();
KahaPersistentAdaptor adaptor = new KahaPersistentAdaptor(new File("activemq-data/storetest"));
broker.setPersistenceAdapter(adaptor);
broker.addConnector("tcp://localhost:0");
return broker;
}
public static Test suite() {
return suite(KahaRecoveryBrokerTest.class);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
}

View File

@ -0,0 +1,55 @@
/**
*
* Copyright 2005-2006 The Apache Software Foundation
*
* Licensed 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.broker.store;
import junit.framework.Test;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.XARecoveryBrokerTest;
import org.apache.activemq.xbean.BrokerFactoryBean;
import org.springframework.core.io.ClassPathResource;
/**
* Used to verify that recovery works correctly against
*
* @version $Revision$
*/
public class KahaXARecoveryBrokerTest extends XARecoveryBrokerTest {
public static Test suite() {
return suite(KahaXARecoveryBrokerTest.class);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
protected BrokerService createBroker() throws Exception {
BrokerFactoryBean brokerFactory=new BrokerFactoryBean(new ClassPathResource("org/apache/activemq/broker/store/kahabroker.xml"));
brokerFactory.afterPropertiesSet();
BrokerService broker = brokerFactory.getBroker();
broker.setDeleteAllMessagesOnStartup(true);
return broker;
}
protected BrokerService createRestartedBroker() throws Exception {
BrokerFactoryBean brokerFactory=new BrokerFactoryBean(new ClassPathResource("org/apache/activemq/broker/store/kahabroker.xml"));
brokerFactory.afterPropertiesSet();
return brokerFactory.getBroker();
}
}

View File

@ -86,7 +86,7 @@ public class LoadTester extends JmsTestSupport {
MessageConsumer consumer = session.createConsumer(destination);
for( int i=0; i < PRODUCE_COUNT; i++) {
printer.increment();
assertNotNull("Getting message: "+i,consumer.receive(5000));
assertNotNull("Getting message: "+i,consumer.receive(20000));
}
end1 = System.currentTimeMillis();
System.out.println("Consumed messages/sec: "+ (PRODUCE_COUNT*1000.0/(end1-start)));

View File

@ -17,13 +17,13 @@
<beans xmlns="http://activemq.org/config/1.0">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker brokerName="master" persistent="false" useJmx="false">
<broker brokerName="master" persistent="false" useJmx="false" deleteAllMessagesOnStartup="true">
<transportConnectors>
<transportConnector uri="tcp://localhost:62001"/>
</transportConnectors>
<persistenceAdapter>
<memoryPersistenceAdapter/>
<kahaPersistentAdaptor dir = "activemq-data/master"/>
</persistenceAdapter>
</broker>

View File

@ -17,7 +17,7 @@
<beans xmlns="http://activemq.org/config/1.0">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker brokerName="slave" persistent="false" useJmx="false" masterConnectorURI="tcp://localhost:62001">
<broker brokerName="slave" persistent="false" useJmx="false" masterConnectorURI="tcp://localhost:62001" deleteAllMessagesOnStartup="true">
<transportConnectors>
<transportConnector uri="tcp://localhost:62002"/>
</transportConnectors>
@ -25,7 +25,7 @@
<persistenceAdapter>
<memoryPersistenceAdapter/>
<kahaPersistentAdaptor dir = "activemq-data/slave"/>
</persistenceAdapter>
</broker>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2005-2006 The Apache Software Foundation
Licensed 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.
-->
<beans xmlns="http://activemq.org/config/1.0">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker brokerName="broker" persistent="false" useJmx="false">
<transportConnectors>
<transportConnector uri="tcp://localhost:0"/>
</transportConnectors>
<persistenceAdapter>
<kahaPersistentAdaptor dir = "activemq-data/storetest"/>
</persistenceAdapter>
</broker>
</beans>

View File

@ -17,7 +17,7 @@
<beans xmlns="http://activemq.org/config/1.0">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker brokerName="broker" persistent="true" useShutdownHook="false">
<broker brokerName="broker" persistent="true" useShutdownHook="false" deleteAllMessagesOnStartup="true">
<transportConnectors>
<transportConnector uri="tcp://localhost:61616"/>
</transportConnectors>