You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/02/07 17:43:17 UTC
svn commit: r1443600 [4/4] - in
/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq:
perf/ security/ selector/ spring/ store/ store/jdbc/ store/kahadb/
store/kahadb/perf/ test/message/ test/retroactive/ transport/
transport/failover/ ...
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyToTopicViaThreeNetworkHopsTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyToTopicViaThreeNetworkHopsTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyToTopicViaThreeNetworkHopsTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyToTopicViaThreeNetworkHopsTest.java Thu Feb 7 16:43:15 2013
@@ -17,6 +17,8 @@
package org.apache.activemq.usecases;
+import static org.junit.Assert.assertTrue;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -25,6 +27,7 @@ import java.util.concurrent.ArrayBlockin
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -33,6 +36,7 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
+
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQSession;
import org.apache.activemq.broker.BrokerService;
@@ -43,9 +47,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-
-
public class RequestReplyToTopicViaThreeNetworkHopsTest {
protected static final int CONCURRENT_CLIENT_COUNT = 5;
protected static final int CONCURRENT_SERVER_COUNT = 5;
@@ -60,7 +61,7 @@ public class RequestReplyToTopicViaThree
protected boolean testError = false;
protected boolean fatalTestError = false;
- protected int echoResponseFill = 0; // Number of "filler" response messages per request
+ protected int echoResponseFill = 0; // Number of "filler" response messages per request
protected static Log LOG;
public boolean duplex = true;
@@ -69,8 +70,7 @@ public class RequestReplyToTopicViaThree
LOG = LogFactory.getLog(RequestReplyToTopicViaThreeNetworkHopsTest.class);
}
- public RequestReplyToTopicViaThreeNetworkHopsTest()
- throws Exception {
+ public RequestReplyToTopicViaThreeNetworkHopsTest() throws Exception {
edge1 = new EmbeddedTcpBroker("edge", 1);
edge2 = new EmbeddedTcpBroker("edge", 2);
core1 = new EmbeddedTcpBroker("core", 1);
@@ -80,7 +80,6 @@ public class RequestReplyToTopicViaThree
edge1.coreConnectTo(core1, duplex);
edge2.coreConnectTo(core2, duplex);
core1.coreConnectTo(core2, duplex);
-
}
public void logMessage(String msg) {
@@ -88,8 +87,7 @@ public class RequestReplyToTopicViaThree
System.out.flush();
}
- public void testMessages(Session sess, MessageProducer req_prod, Destination resp_dest, int num_msg)
- throws Exception {
+ public void testMessages(Session sess, MessageProducer req_prod, Destination resp_dest, int num_msg) throws Exception {
MessageConsumer resp_cons;
TextMessage msg;
MessageClient cons_client;
@@ -130,7 +128,6 @@ public class RequestReplyToTopicViaThree
else
LOG.debug("Consumer client shutdown incomplete!!!");
-
//
// Check that the correct number of messages was received.
//
@@ -144,15 +141,13 @@ public class RequestReplyToTopicViaThree
if (cons_client.getNumMsgReceived() == 0)
fatalTestError = true;
- LOG.error("Have " + cons_client.getNumMsgReceived() + " messages; expected " + tot_expected +
- " on destination " + resp_dest);
+ LOG.error("Have " + cons_client.getNumMsgReceived() + " messages; expected " + tot_expected + " on destination " + resp_dest);
}
resp_cons.close();
}
- protected void sendWithRetryOnDeletedDest(MessageProducer prod, Message msg)
- throws JMSException {
+ protected void sendWithRetryOnDeletedDest(MessageProducer prod, Message msg) throws JMSException {
try {
if (LOG.isDebugEnabled())
LOG.debug("SENDING REQUEST message " + msg);
@@ -167,12 +162,10 @@ public class RequestReplyToTopicViaThree
/**
* Test one destination between the given "producer broker" and "consumer broker" specified.
*/
- public void testOneDest(Connection conn, Session sess, Destination cons_dest, int num_msg)
- throws Exception {
+ public void testOneDest(Connection conn, Session sess, Destination cons_dest, int num_msg) throws Exception {
Destination prod_dest;
MessageProducer msg_prod;
-
//
// Create the Producer to the echo request Queue
//
@@ -180,7 +173,6 @@ public class RequestReplyToTopicViaThree
prod_dest = sess.createQueue("echo");
msg_prod = sess.createProducer(prod_dest);
-
//
// Pass messages around.
//
@@ -189,57 +181,45 @@ public class RequestReplyToTopicViaThree
msg_prod.close();
}
-
/**
* TEST TEMPORARY TOPICS
*/
- public void testTempTopic(String prod_broker_url, String cons_broker_url)
- throws Exception {
+ public void testTempTopic(String prod_broker_url, String cons_broker_url) throws Exception {
Connection conn;
Session sess;
Destination cons_dest;
- int echo_id;
int num_msg;
num_msg = 5;
- LOG.debug("TESTING TEMP TOPICS " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg +
- " messages)");
-
+ LOG.debug("TESTING TEMP TOPICS " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg + " messages)");
//
// Connect to the bus.
//
-
conn = createConnection(cons_broker_url);
conn.start();
sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
//
// Create the destination on which messages are being tested.
//
-
LOG.trace("Creating destination");
cons_dest = sess.createTemporaryTopic();
testOneDest(conn, sess, cons_dest, num_msg);
-
//
// Cleanup
//
-
sess.close();
conn.close();
}
-
/**
* TEST TOPICS
*/
- public void testTopic(String prod_broker_url, String cons_broker_url)
- throws Exception {
+ public void testTopic(String prod_broker_url, String cons_broker_url) throws Exception {
int num_msg;
Connection conn;
@@ -250,19 +230,15 @@ public class RequestReplyToTopicViaThree
num_msg = 5;
- LOG.info("TESTING TOPICS " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg +
- " messages)");
-
+ LOG.info("TESTING TOPICS " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg + " messages)");
conn = createConnection(cons_broker_url);
conn.start();
sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
//
// Create the destination on which messages are being tested.
//
-
topic_name = "topotest2.perm.topic";
LOG.trace("Removing existing Topic");
removeTopic(conn, topic_name);
@@ -271,23 +247,18 @@ public class RequestReplyToTopicViaThree
testOneDest(conn, sess, cons_dest, num_msg);
-
//
// Cleanup
//
-
removeTopic(conn, topic_name);
sess.close();
conn.close();
}
-
/**
* TEST TEMPORARY QUEUES
*/
- public void testTempQueue(String prod_broker_url, String cons_broker_url)
- throws Exception {
- int echo_id;
+ public void testTempQueue(String prod_broker_url, String cons_broker_url) throws Exception {
int num_msg;
Connection conn;
@@ -297,43 +268,34 @@ public class RequestReplyToTopicViaThree
num_msg = 5;
- LOG.info("TESTING TEMP QUEUES " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg +
- " messages)");
-
+ LOG.info("TESTING TEMP QUEUES " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg + " messages)");
//
// Connect to the bus.
//
-
conn = createConnection(cons_broker_url);
conn.start();
sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
//
// Create the destination on which messages are being tested.
//
-
LOG.trace("Creating destination");
cons_dest = sess.createTemporaryQueue();
testOneDest(conn, sess, cons_dest, num_msg);
-
//
// Cleanup
//
-
sess.close();
conn.close();
}
-
/**
* TEST QUEUES
*/
- public void testQueue(String prod_broker_url, String cons_broker_url)
- throws Exception {
+ public void testQueue(String prod_broker_url, String cons_broker_url) throws Exception {
int num_msg;
Connection conn;
@@ -344,15 +306,12 @@ public class RequestReplyToTopicViaThree
num_msg = 5;
- LOG.info("TESTING QUEUES " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg +
- " messages)");
-
+ LOG.info("TESTING QUEUES " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg + " messages)");
conn = createConnection(cons_broker_url);
conn.start();
sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
//
// Create the destination on which messages are being tested.
//
@@ -364,15 +323,13 @@ public class RequestReplyToTopicViaThree
testOneDest(conn, sess, cons_dest, num_msg);
-
removeQueue(conn, queue_name);
sess.close();
conn.close();
}
@Test
- public void runWithTempTopicReplyTo()
- throws Exception {
+ public void runWithTempTopicReplyTo() throws Exception {
EchoService echo_svc;
TopicTrafficGenerator traffic_gen;
Thread start1;
@@ -390,16 +347,15 @@ public class RequestReplyToTopicViaThree
// Execute up to 20 clients at a time to simulate that load.
//
- clientExecPool = new ThreadPoolExecutor(CONCURRENT_CLIENT_COUNT, CONCURRENT_CLIENT_COUNT,
- 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10000));
+ clientExecPool = new ThreadPoolExecutor(CONCURRENT_CLIENT_COUNT, CONCURRENT_CLIENT_COUNT, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10000));
clientCompletionLatch = new CountDownLatch(TOTAL_CLIENT_ITER);
-
// Use threads to avoid startup deadlock since the first broker started waits until
- // it knows the name of the remote broker before finishing its startup, which means
- // the remote must already be running.
+ // it knows the name of the remote broker before finishing its startup, which means
+ // the remote must already be running.
start1 = new Thread() {
+ @Override
public void run() {
try {
edge1.start();
@@ -410,6 +366,7 @@ public class RequestReplyToTopicViaThree
};
start2 = new Thread() {
+ @Override
public void run() {
try {
edge2.start();
@@ -420,6 +377,7 @@ public class RequestReplyToTopicViaThree
};
start3 = new Thread() {
+ @Override
public void run() {
try {
core1.start();
@@ -430,6 +388,7 @@ public class RequestReplyToTopicViaThree
};
start4 = new Thread() {
+ @Override
public void run() {
try {
core2.start();
@@ -452,14 +411,12 @@ public class RequestReplyToTopicViaThree
traffic_gen = new TopicTrafficGenerator(edge1.getConnectionUrl(), edge2.getConnectionUrl());
traffic_gen.start();
-
//
// Now start the echo service with that queue.
//
echo_svc = new EchoService("echo", edge1.getConnectionUrl());
echo_svc.start();
-
//
// Run the tests on Temp Topics.
//
@@ -468,10 +425,10 @@ public class RequestReplyToTopicViaThree
iter = 0;
while ((iter < TOTAL_CLIENT_ITER) && (!fatalTestError)) {
clientExecPool.execute(new Runnable() {
+ @Override
public void run() {
try {
- RequestReplyToTopicViaThreeNetworkHopsTest.this.testTempTopic(edge1.getConnectionUrl(),
- edge2.getConnectionUrl());
+ RequestReplyToTopicViaThreeNetworkHopsTest.this.testTempTopic(edge1.getConnectionUrl(), edge2.getConnectionUrl());
} catch (Exception exc) {
LOG.error("test exception", exc);
fatalTestError = true;
@@ -487,7 +444,8 @@ public class RequestReplyToTopicViaThree
boolean allDoneOnTime = clientCompletionLatch.await(20, TimeUnit.MINUTES);
- LOG.info("** FINISHED TEMP TOPIC TESTS AFTER " + iter + " ITERATIONS, testError:" + testError + ", fatal: " + fatalTestError + ", onTime:" + allDoneOnTime);
+ LOG.info("** FINISHED TEMP TOPIC TESTS AFTER " + iter + " ITERATIONS, testError:" + testError + ", fatal: " + fatalTestError + ", onTime:"
+ + allDoneOnTime);
Thread.sleep(100);
@@ -500,46 +458,39 @@ public class RequestReplyToTopicViaThree
assertTrue("no errors", !testError);
}
- public void shutdown()
- throws Exception {
+ public void shutdown() throws Exception {
edge1.stop();
edge2.stop();
core1.stop();
core2.stop();
}
- protected Connection createConnection(String url)
- throws Exception {
+ protected Connection createConnection(String url) throws Exception {
return org.apache.activemq.ActiveMQConnection.makeConnection(url);
}
- protected static void removeQueue(Connection conn, String dest_name)
- throws java.lang.Exception {
+ protected static void removeQueue(Connection conn, String dest_name) throws java.lang.Exception {
org.apache.activemq.command.ActiveMQDestination dest;
if (conn instanceof org.apache.activemq.ActiveMQConnection) {
- dest = org.apache.activemq.command.ActiveMQDestination.
- createDestination(dest_name, (byte) org.apache.activemq.command.ActiveMQDestination.QUEUE_TYPE);
+ dest = org.apache.activemq.command.ActiveMQDestination.createDestination(dest_name, org.apache.activemq.command.ActiveMQDestination.QUEUE_TYPE);
((org.apache.activemq.ActiveMQConnection) conn).destroyDestination(dest);
}
}
- protected static void removeTopic(Connection conn, String dest_name)
- throws java.lang.Exception {
+ protected static void removeTopic(Connection conn, String dest_name) throws java.lang.Exception {
org.apache.activemq.command.ActiveMQDestination dest;
if (conn instanceof org.apache.activemq.ActiveMQConnection) {
- dest = org.apache.activemq.command.ActiveMQDestination.
- createDestination(dest_name, (byte) org.apache.activemq.command.ActiveMQDestination.TOPIC_TYPE);
+ dest = org.apache.activemq.command.ActiveMQDestination.createDestination(dest_name, org.apache.activemq.command.ActiveMQDestination.TOPIC_TYPE);
((org.apache.activemq.ActiveMQConnection) conn).destroyDestination(dest);
}
}
- public static String fmtMsgInfo(Message msg)
- throws Exception {
+ public static String fmtMsgInfo(Message msg) throws Exception {
StringBuilder msg_desc;
String prop;
- Enumeration prop_enum;
+ Enumeration<?> prop_enum;
msg_desc = new StringBuilder();
msg_desc = new StringBuilder();
@@ -573,8 +524,7 @@ public class RequestReplyToTopicViaThree
protected String tcpUrl;
protected String fullUrl;
- public EmbeddedTcpBroker(String name, int number)
- throws Exception {
+ public EmbeddedTcpBroker(String name, int number) throws Exception {
brokerSvc = new BrokerService();
synchronized (this.getClass()) {
@@ -599,8 +549,7 @@ public class RequestReplyToTopicViaThree
brokerSvc.addConnector(tcpUrl);
}
- public Connection createConnection()
- throws URISyntaxException, JMSException {
+ public Connection createConnection() throws URISyntaxException, JMSException {
Connection result;
result = org.apache.activemq.ActiveMQConnection.makeConnection(this.fullUrl);
@@ -612,9 +561,7 @@ public class RequestReplyToTopicViaThree
return this.fullUrl;
}
-
- public void coreConnectTo(EmbeddedTcpBroker other, boolean duplex_f)
- throws Exception {
+ public void coreConnectTo(EmbeddedTcpBroker other, boolean duplex_f) throws Exception {
this.makeConnectionTo(other, duplex_f, true);
this.makeConnectionTo(other, duplex_f, false);
if (!duplex_f) {
@@ -623,24 +570,20 @@ public class RequestReplyToTopicViaThree
}
}
- public void start()
- throws Exception {
+ public void start() throws Exception {
brokerSvc.start();
brokerSvc.waitUntilStarted();
}
- public void stop()
- throws Exception {
+ public void stop() throws Exception {
brokerSvc.stop();
}
-
- protected void makeConnectionTo(EmbeddedTcpBroker other, boolean duplex_f, boolean queue_f)
- throws Exception {
+ protected void makeConnectionTo(EmbeddedTcpBroker other, boolean duplex_f, boolean queue_f) throws Exception {
NetworkConnector nw_conn;
String prefix;
ActiveMQDestination excl_dest;
- ArrayList excludes;
+ ArrayList<ActiveMQDestination> excludes;
nw_conn = new DiscoveryNetworkConnector(new URI("static:(" + other.tcpUrl + ")"));
nw_conn.setDuplex(duplex_f);
@@ -663,7 +606,7 @@ public class RequestReplyToTopicViaThree
excl_dest = ActiveMQDestination.createDestination(">", ActiveMQDestination.QUEUE_TYPE);
}
- excludes = new ArrayList();
+ excludes = new ArrayList<ActiveMQDestination>();
excludes.add(excl_dest);
nw_conn.setExcludedDestinations(excludes);
@@ -691,6 +634,7 @@ public class RequestReplyToTopicViaThree
shutdownLatch = new CountDownLatch(1);
}
+ @Override
public void run() {
CountDownLatch latch;
@@ -748,8 +692,7 @@ public class RequestReplyToTopicViaThree
return msgCount;
}
- protected void processMessages()
- throws Exception {
+ protected void processMessages() throws Exception {
Message in_msg;
haveFirstSeq = false;
@@ -770,8 +713,7 @@ public class RequestReplyToTopicViaThree
msgCons.close();
}
- protected void checkMessage(Message in_msg)
- throws Exception {
+ protected void checkMessage(Message in_msg) throws Exception {
int seq;
LOG.debug("received message " + fmtMsgInfo(in_msg) + " from " + in_msg.getJMSDestination());
@@ -784,9 +726,7 @@ public class RequestReplyToTopicViaThree
seq = in_msg.getIntProperty("SEQ");
if ((haveFirstSeq) && (seq != (lastSeq + 1))) {
- LOG.error("***ERROR*** incorrect sequence number; expected " +
- Integer.toString(lastSeq + 1) + " but have " +
- Integer.toString(seq));
+ LOG.error("***ERROR*** incorrect sequence number; expected " + Integer.toString(lastSeq + 1) + " but have " + Integer.toString(seq));
testError = true;
}
@@ -794,8 +734,7 @@ public class RequestReplyToTopicViaThree
lastSeq = seq;
if (msgCount > expectedCount) {
- LOG.error("*** have more messages than expected; have " + msgCount +
- "; expect " + expectedCount);
+ LOG.error("*** have more messages than expected; have " + msgCount + "; expect " + expectedCount);
testError = true;
}
@@ -823,8 +762,7 @@ public class RequestReplyToTopicViaThree
protected ThreadPoolExecutor processorPool;
- public EchoService(String dest, Connection broker_conn)
- throws Exception {
+ public EchoService(String dest, Connection broker_conn) throws Exception {
destName = dest;
jmsConn = broker_conn;
@@ -838,16 +776,15 @@ public class RequestReplyToTopicViaThree
waitShutdown = new CountDownLatch(1);
- processorPool = new ThreadPoolExecutor(CONCURRENT_SERVER_COUNT, CONCURRENT_SERVER_COUNT,
- 0, TimeUnit.SECONDS,
- new ArrayBlockingQueue<Runnable>(10000));
+ processorPool = new ThreadPoolExecutor(CONCURRENT_SERVER_COUNT, CONCURRENT_SERVER_COUNT, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(
+ 10000));
}
- public EchoService(String dest, String broker_url)
- throws Exception {
+ public EchoService(String dest, String broker_url) throws Exception {
this(dest, ActiveMQConnection.makeConnection(broker_url));
}
+ @Override
public void run() {
Message req;
@@ -877,7 +814,6 @@ public class RequestReplyToTopicViaThree
}
}
-
/**
* Shut down the service, waiting up to 3 seconds for the service to terminate.
*/
@@ -916,8 +852,7 @@ public class RequestReplyToTopicViaThree
protected Message request;
- public EchoRequestProcessor(Session sess, Message req)
- throws Exception {
+ public EchoRequestProcessor(Session sess, Message req) throws Exception {
this.session = sess;
this.request = req;
@@ -930,6 +865,7 @@ public class RequestReplyToTopicViaThree
this.msg_prod = session.createProducer(this.resp_dest);
}
+ @Override
public void run() {
try {
this.processRequest(this.request);
@@ -941,8 +877,7 @@ public class RequestReplyToTopicViaThree
/**
* Process one request for the Echo Service.
*/
- protected void processRequest(Message req)
- throws Exception {
+ protected void processRequest(Message req) throws Exception {
if (LOG.isDebugEnabled())
LOG.debug("ECHO request message " + req.toString());
@@ -975,8 +910,7 @@ public class RequestReplyToTopicViaThree
protected boolean Shutdown_ind;
protected int send_count;
- public TopicTrafficGenerator(String url1, String url2)
- throws Exception {
+ public TopicTrafficGenerator(String url1, String url2) throws Exception {
conn1 = createConnection(url1);
conn2 = createConnection(url2);
@@ -997,6 +931,7 @@ public class RequestReplyToTopicViaThree
Shutdown_ind = true;
}
+ @Override
public void run() {
Message msg;
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardTest.java Thu Feb 7 16:43:15 2013
@@ -20,7 +20,6 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
-import javax.jms.Destination;
import javax.jms.MessageConsumer;
import org.apache.activemq.JmsMultipleBrokersTestSupport;
@@ -29,9 +28,6 @@ import org.apache.activemq.broker.region
import org.apache.activemq.broker.region.virtual.VirtualDestination;
import org.apache.activemq.broker.region.virtual.VirtualDestinationInterceptor;
import org.apache.activemq.broker.region.virtual.VirtualTopic;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.network.NetworkConnector;
import org.apache.activemq.store.kahadb.KahaDBStore;
import org.apache.activemq.util.MessageIdList;
@@ -100,6 +96,7 @@ public class SingleBrokerVirtualDestinat
Thread.sleep(500);
}
+ @Override
public void setUp() throws Exception {
super.setAutoFail(true);
super.setUp();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java Thu Feb 7 16:43:15 2013
@@ -36,139 +36,136 @@ import org.apache.activemq.broker.Broker
import org.apache.activemq.broker.BrokerService;
public class TestBrokerConnectionDuplexExcludedDestinations extends TestCase {
-
- BrokerService receiverBroker;
- BrokerService senderBroker;
-
- Connection hubConnection;
- Session hubSession;
-
- Connection spokeConnection;
- Session spokeSession;
-
- public void setUp() throws Exception {
- // Hub broker
- String configFileName = "org/apache/activemq/usecases/receiver-duplex.xml";
- URI uri = new URI("xbean:" + configFileName);
- receiverBroker = BrokerFactory.createBroker(uri);
- receiverBroker.setPersistent(false);
- receiverBroker.setBrokerName("Hub");
-
- // Spoke broker
- configFileName = "org/apache/activemq/usecases/sender-duplex.xml";
- uri = new URI("xbean:" + configFileName);
- senderBroker = BrokerFactory.createBroker(uri);
- senderBroker.setPersistent(false);
- senderBroker.setBrokerName("Spoke");
-
- // Start both Hub and Spoke broker
- receiverBroker.start();
- senderBroker.start();
-
- // create hub session
- ConnectionFactory cfHub = new ActiveMQConnectionFactory("tcp://localhost:62002");
-
- hubConnection = cfHub.createConnection();
- hubConnection.start();
- hubSession = hubConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // create spoke session
- ConnectionFactory cfSpoke = new ActiveMQConnectionFactory("tcp://localhost:62001");
- spokeConnection = cfSpoke.createConnection();
- spokeConnection.start();
- spokeSession = spokeConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- }
-
- public void tearDown() throws Exception {
- hubSession.close();
- hubConnection.stop();
- hubConnection.close();
-
- spokeSession.close();
- spokeConnection.stop();
- spokeConnection.close();
-
- senderBroker.stop();
- receiverBroker.stop();
- }
-
- public void testDuplexSendFromHubToSpoke()
- throws Exception {
-
- //create hub producer
- MessageProducer hubProducer = hubSession.createProducer(null);
- hubProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- hubProducer.setDisableMessageID(true);
- hubProducer.setDisableMessageTimestamp(true);
-
- //create spoke producer
- MessageProducer spokeProducer = hubSession.createProducer(null);
- spokeProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- spokeProducer.setDisableMessageID(true);
- spokeProducer.setDisableMessageTimestamp(true);
-
- Queue excludedQueueHub = hubSession.createQueue("exclude.test.foo");
- TextMessage excludedMsgHub = hubSession.createTextMessage();
- excludedMsgHub.setText(excludedQueueHub.toString());
-
- Queue includedQueueHub = hubSession.createQueue("include.test.foo");
-
- TextMessage includedMsgHub = hubSession.createTextMessage();
- includedMsgHub.setText(includedQueueHub.toString());
-
- Queue alwaysIncludedQueueHub = hubSession.createQueue("always.include.test.foo");
-
- TextMessage alwaysIncludedMsgHub = hubSession.createTextMessage();
- alwaysIncludedMsgHub.setText(alwaysIncludedQueueHub.toString());
-
- // Sending from Hub queue
- hubProducer.send(excludedQueueHub, excludedMsgHub);
- hubProducer.send(includedQueueHub, includedMsgHub);
- hubProducer.send(alwaysIncludedQueueHub, alwaysIncludedMsgHub);
+ BrokerService receiverBroker;
+ BrokerService senderBroker;
- Queue excludedQueueSpoke = spokeSession.createQueue("exclude.test.foo");
- MessageConsumer excludedConsumerSpoke = spokeSession.createConsumer(excludedQueueSpoke);
-
- Thread.sleep(100);
+ Connection hubConnection;
+ Session hubSession;
- Queue includedQueueSpoke = spokeSession.createQueue("include.test.foo");
- MessageConsumer includedConsumerSpoke = spokeSession.createConsumer(includedQueueSpoke);
+ Connection spokeConnection;
+ Session spokeSession;
- Thread.sleep(100);
+ @Override
+ public void setUp() throws Exception {
+ // Hub broker
+ String configFileName = "org/apache/activemq/usecases/receiver-duplex.xml";
+ URI uri = new URI("xbean:" + configFileName);
+ receiverBroker = BrokerFactory.createBroker(uri);
+ receiverBroker.setPersistent(false);
+ receiverBroker.setBrokerName("Hub");
+
+ // Spoke broker
+ configFileName = "org/apache/activemq/usecases/sender-duplex.xml";
+ uri = new URI("xbean:" + configFileName);
+ senderBroker = BrokerFactory.createBroker(uri);
+ senderBroker.setPersistent(false);
+ senderBroker.setBrokerName("Spoke");
+
+ // Start both Hub and Spoke broker
+ receiverBroker.start();
+ senderBroker.start();
+
+ // create hub session
+ ConnectionFactory cfHub = new ActiveMQConnectionFactory("tcp://localhost:62002");
+
+ hubConnection = cfHub.createConnection();
+ hubConnection.start();
+ hubSession = hubConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // create spoke session
+ ConnectionFactory cfSpoke = new ActiveMQConnectionFactory("tcp://localhost:62001");
+ spokeConnection = cfSpoke.createConnection();
+ spokeConnection.start();
+ spokeSession = spokeConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ hubSession.close();
+ hubConnection.stop();
+ hubConnection.close();
+
+ spokeSession.close();
+ spokeConnection.stop();
+ spokeConnection.close();
+
+ senderBroker.stop();
+ receiverBroker.stop();
+ }
+
+ public void testDuplexSendFromHubToSpoke() throws Exception {
+
+ //create hub producer
+ MessageProducer hubProducer = hubSession.createProducer(null);
+ hubProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ hubProducer.setDisableMessageID(true);
+ hubProducer.setDisableMessageTimestamp(true);
+
+ //create spoke producer
+ MessageProducer spokeProducer = hubSession.createProducer(null);
+ spokeProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ spokeProducer.setDisableMessageID(true);
+ spokeProducer.setDisableMessageTimestamp(true);
+
+ Queue excludedQueueHub = hubSession.createQueue("exclude.test.foo");
+ TextMessage excludedMsgHub = hubSession.createTextMessage();
+ excludedMsgHub.setText(excludedQueueHub.toString());
+
+ Queue includedQueueHub = hubSession.createQueue("include.test.foo");
+
+ TextMessage includedMsgHub = hubSession.createTextMessage();
+ includedMsgHub.setText(includedQueueHub.toString());
+
+ Queue alwaysIncludedQueueHub = hubSession.createQueue("always.include.test.foo");
+
+ TextMessage alwaysIncludedMsgHub = hubSession.createTextMessage();
+ alwaysIncludedMsgHub.setText(alwaysIncludedQueueHub.toString());
+
+ // Sending from Hub queue
+ hubProducer.send(excludedQueueHub, excludedMsgHub);
+ hubProducer.send(includedQueueHub, includedMsgHub);
+ hubProducer.send(alwaysIncludedQueueHub, alwaysIncludedMsgHub);
- Queue alwaysIncludedQueueSpoke = spokeSession.createQueue("always.include.test.foo");
- MessageConsumer alwaysIncludedConsumerSpoke = spokeSession.createConsumer(alwaysIncludedQueueHub);
+ Queue excludedQueueSpoke = spokeSession.createQueue("exclude.test.foo");
+ MessageConsumer excludedConsumerSpoke = spokeSession.createConsumer(excludedQueueSpoke);
Thread.sleep(100);
- TextMessage alwaysIncludedMsgSpoke = spokeSession.createTextMessage();
- alwaysIncludedMsgSpoke.setText(alwaysIncludedQueueSpoke.toString());
- spokeProducer.send(alwaysIncludedQueueSpoke, alwaysIncludedMsgSpoke);
+ Queue includedQueueSpoke = spokeSession.createQueue("include.test.foo");
+ MessageConsumer includedConsumerSpoke = spokeSession.createConsumer(includedQueueSpoke);
- MessageConsumer alwaysIncludedConsumerHub = spokeSession.createConsumer(alwaysIncludedQueueHub);
+ Thread.sleep(100);
-
- // Receiving from excluded Spoke queue
- Message msg = excludedConsumerSpoke.receive(200);
- assertNull(msg);
-
- // Receiving from included Spoke queue
- msg = includedConsumerSpoke.receive(200);
- assertEquals(includedMsgHub, msg);
-
- // Receiving from included Spoke queue
- msg = alwaysIncludedConsumerSpoke.receive(200);
- assertEquals(alwaysIncludedMsgHub, msg);
-
- // we should be able to receive excluded queue message on Hub
- MessageConsumer excludedConsumerHub = hubSession.createConsumer(excludedQueueHub);
- msg = excludedConsumerHub.receive(200);;
- assertEquals(excludedMsgHub, msg);
+ Queue alwaysIncludedQueueSpoke = spokeSession.createQueue("always.include.test.foo");
+ MessageConsumer alwaysIncludedConsumerSpoke = spokeSession.createConsumer(alwaysIncludedQueueHub);
+
+ Thread.sleep(100);
+ TextMessage alwaysIncludedMsgSpoke = spokeSession.createTextMessage();
+ alwaysIncludedMsgSpoke.setText(alwaysIncludedQueueSpoke.toString());
+ spokeProducer.send(alwaysIncludedQueueSpoke, alwaysIncludedMsgSpoke);
- hubProducer.close();
- excludedConsumerSpoke.close();
+ MessageConsumer alwaysIncludedConsumerHub = spokeSession.createConsumer(alwaysIncludedQueueHub);
+ assertNotNull(alwaysIncludedConsumerHub);
- }
-
+ // Receiving from excluded Spoke queue
+ Message msg = excludedConsumerSpoke.receive(200);
+ assertNull(msg);
+
+ // Receiving from included Spoke queue
+ msg = includedConsumerSpoke.receive(200);
+ assertEquals(includedMsgHub, msg);
+
+ // Receiving from included Spoke queue
+ msg = alwaysIncludedConsumerSpoke.receive(200);
+ assertEquals(alwaysIncludedMsgHub, msg);
+
+ // we should be able to receive excluded queue message on Hub
+ MessageConsumer excludedConsumerHub = hubSession.createConsumer(excludedQueueHub);
+ msg = excludedConsumerHub.receive(200);;
+ assertEquals(excludedMsgHub, msg);
+
+ hubProducer.close();
+ excludedConsumerSpoke.close();
+ }
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestSupport.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestSupport.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestSupport.java Thu Feb 7 16:43:15 2013
@@ -23,22 +23,17 @@ import javax.jms.Message;
import javax.jms.TextMessage;
import junit.framework.TestCase;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQMessage;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Useful base class for unit test cases
- *
- *
*/
public class TestSupport extends TestCase {
-
- private static final Logger LOG = LoggerFactory.getLogger(TestSupport.class);
-
+
protected ActiveMQConnectionFactory connectionFactory;
protected boolean topic = true;
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java Thu Feb 7 16:43:15 2013
@@ -27,20 +27,20 @@ import org.apache.activemq.network.Netwo
import org.apache.activemq.transport.TransportFactory;
/**
- *
+ *
*/
public class ThreeBrokerQueueNetworkUsingTcpTest extends ThreeBrokerQueueNetworkTest {
protected List<DemandForwardingBridge> bridges;
protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception {
- List remoteTransports = remoteBroker.getTransportConnectors();
- List localTransports = localBroker.getTransportConnectors();
+ List<TransportConnector> remoteTransports = remoteBroker.getTransportConnectors();
+ List<TransportConnector> localTransports = localBroker.getTransportConnectors();
URI remoteURI;
URI localURI;
if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) {
- remoteURI = ((TransportConnector)remoteTransports.get(0)).getConnectUri();
- localURI = ((TransportConnector)localTransports.get(0)).getConnectUri();
+ remoteURI = remoteTransports.get(0).getConnectUri();
+ localURI = localTransports.get(0).getConnectUri();
// Ensure that we are connecting using tcp
if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) {
@@ -61,6 +61,7 @@ public class ThreeBrokerQueueNetworkUsin
maxSetupTime = 2000;
}
+ @Override
public void setUp() throws Exception {
super.setUp();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java Thu Feb 7 16:43:15 2013
@@ -38,6 +38,7 @@ public class ThreeBrokerStompTemporaryQu
private static final Logger LOG = LoggerFactory.getLogger(ThreeBrokerStompTemporaryQueueTest.class);
private StompConnection stompConnection;
+ @Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
URI remoteURI;
@@ -108,7 +109,6 @@ public class ThreeBrokerStompTemporaryQu
advisoryTopicsForTempQueues = countTopicsByName("BrokerC", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should have been deleted", 0, advisoryTopicsForTempQueues);
-
LOG.info("Restarting brokerA");
BrokerItem brokerItem = brokers.remove("BrokerA");
if (brokerItem != null) {
@@ -133,7 +133,6 @@ public class ThreeBrokerStompTemporaryQu
assertEquals("Advisory topic should have been deleted", 0, advisoryTopicsForTempQueues);
advisoryTopicsForTempQueues = countTopicsByName("BrokerC", "ActiveMQ.Advisory.Consumer.Queue.ID");
assertEquals("Advisory topic should have been deleted", 0, advisoryTopicsForTempQueues);
-
}
private int countTopicsByName(String broker, String name)
@@ -147,11 +146,12 @@ public class ThreeBrokerStompTemporaryQu
return advisoryTopicsForTempQueues;
}
-
private void bridgeAndConfigureBrokers(String local, String remote) throws Exception {
NetworkConnector bridge = bridgeBrokers(local, remote);
+ assertNotNull(bridge);
}
+ @Override
public void setUp() throws Exception {
super.setAutoFail(true);
super.setUp();
@@ -159,14 +159,11 @@ public class ThreeBrokerStompTemporaryQu
createAndConfigureBroker(new URI("broker:(tcp://localhost:61616,stomp://localhost:61613)/BrokerA" + options));
createAndConfigureBroker(new URI("broker:(tcp://localhost:61617,stomp://localhost:61614)/BrokerB" + options));
createAndConfigureBroker(new URI("broker:(tcp://localhost:61618,stomp://localhost:61615)/BrokerC" + options));
-
}
private BrokerService createAndConfigureBroker(URI uri) throws Exception {
BrokerService broker = createBroker(uri);
-
configurePersistenceAdapter(broker);
-
return broker;
}
@@ -176,5 +173,4 @@ public class ThreeBrokerStompTemporaryQu
kaha.setDirectory(dataFileDir);
broker.setPersistenceAdapter(kaha);
}
-
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java Thu Feb 7 16:43:15 2013
@@ -27,7 +27,7 @@ import org.apache.activemq.JmsMultipleBr
import org.apache.activemq.network.NetworkConnector;
/**
- *
+ *
*/
public class ThreeBrokerTempQueueNetworkTest extends JmsMultipleBrokersTestSupport {
protected static final int MESSAGE_COUNT = 100;
@@ -41,20 +41,20 @@ public class ThreeBrokerTempQueueNetwork
bridgeBrokers("BrokerA", "BrokerB", false, 2);
bridgeBrokers("BrokerB", "BrokerC", false, 2);
startAllBrokers();
- BrokerItem brokerItem = (BrokerItem)brokers.get("BrokerC");
+ BrokerItem brokerItem = brokers.get("BrokerC");
Connection conn = brokerItem.createConnection();
conn.start();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue tempQ = sess.createTemporaryQueue();
Thread.sleep(5000);
- for (Iterator i = brokers.values().iterator(); i.hasNext();) {
- BrokerItem bi = (BrokerItem)i.next();
+ for (Iterator<BrokerItem> i = brokers.values().iterator(); i.hasNext();) {
+ BrokerItem bi = i.next();
assertEquals("No queues on broker " + bi.broker.getBrokerName(), 1, bi.broker.getAdminView().getTemporaryQueues().length);
}
tempQ.delete();
Thread.sleep(2000);
- for (Iterator i = brokers.values().iterator(); i.hasNext();) {
- BrokerItem bi = (BrokerItem)i.next();
+ for (Iterator<BrokerItem> i = brokers.values().iterator(); i.hasNext();) {
+ BrokerItem bi = i.next();
assertEquals("Temp queue left behind on broker " + bi.broker.getBrokerName(), 0, bi.broker.getAdminView().getTemporaryQueues().length);
}
}
@@ -65,26 +65,26 @@ public class ThreeBrokerTempQueueNetwork
bridgeBrokers("BrokerA", "BrokerB", false, 3);
bridgeBrokers("BrokerB", "BrokerC", false, 3);
startAllBrokers();
- BrokerItem brokerItem = (BrokerItem)brokers.get("BrokerC");
+ BrokerItem brokerItem = brokers.get("BrokerC");
Connection conn = brokerItem.createConnection();
conn.start();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue tempQ = sess.createTemporaryQueue();
Thread.sleep(5000);
- for (Iterator i = brokers.values().iterator(); i.hasNext();) {
- BrokerItem bi = (BrokerItem)i.next();
+ for (Iterator<BrokerItem> i = brokers.values().iterator(); i.hasNext();) {
+ BrokerItem bi = i.next();
assertEquals("No queues on broker " + bi.broker.getBrokerName(), 1, bi.broker.getAdminView().getTemporaryQueues().length);
}
createBroker(new URI("broker:(tcp://localhost:61619)/BrokerD?persistent=false&useJmx=true"));
bridgeBrokers("BrokerD", "BrokerA", false, 3);
- BrokerItem newBroker = (BrokerItem)brokers.get("BrokerD");
+ BrokerItem newBroker = brokers.get("BrokerD");
newBroker.broker.start();
Thread.sleep(1000);
assertEquals("No queues on broker D", 1, newBroker.broker.getAdminView().getTemporaryQueues().length);
tempQ.delete();
Thread.sleep(2000);
- for (Iterator i = brokers.values().iterator(); i.hasNext();) {
- BrokerItem bi = (BrokerItem)i.next();
+ for (Iterator<BrokerItem> i = brokers.values().iterator(); i.hasNext();) {
+ BrokerItem bi = i.next();
assertEquals("Temp queue left behind on broker " + bi.broker.getBrokerName(), 0, bi.broker.getAdminView().getTemporaryQueues().length);
}
}
@@ -100,6 +100,7 @@ public class ThreeBrokerTempQueueNetwork
fail("Test should have failed since temp queues are disabled.");
}
+ @Override
public void setUp() throws Exception {
super.setAutoFail(true);
super.setUp();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java Thu Feb 7 16:43:15 2013
@@ -28,14 +28,13 @@ import javax.jms.Topic;
import junit.framework.Test;
import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.JmsMultipleBrokersTestSupport.BrokerItem;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.util.MessageIdList;
/**
- *
+ *
*/
public class ThreeBrokerTopicNetworkTest extends JmsMultipleBrokersTestSupport {
protected static final int MESSAGE_COUNT = 100;
@@ -79,11 +78,11 @@ public class ThreeBrokerTopicNetworkTest
assertEquals(MESSAGE_COUNT * 2, msgsB.getMessageCount());
assertEquals(MESSAGE_COUNT * 2, msgsC.getMessageCount());
}
-
+
public void initCombosForTestABandBCbrokerNetworkWithSelectors() {
- addCombinationValues("dynamicOnly", new Object[] {true, false});
+ addCombinationValues("dynamicOnly", new Object[] {true, false});
}
-
+
/**
* BrokerA -> BrokerB -> BrokerC
*/
@@ -185,7 +184,7 @@ public class ThreeBrokerTopicNetworkTest
// let consumers propogate around the network
Thread.sleep(2000);
-
+
// Send messages
sendMessages("BrokerA", dest, MESSAGE_COUNT);
sendMessages("BrokerB", dest, MESSAGE_COUNT);
@@ -249,7 +248,7 @@ public class ThreeBrokerTopicNetworkTest
}
public void testAllConnectedBrokerNetworkSingleProducerTTL() throws Exception {
-
+
// duplicates are expected with ttl of 2 as each broker is connected to the next
// but the dups are suppressed by the store and now also by the topic sub when enableAudit
// default (true) is present in a matching destination policy entry
@@ -287,7 +286,7 @@ public class ThreeBrokerTopicNetworkTest
// Send messages
sendMessages("BrokerA", dest, 1);
-
+
// Get message count
MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
@@ -299,7 +298,7 @@ public class ThreeBrokerTopicNetworkTest
// ensure we don't get any more messages
Thread.sleep(2000);
-
+
assertEquals(1, msgsA.getMessageCount());
assertEquals(1, msgsB.getMessageCount());
assertEquals(1, msgsC.getMessageCount());
@@ -342,12 +341,12 @@ public class ThreeBrokerTopicNetworkTest
// ensure we don't get any more messages
Thread.sleep(2000);
-
+
assertEquals(1, msgsA.getMessageCount());
assertEquals(1, msgsB.getMessageCount());
assertEquals(1, msgsC.getMessageCount());
}
-
+
/**
* BrokerA <-> BrokerB <-> BrokerC
*/
@@ -364,7 +363,7 @@ public class ThreeBrokerTopicNetworkTest
MessageConsumer clientA = createConsumer("BrokerA", dest);
MessageConsumer clientB = createConsumer("BrokerB", dest);
MessageConsumer clientC = createConsumer("BrokerC", dest);
-
+
//let consumers propogate around the network
Thread.sleep(2000);
@@ -387,16 +386,17 @@ public class ThreeBrokerTopicNetworkTest
assertEquals(MESSAGE_COUNT * 3, msgsC.getMessageCount());
}
+ @Override
public void setUp() throws Exception {
super.setAutoFail(true);
super.setUp();
- String options = new String("?persistent=false&useJmx=false");
+ String options = new String("?persistent=false&useJmx=false");
createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA" + options));
createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB" + options));
createBroker(new URI("broker:(tcp://localhost:61618)/BrokerC" + options));
}
-
+
public static Test suite() {
- return suite(ThreeBrokerTopicNetworkTest.class);
+ return suite(ThreeBrokerTopicNetworkTest.class);
}
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java Thu Feb 7 16:43:15 2013
@@ -27,20 +27,20 @@ import org.apache.activemq.network.Netwo
import org.apache.activemq.transport.TransportFactory;
/**
- *
+ *
*/
public class ThreeBrokerTopicNetworkUsingTcpTest extends ThreeBrokerTopicNetworkTest {
protected List<DemandForwardingBridge> bridges;
protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception {
- List remoteTransports = remoteBroker.getTransportConnectors();
- List localTransports = localBroker.getTransportConnectors();
+ List<TransportConnector> remoteTransports = remoteBroker.getTransportConnectors();
+ List<TransportConnector> localTransports = localBroker.getTransportConnectors();
URI remoteURI;
URI localURI;
if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) {
- remoteURI = ((TransportConnector)remoteTransports.get(0)).getConnectUri();
- localURI = ((TransportConnector)localTransports.get(0)).getConnectUri();
+ remoteURI = remoteTransports.get(0).getConnectUri();
+ localURI = localTransports.get(0).getConnectUri();
// Ensure that we are connecting using tcp
if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) {
@@ -61,6 +61,7 @@ public class ThreeBrokerTopicNetworkUsin
maxSetupTime = 2000;
}
+ @Override
public void setUp() throws Exception {
super.setUp();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TopicDurableConnectStatsTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TopicDurableConnectStatsTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TopicDurableConnectStatsTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TopicDurableConnectStatsTest.java Thu Feb 7 16:43:15 2013
@@ -34,7 +34,9 @@ import javax.management.MBeanServerConne
import javax.management.MBeanServerInvocationHandler;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+
import junit.framework.Test;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQPrefetchPolicy;
import org.apache.activemq.broker.BrokerFactory;
@@ -50,8 +52,8 @@ public class TopicDurableConnectStatsTes
private static final Logger LOG = LoggerFactory.getLogger(TopicDurableConnectStatsTest.class);
private BrokerService broker;
private ActiveMQTopic topic;
- private Vector<Throwable> exceptions = new Vector<Throwable>();
- private int messageSize = 4000;
+ private final Vector<Throwable> exceptions = new Vector<Throwable>();
+ private final int messageSize = 4000;
protected MBeanServerConnection mbeanServer;
protected String domain = "org.apache.activemq";
private ActiveMQConnectionFactory connectionFactory = null;
@@ -59,6 +61,7 @@ public class TopicDurableConnectStatsTes
private static Session session2 = null;
+ @Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
connectionFactory = new ActiveMQConnectionFactory("vm://" + getName(true));
@@ -87,6 +90,7 @@ public class TopicDurableConnectStatsTes
return suite(TopicDurableConnectStatsTest.class);
}
+ @Override
protected void setUp() throws Exception {
exceptions.clear();
topic = (ActiveMQTopic) createDestination();
@@ -96,6 +100,7 @@ public class TopicDurableConnectStatsTes
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
destroyBroker();
@@ -143,6 +148,7 @@ public class TopicDurableConnectStatsTes
Connection consumerCon = createConnection("cliId1");
Session consumerSession = consumerCon.createSession(true, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer1 = consumerSession.createDurableSubscriber(topic, "SubsId", "filter = 'true'", true);
+ assertNotNull(consumer1);
DurableSubscriptionViewMBean subscriber1 = null;
@@ -201,6 +207,7 @@ public class TopicDurableConnectStatsTes
consumer2.setMessageListener(listener);
assertTrue("received all sent", Wait.waitFor(new Wait.Condition() {
+ @Override
public boolean isSatisified() throws Exception {
return numMessages == listener.count;
}
@@ -238,6 +245,7 @@ public class TopicDurableConnectStatsTes
Listener() {
}
+ @Override
public void onMessage(Message message) {
count++;
try {
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionTest.java Thu Feb 7 16:43:15 2013
@@ -17,7 +17,6 @@
package org.apache.activemq.usecases;
import java.util.Date;
-import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -32,6 +31,7 @@ import javax.jms.Session;
import javax.jms.TextMessage;
import junit.framework.TestCase;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.slf4j.Logger;
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
/**
* @author pragmasoft
- *
+ *
*/
public final class TransactionTest extends TestCase {
@@ -54,7 +54,7 @@ public final class TransactionTest exten
private MessageProducer producer;
private MessageConsumer consumer;
private Connection connection;
- private CountDownLatch latch = new CountDownLatch(1);
+ private final CountDownLatch latch = new CountDownLatch(1);
public void testTransaction() throws Exception {
@@ -70,6 +70,7 @@ public final class TransactionTest exten
consumer = consumerSession.createConsumer(queue);
consumer.setMessageListener(new MessageListener() {
+ @Override
public void onMessage(Message m) {
try {
TextMessage tm = (TextMessage)m;
@@ -111,6 +112,7 @@ public final class TransactionTest exten
LOG.info("test completed, destination=" + receivedText);
}
+ @Override
protected void tearDown() throws Exception {
if (connection != null) {
connection.close();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java Thu Feb 7 16:43:15 2013
@@ -47,7 +47,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class TwoBrokerQueueClientsReconnectTest extends JmsMultipleBrokersTestSupport {
protected static final int MESSAGE_COUNT = 100; // Best if a factor of 100
@@ -366,6 +366,7 @@ public class TwoBrokerQueueClientsReconn
assertEquals("Client for " + broker2 + " should have received 50% of the messages.", (int)(MESSAGE_COUNT * 0.50), msgsClient2);
}
+ @SuppressWarnings("unchecked")
public void testDuplicateSend() throws Exception {
broker1 = "BrokerA";
broker2 = "BrokerB";
@@ -391,6 +392,7 @@ public class TwoBrokerQueueClientsReconn
if (first.compareAndSet(false, true)) {
producerExchange.getConnectionContext().setDontSendReponse(true);
Executors.newSingleThreadExecutor().execute(new Runnable() {
+ @Override
public void run() {
try {
LOG.info("Waiting for recepit");
@@ -441,6 +443,7 @@ public class TwoBrokerQueueClientsReconn
}));
}
+ @SuppressWarnings("unchecked")
public void testDuplicateSendWithNoAuditEnqueueCountStat() throws Exception {
broker1 = "BrokerA";
broker2 = "BrokerB";
@@ -463,6 +466,7 @@ public class TwoBrokerQueueClientsReconn
if (first.compareAndSet(false, true)) {
producerExchange.getConnectionContext().setDontSendReponse(true);
Executors.newSingleThreadExecutor().execute(new Runnable() {
+ @Override
public void run() {
try {
LOG.info("Waiting for recepit");
@@ -547,6 +551,7 @@ public class TwoBrokerQueueClientsReconn
return msgsReceived;
}
+ @Override
protected MessageConsumer createConsumer(String brokerName, Destination dest) throws Exception {
Connection conn = createConnection(brokerName);
conn.start();
@@ -554,6 +559,7 @@ public class TwoBrokerQueueClientsReconn
return sess.createConsumer(dest);
}
+ @Override
protected void configureBroker(BrokerService broker) {
PolicyMap policyMap = new PolicyMap();
PolicyEntry defaultEntry = new PolicyEntry();
@@ -562,6 +568,7 @@ public class TwoBrokerQueueClientsReconn
broker.setDestinationPolicy(policyMap);
}
+ @Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
NetworkConnector nc = super.bridgeBrokers(localBroker,remoteBroker, dynamicOnly, networkTTL, conduit, failover);
nc.setPrefetchSize(NETWORK_PREFETCH);
@@ -569,6 +576,7 @@ public class TwoBrokerQueueClientsReconn
return nc;
}
+ @Override
public void setUp() throws Exception {
super.setAutoFail(true);
super.setUp();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java Thu Feb 7 16:43:15 2013
@@ -32,15 +32,16 @@ import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
/**
- *
+ *
*/
public class TwoBrokerTopicSendReceiveTest extends JmsTopicSendReceiveWithTwoConnectionsTest {
private static final Logger LOG = LoggerFactory.getLogger(TwoBrokerTopicSendReceiveTest.class);
protected ActiveMQConnectionFactory sendFactory;
protected ActiveMQConnectionFactory receiveFactory;
- protected HashMap brokers = new HashMap();
+ protected HashMap<String, BrokerService> brokers = new HashMap<String, BrokerService>();
+ @Override
protected void setUp() throws Exception {
sendFactory = createSenderConnectionFactory();
receiveFactory = createReceiverConnectionFactory();
@@ -63,19 +64,22 @@ public class TwoBrokerTopicSendReceiveTe
return createConnectionFactory("org/apache/activemq/usecases/sender.xml", "sender", "vm://sender");
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
- for (Iterator iter = brokers.values().iterator(); iter.hasNext();) {
- BrokerService broker = (BrokerService)iter.next();
+ for (Iterator<BrokerService> iter = brokers.values().iterator(); iter.hasNext();) {
+ BrokerService broker = iter.next();
ServiceSupport.dispose(broker);
iter.remove();
}
}
+ @Override
protected Connection createReceiveConnection() throws JMSException {
return receiveFactory.createConnection();
}
+ @Override
protected Connection createSendConnection() throws JMSException {
return sendFactory.createConnection();
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/util/MessageIdList.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/util/MessageIdList.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/util/MessageIdList.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/util/MessageIdList.java Thu Feb 7 16:43:15 2013
@@ -24,8 +24,7 @@ import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
-import junit.framework.Assert;
-
+import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,15 +36,15 @@ import org.slf4j.LoggerFactory;
* chain these instances together with the {@link #setParent(MessageListener)}
* method so that you can aggregate the total number of messages consumed across
* a number of consumers.
- *
- *
+ *
+ *
*/
public class MessageIdList extends Assert implements MessageListener {
private static final Logger LOG = LoggerFactory.getLogger(MessageIdList.class);
- private List<String> messageIds = new ArrayList<String>();
- private Object semaphore;
+ private final List<String> messageIds = new ArrayList<String>();
+ private final Object semaphore;
private boolean verbose;
private MessageListener parent;
private long maximumDuration = 15000L;
@@ -61,6 +60,7 @@ public class MessageIdList extends Asser
this.semaphore = semaphore;
}
+ @Override
public boolean equals(Object that) {
if (that instanceof MessageIdList) {
MessageIdList thatList = (MessageIdList)that;
@@ -69,12 +69,14 @@ public class MessageIdList extends Asser
return false;
}
+ @Override
public int hashCode() {
synchronized (semaphore) {
return messageIds.hashCode() + 1;
}
}
+ @Override
public String toString() {
synchronized (semaphore) {
return messageIds.toString();
@@ -98,6 +100,7 @@ public class MessageIdList extends Asser
}
}
+ @Override
public void onMessage(Message message) {
String id = null;
try {
@@ -161,7 +164,7 @@ public class MessageIdList extends Asser
/**
* Performs a testing assertion that the correct number of messages have
* been received without waiting
- *
+ *
* @param messageCount
*/
public void assertMessagesReceivedNoWait(int messageCount) {
@@ -172,7 +175,7 @@ public class MessageIdList extends Asser
* Performs a testing assertion that the correct number of messages have
* been received waiting for the messages to arrive up to a fixed amount of
* time.
- *
+ *
* @param messageCount
*/
public void assertMessagesReceived(int messageCount) {
@@ -193,7 +196,7 @@ public class MessageIdList extends Asser
/**
* Asserts that there are at most the number of messages received without
* waiting
- *
+ *
* @param messageCount
*/
public void assertAtMostMessagesReceived(int messageCount) {
@@ -250,7 +253,7 @@ public class MessageIdList extends Asser
/**
* Gets the amount of time the message listener will spend sleeping to
* simulate a processing delay.
- *
+ *
* @return
*/
public long getProcessingDelay() {
@@ -260,7 +263,7 @@ public class MessageIdList extends Asser
/**
* Sets the amount of time the message listener will spend sleeping to
* simulate a processing delay.
- *
+ *
* @param processingDelay
*/
public void setProcessingDelay(long processingDelay) {
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java Thu Feb 7 16:43:15 2013
@@ -32,6 +32,7 @@ import org.apache.activemq.ActiveMQConne
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.network.NetworkConnector;
@@ -39,7 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class ConnectorXBeanConfigTest extends TestCase {
@@ -48,57 +49,57 @@ public class ConnectorXBeanConfigTest ex
public void testConnectorConfiguredCorrectly() throws Exception {
- TransportConnector connector = (TransportConnector)brokerService.getTransportConnectors().get(0);
+ TransportConnector connector = brokerService.getTransportConnectors().get(0);
assertEquals(new URI("tcp://localhost:61636"), connector.getUri());
assertTrue(connector.getTaskRunnerFactory() == brokerService.getTaskRunnerFactory());
- NetworkConnector netConnector = (NetworkConnector)brokerService.getNetworkConnectors().get(0);
- List excludedDestinations = netConnector.getExcludedDestinations();
+ NetworkConnector netConnector = brokerService.getNetworkConnectors().get(0);
+ List<ActiveMQDestination> excludedDestinations = netConnector.getExcludedDestinations();
assertEquals(new ActiveMQQueue("exclude.test.foo"), excludedDestinations.get(0));
assertEquals(new ActiveMQTopic("exclude.test.bar"), excludedDestinations.get(1));
- List dynamicallyIncludedDestinations = netConnector.getDynamicallyIncludedDestinations();
+ List<ActiveMQDestination> dynamicallyIncludedDestinations = netConnector.getDynamicallyIncludedDestinations();
assertEquals(new ActiveMQQueue("include.test.foo"), dynamicallyIncludedDestinations.get(0));
assertEquals(new ActiveMQTopic("include.test.bar"), dynamicallyIncludedDestinations.get(1));
-
}
-
+
public void testBrokerRestartIsAllowed() throws Exception {
- brokerService.stop();
- brokerService.waitUntilStopped();
-
- // redundant start is now ignored
- brokerService.start();
+ brokerService.stop();
+ brokerService.waitUntilStopped();
+
+ // redundant start is now ignored
+ brokerService.start();
}
-
+
public void testForceBrokerRestart() throws Exception {
- brokerService.stop();
- brokerService.waitUntilStopped();
-
- brokerService.start(true); // force restart
- brokerService.waitUntilStarted();
-
- LOG.info("try and connect to restarted broker");
- //send and receive a message from a restarted broker
- ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61636");
- Connection conn = factory.createConnection();
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- conn.start();
- Destination dest = new ActiveMQQueue("test");
- MessageProducer producer = sess.createProducer(dest);
- MessageConsumer consumer = sess.createConsumer(dest);
- producer.send(sess.createTextMessage("test"));
- TextMessage msg = (TextMessage)consumer.receive(1000);
- assertEquals("test", msg.getText());
- }
+ brokerService.stop();
+ brokerService.waitUntilStopped();
+
+ brokerService.start(true); // force restart
+ brokerService.waitUntilStarted();
+ LOG.info("try and connect to restarted broker");
+ //send and receive a message from a restarted broker
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61636");
+ Connection conn = factory.createConnection();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ conn.start();
+ Destination dest = new ActiveMQQueue("test");
+ MessageProducer producer = sess.createProducer(dest);
+ MessageConsumer consumer = sess.createConsumer(dest);
+ producer.send(sess.createTextMessage("test"));
+ TextMessage msg = (TextMessage)consumer.receive(1000);
+ assertEquals("test", msg.getText());
+ }
+ @Override
protected void setUp() throws Exception {
brokerService = createBroker();
brokerService.start();
}
+ @Override
protected void tearDown() throws Exception {
if (brokerService != null) {
brokerService.stop();
@@ -109,5 +110,4 @@ public class ConnectorXBeanConfigTest ex
String uri = "org/apache/activemq/xbean/connector-test.xml";
return BrokerFactory.createBroker(new URI("xbean:" + uri));
}
-
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ManagementContextXBeanConfigTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ManagementContextXBeanConfigTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ManagementContextXBeanConfigTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ManagementContextXBeanConfigTest.java Thu Feb 7 16:43:15 2013
@@ -27,7 +27,9 @@ import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
+
import junit.framework.TestCase;
+
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.jmx.BrokerViewMBean;
@@ -36,7 +38,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class ManagementContextXBeanConfigTest extends TestCase {
@@ -57,7 +59,7 @@ public class ManagementContextXBeanConfi
public void testSuccessAuthentication() throws Exception {
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:2011/jmxrmi");
- Map env = new HashMap();
+ Map<String, Object> env = new HashMap<String, Object>();
env.put(JMXConnector.CREDENTIALS, new String[]{"admin", "activemq"});
JMXConnector connector = JMXConnectorFactory.connect(url, env);
assertAuthentication(connector);
@@ -78,16 +80,18 @@ public class ManagementContextXBeanConfi
connector.connect();
MBeanServerConnection connection = connector.getMBeanServerConnection();
ObjectName name = new ObjectName("test.domain:type=Broker,brokerName=localhost");
- BrokerViewMBean mbean = (BrokerViewMBean) MBeanServerInvocationHandler
+ BrokerViewMBean mbean = MBeanServerInvocationHandler
.newProxyInstance(connection, name, BrokerViewMBean.class, true);
LOG.info("Broker " + mbean.getBrokerId() + " - " + mbean.getBrokerName());
}
+ @Override
protected void setUp() throws Exception {
brokerService = createBroker();
brokerService.start();
}
+ @Override
protected void tearDown() throws Exception {
if (brokerService != null) {
brokerService.stop();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerTest.java Thu Feb 7 16:43:15 2013
@@ -19,14 +19,11 @@ package org.apache.activemq.xbean;
import javax.jms.Connection;
import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.test.retroactive.RetroactiveConsumerWithMessageQueryTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
- * @author Neil Clayton
- *
+ *
*/
public class MultipleTestsWithEmbeddedBrokerTest extends EmbeddedBrokerTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(MultipleTestsWithEmbeddedBrokerTest.class);
@@ -39,6 +36,7 @@ public class MultipleTestsWithEmbeddedBr
public void test2() throws Exception {
}
+ @Override
protected void setUp() throws Exception {
LOG.info("### starting up the test case: " + getName());
@@ -48,6 +46,7 @@ public class MultipleTestsWithEmbeddedBr
LOG.info("### started up the test case: " + getName());
}
+ @Override
protected void tearDown() throws Exception {
connection.close();