summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan Skinner <aidan@apache.org>2009-01-14 13:05:45 +0000
committerAidan Skinner <aidan@apache.org>2009-01-14 13:05:45 +0000
commit45dd4acdb87e52a1078b771c116b339b2fe775bb (patch)
treeaf0ebea7a3bf1973d8a9729f77d7445fd7b49e24
parent82e11b60852a7baa3272f4c31f848312ea274edb (diff)
downloadqpid-python-45dd4acdb87e52a1078b771c116b339b2fe775bb.tar.gz
QPID-1573: Change AMQQueueDeferredOrderingTest, ReturnUnroutableMandatoryMessageTest, DispatcherTest, PriorityTest and TimeToLiveTest to extend QpidTestCase
Add ReturnUnroutableMandatoryMessageTest, PriorityTest and TimeToLiveTest to the 010ExcludeList git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@734379 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/010ExcludeList4
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java19
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java34
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java69
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java33
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java90
6 files changed, 76 insertions, 173 deletions
diff --git a/qpid/java/010ExcludeList b/qpid/java/010ExcludeList
index 7512329220..c685f2dd6b 100644
--- a/qpid/java/010ExcludeList
+++ b/qpid/java/010ExcludeList
@@ -55,3 +55,7 @@ org.apache.qpid.server.security.acl.SimpleACLTest#testClientPublishInvalidQueueS
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#*
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
index fe418535d6..422c70d76b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
@@ -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 @@ public class AMQQueueDeferredOrderingTest extends TestCase
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 @@ public class AMQQueueDeferredOrderingTest extends TestCase
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);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
index 7cca22de6c..6b638ced58 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
@@ -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.jms.Session;
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 @@ import java.util.concurrent.TimeUnit;
* 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 @@ public class DispatcherTest extends TestCase
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 @@ public class DispatcherTest extends TestCase
_producerConnection.close();
super.tearDown();
- TransportConnection.killAllVMBrokers();
}
public void testAsynchronousRecieve()
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
index 74d3c5f1cb..a08e870873 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
@@ -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 @@ public class ReturnUnroutableMandatoryMessageTest extends TestCase implements Ex
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 @@ public class ReturnUnroutableMandatoryMessageTest extends TestCase implements Ex
*
* @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 @@ public class ReturnUnroutableMandatoryMessageTest extends TestCase implements Ex
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 @@ public class ReturnUnroutableMandatoryMessageTest extends TestCase implements Ex
//((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 class ReturnUnroutableMandatoryMessageTest extends TestCase implements Ex
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 @@ public class ReturnUnroutableMandatoryMessageTest extends TestCase implements Ex
//((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 class ReturnUnroutableMandatoryMessageTest extends TestCase implements Ex
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 @@ public class ReturnUnroutableMandatoryMessageTest extends TestCase implements Ex
//((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);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java
index bb386f9f6f..35b4d7c772 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java
@@ -29,6 +29,7 @@ import org.apache.qpid.client.AMQSession;
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.Hashtable;
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 @@ public class PriorityTest extends TestCase
{
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();
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
index c60748b5cb..291983f329 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/TimeToLiveTest.java
@@ -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 @@ public class TimeToLiveTest extends TestCase
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 @@ public class TimeToLiveTest extends TestCase
/**
* 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);