converted more println in the test cases to log.info() calls.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@397324 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-04-26 22:33:48 +00:00
parent 0a3072998b
commit 25a50630ed
18 changed files with 129 additions and 107 deletions

View File

@ -69,7 +69,6 @@ public class PropertiesLoginModule implements LoginModule {
} else { } else {
baseDir = new File("."); baseDir = new File(".");
} }
System.out.println("setting based dir="+baseDir);
debug = "true".equalsIgnoreCase((String) options.get("debug")); debug = "true".equalsIgnoreCase((String) options.get("debug"));
usersFile = (String) options.get(USER_FILE)+""; usersFile = (String) options.get(USER_FILE)+"";

View File

@ -31,8 +31,8 @@ public class XStreamWireFormatTest extends MessageTest {
super.assertBeanMarshalls(original); super.assertBeanMarshalls(original);
String xml = getXStreamWireFormat().toString((Command) original); String xml = getXStreamWireFormat().toString((Command) original);
System.out.println(original.getClass().getName() + " as XML is:"); log.info(original.getClass().getName() + " as XML is:");
System.out.println(xml); log.info(xml);
} }
protected XStreamWireFormat getXStreamWireFormat() { protected XStreamWireFormat getXStreamWireFormat() {

View File

@ -43,6 +43,8 @@ import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
import org.apache.activemq.transport.activeio.ActiveIOTransportServer; import org.apache.activemq.transport.activeio.ActiveIOTransportServer;
import org.apache.activemq.transport.tcp.TcpTransportServer; import org.apache.activemq.transport.tcp.TcpTransportServer;
import org.apache.activemq.xbean.BrokerFactoryBean; import org.apache.activemq.xbean.BrokerFactoryBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.derby.jdbc.EmbeddedDataSource; import org.apache.derby.jdbc.EmbeddedDataSource;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
@ -52,6 +54,9 @@ import org.springframework.core.io.Resource;
* @version $Revision: 1.2 $ * @version $Revision: 1.2 $
*/ */
public class ConfigTest extends TestCase { public class ConfigTest extends TestCase {
private static final Log log = LogFactory.getLog(ConfigTest.class);
protected static final String JOURNAL_ROOT = "target/test-data/"; protected static final String JOURNAL_ROOT = "target/test-data/";
protected static final String DERBY_ROOT = "target/test-data/"; protected static final String DERBY_ROOT = "target/test-data/";
protected static final String CONF_ROOT = "src/sample-conf/"; protected static final String CONF_ROOT = "src/sample-conf/";
@ -99,7 +104,7 @@ public class ConfigTest extends TestCase {
System.out.print("Checking persistence adapter factory settings... "); System.out.print("Checking persistence adapter factory settings... ");
JournalPersistenceAdapter pa = (JournalPersistenceAdapter) broker.getPersistenceAdapter(); JournalPersistenceAdapter pa = (JournalPersistenceAdapter) broker.getPersistenceAdapter();
System.out.println("Success"); log.info("Success");
} finally { } finally {
if (broker != null) { if (broker != null) {
broker.stop(); broker.stop();
@ -128,7 +133,7 @@ public class ConfigTest extends TestCase {
assertTrue("Should have created a DefaultWireFormat", assertTrue("Should have created a DefaultWireFormat",
((JDBCPersistenceAdapter)adapter).getWireFormat() instanceof DefaultWireFormat); ((JDBCPersistenceAdapter)adapter).getWireFormat() instanceof DefaultWireFormat);
System.out.println("Success"); log.info("Success");
} finally { } finally {
if (broker != null) { if (broker != null) {
broker.stop(); broker.stop();
@ -149,7 +154,7 @@ public class ConfigTest extends TestCase {
// Create broker from resource // Create broker from resource
System.out.print("Creating broker... "); System.out.print("Creating broker... ");
broker = createBroker("org/apache/activemq/config/example.xml"); broker = createBroker("org/apache/activemq/config/example.xml");
System.out.println("Success"); log.info("Success");
try { try {
// Check broker configuration // Check broker configuration
@ -161,12 +166,12 @@ public class ConfigTest extends TestCase {
assertEquals("Broker Config Error (persistent)", false, broker.isPersistent()); assertEquals("Broker Config Error (persistent)", false, broker.isPersistent());
assertEquals("Broker Config Error (useShutdownHook)", false, broker.isUseShutdownHook()); assertEquals("Broker Config Error (useShutdownHook)", false, broker.isUseShutdownHook());
assertEquals("Broker Config Error (deleteAllMessagesOnStartup)", true, broker.isDeleteAllMessagesOnStartup()); assertEquals("Broker Config Error (deleteAllMessagesOnStartup)", true, broker.isDeleteAllMessagesOnStartup());
System.out.println("Success"); log.info("Success");
// Check specific vm transport // Check specific vm transport
System.out.print("Checking vm connector... "); System.out.print("Checking vm connector... ");
assertEquals("Should have a specific VM Connector", "vm://javacoola", broker.getVmConnectorURI().toString()); assertEquals("Should have a specific VM Connector", "vm://javacoola", broker.getVmConnectorURI().toString());
System.out.println("Success"); log.info("Success");
// Check transport connectors list // Check transport connectors list
System.out.print("Checking transport connectors... "); System.out.print("Checking transport connectors... ");
@ -188,13 +193,13 @@ public class ConfigTest extends TestCase {
assertEquals("WireFormat Config Error (stackTraceEnabled)", false, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isStackTraceEnabled()); assertEquals("WireFormat Config Error (stackTraceEnabled)", false, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isStackTraceEnabled());
assertEquals("WireFormat Config Error (tcpNoDelayEnabled)", true, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isTcpNoDelayEnabled()); assertEquals("WireFormat Config Error (tcpNoDelayEnabled)", true, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isTcpNoDelayEnabled());
assertEquals("WireFormat Config Error (cacheEnabled)", false, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isCacheEnabled()); assertEquals("WireFormat Config Error (cacheEnabled)", false, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isCacheEnabled());
System.out.println("Success"); log.info("Success");
// Check network connectors // Check network connectors
System.out.print("Checking network connectors... "); System.out.print("Checking network connectors... ");
List networkConnectors = broker.getNetworkConnectors(); List networkConnectors = broker.getNetworkConnectors();
assertEquals("Should have a single network connector", 1, networkConnectors.size()); assertEquals("Should have a single network connector", 1, networkConnectors.size());
System.out.println("Success"); log.info("Success");
// Check dispatch policy configuration // Check dispatch policy configuration
System.out.print("Checking dispatch policies... "); System.out.print("Checking dispatch policies... ");
@ -210,7 +215,7 @@ public class ConfigTest extends TestCase {
dest = new ActiveMQTopic("Topic.StrictOrderDispatch"); dest = new ActiveMQTopic("Topic.StrictOrderDispatch");
assertTrue("Should have a strict order dispatch policy for " + dest.getTopicName(), assertTrue("Should have a strict order dispatch policy for " + dest.getTopicName(),
broker.getDestinationPolicy().getEntryFor(dest).getDispatchPolicy() instanceof StrictOrderDispatchPolicy); broker.getDestinationPolicy().getEntryFor(dest).getDispatchPolicy() instanceof StrictOrderDispatchPolicy);
System.out.println("Success"); log.info("Success");
// Check subscription policy configuration // Check subscription policy configuration
System.out.print("Checking subscription recovery policies... "); System.out.print("Checking subscription recovery policies... ");
@ -241,7 +246,7 @@ public class ConfigTest extends TestCase {
subsPolicy instanceof TimedSubscriptionRecoveryPolicy); subsPolicy instanceof TimedSubscriptionRecoveryPolicy);
assertEquals("TimedSubsPolicy Config Error (recoverDuration)", 25000, assertEquals("TimedSubsPolicy Config Error (recoverDuration)", 25000,
((TimedSubscriptionRecoveryPolicy)subsPolicy).getRecoverDuration()); ((TimedSubscriptionRecoveryPolicy)subsPolicy).getRecoverDuration());
System.out.println("Success"); log.info("Success");
// Check usage manager // Check usage manager
System.out.print("Checking memory manager configurations... "); System.out.print("Checking memory manager configurations... ");
@ -249,9 +254,9 @@ public class ConfigTest extends TestCase {
assertTrue("Should have a memory manager", memMgr != null); assertTrue("Should have a memory manager", memMgr != null);
assertEquals("UsageManager Config Error (limit)", 200000, memMgr.getLimit()); assertEquals("UsageManager Config Error (limit)", 200000, memMgr.getLimit());
assertEquals("UsageManager Config Error (percentUsageMinDelta)", 20, memMgr.getPercentUsageMinDelta()); assertEquals("UsageManager Config Error (percentUsageMinDelta)", 20, memMgr.getPercentUsageMinDelta());
System.out.println("Success"); log.info("Success");
System.out.println("Success"); log.info("Success");
} finally { } finally {
if (broker != null) { if (broker != null) {
broker.stop(); broker.stop();
@ -278,7 +283,7 @@ public class ConfigTest extends TestCase {
assertTrue("Should have created a journal persistence adapter", adapter instanceof JournalPersistenceAdapter); assertTrue("Should have created a journal persistence adapter", adapter instanceof JournalPersistenceAdapter);
assertTrue("Should have created a journal directory at " + journalFile.getAbsolutePath(), journalFile.exists()); assertTrue("Should have created a journal directory at " + journalFile.getAbsolutePath(), journalFile.exists());
System.out.println("Success"); log.info("Success");
} finally { } finally {
if (broker != null) { if (broker != null) {
broker.stop(); broker.stop();
@ -310,7 +315,7 @@ public class ConfigTest extends TestCase {
assertTrue("Should have not created a derby directory at " + derbyFile.getAbsolutePath(), !derbyFile.exists()); assertTrue("Should have not created a derby directory at " + derbyFile.getAbsolutePath(), !derbyFile.exists());
assertTrue("Should have not created a journal directory at " + journalFile.getAbsolutePath(), !journalFile.exists()); assertTrue("Should have not created a journal directory at " + journalFile.getAbsolutePath(), !journalFile.exists());
System.out.println("Success"); log.info("Success");
} finally { } finally {
if (broker != null) { if (broker != null) {
broker.stop(); broker.stop();

View File

@ -16,19 +16,9 @@
*/ */
package org.apache.activemq.transport; package org.apache.activemq.transport;
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger; import java.net.URI;
import java.util.ArrayList;
import org.apache.activemq.ActiveMQConnectionFactory; import java.util.List;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTextMessage;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.network.NetworkConnector;
import org.apache.activemq.transport.discovery.rendezvous.RendezvousDiscoveryAgent;
import org.apache.activemq.util.ServiceStopper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.jms.Connection; import javax.jms.Connection;
import javax.jms.DeliveryMode; import javax.jms.DeliveryMode;
@ -41,17 +31,25 @@ import javax.jms.MessageProducer;
import javax.jms.Session; import javax.jms.Session;
import javax.jms.TextMessage; import javax.jms.TextMessage;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTextMessage;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.util.ServiceStopper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
/** /**
* @version $Revision: 1.1.1.1 $ * @version $Revision: 1.1.1.1 $
*/ */
public class TopicClusterTest extends TestCase implements MessageListener { public class TopicClusterTest extends TestCase implements MessageListener {
protected Log log = LogFactory.getLog(getClass()); protected final static Log log = LogFactory.getLog(TopicClusterTest.class);
protected Destination destination; protected Destination destination;
protected boolean topic = true; protected boolean topic = true;
protected AtomicInteger receivedMessageCount = new AtomicInteger(0); protected AtomicInteger receivedMessageCount = new AtomicInteger(0);
@ -85,7 +83,7 @@ public class TopicClusterTest extends TestCase implements MessageListener {
consumer.setMessageListener(this); consumer.setMessageListener(this);
} }
System.out.println("Sleeping to ensure cluster is fully connected"); log.info("Sleeping to ensure cluster is fully connected");
Thread.sleep(5000); Thread.sleep(5000);
} finally { } finally {
System.setProperty("activemq.store.dir", root); System.setProperty("activemq.store.dir", root);
@ -147,7 +145,7 @@ public class TopicClusterTest extends TestCase implements MessageListener {
* @param msg * @param msg
*/ */
public void onMessage(Message msg) { public void onMessage(Message msg) {
//System.out.println("GOT: " + msg); //log.info("GOT: " + msg);
receivedMessageCount.incrementAndGet(); receivedMessageCount.incrementAndGet();
synchronized (receivedMessageCount) { synchronized (receivedMessageCount) {
if (receivedMessageCount.get() >= expectedReceiveCount()) { if (receivedMessageCount.get() >= expectedReceiveCount()) {

View File

@ -37,7 +37,7 @@ public class CompositeConsumeTest extends JmsTopicSendReceiveWithTwoConnectionsT
Message message = session.createTextMessage(data[i]); Message message = session.createTextMessage(data[i]);
if (verbose) { if (verbose) {
System.out.println("About to send a message: " + message + " with text: " + data[i]); log.info("About to send a message: " + message + " with text: " + data[i]);
} }
producer.send(destinations[destIdx], message); producer.send(destinations[destIdx], message);

View File

@ -51,18 +51,18 @@ public class CompositePublishTest extends JmsSendReceiveTestSupport {
receiveConnection = createConnection(); receiveConnection = createConnection();
receiveConnection.start(); receiveConnection.start();
System.out.println("Created sendConnection: " + sendConnection); log.info("Created sendConnection: " + sendConnection);
System.out.println("Created receiveConnection: " + receiveConnection); log.info("Created receiveConnection: " + receiveConnection);
session = sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); session = sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
receiveSession = receiveConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); receiveSession = receiveConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println("Created sendSession: " + session); log.info("Created sendSession: " + session);
System.out.println("Created receiveSession: " + receiveSession); log.info("Created receiveSession: " + receiveSession);
producer = session.createProducer(null); producer = session.createProducer(null);
System.out.println("Created producer: " + producer); log.info("Created producer: " + producer);
if (topic) { if (topic) {
consumerDestination = session.createTopic(getConsumerSubject()); consumerDestination = session.createTopic(getConsumerSubject());
@ -73,8 +73,8 @@ public class CompositePublishTest extends JmsSendReceiveTestSupport {
producerDestination = session.createQueue(getProducerSubject()); producerDestination = session.createQueue(getProducerSubject());
} }
System.out.println("Created consumer destination: " + consumerDestination + " of type: " + consumerDestination.getClass()); log.info("Created consumer destination: " + consumerDestination + " of type: " + consumerDestination.getClass());
System.out.println("Created producer destination: " + producerDestination + " of type: " + producerDestination.getClass()); log.info("Created producer destination: " + producerDestination + " of type: " + producerDestination.getClass());
Destination[] destinations = getDestinations(); Destination[] destinations = getDestinations();
consumers = new MessageConsumer[destinations.length]; consumers = new MessageConsumer[destinations.length];
@ -87,7 +87,7 @@ public class CompositePublishTest extends JmsSendReceiveTestSupport {
} }
System.out.println("Started connections"); log.info("Started connections");
} }
protected MessageListener createMessageListener(int i, final List messageList) { protected MessageListener createMessageListener(int i, final List messageList) {
@ -120,7 +120,7 @@ public class CompositePublishTest extends JmsSendReceiveTestSupport {
waitForMessagesToBeDelivered(); waitForMessagesToBeDelivered();
for (int i = 0, size = messageLists.length; i < size; i++) { for (int i = 0, size = messageLists.length; i < size; i++) {
System.out.println("Message list: " + i + " contains: " + messageLists[i].size() + " message(s)"); log.info("Message list: " + i + " contains: " + messageLists[i].size() + " message(s)");
} }
for (int i = 0, size = messageLists.length; i < size; i++) { for (int i = 0, size = messageLists.length; i < size; i++) {

View File

@ -47,7 +47,7 @@ public class ConsumeTopicPrefetchTest extends ProducerConsumerTestSupport {
protected void testWithMessageCount(int messageCount) throws JMSException { protected void testWithMessageCount(int messageCount) throws JMSException {
makeMessages(messageCount); makeMessages(messageCount);
System.out.println("About to send and receive: " + messageCount + " on destination: " + destination log.info("About to send and receive: " + messageCount + " on destination: " + destination
+ " of type: " + destination.getClass().getName()); + " of type: " + destination.getClass().getName());
for (int i = 0; i < messageCount; i++) { for (int i = 0; i < messageCount; i++) {

View File

@ -46,20 +46,20 @@ public class CreateLotsOfTemporaryQueuesTest extends EmbeddedBrokerTestSupport {
} }
public void testCreateLotsOfTemporaryQueues() throws Exception { public void testCreateLotsOfTemporaryQueues() throws Exception {
System.out.println("Creating " + numberToCreate + " temporary queue(s)"); log.info("Creating " + numberToCreate + " temporary queue(s)");
Connection connection = createConnection(); Connection connection = createConnection();
connection.start(); connection.start();
Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
for (int i = 0; i < numberToCreate; i++) { for (int i = 0; i < numberToCreate; i++) {
if (i % 1000 == 0) { if (i % 1000 == 0) {
System.out.println("attempt " + i); log.info("attempt " + i);
} }
TemporaryQueue temporaryQueue = session.createTemporaryQueue(); TemporaryQueue temporaryQueue = session.createTemporaryQueue();
temporaryQueue.delete(); temporaryQueue.delete();
Thread.sleep(sleep ); Thread.sleep(sleep );
} }
System.out.println("Created " + numberToCreate + " temporary queue(s)"); log.info("Created " + numberToCreate + " temporary queue(s)");
connection.close(); connection.close();
} }

View File

@ -73,7 +73,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport {
closeConsumer(); closeConsumer();
System.out.println("Now lets create the consumer again and because we didn't ack, we should get it again"); log.info("Now lets create the consumer again and because we didn't ack, we should get it again");
makeConsumer(); makeConsumer();
message = consumer.receive(RECEIVE_TIMEOUT); message = consumer.receive(RECEIVE_TIMEOUT);
@ -82,7 +82,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport {
closeConsumer(); closeConsumer();
System.out.println("Now lets create the consumer again and because we didn't ack, we should get it again"); log.info("Now lets create the consumer again and because we didn't ack, we should get it again");
makeConsumer(); makeConsumer();
message = consumer.receive(2000); message = consumer.receive(2000);
@ -90,7 +90,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport {
closeConsumer(); closeConsumer();
System.out.println("Lets publish one more message now"); log.info("Lets publish one more message now");
publish(); publish();
makeConsumer(); makeConsumer();
@ -147,7 +147,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport {
protected void makeConsumer() throws Exception { protected void makeConsumer() throws Exception {
String durableName = getName(); String durableName = getName();
String clientID = getSubject(); String clientID = getSubject();
System.out.println("Creating a durable subscribe for clientID: " + clientID + " and durable name: " + durableName); log.info("Creating a durable subscribe for clientID: " + clientID + " and durable name: " + durableName);
createSession(clientID); createSession(clientID);
consumer = createConsumer(durableName); consumer = createConsumer(durableName);
} }

View File

@ -71,7 +71,7 @@ public class ExceptionListenerTest extends TestCase implements ExceptionListener
producer.send(session.createTextMessage("This will never get anywhere")); producer.send(session.createTextMessage("This will never get anywhere"));
} }
catch (JMSException e) { catch (JMSException e) {
System.out.println("Caught: " + e); log.info("Caught: " + e);
} }
try { try {

View File

@ -19,6 +19,8 @@ package org.apache.activemq.usecases;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQQueue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.jms.*; import javax.jms.*;
import java.util.List; import java.util.List;
@ -29,6 +31,8 @@ import java.io.File;
public final class PublishOnQueueConsumedMessageInTransactionTest extends TestCase implements MessageListener { public final class PublishOnQueueConsumedMessageInTransactionTest extends TestCase implements MessageListener {
private static final Log log = LogFactory.getLog(PublishOnQueueConsumedMessageInTransactionTest.class);
private Session producerSession; private Session producerSession;
private Session consumerSession; private Session consumerSession;
private Destination queue; private Destination queue;
@ -89,12 +93,12 @@ public final class PublishOnQueueConsumedMessageInTransactionTest extends TestCa
objectMessage = producerSession.createObjectMessage(data[i]); objectMessage = producerSession.createObjectMessage(data[i]);
producer.send(objectMessage); producer.send(objectMessage);
producerSession.commit(); producerSession.commit();
System.out.println("sending message :" + objectMessage); log.info("sending message :" + objectMessage);
} }
} catch (Exception e) { } catch (Exception e) {
if (producerSession != null) { if (producerSession != null) {
producerSession.rollback(); producerSession.rollback();
System.out.println("rollback"); log.info("rollback");
producerSession.close(); producerSession.close();
} }
@ -108,18 +112,18 @@ public final class PublishOnQueueConsumedMessageInTransactionTest extends TestCa
objectMessage = (ObjectMessage) m; objectMessage = (ObjectMessage) m;
consumeMessage(objectMessage,messages); consumeMessage(objectMessage,messages);
System.out.println("consumer received message :" + objectMessage); log.info("consumer received message :" + objectMessage);
consumerSession.commit(); consumerSession.commit();
} catch (Exception e) { } catch (Exception e) {
try { try {
consumerSession.rollback(); consumerSession.rollback();
System.out.println("rolled back transaction"); log.info("rolled back transaction");
} catch (JMSException e1) { } catch (JMSException e1) {
System.out.println(e1); log.info(e1);
e1.printStackTrace(); e1.printStackTrace();
} }
System.out.println(e); log.info(e);
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -59,7 +59,7 @@ public class PublishOnQueueConsumedMessageUsingActivemqXMLTest extends PublishOn
// Create broker from resource // Create broker from resource
System.out.print("Creating broker... "); System.out.print("Creating broker... ");
broker = createBroker("org/apache/activemq/usecases/activemq.xml"); broker = createBroker("org/apache/activemq/usecases/activemq.xml");
System.out.println("Success"); log.info("Success");
super.setUp(); super.setUp();
} }
@ -71,11 +71,11 @@ public class PublishOnQueueConsumedMessageUsingActivemqXMLTest extends PublishOn
* @see junit.framework.TestCase#tearDown() * @see junit.framework.TestCase#tearDown()
*/ */
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
System.out.println("Closing Broker"); log.info("Closing Broker");
if (broker != null) { if (broker != null) {
broker.stop(); broker.stop();
} }
System.out.println("Broker closed..."); log.info("Broker closed...");
} }

View File

@ -37,11 +37,11 @@ public class PublishOnTopicConsumedMessageTest extends JmsTopicSendReceiveWithTw
Message msgCopy = (Message)((org.apache.activemq.command.Message)message).copy(); Message msgCopy = (Message)((org.apache.activemq.command.Message)message).copy();
replyProducer.send(msgCopy); replyProducer.send(msgCopy);
//System.out.println("Sending reply: " + message); //log.info("Sending reply: " + message);
super.onMessage(message); super.onMessage(message);
} }
catch (JMSException e) { catch (JMSException e) {
System.out.println("Failed to send message: " + e); log.info("Failed to send message: " + e);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -59,7 +59,7 @@ public class PublishOnTopicConsumedMessageTest extends JmsTopicSendReceiveWithTw
} }
replyProducer = receiveSession.createProducer(replyDestination); replyProducer = receiveSession.createProducer(replyDestination);
System.out.println("Created replyProducer: " + replyProducer); log.info("Created replyProducer: " + replyProducer);
} }
} }

View File

@ -58,7 +58,7 @@ public class PublishOnTopicConsumerMessageUsingActivemqXMLTest extends PublishOn
// Create broker from resource // Create broker from resource
System.out.print("Creating broker... "); System.out.print("Creating broker... ");
broker = createBroker("org/apache/activemq/usecases/activemq.xml"); broker = createBroker("org/apache/activemq/usecases/activemq.xml");
System.out.println("Success"); log.info("Success");
super.setUp(); super.setUp();
} }
@ -70,11 +70,11 @@ public class PublishOnTopicConsumerMessageUsingActivemqXMLTest extends PublishOn
* @see junit.framework.TestCase#tearDown() * @see junit.framework.TestCase#tearDown()
*/ */
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
System.out.println("Closing Broker"); log.info("Closing Broker");
if (broker != null) { if (broker != null) {
broker.stop(); broker.stop();
} }
System.out.println("Broker closed..."); log.info("Broker closed...");
} }

View File

@ -21,10 +21,8 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.net.URI;
import java.net.URISyntaxException;
import javax.jms.Connection; import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode; import javax.jms.DeliveryMode;
import javax.jms.Destination; import javax.jms.Destination;
import javax.jms.JMSException; import javax.jms.JMSException;
@ -34,10 +32,17 @@ import javax.jms.MessageListener;
import javax.jms.MessageProducer; import javax.jms.MessageProducer;
import javax.jms.Session; import javax.jms.Session;
import javax.jms.TextMessage; import javax.jms.TextMessage;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class QueueDuplicatesTest extends TestCase { public class QueueDuplicatesTest extends TestCase {
private static final Log log = LogFactory.getLog(QueueDuplicatesTest.class);
private static DateFormat formatter = new SimpleDateFormat("HH:mm:ss SSS"); private static DateFormat formatter = new SimpleDateFormat("HH:mm:ss SSS");
private String brokerUrl; private String brokerUrl;
private String subject; private String subject;
@ -127,7 +132,7 @@ public class QueueDuplicatesTest extends TestCase {
String txt = "Text Message: " + i; String txt = "Text Message: " + i;
TextMessage msg = session.createTextMessage(txt); TextMessage msg = session.createTextMessage(txt);
producer.send(msg); producer.send(msg);
System.out.println(formatter.format(new Date()) + " Sent ==> " + msg + " to " + subject); log.info(formatter.format(new Date()) + " Sent ==> " + msg + " to " + subject);
Thread.sleep(1000); Thread.sleep(1000);
} }
session.close(); session.close();
@ -141,7 +146,7 @@ public class QueueDuplicatesTest extends TestCase {
private Map msgs = new HashMap(); private Map msgs = new HashMap();
public void onMessage(Message message) { public void onMessage(Message message) {
System.out.println(formatter.format(new Date()) + " SimpleConsumer Message Received: " + message); log.info(formatter.format(new Date()) + " SimpleConsumer Message Received: " + message);
try { try {
String id = message.getJMSMessageID(); String id = message.getJMSMessageID();
assertNull("Message is duplicate: " + id, msgs.get(id)); assertNull("Message is duplicate: " + id, msgs.get(id));

View File

@ -111,7 +111,7 @@ public class ReliableReconnectTest extends TestSupport {
for (int i = 0;i < firstBatch;i++) { for (int i = 0;i < firstBatch;i++) {
Message msg = consumer.receive(RECEIVE_TIMEOUT); Message msg = consumer.receive(RECEIVE_TIMEOUT);
if (msg != null) { if (msg != null) {
//System.out.println("GOT: " + msg); //log.info("GOT: " + msg);
messagesReceived.incrementAndGet(); messagesReceived.incrementAndGet();
} }
} }
@ -122,7 +122,7 @@ public class ReliableReconnectTest extends TestSupport {
Thread.sleep(2000); Thread.sleep(2000);
for (int i = firstBatch;i < MESSAGE_COUNT;i++) { for (int i = firstBatch;i < MESSAGE_COUNT;i++) {
Message msg = consumer.receive(RECEIVE_TIMEOUT); Message msg = consumer.receive(RECEIVE_TIMEOUT);
//System.out.println("GOT: " + msg); //log.info("GOT: " + msg);
if (msg != null) { if (msg != null) {
messagesReceived.incrementAndGet(); messagesReceived.incrementAndGet();
} }

View File

@ -16,11 +16,8 @@
*/ */
package org.apache.activemq.usecases; package org.apache.activemq.usecases;
import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch; import java.util.ArrayList;
import junit.framework.TestCase; import java.util.List;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import javax.jms.Connection; import javax.jms.Connection;
import javax.jms.Destination; import javax.jms.Destination;
@ -31,8 +28,15 @@ import javax.jms.MessageListener;
import javax.jms.MessageProducer; import javax.jms.MessageProducer;
import javax.jms.Session; import javax.jms.Session;
import javax.jms.TextMessage; import javax.jms.TextMessage;
import java.util.ArrayList;
import java.util.List; import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
/** /**
@ -42,6 +46,7 @@ import java.util.List;
* @version $Revision: 1.1 $ * @version $Revision: 1.1 $
*/ */
public final class TransactionRollbackOrderTest extends TestCase { public final class TransactionRollbackOrderTest extends TestCase {
private static final Log log = LogFactory.getLog(TransactionRollbackOrderTest.class);
private volatile String receivedText; private volatile String receivedText;
@ -87,17 +92,17 @@ public final class TransactionRollbackOrderTest extends TestCase {
msgRedelivered.add(receivedText); msgRedelivered.add(receivedText);
} }
System.out.println("consumer received message: " + receivedText + (tm.getJMSRedelivered() ? " ** Redelivered **" : "")); log.info("consumer received message: " + receivedText + (tm.getJMSRedelivered() ? " ** Redelivered **" : ""));
if (msgCount == 3) { if (msgCount == 3) {
msgRolledBack.add(receivedText); msgRolledBack.add(receivedText);
consumerSession.rollback(); consumerSession.rollback();
System.out.println("[msg: " + receivedText + "] ** rolled back **"); log.info("[msg: " + receivedText + "] ** rolled back **");
} }
else { else {
msgCommittedCount++; msgCommittedCount++;
msgCommitted.add(receivedText); msgCommitted.add(receivedText);
consumerSession.commit(); consumerSession.commit();
System.out.println("[msg: " + receivedText + "] committed transaction "); log.info("[msg: " + receivedText + "] committed transaction ");
} }
if (msgCommittedCount == NUM_MESSAGES) { if (msgCommittedCount == NUM_MESSAGES) {
latch.countDown(); latch.countDown();
@ -106,13 +111,13 @@ public final class TransactionRollbackOrderTest extends TestCase {
catch (JMSException e) { catch (JMSException e) {
try { try {
consumerSession.rollback(); consumerSession.rollback();
System.out.println("rolled back transaction"); log.info("rolled back transaction");
} }
catch (JMSException e1) { catch (JMSException e1) {
System.out.println(e1); log.info(e1);
e1.printStackTrace(); e1.printStackTrace();
} }
System.out.println(e); log.info(e);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -126,21 +131,21 @@ public final class TransactionRollbackOrderTest extends TestCase {
tm.setText("Hello " + i); tm.setText("Hello " + i);
msgSent.add(tm.getText()); msgSent.add(tm.getText());
producer.send(tm); producer.send(tm);
System.out.println("producer sent message: " + tm.getText()); log.info("producer sent message: " + tm.getText());
} }
} }
catch (JMSException e) { catch (JMSException e) {
e.printStackTrace(); e.printStackTrace();
} }
System.out.println("Waiting for latch"); log.info("Waiting for latch");
latch.await(); latch.await();
assertEquals(1, msgRolledBack.size()); assertEquals(1, msgRolledBack.size());
assertEquals(1, msgRedelivered.size()); assertEquals(1, msgRedelivered.size());
System.out.println("msg RolledBack = " + msgRolledBack.get(0)); log.info("msg RolledBack = " + msgRolledBack.get(0));
System.out.println("msg Redelivered = " + msgRedelivered.get(0)); log.info("msg Redelivered = " + msgRedelivered.get(0));
assertEquals(msgRolledBack.get(0), msgRedelivered.get(0)); assertEquals(msgRolledBack.get(0), msgRedelivered.get(0));
@ -153,7 +158,7 @@ public final class TransactionRollbackOrderTest extends TestCase {
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
if (connection != null) { if (connection != null) {
System.out.println("Closing the connection"); log.info("Closing the connection");
connection.close(); connection.close();
} }
super.tearDown(); super.tearDown();

View File

@ -16,9 +16,7 @@
*/ */
package org.apache.activemq.usecases; package org.apache.activemq.usecases;
import junit.framework.TestCase; import java.util.Date;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import javax.jms.Connection; import javax.jms.Connection;
import javax.jms.Destination; import javax.jms.Destination;
@ -29,7 +27,13 @@ import javax.jms.MessageListener;
import javax.jms.MessageProducer; import javax.jms.MessageProducer;
import javax.jms.Session; import javax.jms.Session;
import javax.jms.TextMessage; import javax.jms.TextMessage;
import java.util.Date;
import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch; import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
@ -38,6 +42,8 @@ import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
* @version $Revision: 1.1.1.1 $ * @version $Revision: 1.1.1.1 $
*/ */
public final class TransactionTest extends TestCase { public final class TransactionTest extends TestCase {
private static final Log log = LogFactory.getLog(TransactionTest.class);
private volatile String receivedText; private volatile String receivedText;
@ -70,20 +76,20 @@ public final class TransactionTest extends TestCase {
receivedText = tm.getText(); receivedText = tm.getText();
latch.countDown(); latch.countDown();
System.out.println("consumer received message :" + receivedText); log.info("consumer received message :" + receivedText);
consumerSession.commit(); consumerSession.commit();
System.out.println("committed transaction"); log.info("committed transaction");
} }
catch (JMSException e) { catch (JMSException e) {
try { try {
consumerSession.rollback(); consumerSession.rollback();
System.out.println("rolled back transaction"); log.info("rolled back transaction");
} }
catch (JMSException e1) { catch (JMSException e1) {
System.out.println(e1); log.info(e1);
e1.printStackTrace(); e1.printStackTrace();
} }
System.out.println(e); log.info(e);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -96,16 +102,16 @@ public final class TransactionTest extends TestCase {
tm = producerSession.createTextMessage(); tm = producerSession.createTextMessage();
tm.setText("Hello, " + new Date()); tm.setText("Hello, " + new Date());
producer.send(tm); producer.send(tm);
System.out.println("producer sent message :" + tm.getText()); log.info("producer sent message :" + tm.getText());
} }
catch (JMSException e) { catch (JMSException e) {
e.printStackTrace(); e.printStackTrace();
} }
System.out.println("Waiting for latch"); log.info("Waiting for latch");
latch.await(); latch.await();
System.out.println("test completed, destination=" + receivedText); log.info("test completed, destination=" + receivedText);
} }
protected void tearDown() throws Exception { protected void tearDown() throws Exception {