summaryrefslogtreecommitdiff
path: root/java/systests/src/test
diff options
context:
space:
mode:
authorStephen Vinoski <vinoski@apache.org>2006-11-19 04:14:42 +0000
committerStephen Vinoski <vinoski@apache.org>2006-11-19 04:14:42 +0000
commit26f3bd59751462922e4c3268392a526a60ef7b2f (patch)
tree33d4dcf6804551948e3c78233494e29fbba95c4e /java/systests/src/test
parentbe9f473e274d6cfe4cf8d8b04dd3f5a171ba9de4 (diff)
downloadqpid-python-26f3bd59751462922e4c3268392a526a60ef7b2f.tar.gz
convert tests to junit3
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@476701 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/systests/src/test')
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/UnitTests.java42
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/ack/TxAckTest.java28
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/ack/UnitTests.java37
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTest.java6
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java16
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/exchange/UnitTests.java35
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/protocol/TestProtocolInitiation.java119
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/protocol/UnitTests.java35
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java31
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java21
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java5
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java71
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/MessageTestHelper.java4
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionManagerTest.java16
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionSetTest.java24
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java7
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/store/TestReferenceCounting.java24
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/store/UnitTests.java37
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/txn/TxnBufferTest.java31
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/txn/UnitTests.java37
-rw-r--r--java/systests/src/test/java/org/apache/qpid/test/VMBrokerSetup.java (renamed from java/systests/src/test/java/org/apache/qpid/server/queue/UnitTests.java)43
-rw-r--r--java/systests/src/test/java/org/apache/qpid/test/unit/ack/DisconnectAndRedeliverTest.java61
-rw-r--r--java/systests/src/test/java/org/apache/qpid/test/unit/ack/UnitTests.java35
23 files changed, 252 insertions, 513 deletions
diff --git a/java/systests/src/test/java/org/apache/qpid/server/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/server/UnitTests.java
deleted file mode 100644
index 1f4af59ce7..0000000000
--- a/java/systests/src/test/java/org/apache/qpid/server/UnitTests.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.server;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- org.apache.qpid.server.ack.UnitTests.class,
- org.apache.qpid.server.exchange.UnitTests.class,
- org.apache.qpid.server.protocol.UnitTests.class,
- org.apache.qpid.server.queue.UnitTests.class,
- org.apache.qpid.server.store.UnitTests.class,
- org.apache.qpid.server.txn.UnitTests.class
- })
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/ack/TxAckTest.java b/java/systests/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
index fe2c189c39..1a15ca7561 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
@@ -20,12 +20,6 @@
*/
package org.apache.qpid.server.ack;
-import junit.framework.JUnit4TestAdapter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Ignore;
import org.apache.qpid.AMQException;
import org.apache.qpid.server.queue.AMQMessage;
import org.apache.qpid.server.store.TestableMemoryMessageStore;
@@ -35,15 +29,18 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
-public class TxAckTest
+import junit.framework.TestCase;
+
+public class TxAckTest extends TestCase
{
private Scenario individual;
private Scenario multiple;
private Scenario combined;
- @Before
- public void setup() throws Exception
- {
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
//ack only 5th msg
individual = new Scenario(10, Arrays.asList(5l), Arrays.asList(1l, 2l, 3l, 4l, 6l, 7l, 8l, 9l, 10l));
individual.update(5, false);
@@ -62,24 +59,21 @@ public class TxAckTest
combined.update(10, false);
}
- @Test
- public void prepare() throws AMQException
+ public void testPrepare() throws AMQException
{
individual.prepare();
multiple.prepare();
combined.prepare();
}
- @Test
- public void undoPrepare() throws AMQException
+ public void testUndoPrepare() throws AMQException
{
individual.undoPrepare();
multiple.undoPrepare();
combined.undoPrepare();
}
- @Test
- public void commit() throws AMQException
+ public void testCommit() throws AMQException
{
individual.commit();
multiple.commit();
@@ -88,7 +82,7 @@ public class TxAckTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TxAckTest.class);
+ return new junit.framework.TestSuite(TxAckTest.class);
}
private class Scenario
diff --git a/java/systests/src/test/java/org/apache/qpid/server/ack/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/server/ack/UnitTests.java
deleted file mode 100644
index 45ffe1fd6c..0000000000
--- a/java/systests/src/test/java/org/apache/qpid/server/ack/UnitTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.server.ack;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TxAckTest.class
-})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTest.java b/java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTest.java
index 1bb1d12e1c..53ae097ea6 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTest.java
@@ -32,8 +32,6 @@ import org.apache.qpid.framing.ContentBody;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.AMQException;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
import java.util.List;
import java.util.ArrayList;
@@ -41,7 +39,9 @@ import java.util.Arrays;
import java.util.Set;
import java.util.HashSet;
-public class AbstractHeadersExchangeTest
+import junit.framework.TestCase;
+
+public class AbstractHeadersExchangeTest extends TestCase
{
private final HeadersExchange exchange = new HeadersExchange();
protected final Set<TestQueue> queues = new HashSet<TestQueue>();
diff --git a/java/systests/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java b/java/systests/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
index 7d80a6dce7..1c80e521ca 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
@@ -20,23 +20,19 @@
*/
package org.apache.qpid.server.exchange;
-import org.junit.Test;
-import org.junit.Before;
import org.apache.qpid.AMQException;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.util.TestApplicationRegistry;
-import junit.framework.JUnit4TestAdapter;
public class HeadersExchangeTest extends AbstractHeadersExchangeTest
{
- @Before
- public void init() throws Exception
+ protected void setUp() throws Exception
{
+ super.setUp();
ApplicationRegistry.initialise(new TestApplicationRegistry());
}
- @Test
- public void simple() throws AMQException
+ public void testSimple() throws AMQException
{
TestQueue q1 = bindDefault("F0000");
TestQueue q2 = bindDefault("F0000=Aardvark");
@@ -58,8 +54,7 @@ public class HeadersExchangeTest extends AbstractHeadersExchangeTest
routeAndTest(new Message("Message6", "F0002"));
}
- @Test
- public void any() throws AMQException
+ public void testAny() throws AMQException
{
TestQueue q1 = bindDefault("F0000", "F0001", "X-match=any");
TestQueue q2 = bindDefault("F0000=Aardvark", "F0001=Bear", "X-match=any");
@@ -78,7 +73,6 @@ public class HeadersExchangeTest extends AbstractHeadersExchangeTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(HeadersExchangeTest.class);
+ return new junit.framework.TestSuite(HeadersExchangeTest.class);
}
-
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/exchange/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/server/exchange/UnitTests.java
deleted file mode 100644
index 9ad3b65008..0000000000
--- a/java/systests/src/test/java/org/apache/qpid/server/exchange/UnitTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.server.exchange;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({HeadersExchangeTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/protocol/TestProtocolInitiation.java b/java/systests/src/test/java/org/apache/qpid/server/protocol/TestProtocolInitiation.java
index 847c3cc51b..e76c164f64 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/protocol/TestProtocolInitiation.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/protocol/TestProtocolInitiation.java
@@ -20,8 +20,6 @@
*/
package org.apache.qpid.server.protocol;
-import junit.framework.Assert;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.codec.AMQDecoder;
import org.apache.qpid.codec.AMQEncoder;
import org.apache.qpid.framing.*;
@@ -30,13 +28,13 @@ import org.apache.mina.common.WriteFuture;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
import org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput;
-import org.junit.Before;
-import org.junit.Test;
+
+import junit.framework.TestCase;
/**
* This test suite tests the handling of protocol initiation frames and related issues.
*/
-public class TestProtocolInitiation implements ProtocolVersionList
+public class TestProtocolInitiation extends TestCase implements ProtocolVersionList
{
private AMQPFastProtocolHandler _protocolHandler;
@@ -83,9 +81,9 @@ public class TestProtocolInitiation implements ProtocolVersionList
}
}
- @Before
- public void createCommonObjects()
+ protected void setUp() throws Exception
{
+ super.setUp();
_mockIoSession = new MockIoSession();
_protocolHandler = new AMQPFastProtocolHandler(null, null);
}
@@ -95,67 +93,121 @@ public class TestProtocolInitiation implements ProtocolVersionList
* Tests that the AMQDecoder handles invalid protocol classes
* @throws Exception
*/
- @Test(expected = AMQProtocolClassException.class)
public void testDecoderValidateProtocolClass() throws Exception
{
- ProtocolInitiation pi = createValidProtocolInitiation();
- pi.protocolClass = 2;
- decodePI(pi);
+ try
+ {
+ ProtocolInitiation pi = createValidProtocolInitiation();
+ pi.protocolClass = 2;
+ decodePI(pi);
+ fail("expected exception did not occur");
+ }
+ catch (AMQProtocolClassException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected AMQProtocolClassException, got " + e);
+ }
}
/**
* Tests that the AMQDecoder handles invalid protocol instance numbers
* @throws Exception
*/
- @Test(expected = AMQProtocolInstanceException.class)
public void testDecoderValidatesProtocolInstance() throws Exception
{
- ProtocolInitiation pi = createValidProtocolInitiation();
- pi.protocolInstance = 2;
- decodePI(pi);
+ try
+ {
+ ProtocolInitiation pi = createValidProtocolInitiation();
+ pi.protocolInstance = 2;
+ decodePI(pi);
+ fail("expected exception did not occur");
+ }
+ catch (AMQProtocolInstanceException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected AMQProtocolInstanceException, got " + e);
+ }
}
/**
* Tests that the AMQDecoder handles invalid protocol major
* @throws Exception
*/
- @Test(expected = AMQProtocolVersionException.class)
public void testDecoderValidatesProtocolMajor() throws Exception
{
- ProtocolInitiation pi = createValidProtocolInitiation();
- pi.protocolMajor = 2;
- decodePI(pi);
+ try
+ {
+ ProtocolInitiation pi = createValidProtocolInitiation();
+ pi.protocolMajor = 2;
+ decodePI(pi);
+ fail("expected exception did not occur");
+ }
+ catch (AMQProtocolVersionException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected AMQProtocolVersionException, got " + e);
+ }
}
/**
* Tests that the AMQDecoder handles invalid protocol minor
* @throws Exception
*/
- @Test(expected = AMQProtocolVersionException.class)
public void testDecoderValidatesProtocolMinor() throws Exception
{
- ProtocolInitiation pi = createValidProtocolInitiation();
- pi.protocolMinor = 99;
- decodePI(pi);
+ try
+ {
+ ProtocolInitiation pi = createValidProtocolInitiation();
+ pi.protocolMinor = 99;
+ decodePI(pi);
+ fail("expected exception did not occur");
+ }
+ catch (AMQProtocolVersionException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected AMQProtocolVersionException, got " + e);
+ }
}
/**
* Tests that the AMQDecoder accepts a valid PI
* @throws Exception
*/
- @Test(expected = AMQProtocolHeaderException.class)
public void testDecoderValidatesHeader() throws Exception
{
- ProtocolInitiation pi = createValidProtocolInitiation();
- pi.header = new char[] {'P', 'Q', 'M', 'A' };
- decodePI(pi);
+ try
+ {
+ ProtocolInitiation pi = createValidProtocolInitiation();
+ pi.header = new char[] {'P', 'Q', 'M', 'A' };
+ decodePI(pi);
+ fail("expected exception did not occur");
+ }
+ catch (AMQProtocolHeaderException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected AMQProtocolHeaderException, got " + e);
+ }
}
/**
* Test that a valid header is passed by the decoder.
* @throws Exception
*/
- @Test
public void testDecoderAcceptsValidHeader() throws Exception
{
ProtocolInitiation pi = createValidProtocolInitiation();
@@ -166,18 +218,17 @@ public class TestProtocolInitiation implements ProtocolVersionList
* This test checks that an invalid protocol header results in the
* connection being closed.
*/
- @Test
public void testInvalidProtocolHeaderClosesConnection() throws Exception
{
AMQProtocolHeaderException pe = new AMQProtocolHeaderException("Test");
_protocolHandler.exceptionCaught(_mockIoSession, pe);
- Assert.assertNotNull(_mockIoSession.getLastWrittenObject());
+ assertNotNull(_mockIoSession.getLastWrittenObject());
Object piResponse = _mockIoSession.getLastWrittenObject();
- Assert.assertEquals(piResponse.getClass(), ProtocolInitiation.class);
+ assertEquals(piResponse.getClass(), ProtocolInitiation.class);
ProtocolInitiation pi = (ProtocolInitiation) piResponse;
- Assert.assertEquals("Protocol Initiation sent out was not the broker's expected header", pi,
+ assertEquals("Protocol Initiation sent out was not the broker's expected header", pi,
createValidProtocolInitiation());
- Assert.assertTrue("Session has not been closed", _mockIoSession.isClosing());
+ assertTrue("Session has not been closed", _mockIoSession.isClosing());
}
private ProtocolInitiation createValidProtocolInitiation()
@@ -210,6 +261,6 @@ public class TestProtocolInitiation implements ProtocolVersionList
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TestProtocolInitiation.class);
+ return new junit.framework.TestSuite(TestProtocolInitiation.class);
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/protocol/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/server/protocol/UnitTests.java
deleted file mode 100644
index 53038a4058..0000000000
--- a/java/systests/src/test/java/org/apache/qpid/server/protocol/UnitTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.server.protocol;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({TestProtocolInitiation.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java
index fe04bd43e1..c2511f0a99 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.queue;
-import junit.framework.JUnit4TestAdapter;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicContentHeaderProperties;
@@ -31,17 +30,16 @@ import org.apache.qpid.server.ack.UnacknowledgedMessage;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.store.TestableMemoryMessageStore;
import org.apache.qpid.server.util.TestApplicationRegistry;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
import java.util.Iterator;
import java.util.Map;
+import junit.framework.TestCase;
+
/**
* Tests that acknowledgements are handled correctly.
*/
-public class AckTest
+public class AckTest extends TestCase
{
private static final Logger _log = Logger.getLogger(AckTest.class);
@@ -62,9 +60,9 @@ public class AckTest
ApplicationRegistry.initialise(new TestApplicationRegistry());
}
- @Before
- public void setup() throws Exception
+ protected void setUp() throws Exception
{
+ super.setUp();
_messageStore = new TestableMemoryMessageStore();
_channel = new AMQChannel(5, _messageStore, null/*dont need exchange registry*/);
_protocolSession = new MockProtocolSession(_messageStore);
@@ -107,8 +105,7 @@ public class AckTest
* Tests that the acknowledgements are correctly associated with a channel and
* order is preserved when acks are enabled
*/
- @Test
- public void ackChannelAssociationTest() throws AMQException
+ public void testAckChannelAssociationTest() throws AMQException
{
_subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
final int msgCount = 10;
@@ -134,7 +131,6 @@ public class AckTest
/**
* Tests that in no-ack mode no messages are retained
*/
- @Test
public void testNoAckMode() throws AMQException
{
// false arg means no acks expected
@@ -151,8 +147,7 @@ public class AckTest
* Tests that a single acknowledgement is handled correctly (i.e multiple flag not
* set case)
*/
- @Test
- public void singleAckReceivedTest() throws AMQException
+ public void testSingleAckReceivedTest() throws AMQException
{
_subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
final int msgCount = 10;
@@ -182,8 +177,7 @@ public class AckTest
* Tests that a single acknowledgement is handled correctly (i.e multiple flag not
* set case)
*/
- @Test
- public void multiAckReceivedTest() throws AMQException
+ public void testMultiAckReceivedTest() throws AMQException
{
_subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
final int msgCount = 10;
@@ -208,8 +202,7 @@ public class AckTest
/**
* Tests that a multiple acknowledgement is handled correctly. When ack'ing all pending msgs.
*/
- @Test
- public void multiAckAllReceivedTest() throws AMQException
+ public void testMultiAckAllReceivedTest() throws AMQException
{
_subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
final int msgCount = 10;
@@ -231,8 +224,6 @@ public class AckTest
}
}
-
- @Test
public void testPrefetchHighLow() throws AMQException
{
int lowMark = 5;
@@ -287,7 +278,6 @@ public class AckTest
assertTrue(map.size() == 0);
}
- @Test
public void testPrefetch() throws AMQException
{
_subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
@@ -316,9 +306,8 @@ public class AckTest
assertTrue(map.size() == 0);
}
-
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(AckTest.class);
+ return new junit.framework.TestSuite(AckTest.class);
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java
index 60d86a14a7..a76db6a728 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java
@@ -20,11 +20,6 @@
*/
package org.apache.qpid.server.queue;
-import junit.framework.JUnit4TestAdapter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import org.junit.Test;
-import org.junit.Assert;
import org.apache.qpid.AMQException;
import org.apache.qpid.server.handler.OnCurrentThreadExecutor;
@@ -61,23 +56,21 @@ public class ConcurrencyTest extends MessageTestHelper
new DefaultQueueRegistry()));
}
- @Test
- public void concurrent1() throws InterruptedException, AMQException
+ public void testConcurrent1() throws InterruptedException, AMQException
{
initSubscriptions(10);
initMessages(numMessages);
initThreads(1, 4, 4, 4);
- run();
+ doRun();
check();
}
- @Test
- public void concurrent2() throws InterruptedException, AMQException
+ public void testConcurrent2() throws InterruptedException, AMQException
{
initSubscriptions(10);
initMessages(numMessages);
initThreads(4, 2, 2, 2);
- run();
+ doRun();
check();
}
@@ -126,7 +119,7 @@ public class ConcurrencyTest extends MessageTestHelper
}
}
- void run() throws InterruptedException
+ void doRun() throws InterruptedException
{
for(Thread t : _threads)
{
@@ -147,7 +140,7 @@ public class ConcurrencyTest extends MessageTestHelper
{
_active.remove(s);
Subscription result = _subscriptionMgr.removeSubscriber(s);
- Assert.assertTrue("Removed subscription " + result + " but trying to remove subscription " + s,
+ assertTrue("Removed subscription " + result + " but trying to remove subscription " + s,
result != null && result.equals(s));
}
else
@@ -258,7 +251,7 @@ public class ConcurrencyTest extends MessageTestHelper
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(ConcurrencyTest.class);
+ return new junit.framework.TestSuite(ConcurrencyTest.class);
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java
index 9d841d86f5..3072d44f48 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java
@@ -20,12 +20,11 @@
*/
package org.apache.qpid.server.queue;
+import org.apache.qpid.AMQException;
import org.apache.qpid.server.queue.ConcurrentDeliveryManager;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.DefaultQueueRegistry;
import org.apache.qpid.server.queue.DeliveryManagerTest;
-import org.apache.qpid.AMQException;
-import junit.framework.JUnit4TestAdapter;
public class ConcurrentDeliveryManagerTest extends DeliveryManagerTest
{
@@ -46,6 +45,6 @@ public class ConcurrentDeliveryManagerTest extends DeliveryManagerTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(ConcurrentDeliveryManagerTest.class);
+ return new junit.framework.TestSuite(ConcurrentDeliveryManagerTest.class);
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
index a6739223b0..9cfd9458d1 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
@@ -20,19 +20,10 @@
*/
package org.apache.qpid.server.queue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.junit.runners.Suite;
-import org.junit.runner.RunWith;
import org.apache.qpid.server.handler.OnCurrentThreadExecutor;
import org.apache.qpid.AMQException;
-import junit.framework.JUnit4TestAdapter;
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- ConcurrentDeliveryManagerTest.class,
- SynchronizedDeliveryManagerTest.class})
+import junit.framework.TestSuite;
abstract public class DeliveryManagerTest extends MessageTestHelper
{
@@ -43,9 +34,7 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
{
}
-
- @Test
- public void startInQueueingMode() throws AMQException
+ public void testStartInQueueingMode() throws AMQException
{
AMQMessage[] messages = new AMQMessage[10];
for (int i = 0; i < messages.length; i++)
@@ -90,8 +79,7 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
}
}
- @Test
- public void startInDirectMode() throws AMQException
+ public void testStartInDirectMode() throws AMQException
{
AMQMessage[] messages = new AMQMessage[10];
for (int i = 0; i < messages.length; i++)
@@ -136,27 +124,52 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
}
- @Test(expected = NoConsumersException.class)
- public void noConsumers() throws AMQException
+ public void testNoConsumers() throws AMQException
{
- AMQMessage msg = message(true);
- _mgr.deliver("Me", msg);
- msg.checkDeliveredToConsumer();
+ try
+ {
+ AMQMessage msg = message(true);
+ _mgr.deliver("Me", msg);
+ msg.checkDeliveredToConsumer();
+ fail("expected exception did not occur");
+ }
+ catch (NoConsumersException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected NoConsumersException, got " + e);
+ }
}
- @Test(expected = NoConsumersException.class)
- public void noActiveConsumers() throws AMQException
+ public void testNoActiveConsumers() throws AMQException
{
- TestSubscription s = new TestSubscription("A");
- _subscriptions.addSubscriber(s);
- s.setSuspended(true);
- AMQMessage msg = message(true);
- _mgr.deliver("Me", msg);
- msg.checkDeliveredToConsumer();
+ try
+ {
+ TestSubscription s = new TestSubscription("A");
+ _subscriptions.addSubscriber(s);
+ s.setSuspended(true);
+ AMQMessage msg = message(true);
+ _mgr.deliver("Me", msg);
+ msg.checkDeliveredToConsumer();
+ fail("expected exception did not occur");
+ }
+ catch (NoConsumersException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected NoConsumersException, got " + e);
+ }
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(DeliveryManagerTest.class);
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(ConcurrentDeliveryManagerTest.class);
+ suite.addTestSuite(SynchronizedDeliveryManagerTest.class);
+ return suite;
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/MessageTestHelper.java b/java/systests/src/test/java/org/apache/qpid/server/queue/MessageTestHelper.java
index be40b3c681..8570e6521f 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/MessageTestHelper.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/MessageTestHelper.java
@@ -28,7 +28,9 @@ import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.util.TestApplicationRegistry;
import org.apache.qpid.AMQException;
-class MessageTestHelper
+import junit.framework.TestCase;
+
+class MessageTestHelper extends TestCase
{
private final MessageStore _messageStore = new SkeletonMessageStore();
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionManagerTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionManagerTest.java
index fe0b686c1a..f8db90850f 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionManagerTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionManagerTest.java
@@ -20,18 +20,13 @@
*/
package org.apache.qpid.server.queue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
-public class SubscriptionManagerTest
+public class SubscriptionManagerTest extends TestCase
{
private final SubscriptionSet mgr = new SubscriptionSet();
- @Test
- public void basicSubscriptionManagement()
+ public void testBasicSubscriptionManagement()
{
assertTrue(mgr.isEmpty());
assertFalse(mgr.hasActiveSubscribers());
@@ -58,8 +53,7 @@ public class SubscriptionManagerTest
assertTrue(mgr.isEmpty());
}
- @Test
- public void roundRobin()
+ public void testRoundRobin()
{
TestSubscription a = new TestSubscription("A");
TestSubscription b = new TestSubscription("B");
@@ -103,6 +97,6 @@ public class SubscriptionManagerTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(SubscriptionManagerTest.class);
+ return new junit.framework.TestSuite(SubscriptionManagerTest.class);
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionSetTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionSetTest.java
index e6b0f7e885..4969b5589a 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionSetTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionSetTest.java
@@ -20,12 +20,9 @@
*/
package org.apache.qpid.server.queue;
-import junit.framework.JUnit4TestAdapter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import org.junit.Test;
+import junit.framework.TestCase;
-public class SubscriptionSetTest
+public class SubscriptionSetTest extends TestCase
{
/**
* A SubscriptionSet that counts the number of items scanned.
@@ -58,8 +55,7 @@ public class SubscriptionSetTest
final TestSubscription suspendedSub2 = new TestSubscription("sus2", true);
final TestSubscription suspendedSub3 = new TestSubscription("sus3", true);
- @Test
- public void nextMessage()
+ public void testNextMessage()
{
SubscriptionSet ss = new SubscriptionSet();
assertNull(ss.nextSubscriber(null));
@@ -81,8 +77,7 @@ public class SubscriptionSetTest
assertEquals(3, ss.getCurrentSubscriber());
}
- @Test
- public void nextMessageWhenAllSuspended()
+ public void testNextMessageWhenAllSuspended()
{
SubscriptionSet ss = createAllSuspendedSubscriptionSet();
assertNull(ss.nextSubscriber(null));
@@ -101,8 +96,7 @@ public class SubscriptionSetTest
return ss;
}
- @Test
- public void nextMessageAfterRemove()
+ public void testNextMessageAfterRemove()
{
SubscriptionSet ss = new SubscriptionSet();
ss.addSubscriber(suspendedSub1);
@@ -117,8 +111,7 @@ public class SubscriptionSetTest
assertEquals(2, ss.getCurrentSubscriber());
}
- @Test
- public void nextMessageOverScanning()
+ public void testNextMessageOverScanning()
{
TestSubscriptionSet ss = new TestSubscriptionSet();
TestSubscription sub = new TestSubscription("test");
@@ -137,8 +130,7 @@ public class SubscriptionSetTest
assertEquals(ss.size() + 1, ss.getScanned());
}
- @Test
- public void nextMessageOverscanWorstCase() {
+ public void testNextMessageOverscanWorstCase() {
TestSubscriptionSet ss = createAllSuspendedSubscriptionSet();
ss.nextSubscriber(null);
// Scans the subscriptions twice.
@@ -147,6 +139,6 @@ public class SubscriptionSetTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(SubscriptionSetTest.class);
+ return new junit.framework.TestSuite(SubscriptionSetTest.class);
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java
index faa6bdcbe7..b49166d1ce 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java
@@ -26,7 +26,8 @@ import org.apache.qpid.server.queue.DefaultQueueRegistry;
import org.apache.qpid.server.queue.ConcurrentDeliveryManager;
import org.apache.qpid.server.queue.DeliveryManagerTest;
import org.apache.qpid.AMQException;
-import junit.framework.JUnit4TestAdapter;
+
+import junit.framework.TestSuite;
public class SynchronizedDeliveryManagerTest extends DeliveryManagerTest
{
@@ -47,6 +48,8 @@ public class SynchronizedDeliveryManagerTest extends DeliveryManagerTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(SynchronizedDeliveryManagerTest.class);
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(SynchronizedDeliveryManagerTest.class);
+ return suite;
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/store/TestReferenceCounting.java b/java/systests/src/test/java/org/apache/qpid/server/store/TestReferenceCounting.java
index 7431e6e4cc..f162506fed 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/store/TestReferenceCounting.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/store/TestReferenceCounting.java
@@ -20,52 +20,48 @@
*/
package org.apache.qpid.server.store;
-import junit.framework.JUnit4TestAdapter;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.Before;
import org.apache.qpid.server.queue.AMQMessage;
import org.apache.qpid.AMQException;
+import junit.framework.TestCase;
+
/**
* Tests that reference counting works correctly with AMQMessage and the message store
*/
-public class TestReferenceCounting
+public class TestReferenceCounting extends TestCase
{
private TestableMemoryMessageStore _store;
- @Before
- public void createCommonObjects()
+ protected void setUp() throws Exception
{
+ super.setUp();
_store = new TestableMemoryMessageStore();
}
/**
* Check that when the reference count is decremented the message removes itself from the store
*/
- @Test
public void testMessageGetsRemoved() throws AMQException
{
AMQMessage message = new AMQMessage(_store, null);
_store.put(message);
- Assert.assertTrue(_store.getMessageMap().size() == 1);
+ assertTrue(_store.getMessageMap().size() == 1);
message.decrementReference();
- Assert.assertTrue(_store.getMessageMap().size() == 0);
+ assertTrue(_store.getMessageMap().size() == 0);
}
- @Test
public void testMessageRemains() throws AMQException
{
AMQMessage message = new AMQMessage(_store, null);
_store.put(message);
- Assert.assertTrue(_store.getMessageMap().size() == 1);
+ assertTrue(_store.getMessageMap().size() == 1);
message.incrementReference();
message.decrementReference();
- Assert.assertTrue(_store.getMessageMap().size() == 1);
+ assertTrue(_store.getMessageMap().size() == 1);
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TestReferenceCounting.class);
+ return new junit.framework.TestSuite(TestReferenceCounting.class);
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/store/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/server/store/UnitTests.java
deleted file mode 100644
index 8e11f823a9..0000000000
--- a/java/systests/src/test/java/org/apache/qpid/server/store/UnitTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.server.store;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TestReferenceCounting.class
-})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/txn/TxnBufferTest.java b/java/systests/src/test/java/org/apache/qpid/server/txn/TxnBufferTest.java
index f1b14b69b8..ac5c60a931 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/txn/TxnBufferTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/txn/TxnBufferTest.java
@@ -20,29 +20,19 @@
*/
package org.apache.qpid.server.txn;
-import junit.framework.JUnit4TestAdapter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Ignore;
import org.apache.qpid.AMQException;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.TestableMemoryMessageStore;
import java.util.LinkedList;
-public class TxnBufferTest
+import junit.framework.TestCase;
+
+public class TxnBufferTest extends TestCase
{
private final LinkedList<MockOp> ops = new LinkedList<MockOp>();
- @Before
- public void setup() throws Exception
- {
- }
-
- @Test
- public void commit() throws AMQException
+ public void testCommit() throws AMQException
{
MockStore store = new MockStore();
@@ -60,8 +50,7 @@ public class TxnBufferTest
store.validate();
}
- @Test
- public void rollback() throws AMQException
+ public void testRollback() throws AMQException
{
MockStore store = new MockStore();
@@ -76,8 +65,7 @@ public class TxnBufferTest
store.validate();
}
- @Test
- public void commitWithFailureDuringPrepare() throws AMQException
+ public void testCommitWithFailureDuringPrepare() throws AMQException
{
MockStore store = new MockStore();
store.expectBegin().expectAbort();
@@ -95,8 +83,7 @@ public class TxnBufferTest
store.validate();
}
- @Test
- public void commitWithPersistance() throws AMQException
+ public void testCommitWithPersistance() throws AMQException
{
MockStore store = new MockStore();
store.expectBegin().expectCommit();
@@ -115,7 +102,7 @@ public class TxnBufferTest
private void validateOps()
{
- for(MockOp op : ops)
+ for (MockOp op : ops)
{
op.validate();
}
@@ -123,7 +110,7 @@ public class TxnBufferTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TxnBufferTest.class);
+ return new junit.framework.TestSuite(TxnBufferTest.class);
}
class MockOp implements TxnOp
diff --git a/java/systests/src/test/java/org/apache/qpid/server/txn/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/server/txn/UnitTests.java
deleted file mode 100644
index 975e8eea72..0000000000
--- a/java/systests/src/test/java/org/apache/qpid/server/txn/UnitTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.server.txn;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TxnBufferTest.class
-})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
index fbdcaf7467..e859fac4af 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/UnitTests.java
+++ b/java/systests/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
@@ -1,5 +1,4 @@
/*
- *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,24 +17,36 @@
* under the License.
*
*/
-package org.apache.qpid.server.queue;
+package org.apache.qpid.test;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
+import org.apache.qpid.client.transport.TransportConnection;
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- AckTest.class,
- DeliveryManagerTest.class,
- SubscriptionManagerTest.class,
- SubscriptionSetTest.class,
- ConcurrencyTest.class}
-)
-public class UnitTests
+public class VMBrokerSetup extends TestSetup
{
- public static junit.framework.Test suite()
+ public VMBrokerSetup(Test t)
+ {
+ super(t);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ try
+ {
+ TransportConnection.createVMBroker(1);
+ }
+ catch (Exception e)
+ {
+ fail("Unable to create broker: " + e);
+ }
+ }
+
+ protected void tearDown() throws Exception
{
- return new JUnit4TestAdapter(UnitTests.class);
+ TransportConnection.killVMBroker(1);
+ super.tearDown();
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/test/unit/ack/DisconnectAndRedeliverTest.java b/java/systests/src/test/java/org/apache/qpid/test/unit/ack/DisconnectAndRedeliverTest.java
index 53d83fb6a3..a3e555aac9 100644
--- a/java/systests/src/test/java/org/apache/qpid/test/unit/ack/DisconnectAndRedeliverTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/test/unit/ack/DisconnectAndRedeliverTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.test.unit.ack;
-import junit.framework.JUnit4TestAdapter;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import org.apache.qpid.client.AMQConnection;
@@ -31,18 +30,16 @@ import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.store.TestableMemoryMessageStore;
import org.apache.qpid.server.util.TestApplicationRegistry;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.*;
-public class DisconnectAndRedeliverTest
+import junit.framework.TestCase;
+
+public class DisconnectAndRedeliverTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(DisconnectAndRedeliverTest.class);
-
static
{
String workdir = System.getProperty("QPID_WORK");
@@ -52,34 +49,18 @@ public class DisconnectAndRedeliverTest
System.out.println("QPID_WORK not set using tmp directory: " + tempdir);
System.setProperty("QPID_WORK", tempdir);
}
- //DOMConfigurator.configure("../etc/log4j.xml");
- DOMConfigurator.configure("broker/etc/log4j.xml");
+ DOMConfigurator.configure("../broker/etc/log4j.xml");
}
- @Before
- public void resetAppliactionRegistry() throws Exception
+ protected void setUp() throws Exception
{
- createVMBroker();
+ super.setUp();
ApplicationRegistry.initialise(new TestApplicationRegistry(), 1);
}
-
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
- }
-
- @After
- public void stopVmBroker()
+ protected void tearDown() throws Exception
{
- TransportConnection.killVMBroker(1);
+ super.tearDown();
}
/**
@@ -88,8 +69,7 @@ public class DisconnectAndRedeliverTest
*
* @throws Exception
*/
- @Test
- public void disconnectRedeliversMessages() throws Exception
+ public void testDisconnectRedeliversMessages() throws Exception
{
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
@@ -134,15 +114,15 @@ public class DisconnectAndRedeliverTest
con.start();
tm = (TextMessage) consumer.receive(3000);
- Assert.assertEquals("msg2", tm.getText());
+ assertEquals("msg2", tm.getText());
tm = (TextMessage) consumer.receive(3000);
- Assert.assertEquals("msg3", tm.getText());
+ assertEquals("msg3", tm.getText());
tm = (TextMessage) consumer.receive(3000);
- Assert.assertEquals("msg4", tm.getText());
+ assertEquals("msg4", tm.getText());
_logger.info("Received redelivery of three messages. Acknowledging last message");
tm.acknowledge();
@@ -155,7 +135,7 @@ public class DisconnectAndRedeliverTest
_logger.info("Starting third consumer connection");
con.start();
tm = (TextMessage) consumer.receiveNoWait();
- Assert.assertNull(tm);
+ assertNull(tm);
_logger.info("No messages redelivered as is expected");
con.close();
@@ -165,12 +145,12 @@ public class DisconnectAndRedeliverTest
_logger.info("Starting fourth consumer connection");
con.start();
tm = (TextMessage) consumer.receive(3000);
- Assert.assertNull(tm);
+ assertNull(tm);
_logger.info("No messages redelivered as is expected");
con.close();
_logger.info("Actually:" + store.getMessageMap().size());
- // Assert.assertTrue(store.getMessageMap().size() == 0);
+ // assertTrue(store.getMessageMap().size() == 0);
}
/**
@@ -179,8 +159,7 @@ public class DisconnectAndRedeliverTest
*
* @throws Exception
*/
- @Test
- public void disconnectWithTransientQueueThrowsAwayMessages() throws Exception
+ public void testDisconnectWithTransientQueueThrowsAwayMessages() throws Exception
{
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
@@ -222,16 +201,16 @@ public class DisconnectAndRedeliverTest
con.start();
tm = (TextMessage) consumer.receiveNoWait();
- Assert.assertNull(tm);
+ assertNull(tm);
_logger.info("No messages redelivered as is expected");
_logger.info("Actually:" + store.getMessageMap().size());
- Assert.assertTrue(store.getMessageMap().size() == 0);
+ assertTrue(store.getMessageMap().size() == 0);
con.close();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(DisconnectAndRedeliverTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(DisconnectAndRedeliverTest.class));
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/test/unit/ack/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/test/unit/ack/UnitTests.java
deleted file mode 100644
index 498667e2bc..0000000000
--- a/java/systests/src/test/java/org/apache/qpid/test/unit/ack/UnitTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.test.unit.ack;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({DisconnectAndRedeliverTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}