summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2006-11-07 14:14:13 +0000
committerMartin Ritchie <ritchiem@apache.org>2006-11-07 14:14:13 +0000
commit063f07b75654275ee80f9b3432932cad2a023a6c (patch)
tree84f081e8249fd764b4b4d292f4d4e0b40f7f897b
parentbd4af459d39288b8563c54418da7b6b35839f098 (diff)
downloadqpid-python-063f07b75654275ee80f9b3432932cad2a023a6c.tar.gz
Removed explicit VM references to allow auto creation to occur. Added some sleeps to allow broker instantiation during tests.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/java@472124 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--client/test/src/org/apache/qpid/client/TestAMQConnection.java20
-rw-r--r--client/test/src/org/apache/qpid/client/TestAMQSession.java52
-rw-r--r--client/test/src/org/apache/qpid/topic/DurableSubscriptionTest.java35
-rw-r--r--client/test/src/org/apache/qpid/topic/Publisher.java3
-rw-r--r--client/test/src/org/apache/qpid/transacted/TransactedTest.java47
5 files changed, 62 insertions, 95 deletions
diff --git a/client/test/src/org/apache/qpid/client/TestAMQConnection.java b/client/test/src/org/apache/qpid/client/TestAMQConnection.java
index d0e1a793f8..e656bf5fff 100644
--- a/client/test/src/org/apache/qpid/client/TestAMQConnection.java
+++ b/client/test/src/org/apache/qpid/client/TestAMQConnection.java
@@ -37,7 +37,6 @@ public class TestAMQConnection {
@BeforeClass
public static void setUp() throws AMQException, URLSyntaxException, JMSException {
//initialise the variables we need for testing
- startVmBrokers();
_connection = new AMQConnection("vm://:1", "guest", "guest", "fred", "/test");
_topic = new AMQTopic("mytopic");
_queue = new AMQQueue("myqueue");
@@ -95,27 +94,8 @@ public class TestAMQConnection {
_queueSession.unsubscribe("abc");
}
- @AfterClass
- public static void stopVmBrokers()
- {
- TransportConnection.killVMBroker(1);
- }
-
public static junit.framework.Test suite()
{
return new JUnit4TestAdapter(TestAMQConnection.class);
}
-
- private static void startVmBrokers()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create VM Broker: " + e.getMessage());
- }
- }
-
}
diff --git a/client/test/src/org/apache/qpid/client/TestAMQSession.java b/client/test/src/org/apache/qpid/client/TestAMQSession.java
index 3f2457f682..48ccc843f1 100644
--- a/client/test/src/org/apache/qpid/client/TestAMQSession.java
+++ b/client/test/src/org/apache/qpid/client/TestAMQSession.java
@@ -32,16 +32,17 @@ import junit.framework.JUnit4TestAdapter;
/**
* Tests for QueueReceiver and TopicSubscriber creation methods on AMQSession
*/
-public class TestAMQSession {
+public class TestAMQSession
+{
private static AMQSession _session;
private static AMQTopic _topic;
private static AMQQueue _queue;
@BeforeClass
- public static void setUp() throws AMQException, URLSyntaxException, JMSException {
+ public static void setUp() throws AMQException, URLSyntaxException, JMSException
+ {
//initialise the variables we need for testing
- startVmBrokers();
AMQConnection connection = new AMQConnection("vm://:1", "guest", "guest", "fred", "/test");
_topic = new AMQTopic("mytopic");
_queue = new AMQQueue("myqueue");
@@ -49,45 +50,48 @@ public class TestAMQSession {
}
@Test
- public void testCreateSubscriber() throws JMSException {
+ public void testCreateSubscriber() throws JMSException
+ {
TopicSubscriber subscriber = _session.createSubscriber(_topic);
- Assert.assertEquals("Topic names should match from TopicSubscriber",_topic.getTopicName(),subscriber.getTopic().getTopicName());
+ Assert.assertEquals("Topic names should match from TopicSubscriber", _topic.getTopicName(), subscriber.getTopic().getTopicName());
- subscriber = _session.createSubscriber(_topic,"abc",false);
- Assert.assertEquals("Topic names should match from TopicSubscriber with selector",_topic.getTopicName(),subscriber.getTopic().getTopicName());
+ subscriber = _session.createSubscriber(_topic, "abc", false);
+ Assert.assertEquals("Topic names should match from TopicSubscriber with selector", _topic.getTopicName(), subscriber.getTopic().getTopicName());
}
@Test
- public void testCreateDurableSubscriber() throws JMSException {
+ public void testCreateDurableSubscriber() throws JMSException
+ {
TopicSubscriber subscriber = _session.createDurableSubscriber(_topic, "mysubname");
- Assert.assertEquals("Topic names should match from durable TopicSubscriber",_topic.getTopicName(),subscriber.getTopic().getTopicName());
+ Assert.assertEquals("Topic names should match from durable TopicSubscriber", _topic.getTopicName(), subscriber.getTopic().getTopicName());
- subscriber = _session.createDurableSubscriber(_topic,"mysubname","abc",false);
- Assert.assertEquals("Topic names should match from durable TopicSubscriber with selector",_topic.getTopicName(),subscriber.getTopic().getTopicName());
+ subscriber = _session.createDurableSubscriber(_topic, "mysubname", "abc", false);
+ Assert.assertEquals("Topic names should match from durable TopicSubscriber with selector", _topic.getTopicName(), subscriber.getTopic().getTopicName());
}
@Test
- public void testCreateQueueReceiver() throws JMSException {
+ public void testCreateQueueReceiver() throws JMSException
+ {
QueueReceiver receiver = _session.createQueueReceiver(_queue);
- Assert.assertEquals("Queue names should match from QueueReceiver",_queue.getQueueName(),receiver.getQueue().getQueueName());
+ Assert.assertEquals("Queue names should match from QueueReceiver", _queue.getQueueName(), receiver.getQueue().getQueueName());
receiver = _session.createQueueReceiver(_queue, "abc");
- Assert.assertEquals("Queue names should match from QueueReceiver with selector",_queue.getQueueName(),receiver.getQueue().getQueueName());
+ Assert.assertEquals("Queue names should match from QueueReceiver with selector", _queue.getQueueName(), receiver.getQueue().getQueueName());
}
@Test
- public void testCreateReceiver() throws JMSException {
+ public void testCreateReceiver() throws JMSException
+ {
QueueReceiver receiver = _session.createReceiver(_queue);
- Assert.assertEquals("Queue names should match from QueueReceiver",_queue.getQueueName(),receiver.getQueue().getQueueName());
+ Assert.assertEquals("Queue names should match from QueueReceiver", _queue.getQueueName(), receiver.getQueue().getQueueName());
receiver = _session.createReceiver(_queue, "abc");
- Assert.assertEquals("Queue names should match from QueueReceiver with selector",_queue.getQueueName(),receiver.getQueue().getQueueName());
+ Assert.assertEquals("Queue names should match from QueueReceiver with selector", _queue.getQueueName(), receiver.getQueue().getQueueName());
}
@AfterClass
public static void stopVmBrokers()
{
- TransportConnection.killVMBroker(1);
_queue = null;
_topic = null;
_session = null;
@@ -98,15 +102,5 @@ public class TestAMQSession {
return new JUnit4TestAdapter(TestAMQSession.class);
}
- private static void startVmBrokers()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create VM Broker: " + e.getMessage());
- }
- }
+
}
diff --git a/client/test/src/org/apache/qpid/topic/DurableSubscriptionTest.java b/client/test/src/org/apache/qpid/topic/DurableSubscriptionTest.java
index 784c7d5c07..0f190c73a9 100644
--- a/client/test/src/org/apache/qpid/topic/DurableSubscriptionTest.java
+++ b/client/test/src/org/apache/qpid/topic/DurableSubscriptionTest.java
@@ -40,26 +40,6 @@ import javax.jms.TopicSubscriber;
public class DurableSubscriptionTest
{
-
- @Before
- public void startVmBrokers()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create VM Broker: " + e.getMessage());
- }
- }
-
- @After
- public void stopVmBrokers()
- {
- TransportConnection.killVMBroker(1);
- }
-
@Test
public void unsubscribe() throws AMQException, JMSException, URLSyntaxException
{
@@ -74,6 +54,21 @@ public class DurableSubscriptionTest
con.start();
+ // Sleep to ensure all queues have been created in the Broker.
+ try
+ {
+ System.out.println("Allowing Server to create queues");
+ Thread.sleep(2000);
+ }
+ catch (InterruptedException e)
+ {
+ //do nothing
+ }
+ finally
+ {
+ System.out.println("Setup Complete");
+ }
+
producer.send(session1.createTextMessage("A"));
Message msg;
diff --git a/client/test/src/org/apache/qpid/topic/Publisher.java b/client/test/src/org/apache/qpid/topic/Publisher.java
index 3b8c7ce810..9a26e9e7ad 100644
--- a/client/test/src/org/apache/qpid/topic/Publisher.java
+++ b/client/test/src/org/apache/qpid/topic/Publisher.java
@@ -154,7 +154,8 @@ public class Publisher implements MessageListener
}
sum -= min;
sum -= max;
- return (sum / times.length - 2);
+
+ return (sum / (times.length - 2));
}
public static void main(String[] argv) throws Exception
diff --git a/client/test/src/org/apache/qpid/transacted/TransactedTest.java b/client/test/src/org/apache/qpid/transacted/TransactedTest.java
index 3b102f5373..3a574ea158 100644
--- a/client/test/src/org/apache/qpid/transacted/TransactedTest.java
+++ b/client/test/src/org/apache/qpid/transacted/TransactedTest.java
@@ -53,34 +53,13 @@ public class TransactedTest
private MessageConsumer testConsumer1;
private MessageConsumer testConsumer2;
- @BeforeClass
- public static void setupBeforeClass()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create VM Broker: " + e.getMessage());
- }
- }
-
- @AfterClass
- public static void setupAfterClass()
- {
- TransportConnection.killVMBroker(1);
- }
@Before
public void setup() throws Exception
{
-
-
queue1 = new AMQQueue("Q1", false);
queue2 = new AMQQueue("Q2", false);
-
con = new AMQConnection("vm://:1", "guest", "guest", "TransactedTest", "/test");
session = con.createSession(true, 0);
consumer1 = session.createConsumer(queue1);
@@ -92,6 +71,21 @@ public class TransactedTest
prepProducer1 = prepSession.createProducer(queue1);
prepCon.start();
+ // Sleep to ensure all queues have been created in the Broker.
+ try
+ {
+ System.out.println("Allowing Server to create queues");
+ Thread.sleep(2000);
+ }
+ catch (InterruptedException e)
+ {
+ //do nothing
+ }
+ finally
+ {
+ System.out.println("Setup Complete");
+ }
+
//add some messages
prepProducer1.send(prepSession.createTextMessage("A"));
prepProducer1.send(prepSession.createTextMessage("B"));
@@ -103,17 +97,20 @@ public class TransactedTest
testConsumer2 = testSession.createConsumer(queue2);
testCon.start();
- // Sleep to ensure all queues have been created in the Broker.
+ // Sleep to ensure all queues have been created in the Broker.
try
{
- System.out.println("Finishing Setup");
- Thread.sleep(3000);
+ System.out.println("Allowing Server to create queues");
+ Thread.sleep(2000);
}
catch (InterruptedException e)
{
//do nothing
}
- System.out.println("Setup Complete");
+ finally
+ {
+ System.out.println("Setup Complete");
+ }
}
@After