You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ai...@apache.org on 2009/01/14 14:06:12 UTC
svn commit: r734379 - in /qpid/trunk/qpid/java: ./
systests/src/main/java/org/apache/qpid/client/
systests/src/main/java/org/apache/qpid/server/exchange/
systests/src/main/java/org/apache/qpid/server/queue/
Author: aidan
Date: Wed Jan 14 05:05:45 2009
New Revision: 734379
URL: http://svn.apache.org/viewvc?rev=734379&view=rev
Log:
QPID-1573: Change AMQQueueDeferredOrderingTest, ReturnUnroutableMandatoryMessageTest, DispatcherTest, PriorityTest and TimeToLiveTest to extend QpidTestCase
Add ReturnUnroutableMandatoryMessageTest, PriorityTest and TimeToLiveTest to the 010ExcludeList
Modified:
qpid/trunk/qpid/java/010ExcludeList
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
Modified: qpid/trunk/qpid/java/010ExcludeList
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/010ExcludeList?rev=734379&r1=734378&r2=734379&view=diff
==============================================================================
--- qpid/trunk/qpid/java/010ExcludeList (original)
+++ qpid/trunk/qpid/java/010ExcludeList Wed Jan 14 05:05:45 2009
@@ -55,3 +55,7 @@
org.apache.qpid.test.client.timeouts.SyncWaitDelayTest#*
// QPID-1262, QPID-1119 : This test fails occasionally due to potential protocol issue.
org.apache.qpid.test.client.timeouts.SyncWaitTimeoutDelayTest#*
+// c++ broker doesn't support priorities, TTL or message bouncing
+org.apache.qpid.server.exchange.ReturnUnroutableMandatoryMessageTest#*
+org.apache.qpid.server.queue.PriorityTest#*
+org.apache.qpid.server.queue.TimeToLiveTest#*
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java?rev=734379&r1=734378&r2=734379&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java Wed Jan 14 05:05:45 2009
@@ -20,30 +20,26 @@
*/
package org.apache.qpid.client;
+import javax.jms.Connection;
+import javax.jms.Session;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.TextMessage;
-import junit.framework.TestCase;
-
import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.jms.Session;
+import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.client.transport.TransportConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * This class tests all the alerts an AMQQueue can throw based on threshold
- * values of different parameters
- */
-public class AMQQueueDeferredOrderingTest extends TestCase
+public class AMQQueueDeferredOrderingTest extends QpidTestCase
{
private static final int NUM_MESSAGES = 1000;
- private AMQConnection con;
+ private Connection con;
private Session session;
private AMQQueue queue;
private MessageConsumer consumer;
@@ -51,7 +47,6 @@
private static final Logger _logger = LoggerFactory.getLogger(AMQQueueDeferredOrderingTest.class);
private ASyncProducer producerThread;
- private static final String BROKER = "vm://:1";
private class ASyncProducer extends Thread
{
@@ -95,11 +90,11 @@
TransportConnection.createVMBroker(1);
_logger.info("Create Connection");
- con = new AMQConnection(BROKER, "guest", "guest", "OrderingTest", "test");
+ con = getConnection();
_logger.info("Create Session");
session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
_logger.info("Create Q");
- queue = new AMQQueue(session.getDefaultQueueExchangeName(), new AMQShortString("Q"), new AMQShortString("Q"),
+ queue = new AMQQueue(new AMQShortString("amq.direct"), new AMQShortString("Q"), new AMQShortString("Q"),
false, true);
_logger.info("Create Consumer of Q");
consumer = session.createConsumer(queue);
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java?rev=734379&r1=734378&r2=734379&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java Wed Jan 14 05:05:45 2009
@@ -20,13 +20,9 @@
*/
package org.apache.qpid.client;
-import junit.framework.TestCase;
-
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.Hashtable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -40,9 +36,11 @@
import javax.naming.Context;
import javax.naming.spi.InitialContextFactory;
-import java.util.Hashtable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery queue
@@ -56,7 +54,7 @@
* When setting the message listener later the _synchronousQueue is just poll()'ed and the first message delivered
* the remaining messages will be left on the queue and lost, subsequent messages on the session will arrive first.
*/
-public class DispatcherTest extends TestCase
+public class DispatcherTest extends QpidTestCase
{
private static final Logger _logger = LoggerFactory.getLogger(DispatcherTest.class);
@@ -78,28 +76,21 @@
protected void setUp() throws Exception
{
super.setUp();
- TransportConnection.createVMBroker(1);
InitialContextFactory factory = new PropertiesFileInitialContextFactory();
Hashtable<String, String> env = new Hashtable<String, String>();
- env.put("connectionfactory.connection", "amqp://guest:guest@MLT_ID/test?brokerlist='vm://:1'");
- env.put("queue.queue", "MessageListenerTest");
-
- _context = factory.getInitialContext(env);
-
- Queue queue = (Queue) _context.lookup("queue");
-
// Create Client 1
- _clientConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
+ _clientConnection = getConnection();
_clientSession = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Queue queue = _clientSession.createQueue(this.getClass().getName());
_consumer = _clientSession.createConsumer(queue);
// Create Producer
- _producerConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
+ _producerConnection = getConnection();
_producerConnection.start();
@@ -120,7 +111,6 @@
_producerConnection.close();
super.tearDown();
- TransportConnection.killAllVMBrokers();
}
public void testAsynchronousRecieve()
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java?rev=734379&r1=734378&r2=734379&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java Wed Jan 14 05:05:45 2009
@@ -21,33 +21,37 @@
package org.apache.qpid.server.exchange;
-import junit.framework.TestCase;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.jms.Connection;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
import org.apache.log4j.Logger;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.util.NullApplicationRegistry;
-import org.apache.qpid.client.*;
+import org.apache.qpid.client.AMQHeadersExchange;
+import org.apache.qpid.client.AMQNoRouteException;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.configuration.ClientProperties;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.url.AMQBindingURL;
-import org.apache.qpid.url.BindingURL;
-import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.AMQException;
-
-import javax.jms.*;
-import java.util.List;
-import java.util.Collections;
-import java.util.ArrayList;
-import java.net.URISyntaxException;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.url.AMQBindingURL;
+import org.apache.qpid.url.BindingURL;
-public class ReturnUnroutableMandatoryMessageTest extends TestCase implements ExceptionListener
+public class ReturnUnroutableMandatoryMessageTest extends QpidTestCase implements ExceptionListener
{
private static final Logger _logger = Logger.getLogger(ReturnUnroutableMandatoryMessageTest.class);
private final List<Message> _bouncedMessageList = Collections.synchronizedList(new ArrayList<Message>());
- private static final String VIRTUALHOST = "test";
- private static final String BROKER = "vm://:1";
static
{
@@ -58,21 +62,6 @@
System.out.println("QPID_WORK not set using tmp directory: " + tempdir);
System.setProperty("QPID_WORK", tempdir);
}
-// DOMConfigurator.configure("../broker/etc/log4j.xml");
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- TransportConnection.createVMBroker(1);
- ApplicationRegistry.initialise(new NullApplicationRegistry(), 1);
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- TransportConnection.killAllVMBrokers();
- ApplicationRegistry.remove(1);
}
/**
@@ -80,7 +69,7 @@
*
* @throws Exception
*/
- public void testReturnUnroutableMandatoryMessage_HEADERS() throws URISyntaxException, AMQException, JMSException
+ public void testReturnUnroutableMandatoryMessage_HEADERS() throws Exception
{
_bouncedMessageList.clear();
MessageConsumer consumer = null;
@@ -89,7 +78,7 @@
Connection con=null, con2 = null;
try
{
- con = new AMQConnection(BROKER, "guest", "guest", "consumer1", VIRTUALHOST);
+ con = getConnection();
AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
@@ -102,7 +91,7 @@
//((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME, ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
// This is the default now
- con2 = new AMQConnection(BROKER, "guest", "guest", "producer1", VIRTUALHOST);
+ con2 = getConnection();
con2.setExceptionListener(this);
producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
@@ -169,7 +158,7 @@
public void testReturnUnroutableMandatoryMessage_QUEUE() throws Exception
{
_bouncedMessageList.clear();
- Connection con = new AMQConnection(BROKER, "guest", "guest", "consumer1", VIRTUALHOST);
+ Connection con = getConnection();
AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
@@ -181,7 +170,7 @@
//((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME, ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
// This is the default now
- Connection con2 = new AMQConnection(BROKER, "guest", "guest", "producer1", VIRTUALHOST);
+ Connection con2 = getConnection();
con2.setExceptionListener(this);
AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
@@ -230,7 +219,7 @@
public void testReturnUnroutableMandatoryMessage_TOPIC() throws Exception
{
_bouncedMessageList.clear();
- Connection con = new AMQConnection(BROKER, "guest", "guest", "consumer1", VIRTUALHOST);
+ Connection con = getConnection();
AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
@@ -242,7 +231,7 @@
//((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME, ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
// This is the default now
- Connection con2 = new AMQConnection(BROKER, "guest", "guest", "producer1", VIRTUALHOST);
+ Connection con2 = getConnection();
con2.setExceptionListener(this);
AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java?rev=734379&r1=734378&r2=734379&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java Wed Jan 14 05:05:45 2009
@@ -29,6 +29,7 @@
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
+import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.AMQShortString;
@@ -42,22 +43,17 @@
import java.util.HashMap;
import java.util.Map;
-/** Test Case provided by client Non-functional Test NF101: heap exhaustion behaviour */
-public class PriorityTest extends TestCase
+public class PriorityTest extends QpidTestCase
{
private static final int TIMEOUT = 1500;
private static final Logger _logger = Logger.getLogger(PriorityTest.class);
-
- protected final String BROKER = "vm://:1";
- protected final String VHOST = "/test";
protected final String QUEUE = "PriorityQueue";
private static final int MSG_COUNT = 50;
- private Context context = null;
private Connection producerConnection;
private MessageProducer producer;
private Session producerSession;
@@ -72,41 +68,20 @@
{
super.setUp();
- if (usingInVMBroker())
- {
- TransportConnection.createVMBroker(1);
- }
-
- InitialContextFactory factory = new PropertiesFileInitialContextFactory();
- Hashtable<String, String> env = new Hashtable<String, String>();
-
- env.put("connectionfactory.connection", "amqp://guest:guest@PRIORITY_TEST_ID" + VHOST + "?brokerlist='" + BROKER + "'");
- env.put("queue.queue", QUEUE);
-
- context = factory.getInitialContext(env);
- producerConnection = ((ConnectionFactory) context.lookup("connection")).createConnection();
+ producerConnection = getConnection();
producerSession = producerConnection.createSession(true, Session.AUTO_ACKNOWLEDGE);
producerConnection.start();
- consumerConnection = ((ConnectionFactory) context.lookup("connection")).createConnection();
+ consumerConnection = getConnection();
consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
- private boolean usingInVMBroker()
- {
- return BROKER.startsWith("vm://");
- }
-
protected void tearDown() throws Exception
{
producerConnection.close();
consumerConnection.close();
- if (usingInVMBroker())
- {
- TransportConnection.killAllVMBrokers();
- }
super.tearDown();
}
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java?rev=734379&r1=734378&r2=734379&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java Wed Jan 14 05:05:45 2009
@@ -21,40 +21,26 @@
package org.apache.qpid.server.queue;
-import junit.framework.TestCase;
-import junit.framework.Assert;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.log4j.Logger;
-
+import javax.jms.Connection;
import javax.jms.JMSException;
-import javax.jms.Session;
+import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.naming.spi.InitialContextFactory;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import java.util.Hashtable;
+import javax.jms.Session;
+
+import junit.framework.Assert;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidTestCase;
-/** Test Case provided by client Non-functional Test NF101: heap exhaustion behaviour */
-public class TimeToLiveTest extends TestCase
+public class TimeToLiveTest extends QpidTestCase
{
private static final Logger _logger = Logger.getLogger(TimeToLiveTest.class);
-
- protected final String BROKER = "vm://:1";
- protected final String VHOST = "/test";
protected final String QUEUE = "TimeToLiveQueue";
private final long TIME_TO_LIVE = 1000L;
@@ -62,55 +48,18 @@
private static final int MSG_COUNT = 50;
private static final long SERVER_TTL_TIMEOUT = 60000L;
- protected void setUp() throws Exception
- {
- super.setUp();
-
- if (usingInVMBroker())
- {
- TransportConnection.createVMBroker(1);
- }
-
-
- }
-
- private boolean usingInVMBroker()
- {
- return BROKER.startsWith("vm://");
- }
-
- protected void tearDown() throws Exception
- {
- if (usingInVMBroker())
- {
- TransportConnection.killVMBroker(1);
- ApplicationRegistry.remove(1);
- }
- super.tearDown();
- }
-
- public void testPassiveTTL() throws JMSException, NamingException
+ public void testPassiveTTL() throws Exception
{
- InitialContextFactory factory = new PropertiesFileInitialContextFactory();
-
- Hashtable<String, String> env = new Hashtable<String, String>();
-
- env.put("connectionfactory.connection", "amqp://guest:guest@TTL_TEST_ID" + VHOST + "?brokerlist='" + BROKER + "'");
- env.put("queue.queue", QUEUE);
-
- Context context = factory.getInitialContext(env);
-
- Queue queue = (Queue) context.lookup("queue");
-
//Create Client 1
- Connection clientConnection = ((ConnectionFactory) context.lookup("connection")).createConnection();
-
+ Connection clientConnection = getConnection();
+
Session clientSession = clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
+ Queue queue = clientSession.createQueue(QUEUE);
+
MessageConsumer consumer = clientSession.createConsumer(queue);
//Create Producer
- Connection producerConnection = ((ConnectionFactory) context.lookup("connection")).createConnection();
+ Connection producerConnection = getConnection();
producerConnection.start();
@@ -176,10 +125,11 @@
/**
* Tests the expired messages get actively deleted even on queues which have no consumers
+ * @throws Exception
*/
- public void testActiveTTL() throws URLSyntaxException, AMQException, JMSException, InterruptedException
+ public void testActiveTTL() throws Exception
{
- Connection producerConnection = new AMQConnection(BROKER,"guest","guest","activeTTLtest","test");
+ Connection producerConnection = getConnection();
AMQSession producerSession = (AMQSession) producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = producerSession.createTemporaryQueue();
producerSession.declareAndBind((AMQDestination) queue);