added test cases to test release's activemq.xml. The test cases perform a publish/consume on both topic and queue.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@357139 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonas B. Lim 2005-12-16 07:20:06 +00:00
parent 4cb407cc4b
commit 1416f77de3
3 changed files with 233 additions and 0 deletions

View File

@ -35,6 +35,7 @@
<!-- Default Global Goals --> <!-- Default Global Goals -->
<!-- ==================== --> <!-- ==================== -->
<goal name="default"> <goal name="default">
<ant:copy todir="${basedir}/src/test/org/activemq/usecases" file="${basedir}/src/release/conf/activemq.xml" overwrite="true"/>
<attainGoal name="dist:build-bin"/> <attainGoal name="dist:build-bin"/>
</goal> </goal>

View File

@ -0,0 +1,115 @@
/**
* <a href="http://activemq.org">ActiveMQ: The Open Source Message Fabric</a>
*
* Copyright 2005 (C) LogicBlaze, Inc. http://www.logicblaze.com
*
* 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.activemq.usecases;
import org.activemq.broker.BrokerService;
import org.activemq.xbean.BrokerFactoryBean;
import org.activemq.ActiveMQConnectionFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import java.io.File;
/**
*
* Test Publish/Consume queue using the release activemq.xml configuration file
*
* @version $Revision: 1.2 $
*/
public class PublishOnQueueConsumedMessageUsingActivemqXMLTest extends PublishOnTopicConsumedMessageTest {
protected static final String JOURNAL_ROOT = "../data/";
BrokerService broker;
/**
* Use the transportConnector uri configured on the activemq.xml
*
* @return ActiveMQConnectionFactory
* @throws Exception
*/
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
return new ActiveMQConnectionFactory("tcp://localhost:61616");
}
/**
* Sets up a test where the producer and consumer have their own connection.
*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
;
File journalFile = new File(JOURNAL_ROOT);
recursiveDelete(journalFile);
// Create broker from resource
System.out.print("Creating broker... ");
broker = createBroker("org/activemq/usecases/activemq.xml");
System.out.println("Success");
super.setUp();
}
/*
* Stops the Broker
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
System.out.println("Closing Broker");
if (broker != null) {
broker.stop();
}
System.out.println("Broker closed...");
}
/*
* clean up the journal
*/
protected static void recursiveDelete(File file) {
if( file.isDirectory() ) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
recursiveDelete(files[i]);
}
}
file.delete();
}
protected BrokerService createBroker(String resource) throws Exception {
return createBroker(new ClassPathResource(resource));
}
protected BrokerService createBroker(Resource resource) throws Exception {
BrokerFactoryBean factory = new BrokerFactoryBean(resource);
factory.afterPropertiesSet();
BrokerService broker = factory.getBroker();
//assertTrue("Should have a broker!", broker != null);
return broker;
}
}

View File

@ -0,0 +1,117 @@
/**
* <a href="http://activemq.org">ActiveMQ: The Open Source Message Fabric</a>
*
* Copyright 2005 (C) LogicBlaze, Inc. http://www.logicblaze.com
*
* 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.activemq.usecases;
import org.activemq.broker.BrokerService;
import org.activemq.xbean.BrokerFactoryBean;
import org.activemq.ActiveMQConnectionFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import java.io.File;
/**
*
* Test Publish/Consume topic using the release activemq.xml configuration file
*
* @version $Revision: 1.2 $
*/
public class PublishOnTopicConsumerMessageUsingActivemqXMLTest extends PublishOnTopicConsumedMessageTest {
protected static final String JOURNAL_ROOT = "../data/";
BrokerService broker;
/**
* Use the transportConnector uri configured on the activemq.xml
*
* @return ActiveMQConnectionFactory
* @throws Exception
*/
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
return new ActiveMQConnectionFactory("tcp://localhost:61616");
}
/**
* Sets up a test where the producer and consumer have their own connection.
*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
;
File journalFile = new File(JOURNAL_ROOT);
recursiveDelete(journalFile);
// Create broker from resource
System.out.print("Creating broker... ");
broker = createBroker("org/activemq/usecases/activemq.xml");
System.out.println("Success");
super.setUp();
}
/*
* Stops the Broker
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
System.out.println("Closing Broker");
if (broker != null) {
broker.stop();
}
System.out.println("Broker closed...");
}
/*
* clean up the journal
*/
protected static void recursiveDelete(File file) {
if( file.isDirectory() ) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
recursiveDelete(files[i]);
}
}
file.delete();
}
protected BrokerService createBroker(String resource) throws Exception {
return createBroker(new ClassPathResource(resource));
}
protected BrokerService createBroker(Resource resource) throws Exception {
BrokerFactoryBean factory = new BrokerFactoryBean(resource);
factory.afterPropertiesSet();
BrokerService broker = factory.getBroker();
//assertTrue("Should have a broker!", broker != null);
return broker;
}
}