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 {
baseDir = new File(".");
}
System.out.println("setting based dir="+baseDir);
debug = "true".equalsIgnoreCase((String) options.get("debug"));
usersFile = (String) options.get(USER_FILE)+"";

View File

@ -31,8 +31,8 @@ public class XStreamWireFormatTest extends MessageTest {
super.assertBeanMarshalls(original);
String xml = getXStreamWireFormat().toString((Command) original);
System.out.println(original.getClass().getName() + " as XML is:");
System.out.println(xml);
log.info(original.getClass().getName() + " as XML is:");
log.info(xml);
}
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.tcp.TcpTransportServer;
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.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
@ -52,6 +54,9 @@ import org.springframework.core.io.Resource;
* @version $Revision: 1.2 $
*/
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 DERBY_ROOT = "target/test-data/";
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... ");
JournalPersistenceAdapter pa = (JournalPersistenceAdapter) broker.getPersistenceAdapter();
System.out.println("Success");
log.info("Success");
} finally {
if (broker != null) {
broker.stop();
@ -128,7 +133,7 @@ public class ConfigTest extends TestCase {
assertTrue("Should have created a DefaultWireFormat",
((JDBCPersistenceAdapter)adapter).getWireFormat() instanceof DefaultWireFormat);
System.out.println("Success");
log.info("Success");
} finally {
if (broker != null) {
broker.stop();
@ -149,7 +154,7 @@ public class ConfigTest extends TestCase {
// Create broker from resource
System.out.print("Creating broker... ");
broker = createBroker("org/apache/activemq/config/example.xml");
System.out.println("Success");
log.info("Success");
try {
// Check broker configuration
@ -161,12 +166,12 @@ public class ConfigTest extends TestCase {
assertEquals("Broker Config Error (persistent)", false, broker.isPersistent());
assertEquals("Broker Config Error (useShutdownHook)", false, broker.isUseShutdownHook());
assertEquals("Broker Config Error (deleteAllMessagesOnStartup)", true, broker.isDeleteAllMessagesOnStartup());
System.out.println("Success");
log.info("Success");
// Check specific vm transport
System.out.print("Checking vm connector... ");
assertEquals("Should have a specific VM Connector", "vm://javacoola", broker.getVmConnectorURI().toString());
System.out.println("Success");
log.info("Success");
// Check transport connectors list
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 (tcpNoDelayEnabled)", true, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isTcpNoDelayEnabled());
assertEquals("WireFormat Config Error (cacheEnabled)", false, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isCacheEnabled());
System.out.println("Success");
log.info("Success");
// Check network connectors
System.out.print("Checking network connectors... ");
List networkConnectors = broker.getNetworkConnectors();
assertEquals("Should have a single network connector", 1, networkConnectors.size());
System.out.println("Success");
log.info("Success");
// Check dispatch policy configuration
System.out.print("Checking dispatch policies... ");
@ -210,7 +215,7 @@ public class ConfigTest extends TestCase {
dest = new ActiveMQTopic("Topic.StrictOrderDispatch");
assertTrue("Should have a strict order dispatch policy for " + dest.getTopicName(),
broker.getDestinationPolicy().getEntryFor(dest).getDispatchPolicy() instanceof StrictOrderDispatchPolicy);
System.out.println("Success");
log.info("Success");
// Check subscription policy configuration
System.out.print("Checking subscription recovery policies... ");
@ -241,7 +246,7 @@ public class ConfigTest extends TestCase {
subsPolicy instanceof TimedSubscriptionRecoveryPolicy);
assertEquals("TimedSubsPolicy Config Error (recoverDuration)", 25000,
((TimedSubscriptionRecoveryPolicy)subsPolicy).getRecoverDuration());
System.out.println("Success");
log.info("Success");
// Check usage manager
System.out.print("Checking memory manager configurations... ");
@ -249,9 +254,9 @@ public class ConfigTest extends TestCase {
assertTrue("Should have a memory manager", memMgr != null);
assertEquals("UsageManager Config Error (limit)", 200000, memMgr.getLimit());
assertEquals("UsageManager Config Error (percentUsageMinDelta)", 20, memMgr.getPercentUsageMinDelta());
System.out.println("Success");
log.info("Success");
System.out.println("Success");
log.info("Success");
} finally {
if (broker != null) {
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 directory at " + journalFile.getAbsolutePath(), journalFile.exists());
System.out.println("Success");
log.info("Success");
} finally {
if (broker != null) {
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 journal directory at " + journalFile.getAbsolutePath(), !journalFile.exists());
System.out.println("Success");
log.info("Success");
} finally {
if (broker != null) {
broker.stop();

View File

@ -16,19 +16,9 @@
*/
package org.apache.activemq.transport;
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
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.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 java.net.URI;
import java.util.ArrayList;
import java.util.List;
import javax.jms.Connection;
import javax.jms.DeliveryMode;
@ -41,17 +31,25 @@ import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
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 $
*/
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 boolean topic = true;
protected AtomicInteger receivedMessageCount = new AtomicInteger(0);
@ -85,7 +83,7 @@ public class TopicClusterTest extends TestCase implements MessageListener {
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);
} finally {
System.setProperty("activemq.store.dir", root);
@ -147,7 +145,7 @@ public class TopicClusterTest extends TestCase implements MessageListener {
* @param msg
*/
public void onMessage(Message msg) {
//System.out.println("GOT: " + msg);
//log.info("GOT: " + msg);
receivedMessageCount.incrementAndGet();
synchronized (receivedMessageCount) {
if (receivedMessageCount.get() >= expectedReceiveCount()) {

View File

@ -37,7 +37,7 @@ public class CompositeConsumeTest extends JmsTopicSendReceiveWithTwoConnectionsT
Message message = session.createTextMessage(data[i]);
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);

View File

@ -51,18 +51,18 @@ public class CompositePublishTest extends JmsSendReceiveTestSupport {
receiveConnection = createConnection();
receiveConnection.start();
System.out.println("Created sendConnection: " + sendConnection);
System.out.println("Created receiveConnection: " + receiveConnection);
log.info("Created sendConnection: " + sendConnection);
log.info("Created receiveConnection: " + receiveConnection);
session = sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
receiveSession = receiveConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println("Created sendSession: " + session);
System.out.println("Created receiveSession: " + receiveSession);
log.info("Created sendSession: " + session);
log.info("Created receiveSession: " + receiveSession);
producer = session.createProducer(null);
System.out.println("Created producer: " + producer);
log.info("Created producer: " + producer);
if (topic) {
consumerDestination = session.createTopic(getConsumerSubject());
@ -73,8 +73,8 @@ public class CompositePublishTest extends JmsSendReceiveTestSupport {
producerDestination = session.createQueue(getProducerSubject());
}
System.out.println("Created consumer destination: " + consumerDestination + " of type: " + consumerDestination.getClass());
System.out.println("Created producer destination: " + producerDestination + " of type: " + producerDestination.getClass());
log.info("Created consumer destination: " + consumerDestination + " of type: " + consumerDestination.getClass());
log.info("Created producer destination: " + producerDestination + " of type: " + producerDestination.getClass());
Destination[] destinations = getDestinations();
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) {
@ -120,7 +120,7 @@ public class CompositePublishTest extends JmsSendReceiveTestSupport {
waitForMessagesToBeDelivered();
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++) {

View File

@ -47,7 +47,7 @@ public class ConsumeTopicPrefetchTest extends ProducerConsumerTestSupport {
protected void testWithMessageCount(int messageCount) throws JMSException {
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());
for (int i = 0; i < messageCount; i++) {

View File

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

View File

@ -73,7 +73,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport {
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();
message = consumer.receive(RECEIVE_TIMEOUT);
@ -82,7 +82,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport {
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();
message = consumer.receive(2000);
@ -90,7 +90,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport {
closeConsumer();
System.out.println("Lets publish one more message now");
log.info("Lets publish one more message now");
publish();
makeConsumer();
@ -147,7 +147,7 @@ public class DurableConsumerCloseAndReconnectTest extends TestSupport {
protected void makeConsumer() throws Exception {
String durableName = getName();
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);
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"));
}
catch (JMSException e) {
System.out.println("Caught: " + e);
log.info("Caught: " + e);
}
try {

View File

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

View File

@ -59,7 +59,7 @@ public class PublishOnQueueConsumedMessageUsingActivemqXMLTest extends PublishOn
// Create broker from resource
System.out.print("Creating broker... ");
broker = createBroker("org/apache/activemq/usecases/activemq.xml");
System.out.println("Success");
log.info("Success");
super.setUp();
}
@ -71,11 +71,11 @@ public class PublishOnQueueConsumedMessageUsingActivemqXMLTest extends PublishOn
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
System.out.println("Closing Broker");
log.info("Closing Broker");
if (broker != null) {
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();
replyProducer.send(msgCopy);
//System.out.println("Sending reply: " + message);
//log.info("Sending reply: " + message);
super.onMessage(message);
}
catch (JMSException e) {
System.out.println("Failed to send message: " + e);
log.info("Failed to send message: " + e);
e.printStackTrace();
}
}
@ -59,7 +59,7 @@ public class PublishOnTopicConsumedMessageTest extends JmsTopicSendReceiveWithTw
}
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
System.out.print("Creating broker... ");
broker = createBroker("org/apache/activemq/usecases/activemq.xml");
System.out.println("Success");
log.info("Success");
super.setUp();
}
@ -70,11 +70,11 @@ public class PublishOnTopicConsumerMessageUsingActivemqXMLTest extends PublishOn
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
System.out.println("Closing Broker");
log.info("Closing Broker");
if (broker != null) {
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.HashMap;
import java.util.Map;
import java.net.URI;
import java.net.URISyntaxException;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
@ -34,10 +32,17 @@ import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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 String brokerUrl;
private String subject;
@ -127,7 +132,7 @@ public class QueueDuplicatesTest extends TestCase {
String txt = "Text Message: " + i;
TextMessage msg = session.createTextMessage(txt);
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);
}
session.close();
@ -141,7 +146,7 @@ public class QueueDuplicatesTest extends TestCase {
private Map msgs = new HashMap();
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 {
String id = message.getJMSMessageID();
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++) {
Message msg = consumer.receive(RECEIVE_TIMEOUT);
if (msg != null) {
//System.out.println("GOT: " + msg);
//log.info("GOT: " + msg);
messagesReceived.incrementAndGet();
}
}
@ -122,7 +122,7 @@ public class ReliableReconnectTest extends TestSupport {
Thread.sleep(2000);
for (int i = firstBatch;i < MESSAGE_COUNT;i++) {
Message msg = consumer.receive(RECEIVE_TIMEOUT);
//System.out.println("GOT: " + msg);
//log.info("GOT: " + msg);
if (msg != null) {
messagesReceived.incrementAndGet();
}

View File

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

View File

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