summaryrefslogtreecommitdiff
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
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
-rw-r--r--java/broker/pom.xml43
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/UnitTests.java39
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java11
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java41
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/exchange/UnitTests.java35
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java30
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/util/UnitTests.java35
-rw-r--r--java/client/pom.xml51
-rw-r--r--java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java1
-rw-r--r--java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java24
-rw-r--r--java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java19
-rw-r--r--java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java21
-rw-r--r--java/client/src/test/java/org/apache/qpid/mina/WriterTest.java294
-rw-r--r--java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java44
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java (renamed from java/client/src/test/java/org/apache/qpid/test/unit/client/message/MessageUnitTests.java)36
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java48
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/ack/UnitTests.java35
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java41
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java33
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java39
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java34
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java45
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java34
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java47
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java42
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/UnitTests.java43
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java142
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java55
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/AllClientUnitTests.java50
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java62
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/UnitTests.java37
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java61
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java306
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/UnitTests.java35
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java106
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/UnitTests.java35
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java32
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/UnitTests.java37
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java360
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java93
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java18
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java83
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java35
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java10
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java53
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/UnitTests.java35
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java69
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java51
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/transacted/UnitTests.java35
-rw-r--r--java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java11
-rw-r--r--java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java8
-rw-r--r--java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleMemberHandleTest.java13
-rw-r--r--java/pom.xml12
-rw-r--r--java/systests/pom.xml19
-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/queue/UnitTests.java41
-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/broker/src/test/java/org/apache/qpid/server/configuration/UnitTests.java)37
-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
79 files changed, 1406 insertions, 2451 deletions
diff --git a/java/broker/pom.xml b/java/broker/pom.xml
index c66ddd82e6..85aae51217 100644
--- a/java/broker/pom.xml
+++ b/java/broker/pom.xml
@@ -86,47 +86,4 @@
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>ant-test</id>
- <phase>test</phase>
- <configuration>
- <tasks unless="${maven.test.skip}">
- <taskdef name="junit"
- classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
- <classpath>
- <path refid="maven.test.classpath"/>
- </classpath>
- </taskdef>
- <mkdir dir="${project.build.directory}/test-classes"/>
- <junit fork="yes" showoutput="true" haltonfailure="yes">
- <test name="org.apache.qpid.server.UnitTests"
- todir="${project.build.directory}"/>
- <formatter type="plain"/>
- <classpath>
- <path refid="maven.test.classpath"/>
- </classpath>
- </junit>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/java/broker/src/test/java/org/apache/qpid/server/UnitTests.java b/java/broker/src/test/java/org/apache/qpid/server/UnitTests.java
deleted file mode 100644
index fcae268288..0000000000
--- a/java/broker/src/test/java/org/apache/qpid/server/UnitTests.java
+++ /dev/null
@@ -1,39 +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.configuration.UnitTests.class,
- org.apache.qpid.server.exchange.UnitTests.class,
- org.apache.qpid.server.util.UnitTests.class
- })
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java b/java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java
index 8bab0fbc12..3b83190e42 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java
@@ -20,16 +20,14 @@
*/
package org.apache.qpid.server.configuration;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.configuration.PropertyException;
import org.apache.qpid.configuration.PropertyUtils;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
+
+import junit.framework.TestCase;
// TODO: This belongs in the "common" module.
-public class TestPropertyUtils
+public class TestPropertyUtils extends TestCase
{
- @Test
public void testSimpleExpansion() throws PropertyException
{
System.setProperty("banana", "fruity");
@@ -37,7 +35,6 @@ public class TestPropertyUtils
assertEquals(expandedProperty, "fruity");
}
- @Test
public void testDualExpansion() throws PropertyException
{
System.setProperty("banana", "fruity");
@@ -48,6 +45,6 @@ public class TestPropertyUtils
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TestPropertyUtils.class);
+ return new junit.framework.TestSuite(TestPropertyUtils.class);
}
}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java b/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
index 0e7ab10c59..f8c15d937a 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
@@ -20,24 +20,19 @@
*/
package org.apache.qpid.server.exchange;
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-
import java.util.Map;
import java.util.HashMap;
-import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
/**
*/
-public class HeadersBindingTest
+public class HeadersBindingTest extends TestCase
{
private Map<String, String> bindHeaders = new HashMap<String, String>();
private Map<String, String> matchHeaders = new HashMap<String, String>();
- @Test public void default_1()
+ public void testDefault_1()
{
bindHeaders.put("A", "Value of A");
@@ -46,7 +41,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void default_2()
+ public void testDefault_2()
{
bindHeaders.put("A", "Value of A");
@@ -56,7 +51,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void default_3()
+ public void testDefault_3()
{
bindHeaders.put("A", "Value of A");
@@ -65,7 +60,7 @@ public class HeadersBindingTest
assertFalse(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void all_1()
+ public void testAll_1()
{
bindHeaders.put("X-match", "all");
bindHeaders.put("A", "Value of A");
@@ -75,7 +70,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void all_2()
+ public void testAll_2()
{
bindHeaders.put("X-match", "all");
bindHeaders.put("A", "Value of A");
@@ -86,7 +81,7 @@ public class HeadersBindingTest
assertFalse(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void all_3()
+ public void testAll_3()
{
bindHeaders.put("X-match", "all");
bindHeaders.put("A", "Value of A");
@@ -98,7 +93,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void all_4()
+ public void testAll_4()
{
bindHeaders.put("X-match", "all");
bindHeaders.put("A", "Value of A");
@@ -111,7 +106,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void all_5()
+ public void testAll_5()
{
bindHeaders.put("X-match", "all");
bindHeaders.put("A", "Value of A");
@@ -124,7 +119,7 @@ public class HeadersBindingTest
assertFalse(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void any_1()
+ public void testAny_1()
{
bindHeaders.put("X-match", "any");
bindHeaders.put("A", "Value of A");
@@ -134,7 +129,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void any_2()
+ public void testAny_2()
{
bindHeaders.put("X-match", "any");
bindHeaders.put("A", "Value of A");
@@ -145,7 +140,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void any_3()
+ public void testAny_3()
{
bindHeaders.put("X-match", "any");
bindHeaders.put("A", "Value of A");
@@ -157,7 +152,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void any_4()
+ public void testAny_4()
{
bindHeaders.put("X-match", "any");
bindHeaders.put("A", "Value of A");
@@ -170,7 +165,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void any_5()
+ public void testAny_5()
{
bindHeaders.put("X-match", "any");
bindHeaders.put("A", "Value of A");
@@ -183,7 +178,7 @@ public class HeadersBindingTest
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
- @Test public void any_6()
+ public void testAny_6()
{
bindHeaders.put("X-match", "any");
bindHeaders.put("A", "Value of A");
@@ -195,9 +190,9 @@ public class HeadersBindingTest
assertFalse(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
+
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(HeadersBindingTest.class);
+ return new junit.framework.TestSuite(HeadersBindingTest.class);
}
-
}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/exchange/UnitTests.java b/java/broker/src/test/java/org/apache/qpid/server/exchange/UnitTests.java
deleted file mode 100644
index ce3812be7f..0000000000
--- a/java/broker/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({HeadersBindingTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java b/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java
index 878500689a..c7db51016e 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java
@@ -20,16 +20,13 @@
*/
package org.apache.qpid.server.util;
-import junit.framework.JUnit4TestAdapter;
-import org.junit.Assert;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-public class LoggingProxyTest
+import junit.framework.TestCase;
+
+public class LoggingProxyTest extends TestCase
{
static interface IFoo {
void foo();
@@ -58,35 +55,34 @@ public class LoggingProxyTest
}
}
- @Test
- public void simple() {
+ public void testSimple() {
LoggingProxy proxy = new LoggingProxy(new Foo(), 20);
IFoo foo = (IFoo)proxy.getProxy(IFoo.class);
foo.foo();
assertEquals(2, proxy.getBufferSize());
- Assert.assertTrue(proxy.getBuffer().get(0).toString().matches(".*: foo\\(\\) entered$"));
- Assert.assertTrue(proxy.getBuffer().get(1).toString().matches(".*: foo\\(\\) returned$"));
+ assertTrue(proxy.getBuffer().get(0).toString().matches(".*: foo\\(\\) entered$"));
+ assertTrue(proxy.getBuffer().get(1).toString().matches(".*: foo\\(\\) returned$"));
foo.foo(3, Arrays.asList(0, 1, 2));
assertEquals(4, proxy.getBufferSize());
- Assert.assertTrue(proxy.getBuffer().get(2).toString().matches(".*: foo\\(\\[3, \\[0, 1, 2\\]\\]\\) entered$"));
- Assert.assertTrue(proxy.getBuffer().get(3).toString().matches(".*: foo\\(\\) returned$"));
+ assertTrue(proxy.getBuffer().get(2).toString().matches(".*: foo\\(\\[3, \\[0, 1, 2\\]\\]\\) entered$"));
+ assertTrue(proxy.getBuffer().get(3).toString().matches(".*: foo\\(\\) returned$"));
foo.bar();
assertEquals(6, proxy.getBufferSize());
- Assert.assertTrue(proxy.getBuffer().get(4).toString().matches(".*: bar\\(\\) entered$"));
- Assert.assertTrue(proxy.getBuffer().get(5).toString().matches(".*: bar\\(\\) returned null$"));
+ assertTrue(proxy.getBuffer().get(4).toString().matches(".*: bar\\(\\) entered$"));
+ assertTrue(proxy.getBuffer().get(5).toString().matches(".*: bar\\(\\) returned null$"));
foo.bar("hello", Arrays.asList(1, 2, 3));
assertEquals(8, proxy.getBufferSize());
- Assert.assertTrue(proxy.getBuffer().get(6).toString().matches(".*: bar\\(\\[hello, \\[1, 2, 3\\]\\]\\) entered$"));
- Assert.assertTrue(proxy.getBuffer().get(7).toString().matches(".*: bar\\(\\) returned ha$"));
+ assertTrue(proxy.getBuffer().get(6).toString().matches(".*: bar\\(\\[hello, \\[1, 2, 3\\]\\]\\) entered$"));
+ assertTrue(proxy.getBuffer().get(7).toString().matches(".*: bar\\(\\) returned ha$"));
proxy.dump();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(LoggingProxyTest.class);
+ return new junit.framework.TestSuite(LoggingProxyTest.class);
}
}
diff --git a/java/broker/src/test/java/org/apache/qpid/server/util/UnitTests.java b/java/broker/src/test/java/org/apache/qpid/server/util/UnitTests.java
deleted file mode 100644
index 5314fa0df8..0000000000
--- a/java/broker/src/test/java/org/apache/qpid/server/util/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.util;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({LoggingProxyTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/pom.xml b/java/client/pom.xml
index 71e8fb59e9..6965a72759 100644
--- a/java/client/pom.xml
+++ b/java/client/pom.xml
@@ -105,46 +105,21 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>ant-test</id>
- <phase>test</phase>
- <configuration>
- <tasks unless="${maven.test.skip}">
- <taskdef name="junit"
- classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
- <classpath>
- <path refid="maven.test.classpath"/>
- </classpath>
- </taskdef>
- <mkdir dir="${project.build.directory}/test-classes"/>
- <junit fork="yes" printsummary="yes" showoutput="true" haltonfailure="yes">
- <sysproperty key="amqj.noAutoCreateVMBroker" value="true"/>
- <formatter type="plain"/>
- <classpath>
- <path refid="maven.test.classpath"/>
- </classpath>
- <batchtest fork="yes" todir="${project.build.directory}">
- <fileset dir="src/test/java">
- <include name="**/test/unit/**/*Test.java"/>
- <exclude name="**/test/unit/**/*UnitTests.java"/>
- </fileset>
- </batchtest>
- </junit>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <skip>true</skip>
+ <systemProperties>
+ <property>
+ <name>amqj.noAutoCreateVMBroker</name>
+ <value>true</value>
+ </property>
+ </systemProperties>
+ <includes>
+ <include>**/test/unit/**/*Test.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/JNDIReferenceableTest.java</exclude>
+ <exclude>**/TransactedTest.java</exclude>
+ </excludes>
</configuration>
</plugin>
</plugins>
diff --git a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java b/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java
index 836727df5d..5f328a4107 100644
--- a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java
+++ b/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java
@@ -26,7 +26,6 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQQueue;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
-import org.junit.Assert;
import javax.naming.Context;
import javax.naming.InitialContext;
diff --git a/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java b/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java
index a75fff68e1..49e1630f15 100644
--- a/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java
+++ b/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java
@@ -20,10 +20,7 @@
*/
package org.apache.qpid.framing;
-import junit.framework.JUnit4TestAdapter;
import org.apache.mina.common.ByteBuffer;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
import java.io.BufferedReader;
import java.io.IOException;
@@ -32,10 +29,11 @@ import java.io.Reader;
import java.util.Enumeration;
import java.util.Properties;
-public class FieldTableTest
+import junit.framework.TestCase;
+
+public class FieldTableTest extends TestCase
{
- @Test
- public void dataDump() throws IOException, AMQFrameDecodingException
+ public void testDataDump() throws IOException, AMQFrameDecodingException
{
byte[] data = readBase64("content.txt");
System.out.println("Got " + data.length + " bytes of data");
@@ -52,19 +50,17 @@ public class FieldTableTest
}
/*
- @Test
- public void case1() throws AMQFrameDecodingException, IOException
+ public void testCase1() throws AMQFrameDecodingException, IOException
{
- testEncoding(load("FieldTableTest.properties"));
+ doTestEncoding(load("FieldTableTest.properties"));
}
- @Test
- public void case2() throws AMQFrameDecodingException, IOException
+ public void testCase2() throws AMQFrameDecodingException, IOException
{
- testEncoding(load("FieldTableTest2.properties"));
+ doTestEncoding(load("FieldTableTest2.properties"));
}
*/
- void testEncoding(FieldTable table) throws AMQFrameDecodingException
+ void doTestEncoding(FieldTable table) throws AMQFrameDecodingException
{
assertEquivalent(table, encodeThenDecode(table));
}
@@ -157,6 +153,6 @@ public class FieldTableTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(FieldTableTest.class);
+ return new junit.framework.TestSuite(FieldTableTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java b/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java
index bae3a60675..de3d558f7c 100644
--- a/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java
+++ b/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.mina;
-import junit.framework.JUnit4TestAdapter;
import org.apache.log4j.Logger;
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoAcceptor;
@@ -29,17 +28,18 @@ import org.apache.mina.common.IoSession;
import org.apache.mina.transport.socket.nio.SocketAcceptor;
import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
import org.apache.mina.transport.socket.nio.SocketSessionConfig;
-import org.junit.Test;
import org.apache.qpid.pool.ReadWriteThreadModel;
import java.io.IOException;
import java.net.InetSocketAddress;
+import junit.framework.TestCase;
+
/**
* Tests MINA socket performance. This acceptor simply reads data from the network and writes it back again.
*
*/
-public class AcceptorTest
+public class AcceptorTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(AcceptorTest.class);
@@ -71,8 +71,7 @@ public class AcceptorTest
}
}
- @Test
- public void startAcceptor() throws IOException
+ public void testStartAcceptor() throws IOException
{
IoAcceptor acceptor = null;
acceptor = new SocketAcceptor();
@@ -90,14 +89,14 @@ public class AcceptorTest
_logger.info("Bound on port " + PORT);
}
- public static junit.framework.Test suite()
+ public static void main(String[] args) throws IOException
{
- return new JUnit4TestAdapter(AcceptorTest.class);
+ AcceptorTest a = new AcceptorTest();
+ a.testStartAcceptor();
}
- public static void main(String[] args) throws IOException
+ public static junit.framework.Test suite()
{
- AcceptorTest a = new AcceptorTest();
- a.startAcceptor();
+ return new junit.framework.TestSuite(AcceptorTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java b/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java
index 79dba32e47..bfe29c47e6 100644
--- a/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java
+++ b/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java
@@ -20,9 +20,7 @@
*/
package org.apache.qpid.mina;
-import junit.framework.JUnit4TestAdapter;
import org.apache.log4j.Logger;
-import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -30,19 +28,15 @@ import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
-public class BlockingAcceptorTest
+import junit.framework.TestCase;
+
+public class BlockingAcceptorTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(BlockingAcceptorTest.class);
public static int PORT = 9999;
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(AcceptorTest.class);
- }
-
- @Test
- public void startAcceptor() throws IOException
+ public void testStartAcceptor() throws IOException
{
ServerSocket sock = new ServerSocket(PORT);
@@ -89,6 +83,11 @@ public class BlockingAcceptorTest
public static void main(String[] args) throws IOException
{
BlockingAcceptorTest a = new BlockingAcceptorTest();
- a.startAcceptor();
+ a.testStartAcceptor();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(AcceptorTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java b/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
index dc29861c87..910345624f 100644
--- a/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
+++ b/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
@@ -20,240 +20,237 @@
*/
package org.apache.qpid.mina;
-import junit.framework.JUnit4TestAdapter;
import org.apache.log4j.Logger;
import org.apache.mina.common.*;
import org.apache.mina.transport.socket.nio.SocketConnector;
import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
import org.apache.mina.transport.socket.nio.SocketSessionConfig;
-import org.junit.Test;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
-public class WriterTest implements Runnable
+import junit.framework.TestCase;
+
+public class WriterTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(WriterTest.class);
- private IoSession _session;
+ private static class RunnableWriterTest implements Runnable
+ {
+ private Logger _logger;
- private long _startTime;
+ private IoSession _session;
- private long[] _chunkTimes;
+ private long _startTime;
- private int _chunkCount = 500000;
+ private long[] _chunkTimes;
- private int _chunkSize = 1024;
+ private int _chunkCount = 500000;
- private CountDownLatch _notifier;
+ private int _chunkSize = 1024;
- public void run()
- {
- _startTime = System.currentTimeMillis();
- _notifier = new CountDownLatch(1);
- for (int i = 0; i < _chunkCount; i++)
- {
- ByteBuffer buf = ByteBuffer.allocate(_chunkSize, false);
- byte check = (byte) (i % 128);
- buf.put(check);
- buf.fill((byte)88, buf.remaining());
- buf.flip();
- _session.write(buf);
- }
+ private CountDownLatch _notifier;
- try
+ public RunnableWriterTest(Logger logger)
{
- _logger.info("All buffers sent; waiting for receipt from server");
- _notifier.await();
+ _logger = logger;
}
- catch (InterruptedException e)
- {
- }
- _logger.info("Completed");
- long totalTime = System.currentTimeMillis() - _startTime;
- _logger.info("Total time: " + totalTime);
- _logger.info("MB per second: " + (_chunkSize * _chunkCount)/totalTime);
- long lastChunkTime = _startTime;
- double average = 0;
- for (int i = 0; i < _chunkTimes.length; i++)
+
+ public void run()
{
- if (i == 0)
+ _startTime = System.currentTimeMillis();
+ _notifier = new CountDownLatch(1);
+ for (int i = 0; i < _chunkCount; i++)
+ {
+ ByteBuffer buf = ByteBuffer.allocate(_chunkSize, false);
+ byte check = (byte) (i % 128);
+ buf.put(check);
+ buf.fill((byte)88, buf.remaining());
+ buf.flip();
+ _session.write(buf);
+ }
+
+ try
{
- average = _chunkTimes[i] - _startTime;
+ _logger.info("All buffers sent; waiting for receipt from server");
+ _notifier.await();
}
- else
+ catch (InterruptedException e)
{
- long delta = _chunkTimes[i] - lastChunkTime;
- if (delta != 0)
+ }
+ _logger.info("Completed");
+ long totalTime = System.currentTimeMillis() - _startTime;
+ _logger.info("Total time: " + totalTime);
+ _logger.info("MB per second: " + (_chunkSize * _chunkCount)/totalTime);
+ long lastChunkTime = _startTime;
+ double average = 0;
+ for (int i = 0; i < _chunkTimes.length; i++)
+ {
+ if (i == 0)
+ {
+ average = _chunkTimes[i] - _startTime;
+ }
+ else
{
- average = (average + delta)/2;
+ long delta = _chunkTimes[i] - lastChunkTime;
+ if (delta != 0)
+ {
+ average = (average + delta)/2;
+ }
}
+ lastChunkTime = _chunkTimes[i];
}
- lastChunkTime = _chunkTimes[i];
+ _logger.info("Average chunk time: " + average + "ms");
+ CloseFuture cf = _session.close();
+ cf.join();
}
- _logger.info("Average chunk time: " + average + "ms");
- CloseFuture cf = _session.close();
- cf.join();
- }
- private class WriterHandler extends IoHandlerAdapter
- {
- private int _chunksReceived = 0;
+ private class WriterHandler extends IoHandlerAdapter
+ {
+ private int _chunksReceived = 0;
- private int _partialBytesRead = 0;
+ private int _partialBytesRead = 0;
- private byte _partialCheckNumber;
+ private byte _partialCheckNumber;
- private int _totalBytesReceived = 0;
+ private int _totalBytesReceived = 0;
- public void messageReceived(IoSession session, Object message) throws Exception
- {
- ByteBuffer result = (ByteBuffer) message;
- _totalBytesReceived += result.remaining();
- int size = result.remaining();
- long now = System.currentTimeMillis();
- if (_partialBytesRead > 0)
+ public void messageReceived(IoSession session, Object message) throws Exception
{
- int offset = _chunkSize - _partialBytesRead;
- if (size >= offset)
- {
- _chunkTimes[_chunksReceived++] = now;
- result.position(offset);
- }
- else
+ ByteBuffer result = (ByteBuffer) message;
+ _totalBytesReceived += result.remaining();
+ int size = result.remaining();
+ long now = System.currentTimeMillis();
+ if (_partialBytesRead > 0)
{
- // have not read even one chunk, including the previous partial bytes
- _partialBytesRead += size;
- return;
+ int offset = _chunkSize - _partialBytesRead;
+ if (size >= offset)
+ {
+ _chunkTimes[_chunksReceived++] = now;
+ result.position(offset);
+ }
+ else
+ {
+ // have not read even one chunk, including the previous partial bytes
+ _partialBytesRead += size;
+ return;
+ }
}
- }
- int chunkCount = result.remaining()/_chunkSize;
+ int chunkCount = result.remaining()/_chunkSize;
- for (int i = 0; i < chunkCount; i++)
- {
- _chunkTimes[_chunksReceived++] = now;
- byte check = result.get();
- _logger.debug("Check number " + check + " read");
- if (check != (byte)((_chunksReceived - 1)%128))
+ for (int i = 0; i < chunkCount; i++)
{
- _logger.error("Check number " + check + " read when expected " + (_chunksReceived%128));
+ _chunkTimes[_chunksReceived++] = now;
+ byte check = result.get();
+ _logger.debug("Check number " + check + " read");
+ if (check != (byte)((_chunksReceived - 1)%128))
+ {
+ _logger.error("Check number " + check + " read when expected " + (_chunksReceived%128));
+ }
+ _logger.debug("Chunk times recorded");
+
+ try
+ {
+ result.skip(_chunkSize - 1);
+ }
+ catch (IllegalArgumentException e)
+ {
+ _logger.error("Position was: " + result.position());
+ _logger.error("Tried to skip to: " + (_chunkSize * i));
+ _logger.error("limit was; " + result.limit());
+ }
}
- _logger.debug("Chunk times recorded");
+ _logger.debug("Chunks received now " + _chunksReceived);
+ _logger.debug("Bytes received: " + _totalBytesReceived);
+ _partialBytesRead = result.remaining();
- try
+ if (_partialBytesRead > 0)
{
- result.skip(_chunkSize - 1);
+ _partialCheckNumber = result.get();
}
- catch (IllegalArgumentException e)
+
+ if (_chunksReceived >= _chunkCount)
{
- _logger.error("Position was: " + result.position());
- _logger.error("Tried to skip to: " + (_chunkSize * i));
- _logger.error("limit was; " + result.limit());
+ _notifier.countDown();
}
- }
- _logger.debug("Chunks received now " + _chunksReceived);
- _logger.debug("Bytes received: " + _totalBytesReceived);
- _partialBytesRead = result.remaining();
- if (_partialBytesRead > 0)
- {
- _partialCheckNumber = result.get();
}
- if (_chunksReceived >= _chunkCount)
+ public void exceptionCaught(IoSession session, Throwable cause) throws Exception
{
- _notifier.countDown();
+ _logger.error("Error: " + cause, cause);
}
-
}
- public void exceptionCaught(IoSession session, Throwable cause) throws Exception
+ public void startWriter(int chunkSize) throws IOException, InterruptedException
{
- _logger.error("Error: " + cause, cause);
- }
- }
+ _chunkSize = chunkSize;
- public void startWriter() throws IOException, InterruptedException
- {
- IoConnector ioConnector = null;
+ IoConnector ioConnector = null;
- ioConnector = new SocketConnector();
+ ioConnector = new SocketConnector();
- SocketConnectorConfig cfg = (SocketConnectorConfig) ioConnector.getDefaultConfig();
- cfg.setThreadModel(ThreadModel.MANUAL);
- SocketSessionConfig scfg = (SocketSessionConfig) cfg.getSessionConfig();
- scfg.setTcpNoDelay(true);
- scfg.setSendBufferSize(32768);
- scfg.setReceiveBufferSize(32768);
-
- final InetSocketAddress address = new InetSocketAddress("localhost", AcceptorTest.PORT);
- _logger.info("Attempting connection to " + address);
- ConnectFuture future = ioConnector.connect(address, new WriterHandler());
- // wait for connection to complete
- future.join();
- _logger.info("Connection completed");
- // we call getSession which throws an IOException if there has been an error connecting
- _session = future.getSession();
- _chunkTimes = new long[_chunkCount];
- Thread t = new Thread(this);
- t.start();
- t.join();
- _logger.info("Test completed");
+ SocketConnectorConfig cfg = (SocketConnectorConfig) ioConnector.getDefaultConfig();
+ cfg.setThreadModel(ThreadModel.MANUAL);
+ SocketSessionConfig scfg = (SocketSessionConfig) cfg.getSessionConfig();
+ scfg.setTcpNoDelay(true);
+ scfg.setSendBufferSize(32768);
+ scfg.setReceiveBufferSize(32768);
+
+ final InetSocketAddress address = new InetSocketAddress("localhost", AcceptorTest.PORT);
+ _logger.info("Attempting connection to " + address);
+ ConnectFuture future = ioConnector.connect(address, new WriterHandler());
+ // wait for connection to complete
+ future.join();
+ _logger.info("Connection completed");
+ // we call getSession which throws an IOException if there has been an error connecting
+ _session = future.getSession();
+ _chunkTimes = new long[_chunkCount];
+ Thread t = new Thread(this);
+ t.start();
+ t.join();
+ _logger.info("Test completed");
+ }
}
- @Test
+ private RunnableWriterTest _runnableWriterTest = new RunnableWriterTest(_logger);
+
public void test1k() throws IOException, InterruptedException
{
_logger.info("Starting 1k test");
- _chunkSize = 1024;
- startWriter();
+ _runnableWriterTest.startWriter(1024);
}
- @Test
public void test2k() throws IOException, InterruptedException
{
_logger.info("Starting 2k test");
- _chunkSize = 2048;
- startWriter();
+ _runnableWriterTest.startWriter(2048);
}
- @Test
public void test4k() throws IOException, InterruptedException
{
_logger.info("Starting 4k test");
- _chunkSize = 4096;
- startWriter();
+ _runnableWriterTest.startWriter(4096);
}
- @Test
public void test8k() throws IOException, InterruptedException
{
_logger.info("Starting 8k test");
- _chunkSize = 8192;
- startWriter();
+ _runnableWriterTest.startWriter(8192);
}
- @Test
public void test16k() throws IOException, InterruptedException
{
_logger.info("Starting 16k test");
- _chunkSize = 16384;
- startWriter();
+ _runnableWriterTest.startWriter(16384);
}
- @Test
public void test32k() throws IOException, InterruptedException
{
_logger.info("Starting 32k test");
- _chunkSize = 32768;
- startWriter();
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(WriterTest.class);
+ _runnableWriterTest.startWriter(32768);
}
public static void main(String[] args) throws IOException, InterruptedException
@@ -266,4 +263,9 @@ public class WriterTest implements Runnable
//w.test16k();
//w.test32k();
}
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(WriterTest.class);
+ }
}
diff --git a/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java b/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
index ada10dcd13..56d1ce9b6d 100644
--- a/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
+++ b/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
@@ -22,38 +22,16 @@ package org.apache.qpid.requestreply1;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.Assert;
-import org.junit.After;
+import org.apache.qpid.test.VMBrokerSetup;
import org.apache.log4j.Logger;
-import junit.framework.JUnit4TestAdapter;
-public class VmRequestReply
+import junit.framework.TestCase;
+
+public class VmRequestReply extends TestCase
{
private static final Logger _logger = Logger.getLogger(VmRequestReply.class);
- @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 simpleClient() throws Exception
+ public void testSimpleClient() throws Exception
{
ServiceProvidingClient serviceProvider = new ServiceProvidingClient("vm://:1", "guest", "guest",
"serviceProvidingClient", "/test",
@@ -74,21 +52,21 @@ public class VmRequestReply
}
}
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(VmRequestReply.class);
- }
-
public static void main(String[] args)
{
VmRequestReply rr = new VmRequestReply();
try
{
- rr.simpleClient();
+ rr.testSimpleClient();
}
catch (Exception e)
{
_logger.error("Error: " + e, e);
}
}
+
+ public static junit.framework.Test suite()
+ {
+ return new VMBrokerSetup(new junit.framework.TestSuite(VmRequestReply.class));
+ }
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MessageUnitTests.java b/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
index dfcd80649d..e859fac4af 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MessageUnitTests.java
+++ b/java/client/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,19 +17,36 @@
* under the License.
*
*/
-package org.apache.qpid.test.unit.client.message;
+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({BytesMessageTest.class, TextMessageTest.class})
-public class MessageUnitTests
+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(MessageUnitTests.class);
+ TransportConnection.killVMBroker(1);
+ super.tearDown();
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
index f9b2b15be5..5161705ef2 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.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
@@ -20,7 +19,6 @@
*/
package org.apache.qpid.test.unit.ack;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
@@ -28,14 +26,13 @@ import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.*;
-public class RecoverTest
+import junit.framework.TestCase;
+
+public class RecoverTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(RecoverTest.class);
@@ -48,31 +45,10 @@ public class RecoverTest
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");
- }
-
- @Before
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
+ DOMConfigurator.configure("../broker/etc/log4j.xml");
}
- @After
- public void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
- }
-
- @Test
- public void recoverResendsMsgs() throws Exception
+ public void testRecoverResendsMsgs() throws Exception
{
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
@@ -106,13 +82,13 @@ public class RecoverTest
// no ack for last three messages so when I call recover I expect to get three messages back
consumerSession.recover();
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();
@@ -122,16 +98,14 @@ public class RecoverTest
consumerSession.recover();
tm = (TextMessage) consumer.receiveNoWait();
- Assert.assertNull(tm);
+ assertNull(tm);
_logger.info("No messages redelivered as is expected");
con.close();
-
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(RecoverTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(RecoverTest.class));
}
}
-
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/ack/UnitTests.java b/java/client/src/test/java/org/apache/qpid/test/unit/ack/UnitTests.java
deleted file mode 100644
index a0eec941d5..0000000000
--- a/java/client/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({RecoverTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
index 8013e9e527..bf97c1918e 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.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
@@ -20,7 +19,6 @@
*/
package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
@@ -28,18 +26,17 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSBytesMessage;
+import org.apache.qpid.test.VMBrokerSetup;
import org.apache.mina.common.ByteBuffer;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.Assert;
-import org.junit.After;
-import javax.jms.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import javax.jms.*;
+
+import junit.framework.TestCase;
-public class BytesMessageTest implements MessageListener
+public class BytesMessageTest extends TestCase implements MessageListener
{
private Connection _connection;
private Destination _destination;
@@ -49,29 +46,15 @@ public class BytesMessageTest implements MessageListener
private int _count = 100;
public String _connectionString = "vm://:1";
- @Before
- public void init() throws Exception
+ protected void setUp() throws Exception
{
- createVMBroker();
- init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
+ super.setUp();
+ init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
}
- public void createVMBroker()
+ protected void tearDown() throws Exception
{
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
- }
-
- @After
- public void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
+ super.tearDown();
}
void init(AMQConnection connection) throws Exception
@@ -90,10 +73,8 @@ public class BytesMessageTest implements MessageListener
connection.start();
}
- @Test
public void test() throws Exception
{
-
try
{
send(_count);
@@ -229,6 +210,6 @@ public class BytesMessageTest implements MessageListener
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(BytesMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(BytesMessageTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
index f78014a4b6..079def81d0 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
@@ -20,22 +20,18 @@
*/
package org.apache.qpid.test.unit.basic;
-import org.junit.Test;
-import org.junit.Assert;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.client.message.JMSTextMessage;
import org.apache.qpid.client.message.TestMessageHelper;
-
import java.util.Enumeration;
-import junit.framework.JUnit4TestAdapter;
-
import javax.jms.JMSException;
-public class FieldTableKeyEnumeratorTest
+import junit.framework.TestCase;
+
+public class FieldTableKeyEnumeratorTest extends TestCase
{
- @Test
public void testKeyEnumeration()
{
FieldTable result = new FieldTable();
@@ -47,14 +43,13 @@ public class FieldTableKeyEnumeratorTest
Enumeration e = result.keys();
- Assert.assertTrue("one".equals(e.nextElement()));
- Assert.assertTrue("two".equals(e.nextElement()));
- Assert.assertTrue("three".equals(e.nextElement()));
- Assert.assertTrue("four".equals(e.nextElement()));
- Assert.assertTrue("five".equals(e.nextElement()));
+ assertTrue("one".equals(e.nextElement()));
+ assertTrue("two".equals(e.nextElement()));
+ assertTrue("three".equals(e.nextElement()));
+ assertTrue("four".equals(e.nextElement()));
+ assertTrue("five".equals(e.nextElement()));
}
- @Test
public void testPropertEnu()
{
try
@@ -68,10 +63,10 @@ public class FieldTableKeyEnumeratorTest
Enumeration e = text.getPropertyNames();
- Assert.assertTrue("Boolean1".equals(e.nextElement()));
- Assert.assertTrue("Boolean2".equals(e.nextElement()));
- Assert.assertTrue("Int".equals(e.nextElement()));
- Assert.assertTrue("Long".equals(e.nextElement()));
+ assertTrue("Boolean1".equals(e.nextElement()));
+ assertTrue("Boolean2".equals(e.nextElement()));
+ assertTrue("Int".equals(e.nextElement()));
+ assertTrue("Long".equals(e.nextElement()));
}
catch (JMSException e)
{
@@ -81,8 +76,6 @@ public class FieldTableKeyEnumeratorTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(FieldTableKeyEnumeratorTest.class);
+ return new junit.framework.TestSuite(FieldTableKeyEnumeratorTest.class);
}
-
-
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
index c04166aa12..b969942128 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
@@ -31,17 +30,16 @@ import org.apache.qpid.client.message.JMSBytesMessage;
import org.apache.qpid.framing.AMQFrameDecodingException;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.framing.FieldTableTest;
+import org.apache.qpid.test.VMBrokerSetup;
import org.apache.mina.common.ByteBuffer;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.After;
-import javax.jms.*;
import java.io.IOException;
import java.util.ArrayList;
+import javax.jms.*;
+
+import junit.framework.TestCase;
-public class FieldTableMessageTest implements MessageListener
+public class FieldTableMessageTest extends TestCase implements MessageListener
{
private AMQConnection _connection;
private AMQDestination _destination;
@@ -51,29 +49,15 @@ public class FieldTableMessageTest implements MessageListener
private int _count = 10;
public String _connectionString = "vm://:1";
- @Before
- public void init() throws Exception
+ protected void setUp() throws Exception
{
- createVMBroker();
+ super.setUp();
init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
}
- 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();
}
@@ -108,7 +92,6 @@ public class FieldTableMessageTest implements MessageListener
return result;
}
- @Test
public void test() throws Exception
{
int count = _count;
@@ -170,13 +153,13 @@ public class FieldTableMessageTest implements MessageListener
{
FieldTableMessageTest test = new FieldTableMessageTest();
test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
- test.init();
+ test.setUp();
test._count = argv.length > 1 ? Integer.parseInt(argv[1]) : 5;
test.test();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(FieldTableMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(FieldTableMessageTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
index 1b2108b928..a2569a4701 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.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
@@ -20,24 +19,22 @@
*/
package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.*;
+import junit.framework.TestCase;
+
/**
* This is a slow test.
*/
-public class MultipleConnectionTest
+public class MultipleConnectionTest extends TestCase
{
public static String _connectionString = "vm://:1";
@@ -178,7 +175,6 @@ public class MultipleConnectionTest
test.test();
}
- @Test
public void test() throws Exception
{
String broker = _connectionString;
@@ -220,28 +216,8 @@ public class MultipleConnectionTest
}
}
- @BeforeClass
- public static void createVMBroker() throws Exception
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
- }
-
- @AfterClass
- public static void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
- }
-
-
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(MultipleConnectionTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(MultipleConnectionTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
index a86d756e67..c09369b4b5 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.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
@@ -20,7 +19,6 @@
*/
package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
@@ -28,10 +26,7 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSObjectMessage;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.After;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -42,7 +37,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-public class ObjectMessageTest implements MessageListener
+import junit.framework.TestCase;
+
+public class ObjectMessageTest extends TestCase implements MessageListener
{
private AMQConnection _connection;
private AMQDestination _destination;
@@ -52,37 +49,22 @@ public class ObjectMessageTest implements MessageListener
private int _count = 100;
public String _connectionString = "vm://:1";
- @Before
- public void init()
+ protected void setUp() throws Exception
{
- String broker = _connectionString;
- createVMBroker();
+ super.setUp();
try
- {
- init(new AMQConnection(broker, "guest", "guest", randomize("Client"), "/test_path"));
+ {
+ init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
}
catch (Exception e)
{
- Assert.fail("Uable to initialise: " + e);
- }
- }
-
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
+ fail("Uable to initialise: " + e);
}
}
- @After
- public void stopVmBroker()
+ protected void tearDown() throws Exception
{
- TransportConnection.killVMBroker(1);
+ super.tearDown();
}
private void init(AMQConnection connection) throws Exception
@@ -101,7 +83,6 @@ public class ObjectMessageTest implements MessageListener
connection.start();
}
- @Test
public void test() throws Exception
{
int count = _count;
@@ -225,7 +206,7 @@ public class ObjectMessageTest implements MessageListener
{
ObjectMessageTest test = new ObjectMessageTest();
test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
- test.init();
+ test.setUp();
if (argv.length > 1)
{
test._count = Integer.parseInt(argv[1]);
@@ -235,6 +216,6 @@ public class ObjectMessageTest implements MessageListener
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(ObjectMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(ObjectMessageTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
index cfa438dfdb..e73479eba0 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
@@ -28,14 +27,11 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.After;
-
import javax.jms.MessageConsumer;
-public class ReceiveTest
+import junit.framework.TestCase;
+
+public class ReceiveTest extends TestCase
{
private AMQConnection _connection;
private AMQDestination _destination;
@@ -45,16 +41,15 @@ public class ReceiveTest
private static final String VM_BROKER = "vm://:1";
public String _connectionString = VM_BROKER;
- @Before
- public void init() throws Exception
+ protected void setUp() throws Exception
{
+ super.setUp();
if (_connectionString.equals(VM_BROKER))
{
createVMBroker();
+ String broker = _connectionString;
+ init(new AMQConnection(broker, "guest", "guest", "ReceiveTestClient", "/test_path"));
}
-
- String broker = _connectionString;
- init(new AMQConnection(broker, "guest", "guest", "ReceiveTestClient", "/test_path"));
}
public void createVMBroker()
@@ -63,23 +58,21 @@ public class ReceiveTest
{
TransportConnection.createVMBroker(1);
}
- catch (
- AMQVMBrokerCreationException e)
+ catch (AMQVMBrokerCreationException e)
{
- Assert.fail("Unable to create broker: " + e);
+ fail("Unable to create broker: " + e);
}
}
- @After
- public void stopVmBroker()
+ protected void tearDown() throws Exception
{
if (_connectionString.equals(VM_BROKER))
{
TransportConnection.killVMBroker(1);
}
+ super.tearDown();
}
-
private void init(AMQConnection connection) throws Exception
{
init(connection, new AMQQueue("ReceiveTest", true));
@@ -94,7 +87,6 @@ public class ReceiveTest
_connection.start();
}
- @Test
public void test() throws Exception
{
_consumer.receive(5000);
@@ -105,12 +97,12 @@ public class ReceiveTest
{
ReceiveTest test = new ReceiveTest();
test._connectionString = argv.length == 0 ? VM_BROKER : argv[0];
- test.init();
+ test.setUp();
test.test();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(ReceiveTest.class);
+ return new junit.framework.TestSuite(ReceiveTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
index 436be3c1c9..6fa8ab95bf 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
@@ -20,24 +20,21 @@
*/
package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.After;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
-public class SessionStartTest implements MessageListener
+import junit.framework.TestCase;
+
+public class SessionStartTest extends TestCase implements MessageListener
{
private AMQConnection _connection;
private AMQDestination _destination;
@@ -45,36 +42,15 @@ public class SessionStartTest implements MessageListener
private int count;
public String _connectionString = "vm://:1";
- @Before
- public void init()
+ protected void setUp() throws Exception
{
- createVMBroker();
- try
- {
- init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
- }
- catch (Exception e)
- {
- Assert.fail("Unable to initialise connection: " + e);
- }
- }
-
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
+ super.setUp();
+ init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
}
- @After
- public void stopVmBroker()
+ protected void tearDown() throws Exception
{
- TransportConnection.killVMBroker(1);
+ super.tearDown();
}
private void init(AMQConnection connection) throws Exception
@@ -92,7 +68,6 @@ public class SessionStartTest implements MessageListener
_session.createConsumer(destination).setMessageListener(this);
}
- @Test
public synchronized void test() throws JMSException, InterruptedException
{
try
@@ -131,12 +106,12 @@ public class SessionStartTest implements MessageListener
{
SessionStartTest test = new SessionStartTest();
test._connectionString = argv.length == 0 ? "localhost:5672" : argv[0];
- test.init();
+ test.setUp();
test.test();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(SessionStartTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(SessionStartTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
index ddd8c0865d..11f511449f 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
@@ -28,17 +27,16 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSTextMessage;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.After;
+import org.apache.qpid.test.VMBrokerSetup;
-import javax.jms.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import javax.jms.*;
+
+import junit.framework.TestCase;
-public class TextMessageTest implements MessageListener
+public class TextMessageTest extends TestCase implements MessageListener
{
private AMQConnection _connection;
private Destination _destination;
@@ -48,37 +46,22 @@ public class TextMessageTest implements MessageListener
private int _count = 100;
public String _connectionString = "vm://:1";
- @Before
- public void init()
+ protected void setUp() throws Exception
{
- createVMBroker();
-
+ super.setUp();
try
{
init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
}
catch (Exception e)
{
- Assert.fail("Unable to initialilse connection: " + e);
- }
- }
-
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
+ fail("Unable to initialilse connection: " + e);
}
}
- @After
- public void stopVmBroker()
+ protected void tearDown() throws Exception
{
- TransportConnection.killVMBroker(1);
+ super.tearDown();
}
private void init(AMQConnection connection) throws Exception
@@ -98,7 +81,6 @@ public class TextMessageTest implements MessageListener
connection.start();
}
- @Test
public void test() throws Exception
{
int count = _count;
@@ -197,7 +179,7 @@ public class TextMessageTest implements MessageListener
{
TextMessageTest test = new TextMessageTest();
test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
- test.init();
+ test.setUp();
if (argv.length > 1)
{
test._count = Integer.parseInt(argv[1]);
@@ -207,6 +189,6 @@ public class TextMessageTest implements MessageListener
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TextMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(TextMessageTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/UnitTests.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/UnitTests.java
deleted file mode 100644
index 89bb00edd9..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/UnitTests.java
+++ /dev/null
@@ -1,43 +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.basic;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- BytesMessageTest.class,
- FieldTableMessageTest.class,
- FieldTableKeyEnumeratorTest.class,
- MultipleConnectionTest.class,
- ObjectMessageTest.class,
- SessionStartTest.class,
- TextMessageTest.class
- })
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
index 7086d21a81..9b46c5b18a 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.test.unit.client;
-import org.junit.*;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.AMQTopic;
@@ -29,44 +28,30 @@ import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.AMQException;
import org.apache.qpid.url.URLSyntaxException;
-import junit.framework.JUnit4TestAdapter;
+import org.apache.qpid.test.VMBrokerSetup;
+import java.lang.reflect.Method;
import javax.jms.*;
-public class AMQConnectionTest
-{
+import junit.framework.TestCase;
+public class AMQConnectionTest extends TestCase
+{
private static AMQConnection _connection;
private static AMQTopic _topic;
private static AMQQueue _queue;
private static QueueSession _queueSession;
private static TopicSession _topicSession;
-
- @Before
- public void setUp() throws AMQException, URLSyntaxException, JMSException
+ protected void setUp() throws Exception
{
- createVMBroker();
- //initialise the variables we need for testing
+ super.setUp();
_connection = new AMQConnection("vm://:1", "guest", "guest", "fred", "/test");
_topic = new AMQTopic("mytopic");
_queue = new AMQQueue("myqueue");
}
- 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
{
try
{
@@ -76,7 +61,7 @@ public class AMQConnectionTest
{
//ignore
}
- TransportConnection.killVMBroker(1);
+ super.tearDown();
}
/**
@@ -84,62 +69,137 @@ public class AMQConnectionTest
* And that they throw exceptions where appropriate as per JMS spec
*/
- @Test
public void testCreateQueueSession() throws JMSException
{
_queueSession = _connection.createQueueSession(false, AMQSession.NO_ACKNOWLEDGE);
}
- @Test
public void testCreateTopicSession() throws JMSException
{
_topicSession = _connection.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE);
}
- @Test(expected = javax.jms.IllegalStateException.class)
public void testTopicSessionCreateBrowser() throws JMSException
{
- _topicSession.createBrowser(_queue);
+ try
+ {
+ _topicSession.createBrowser(_queue);
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
}
- @Test(expected = javax.jms.IllegalStateException.class)
public void testTopicSessionCreateQueue() throws JMSException
{
- _topicSession.createQueue("abc");
+ try
+ {
+ _topicSession.createQueue("abc");
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
}
- @Test(expected = javax.jms.IllegalStateException.class)
public void testTopicSessionCreateTemporaryQueue() throws JMSException
{
- _topicSession.createTemporaryQueue();
+ try
+ {
+ _topicSession.createTemporaryQueue();
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
}
- @Test(expected = javax.jms.IllegalStateException.class)
public void testQueueSessionCreateTemporaryTopic() throws JMSException
{
- _queueSession.createTemporaryTopic();
+ try
+ {
+ _queueSession.createTemporaryTopic();
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
}
- @Test(expected = javax.jms.IllegalStateException.class)
public void testQueueSessionCreateTopic() throws JMSException
{
- _queueSession.createTopic("abc");
+ try
+ {
+ _queueSession.createTopic("abc");
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
}
- @Test(expected = javax.jms.IllegalStateException.class)
public void testQueueSessionDurableSubscriber() throws JMSException
{
- _queueSession.createDurableSubscriber(_topic, "abc");
+ try
+ {
+ _queueSession.createDurableSubscriber(_topic, "abc");
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
}
- @Test(expected = javax.jms.IllegalStateException.class)
public void testQueueSessionUnsubscribe() throws JMSException
{
- _queueSession.unsubscribe("abc");
+ try
+ {
+ _queueSession.unsubscribe("abc");
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(AMQConnectionTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(AMQConnectionTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
index 871bd41684..af4673856e 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.test.unit.client;
-import org.junit.*;
import org.apache.qpid.AMQException;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
@@ -28,18 +27,19 @@ import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.test.VMBrokerSetup;
import org.apache.qpid.url.URLSyntaxException;
import javax.jms.JMSException;
import javax.jms.TopicSubscriber;
import javax.jms.QueueReceiver;
-import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
/**
* Tests for QueueReceiver and TopicSubscriber creation methods on AMQSession
*/
-public class AMQSessionTest
+public class AMQSessionTest extends TestCase
{
private static AMQSession _session;
@@ -47,32 +47,16 @@ public class AMQSessionTest
private static AMQQueue _queue;
private static AMQConnection _connection;
- @Before
- public void setUp() throws AMQException, URLSyntaxException, JMSException
+ protected void setUp() throws Exception
{
- createVMBroker();
- //initialise the variables we need for testing
+ super.setUp();
_connection = new AMQConnection("vm://:1", "guest", "guest", "fred", "/test");
_topic = new AMQTopic("mytopic");
_queue = new AMQQueue("myqueue");
_session = (AMQSession) _connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
}
-
- 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
{
try
{
@@ -82,50 +66,45 @@ public class AMQSessionTest
{
//just close
}
- TransportConnection.killVMBroker(1);
+ super.tearDown();
}
- @Test
public void testCreateSubscriber() throws JMSException
{
TopicSubscriber subscriber = _session.createSubscriber(_topic);
- Assert.assertEquals("Topic names should match from TopicSubscriber", _topic.getTopicName(), subscriber.getTopic().getTopicName());
+ 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());
+ assertEquals("Topic names should match from TopicSubscriber with selector", _topic.getTopicName(), subscriber.getTopic().getTopicName());
}
- @Test
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());
+ 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());
+ assertEquals("Topic names should match from durable TopicSubscriber with selector", _topic.getTopicName(), subscriber.getTopic().getTopicName());
}
- @Test
public void testCreateQueueReceiver() throws JMSException
{
QueueReceiver receiver = _session.createQueueReceiver(_queue);
- Assert.assertEquals("Queue names should match from QueueReceiver", _queue.getQueueName(), receiver.getQueue().getQueueName());
+ 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());
+ assertEquals("Queue names should match from QueueReceiver with selector", _queue.getQueueName(), receiver.getQueue().getQueueName());
}
- @Test
public void testCreateReceiver() throws JMSException
{
QueueReceiver receiver = _session.createReceiver(_queue);
- Assert.assertEquals("Queue names should match from QueueReceiver", _queue.getQueueName(), receiver.getQueue().getQueueName());
+ 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());
+ assertEquals("Queue names should match from QueueReceiver with selector", _queue.getQueueName(), receiver.getQueue().getQueueName());
}
- @AfterClass
public static void stopVmBrokers()
{
_queue = null;
@@ -135,8 +114,6 @@ public class AMQSessionTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(AMQSessionTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(AMQSessionTest.class));
}
-
-
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/AllClientUnitTests.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/AllClientUnitTests.java
deleted file mode 100644
index b3cb87a171..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/AllClientUnitTests.java
+++ /dev/null
@@ -1,50 +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.client;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * All client unit tests - even one in packages like org.apache.qpid.ack.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- org.apache.qpid.test.unit.ack.UnitTests.class,
- org.apache.qpid.test.unit.basic.UnitTests.class,
- org.apache.qpid.test.unit.client.channelclose.UnitTests.class,
- org.apache.qpid.test.unit.client.message.MessageUnitTests.class,
- org.apache.qpid.test.unit.client.forwardall.UnitTests.class,
- org.apache.qpid.test.unit.client.destinationurl.UnitTests.class,
- org.apache.qpid.test.unit.jndi.referenceabletest.UnitTests.class,
- org.apache.qpid.test.unit.transacted.UnitTests.class,
- org.apache.qpid.test.unit.client.protocol.AMQProtocolSessionTest.class,
- org.apache.qpid.test.unit.client.AMQConnectionTest.class,
- org.apache.qpid.test.unit.client.AMQSessionTest.class
- })
-public class AllClientUnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(AllClientUnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
index c90d2cc4d3..d3a05c3d75 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
@@ -20,22 +20,20 @@
*/
package org.apache.qpid.test.unit.client.channelclose;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.test.VMBrokerSetup;
import org.apache.log4j.Logger;
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
import javax.jms.*;
import java.util.ArrayList;
import java.util.List;
+import junit.framework.TestCase;
+import junit.textui.TestRunner;
+
/**
* Due to bizarre exception handling all sessions are closed if you get
* a channel close request and no exception listener is registered.
@@ -50,7 +48,7 @@ import java.util.List;
* 3. Since client does not have an exception listener, currently all sessions are
* closed.
*/
-public class ChannelCloseOkTest
+public class ChannelCloseOkTest extends TestCase
{
private Connection _connection;
private Destination _destination1;
@@ -64,27 +62,9 @@ public class ChannelCloseOkTest
public String _connectionString = "vm://:1";
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
- }
-
- public void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
- }
-
- @Before
- public void init() throws Exception
+ protected void setUp() throws Exception
{
- createVMBroker();
+ super.setUp();
_connection = new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path");
@@ -133,7 +113,12 @@ public class ChannelCloseOkTest
}
}
- @After
+ protected void tearDown() throws Exception
+ {
+ closeConnection();
+ super.tearDown();
+ }
+
public void closeConnection() throws JMSException
{
if (_connection != null)
@@ -141,17 +126,13 @@ public class ChannelCloseOkTest
System.out.println(">>>>>>>>>>>>>>.. closing");
_connection.close();
}
-
- stopVmBroker();
}
- @Test
public void testWithoutExceptionListener() throws Exception
{
- test();
+ doTest();
}
- @Test
public void testWithExceptionListener() throws Exception
{
_connection.setExceptionListener(new ExceptionListener()
@@ -162,10 +143,10 @@ public class ChannelCloseOkTest
}
});
- test();
+ doTest();
}
- public void test() throws Exception
+ public void doTest() throws Exception
{
// Check both sessions are ok.
sendAndWait(_session1, _destination1, "first", _received1, 1);
@@ -223,16 +204,13 @@ public class ChannelCloseOkTest
return in + System.currentTimeMillis();
}
- /**
- * For Junit 3 compatibility.
- */
- public static junit.framework.Test suite()
+ public static void main(String[] args)
{
- return new JUnit4TestAdapter(ChannelCloseOkTest.class);
+ TestRunner.run(ChannelCloseOkTest.class);
}
- public static void main(String[] args)
+ public static junit.framework.Test suite()
{
- org.junit.runner.JUnitCore.main(ChannelCloseOkTest.class.getName());
+ return new VMBrokerSetup(new junit.framework.TestSuite(ChannelCloseOkTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/UnitTests.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/UnitTests.java
deleted file mode 100644
index 6daf8e048c..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/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.test.unit.client.channelclose;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- ChannelCloseOkTest.class
- })
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
index 990a9f3121..d7862d047f 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
@@ -27,44 +27,20 @@ import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.AMQException;
import org.apache.qpid.AMQConnectionException;
import org.apache.qpid.AMQUnresolvedAddressException;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.Ignore;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.Connection;
-import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
-public class ConnectionTest
+public class ConnectionTest extends TestCase
{
String _broker = "vm://:1";
String _broker_NotRunning = "vm://:2";
String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs";
- @Before
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
- }
-
- @After
- public void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
- }
-
- @Test
- public void simpleConnection()
+ public void testSimpleConnection()
{
try
{
@@ -73,68 +49,61 @@ public class ConnectionTest
}
catch (Exception e)
{
- Assert.fail("Connection to " + _broker + " should succeed. Reason: " + e);
+ fail("Connection to " + _broker + " should succeed. Reason: " + e);
}
}
- @Ignore("The inVM broker currently has no authentication .. Needs added QPID-70")
- @Test
+ // FIXME The inVM broker currently has no authentication .. Needs added QPID-70
public void passwordFailureConnection() throws Exception
{
try
{
new AMQConnection("amqp://guest:rubbishpassword@clientid/testpath?brokerlist='" + _broker + "?retries='1''");
- Assert.fail("Connection should not be established password is wrong.");
+ fail("Connection should not be established password is wrong.");
}
catch (AMQException amqe)
{
if (!(amqe instanceof AMQAuthenticationException))
{
- Assert.fail("Correct exception not thrown. Excpected 'AMQAuthenticationException' got: " + amqe);
+ fail("Correct exception not thrown. Excpected 'AMQAuthenticationException' got: " + amqe);
}
}
}
- @Test
- public void connectionFailure() throws Exception
+ public void testConnectionFailure() throws Exception
{
try
{
new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='" + _broker_NotRunning + "?retries='0''");
- Assert.fail("Connection should not be established");
+ fail("Connection should not be established");
}
catch (AMQException amqe)
{
if (!(amqe instanceof AMQConnectionException))
{
- Assert.fail("Correct exception not thrown. Excpected 'AMQConnectionException' got: " + amqe);
+ fail("Correct exception not thrown. Excpected 'AMQConnectionException' got: " + amqe);
}
}
}
- @Test
- public void unresolvedHostFailure() throws Exception
+ public void testUnresolvedHostFailure() throws Exception
{
try
{
new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='" + _broker_BadDNS + "?retries='0''");
- Assert.fail("Connection should not be established");
+ fail("Connection should not be established");
}
catch (AMQException amqe)
{
if (!(amqe instanceof AMQUnresolvedAddressException))
{
- Assert.fail("Correct exception not thrown. Excpected 'AMQUnresolvedAddressException' got: " + amqe);
+ fail("Correct exception not thrown. Excpected 'AMQUnresolvedAddressException' got: " + amqe);
}
}
}
- /**
- * For Junit 3 compatibility.
- */
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(ConnectionTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(ConnectionTest.class));
}
-
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java
index 9fbfab7664..d89bc4a771 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java
@@ -20,14 +20,14 @@
*/
package org.apache.qpid.test.unit.client.connection;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.AMQException;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.client.AMQConnection;
import org.apache.log4j.Logger;
-import org.junit.Test;
-public class TestManyConnections
+import junit.framework.TestCase;
+
+public class TestManyConnections extends TestCase
{
private static final Logger _log = Logger.getLogger(TestManyConnections.class);
@@ -53,50 +53,43 @@ public class TestManyConnections
"ms");
}
- @Test
- public void create10Connections() throws AMQException, URLSyntaxException
+ public void testCreate10Connections() throws AMQException, URLSyntaxException
{
createConnections(10);
}
- @Test
- public void create50Connections() throws AMQException, URLSyntaxException
+ public void testCreate50Connections() throws AMQException, URLSyntaxException
{
createConnections(50);
}
- @Test
- public void create100Connections() throws AMQException, URLSyntaxException
+ public void testCreate100Connections() throws AMQException, URLSyntaxException
{
createConnections(100);
}
- @Test
- public void create250Connections() throws AMQException, URLSyntaxException
+ public void testCreate250Connections() throws AMQException, URLSyntaxException
{
createConnections(250);
}
- @Test
- public void create500Connections() throws AMQException, URLSyntaxException
+ public void testCreate500Connections() throws AMQException, URLSyntaxException
{
createConnections(500);
}
- @Test
- public void create1000Connections() throws AMQException, URLSyntaxException
+ public void testCreate1000Connections() throws AMQException, URLSyntaxException
{
createConnections(1000);
}
- @Test
- public void create5000Connections() throws AMQException, URLSyntaxException
+ public void testCreate5000Connections() throws AMQException, URLSyntaxException
{
createConnections(5000);
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TestManyConnections.class);
+ return new junit.framework.TestSuite(TestManyConnections.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
index 1a5c6f84f7..13a6d214ba 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
@@ -20,11 +20,6 @@
*/
package org.apache.qpid.test.unit.client.connectionurl;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.Ignore;
import org.apache.qpid.client.AMQConnectionURL;
import org.apache.qpid.client.AMQBrokerDetails;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
@@ -32,280 +27,269 @@ import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.jms.ConnectionURL;
import org.apache.qpid.jms.BrokerDetails;
import org.apache.qpid.url.URLSyntaxException;
-import junit.framework.JUnit4TestAdapter;
-public class ConnectionURLTest
+import junit.framework.TestCase;
+
+public class ConnectionURLTest extends TestCase
{
- @Test
- public void failoverURL() throws URLSyntaxException
+ public void testFailoverURL() throws URLSyntaxException
{
String url = "amqp://ritchiem:bob@/temp?brokerlist='tcp://localhost:5672;tcp://fancyserver:3000/',failover='roundrobin'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod().equals("roundrobin"));
- Assert.assertTrue(connectionurl.getUsername().equals("ritchiem"));
- Assert.assertTrue(connectionurl.getPassword().equals("bob"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+ assertTrue(connectionurl.getFailoverMethod().equals("roundrobin"));
+ assertTrue(connectionurl.getUsername().equals("ritchiem"));
+ assertTrue(connectionurl.getPassword().equals("bob"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 2);
+ assertTrue(connectionurl.getBrokerCount() == 2);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
service = connectionurl.getBrokerDetails(1);
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("fancyserver"));
- Assert.assertTrue(service.getPort() == 3000);
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("fancyserver"));
+ assertTrue(service.getPort() == 3000);
}
- @Test
- public void singleTransportUsernamePasswordURL() throws URLSyntaxException
+ public void testSingleTransportUsernamePasswordURL() throws URLSyntaxException
{
String url = "amqp://ritchiem:bob@/temp?brokerlist='tcp://localhost:5672'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("ritchiem"));
- Assert.assertTrue(connectionurl.getPassword().equals("bob"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("ritchiem"));
+ assertTrue(connectionurl.getPassword().equals("bob"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
+ assertTrue(connectionurl.getBrokerCount() == 1);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
}
- @Test
- public void singleTransportUsernameBlankPasswordURL() throws URLSyntaxException
+ public void testSingleTransportUsernameBlankPasswordURL() throws URLSyntaxException
{
String url = "amqp://ritchiem:@/temp?brokerlist='tcp://localhost:5672'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("ritchiem"));
- Assert.assertTrue(connectionurl.getPassword().equals(""));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("ritchiem"));
+ assertTrue(connectionurl.getPassword().equals(""));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
+ assertTrue(connectionurl.getBrokerCount() == 1);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
}
- @Test
- public void failedURLNullPassword()
+ public void testFailedURLNullPassword()
{
String url = "amqp://ritchiem@/temp?brokerlist='tcp://localhost:5672'";
try
{
new AMQConnectionURL(url);
- Assert.fail("URL has null password");
+ fail("URL has null password");
}
catch (URLSyntaxException e)
{
- Assert.assertTrue(e.getReason().equals("Null password in user information not allowed."));
- Assert.assertTrue(e.getIndex() == 7);
+ assertTrue(e.getReason().equals("Null password in user information not allowed."));
+ assertTrue(e.getIndex() == 7);
}
}
- @Test
- public void singleTransportURL() throws URLSyntaxException
+ public void testSingleTransportURL() throws URLSyntaxException
{
String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/test"));
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/test"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
+ assertTrue(connectionurl.getBrokerCount() == 1);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
}
- @Test
- public void singleTransportWithClientURLURL() throws URLSyntaxException
+ public void testSingleTransportWithClientURLURL() throws URLSyntaxException
{
String url = "amqp://guest:guest@clientname/temp?brokerlist='tcp://localhost:5672'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
- Assert.assertTrue(connectionurl.getClientName().equals("clientname"));
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+ assertTrue(connectionurl.getClientName().equals("clientname"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
+ assertTrue(connectionurl.getBrokerCount() == 1);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
}
- @Test
- public void singleTransport1OptionURL() throws URLSyntaxException
+ public void testSingleTransport1OptionURL() throws URLSyntaxException
{
String url = "amqp://guest:guest@/temp?brokerlist='tcp://localhost:5672',routingkey='jim'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
+ assertTrue(connectionurl.getBrokerCount() == 1);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
- Assert.assertTrue(connectionurl.getOption("routingkey").equals("jim"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
+ assertTrue(connectionurl.getOption("routingkey").equals("jim"));
}
- @Test
- public void singleTransportDefaultedBroker() throws URLSyntaxException
+ public void testSingleTransportDefaultedBroker() throws URLSyntaxException
{
String url = "amqp://guest:guest@/temp?brokerlist='localhost'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
+ assertTrue(connectionurl.getBrokerCount() == 1);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
}
- @Test
- public void singleTransportMultiOptionURL() throws URLSyntaxException
+ public void testSingleTransportMultiOptionURL() throws URLSyntaxException
{
String url = "amqp://guest:guest@/temp?brokerlist='tcp://localhost:5672',routingkey='jim',timeout='200',immediatedelivery='true'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
+ assertTrue(connectionurl.getBrokerCount() == 1);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
- Assert.assertTrue(connectionurl.getOption("routingkey").equals("jim"));
- Assert.assertTrue(connectionurl.getOption("timeout").equals("200"));
- Assert.assertTrue(connectionurl.getOption("immediatedelivery").equals("true"));
+ assertTrue(connectionurl.getOption("routingkey").equals("jim"));
+ assertTrue(connectionurl.getOption("timeout").equals("200"));
+ assertTrue(connectionurl.getOption("immediatedelivery").equals("true"));
}
- @Test
- public void singlevmURL() throws URLSyntaxException
+ public void testSinglevmURL() throws URLSyntaxException
{
String url = "amqp://guest:guest@/messages?brokerlist='vm://:2'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/messages"));
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/messages"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
+ assertTrue(connectionurl.getBrokerCount() == 1);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("vm"));
- Assert.assertTrue(service.getHost().equals(""));
- Assert.assertTrue(service.getPort() == 2);
+ assertTrue(service.getTransport().equals("vm"));
+ assertTrue(service.getHost().equals(""));
+ assertTrue(service.getPort() == 2);
}
- @Test
- public void failoverVMURL() throws URLSyntaxException
+ public void testFailoverVMURL() throws URLSyntaxException
{
String url = "amqp://ritchiem:bob@/temp?brokerlist='vm://:2;vm://:3',failover='roundrobin'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getFailoverMethod().equals("roundrobin"));
- Assert.assertTrue(connectionurl.getUsername().equals("ritchiem"));
- Assert.assertTrue(connectionurl.getPassword().equals("bob"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+ assertTrue(connectionurl.getFailoverMethod().equals("roundrobin"));
+ assertTrue(connectionurl.getUsername().equals("ritchiem"));
+ assertTrue(connectionurl.getPassword().equals("bob"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 2);
+ assertTrue(connectionurl.getBrokerCount() == 2);
BrokerDetails service = connectionurl.getBrokerDetails(0);
- Assert.assertTrue(service.getTransport().equals("vm"));
- Assert.assertTrue(service.getHost().equals(""));
- Assert.assertTrue(service.getPort() == 2);
+ assertTrue(service.getTransport().equals("vm"));
+ assertTrue(service.getHost().equals(""));
+ assertTrue(service.getPort() == 2);
service = connectionurl.getBrokerDetails(1);
- Assert.assertTrue(service.getTransport().equals("vm"));
- Assert.assertTrue(service.getHost().equals(""));
- Assert.assertTrue(service.getPort() == 3);
+ assertTrue(service.getTransport().equals("vm"));
+ assertTrue(service.getHost().equals(""));
+ assertTrue(service.getPort() == 3);
}
- @Test
- public void noVirtualHostURL()
+ public void testNoVirtualHostURL()
{
String url = "amqp://user@?brokerlist='tcp://localhost:5672'";
try
{
new AMQConnectionURL(url);
- Assert.fail("URL has no virtual host should not parse");
+ fail("URL has no virtual host should not parse");
}
catch (URLSyntaxException e)
{
@@ -313,23 +297,22 @@ public class ConnectionURLTest
}
}
- @Test
- public void noClientID() throws URLSyntaxException
+ public void testNoClientID() throws URLSyntaxException
{
String url = "amqp://user:@/test?brokerlist='tcp://localhost:5672'";
ConnectionURL connectionurl = new AMQConnectionURL(url);
- Assert.assertTrue(connectionurl.getUsername().equals("user"));
- Assert.assertTrue(connectionurl.getPassword().equals(""));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/test"));
+ assertTrue(connectionurl.getUsername().equals("user"));
+ assertTrue(connectionurl.getPassword().equals(""));
+ assertTrue(connectionurl.getVirtualHost().equals("/test"));
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
+ assertTrue(connectionurl.getBrokerCount() == 1);
}
- @Ignore("Connection now parses but result is wrong QPID-71")
- @Test
- public void wrongOptionSeperatorInBroker()
+ // FIXME Connection now parses but result is wrong QPID-71
+ /*
+ public void testWrongOptionSeparatorInBroker()
{
String url = "amqp://user:@/test?brokerlist='tcp://localhost:5672+option='value''";
@@ -340,103 +323,97 @@ public class ConnectionURLTest
Float version = Float.parseFloat(System.getProperty("java.specification.version"));
if (version > 1.5)
{
- Assert.fail("URL Should not parse on Java " + version + " Connection is:" + connection);
+ fail("URL Should not parse on Java " + version + " Connection is:" + connection);
}
}
catch (URLSyntaxException urise)
{
- Assert.assertTrue(urise.getReason().equals("Illegal character in port number"));
+ assertTrue(urise.getReason().equals("Illegal character in port number"));
}
}
+ */
- @Test
- public void wrongOptionSeperatorInOptions()
+ public void testWrongOptionSeparatorInOptions()
{
String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'+failover='roundrobin'";
try
{
new AMQConnectionURL(url);
- Assert.fail("URL Should not parse");
+ fail("URL Should not parse");
}
catch (URLSyntaxException urise)
{
- Assert.assertTrue(urise.getReason().equals("Unterminated option. Possible illegal option separator:'+'"));
+ assertTrue(urise.getReason().equals("Unterminated option. Possible illegal option separator:'+'"));
}
}
- @Test
- public void transportsDefaultToTCP() throws URLSyntaxException
+ public void testTransportsDefaultToTCP() throws URLSyntaxException
{
String url = "amqp://guest:guest@/test?brokerlist='localhost:5672;myhost:5673'&failover='roundrobin'";
AMQConnectionURL connection = new AMQConnectionURL(url);
BrokerDetails broker = connection.getBrokerDetails(0);
- Assert.assertTrue(broker.getTransport().equals("tcp"));
+ assertTrue(broker.getTransport().equals("tcp"));
broker = connection.getBrokerDetails(1);
- Assert.assertTrue(broker.getTransport().equals("tcp"));
+ assertTrue(broker.getTransport().equals("tcp"));
}
- @Test
- public void noUserDetailsProvidedWithClientID()
+ public void testNoUserDetailsProvidedWithClientID()
{
String url = "amqp://clientID/test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'";
try
{
new AMQConnectionURL(url);
- Assert.fail("URL Should not parse");
+ fail("URL Should not parse");
}
catch (URLSyntaxException urise)
{
- Assert.assertTrue(urise.getMessage().startsWith("User information not found on url"));
+ assertTrue(urise.getMessage().startsWith("User information not found on url"));
}
}
- @Test
- public void noUserDetailsProvidedNOClientID()
+ public void testNoUserDetailsProvidedNOClientID()
{
String url = "amqp:///test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'";
try
{
new AMQConnectionURL(url);
- Assert.fail("URL Should not parse");
+ fail("URL Should not parse");
}
catch (URLSyntaxException urise)
{
- Assert.assertTrue(urise.getMessage().startsWith("User information not found on url"));
+ assertTrue(urise.getMessage().startsWith("User information not found on url"));
}
}
- @Test
- public void checkVirtualhostFormat() throws URLSyntaxException
+ public void testCheckVirtualhostFormat() throws URLSyntaxException
{
String url = "amqp://guest:guest@/t.-_+!=:?brokerlist='tcp://localhost:5672'";
AMQConnectionURL connection = new AMQConnectionURL(url);
- Assert.assertTrue(connection.getVirtualHost().equals("/t.-_+!=:"));
+ assertTrue(connection.getVirtualHost().equals("/t.-_+!=:"));
}
- @Test
- public void checkDefaultPort() throws URLSyntaxException
+ public void testCheckDefaultPort() throws URLSyntaxException
{
String url = "amqp://guest:guest@/test=:?brokerlist='tcp://localhost'";
AMQConnectionURL connection = new AMQConnectionURL(url);
BrokerDetails broker = connection.getBrokerDetails(0);
- Assert.assertTrue(broker.getPort() == AMQBrokerDetails.DEFAULT_PORT);
+ assertTrue(broker.getPort() == AMQBrokerDetails.DEFAULT_PORT);
}
- @Test
- public void checkMissingFinalQuote() throws URLSyntaxException
+ public void testCheckMissingFinalQuote() throws URLSyntaxException
{
String url = "amqp://guest:guest@id/test" + "?brokerlist='tcp://localhost:5672";
@@ -446,15 +423,12 @@ public class ConnectionURLTest
}
catch (URLSyntaxException e)
{
- Assert.assertEquals(e.getMessage(), "Unterminated option at index 32: brokerlist='tcp://localhost:5672");
+ assertEquals(e.getMessage(), "Unterminated option at index 32: brokerlist='tcp://localhost:5672");
}
-
-
}
-
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(ConnectionURLTest.class);
+ return new junit.framework.TestSuite(ConnectionURLTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/UnitTests.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/UnitTests.java
deleted file mode 100644
index 6184810880..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/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.client.connectionurl;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import junit.framework.JUnit4TestAdapter;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ConnectionURLTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(org.apache.qpid.test.unit.client.connectionurl.UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
index aad5aace65..58a3c8c282 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
@@ -20,134 +20,126 @@
*/
package org.apache.qpid.test.unit.client.destinationurl;
-import org.junit.Test;
-import org.junit.Assert;
import org.apache.qpid.url.AMQBindingURL;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.exchange.ExchangeDefaults;
-import junit.framework.JUnit4TestAdapter;
-public class DestinationURLTest
+import junit.framework.TestCase;
+
+public class DestinationURLTest extends TestCase
{
- @Test
- public void fullURL() throws URLSyntaxException
+ public void testFullURL() throws URLSyntaxException
{
String url = "exchange.Class://exchangeName/Destination/Queue";
AMQBindingURL dest = new AMQBindingURL(url);
- Assert.assertTrue(url.equals(dest.toString()));
+ assertTrue(url.equals(dest.toString()));
- Assert.assertTrue(dest.getExchangeClass().equals("exchange.Class"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals("Destination"));
- Assert.assertTrue(dest.getQueueName().equals("Queue"));
+ assertTrue(dest.getExchangeClass().equals("exchange.Class"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals("Destination"));
+ assertTrue(dest.getQueueName().equals("Queue"));
}
- @Test
- public void queue() throws URLSyntaxException
+ public void testQueue() throws URLSyntaxException
{
String url = "exchangeClass://exchangeName//Queue";
AMQBindingURL dest = new AMQBindingURL(url);
- Assert.assertTrue(url.equals(dest.toString()));
+ assertTrue(url.equals(dest.toString()));
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals(""));
- Assert.assertTrue(dest.getQueueName().equals("Queue"));
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals(""));
+ assertTrue(dest.getQueueName().equals("Queue"));
}
- @Test
- public void queueWithOption() throws URLSyntaxException
+ public void testQueueWithOption() throws URLSyntaxException
{
String url = "exchangeClass://exchangeName//Queue?option='value'";
AMQBindingURL dest = new AMQBindingURL(url);
- Assert.assertTrue(url.equals(dest.toString()));
+ assertTrue(url.equals(dest.toString()));
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals(""));
- Assert.assertTrue(dest.getQueueName().equals("Queue"));
- Assert.assertTrue(dest.getOption("option").equals("value"));
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals(""));
+ assertTrue(dest.getQueueName().equals("Queue"));
+ assertTrue(dest.getOption("option").equals("value"));
}
- @Test
- public void destination() throws URLSyntaxException
+ public void testDestination() throws URLSyntaxException
{
String url = "exchangeClass://exchangeName/Destination/";
AMQBindingURL dest = new AMQBindingURL(url);
- Assert.assertTrue(url.equals(dest.toString()));
+ assertTrue(url.equals(dest.toString()));
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals("Destination"));
- Assert.assertTrue(dest.getQueueName().equals(""));
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals("Destination"));
+ assertTrue(dest.getQueueName().equals(""));
}
- @Test
- public void destinationWithOption() throws URLSyntaxException
+ public void testDestinationWithOption() throws URLSyntaxException
{
String url = "exchangeClass://exchangeName/Destination/?option='value'";
AMQBindingURL dest = new AMQBindingURL(url);
- Assert.assertTrue(url.equals(dest.toString()));
+ assertTrue(url.equals(dest.toString()));
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals("Destination"));
- Assert.assertTrue(dest.getQueueName().equals(""));
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals("Destination"));
+ assertTrue(dest.getQueueName().equals(""));
- Assert.assertTrue(dest.getOption("option").equals("value"));
+ assertTrue(dest.getOption("option").equals("value"));
}
- @Test
- public void destinationWithMultiOption() throws URLSyntaxException
+ public void testDestinationWithMultiOption() throws URLSyntaxException
{
String url = "exchangeClass://exchangeName/Destination/?option='value',option2='value2'";
AMQBindingURL dest = new AMQBindingURL(url);
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals("Destination"));
- Assert.assertTrue(dest.getQueueName().equals(""));
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals("Destination"));
+ assertTrue(dest.getQueueName().equals(""));
- Assert.assertTrue(dest.getOption("option").equals("value"));
- Assert.assertTrue(dest.getOption("option2").equals("value2"));
+ assertTrue(dest.getOption("option").equals("value"));
+ assertTrue(dest.getOption("option2").equals("value2"));
}
- @Test
- public void destinationWithNoExchangeDefaultsToDirect() throws URLSyntaxException
+ public void testDestinationWithNoExchangeDefaultsToDirect() throws URLSyntaxException
{
String url = "IBMPerfQueue1?durable='true'";
AMQBindingURL dest = new AMQBindingURL(url);
- Assert.assertTrue(dest.getExchangeClass().equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS));
- Assert.assertTrue(dest.getExchangeName().equals(ExchangeDefaults.DIRECT_EXCHANGE_NAME));
- Assert.assertTrue(dest.getDestinationName().equals(""));
- Assert.assertTrue(dest.getQueueName().equals("IBMPerfQueue1"));
+ assertTrue(dest.getExchangeClass().equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS));
+ assertTrue(dest.getExchangeName().equals(ExchangeDefaults.DIRECT_EXCHANGE_NAME));
+ assertTrue(dest.getDestinationName().equals(""));
+ assertTrue(dest.getQueueName().equals("IBMPerfQueue1"));
- Assert.assertTrue(dest.getOption("durable").equals("true"));
+ assertTrue(dest.getOption("durable").equals("true"));
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(DestinationURLTest.class);
+ return new junit.framework.TestSuite(DestinationURLTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/UnitTests.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/UnitTests.java
deleted file mode 100644
index db7d9f3f0b..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/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.client.destinationurl;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import junit.framework.JUnit4TestAdapter;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({DestinationURLTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
index be2f85e878..9218424a5e 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
@@ -20,43 +20,31 @@
*/
package org.apache.qpid.test.unit.client.forwardall;
-import junit.framework.JUnit4TestAdapter;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.Assert;
-import org.junit.After;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.test.VMBrokerSetup;
+
+import junit.framework.TestCase;
/**
* Runs the Service's and Client parts of the test in the same process
* as the broker
*/
-public class CombinedTest
+public class CombinedTest extends TestCase
{
- @Before
- public void createVMBroker()
+ protected void setUp() throws Exception
{
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
+ super.setUp();
}
- @After
- public void stopVmBroker()
+ protected void tearDown() throws Exception
{
ServiceCreator.closeAll();
- TransportConnection.killVMBroker(1);
+ super.tearDown();
}
- @Test
- public void forwardAll() throws Exception
+ public void testForwardAll() throws Exception
{
int services = 2;
ServiceCreator.start("vm://:1", services);
@@ -70,6 +58,6 @@ public class CombinedTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(CombinedTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(CombinedTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/UnitTests.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/UnitTests.java
deleted file mode 100644
index 6be99bcda9..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/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.test.unit.client.forwardall;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- CombinedTest.class
-})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java
index fbd32d0783..2a76c920b1 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java
@@ -20,9 +20,6 @@
*/
package org.apache.qpid.test.unit.client.message;
-import junit.framework.JUnit4TestAdapter;
-import org.junit.Test;
-import org.junit.Assert;
import org.apache.qpid.client.message.JMSBytesMessage;
import org.apache.qpid.client.message.TestMessageHelper;
@@ -30,29 +27,52 @@ import javax.jms.MessageNotReadableException;
import javax.jms.MessageNotWriteableException;
import javax.jms.MessageEOFException;
-public class BytesMessageTest
+import junit.framework.TestCase;
+
+public class BytesMessageTest extends TestCase
{
/**
* Tests that on creation a call to getBodyLength() throws an exception
* if null was passed in during creation
*/
- @Test(expected=MessageNotReadableException.class)
public void testNotReadableOnCreationWithNull() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.getBodyLength();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.getBodyLength();
+ fail("expected exception did not occur");
+ }
+ catch (MessageNotReadableException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageNotReadableException, got " + e);
+ }
}
- @Test(expected= MessageNotWriteableException.class)
public void testResetMakesReadble() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeInt(10);
- bm.reset();
- bm.writeInt(12);
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeInt(10);
+ bm.reset();
+ bm.writeInt(12);
+ fail("expected exception did not occur");
+ }
+ catch (MessageNotWriteableException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageNotWriteableException, got " + e);
+ }
}
- @Test
public void testClearBodyMakesWritable() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
@@ -62,153 +82,271 @@ public class BytesMessageTest
bm.writeInt(10);
}
- @Test
public void testWriteInt() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeInt(10);
bm.reset();
long len = bm.getBodyLength();
- Assert.assertTrue(len == 4);
+ assertTrue(len == 4);
int val = bm.readInt();
- Assert.assertTrue(val == 10);
+ assertTrue(val == 10);
}
- @Test
public void testWriteString() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeUTF("Bananas");
bm.reset();
String res = bm.readUTF();
- Assert.assertEquals("Bananas", res);
+ assertEquals("Bananas", res);
}
- @Test(expected=NullPointerException.class)
public void testWriteObjectThrowsNPE() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeObject(null);
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeObject(null);
+ fail("expected exception did not occur");
+ }
+ catch (NullPointerException n)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected NullPointerException, got " + e);
+ }
}
- @Test
public void testReadBoolean() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.writeBoolean(true);
bm.reset();
boolean result = bm.readBoolean();
- Assert.assertTrue(result);
+ assertTrue(result);
}
- @Test(expected=MessageEOFException.class)
public void testEOFByte() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeByte((byte)1);
- bm.reset();
- bm.readByte();
- // should throw
- bm.readByte();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeByte((byte)1);
+ bm.reset();
+ bm.readByte();
+ // should throw
+ bm.readByte();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
- @Test(expected=MessageEOFException.class)
public void testEOFUnsignedByte() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeByte((byte)1);
- bm.reset();
- bm.readByte();
- // should throw
- bm.readUnsignedByte();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeByte((byte)1);
+ bm.reset();
+ bm.readByte();
+ // should throw
+ bm.readUnsignedByte();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
- @Test(expected=MessageEOFException.class)
public void testEOFBoolean() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeBoolean(true);
- bm.reset();
- bm.readBoolean();
- // should throw
- bm.readBoolean();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeBoolean(true);
+ bm.reset();
+ bm.readBoolean();
+ // should throw
+ bm.readBoolean();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
- @Test(expected=MessageEOFException.class)
public void testEOFChar() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeChar('A');
- bm.reset();
- bm.readChar();
- // should throw
- bm.readChar();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeChar('A');
+ bm.reset();
+ bm.readChar();
+ // should throw
+ bm.readChar();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
- @Test(expected=MessageEOFException.class)
public void testEOFDouble() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeDouble(1.3d);
- bm.reset();
- bm.readDouble();
- // should throw
- bm.readDouble();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeDouble(1.3d);
+ bm.reset();
+ bm.readDouble();
+ // should throw
+ bm.readDouble();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
- @Test(expected=MessageEOFException.class)
public void testEOFFloat() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeFloat(1.3f);
- bm.reset();
- bm.readFloat();
- // should throw
- bm.readFloat();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeFloat(1.3f);
+ bm.reset();
+ bm.readFloat();
+ // should throw
+ bm.readFloat();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
- @Test(expected=MessageEOFException.class)
public void testEOFInt() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeInt(99);
- bm.reset();
- bm.readInt();
- // should throw
- bm.readInt();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeInt(99);
+ bm.reset();
+ bm.readInt();
+ // should throw
+ bm.readInt();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
- @Test(expected=MessageEOFException.class)
public void testEOFLong() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeLong(4L);
- bm.reset();
- bm.readLong();
- // should throw
- bm.readLong();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeLong(4L);
+ bm.reset();
+ bm.readLong();
+ // should throw
+ bm.readLong();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
- @Test(expected=MessageEOFException.class)
public void testEOFShort() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeShort((short)4);
- bm.reset();
- bm.readShort();
- // should throw
- bm.readShort();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeShort((short)4);
+ bm.reset();
+ bm.readShort();
+ // should throw
+ bm.readShort();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
- @Test(expected=MessageEOFException.class)
public void testEOFUnsignedShort() throws Exception
{
- JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
- bm.writeShort((short)4);
- bm.reset();
- bm.readUnsignedShort();
- // should throw
- bm.readUnsignedShort();
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeShort((short)4);
+ bm.reset();
+ bm.readUnsignedShort();
+ // should throw
+ bm.readUnsignedShort();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
}
/**
@@ -216,7 +354,6 @@ public class BytesMessageTest
* correctly
* @throws Exception
*/
- @Test
public void testReadBytes() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
@@ -225,12 +362,11 @@ public class BytesMessageTest
bm.reset();
byte[] result = new byte[2];
int count = bm.readBytes(result);
- Assert.assertEquals((byte)3, result[0]);
- Assert.assertEquals((byte)4, result[1]);
- Assert.assertEquals(2, count);
+ assertEquals((byte)3, result[0]);
+ assertEquals((byte)4, result[1]);
+ assertEquals(2, count);
}
- @Test
public void testReadBytesEOF() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
@@ -240,10 +376,9 @@ public class BytesMessageTest
byte[] result = new byte[2];
bm.readBytes(result);
int count = bm.readBytes(result);
- Assert.assertEquals(-1, count);
+ assertEquals(-1, count);
}
- @Test
public void testReadBytesWithLargerArray() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
@@ -252,13 +387,12 @@ public class BytesMessageTest
bm.reset();
byte[] result = new byte[3];
int count = bm.readBytes(result);
- Assert.assertEquals(2, count);
- Assert.assertEquals((byte)3, result[0]);
- Assert.assertEquals((byte)4, result[1]);
- Assert.assertEquals((byte)0, result[2]);
+ assertEquals(2, count);
+ assertEquals((byte)3, result[0]);
+ assertEquals((byte)4, result[1]);
+ assertEquals((byte)0, result[2]);
}
- @Test
public void testReadBytesWithCount() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
@@ -268,13 +402,12 @@ public class BytesMessageTest
bm.reset();
byte[] result = new byte[3];
int count = bm.readBytes(result, 2);
- Assert.assertEquals(2, count);
- Assert.assertEquals((byte)3, result[0]);
- Assert.assertEquals((byte)4, result[1]);
- Assert.assertEquals((byte)0, result[2]);
+ assertEquals(2, count);
+ assertEquals((byte)3, result[0]);
+ assertEquals((byte)4, result[1]);
+ assertEquals((byte)0, result[2]);
}
- @Test
public void testToBodyString() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
@@ -282,20 +415,19 @@ public class BytesMessageTest
bm.writeUTF(testText);
bm.reset();
String result = bm.toBodyString();
- Assert.assertEquals(testText, result);
+ assertEquals(testText, result);
}
- @Test
public void testToBodyStringWithNull() throws Exception
{
JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
bm.reset();
String result = bm.toBodyString();
- Assert.assertNull(result);
+ assertNull(result);
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(BytesMessageTest.class);
+ return new junit.framework.TestSuite(BytesMessageTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
index 13deeed1fa..9425b7c304 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
@@ -26,11 +26,7 @@ import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
-
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
@@ -41,58 +37,25 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.ArrayList;
-import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
-public class ObjectMessageTest implements MessageListener
+public class ObjectMessageTest extends TestCase implements MessageListener
{
- private final AMQConnection connection;
- private final AMQDestination destination;
- private final AMQSession session;
- private final Serializable[] data;
+ private AMQConnection connection;
+ private AMQDestination destination;
+ private AMQSession session;
+ private Serializable[] data;
private volatile boolean waiting;
private int received;
private final ArrayList items = new ArrayList();
+ private String _broker = "vm://:1";
- @BeforeClass
- public static void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
- }
-
- @AfterClass
- public static void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
- }
-
-
- public ObjectMessageTest() throws Exception
- {
- this(new AMQConnection("vm://:1", "guest", "guest", randomize("Client"), "/test_path"));
- }
-
- ObjectMessageTest(String broker) throws Exception
- {
- this(new AMQConnection(broker, "guest", "guest", randomize("Client"), "/test_path"));
- }
-
- ObjectMessageTest(AMQConnection connection) throws Exception
- {
- this(connection, new AMQQueue(randomize("LatencyTest"), true));
- }
-
- ObjectMessageTest(AMQConnection connection, AMQDestination destination) throws Exception
+ protected void setUp() throws Exception
{
- this.connection = connection;
- this.destination = destination;
+ super.setUp();
+ connection = new AMQConnection(_broker, "guest", "guest", randomize("Client"), "/test_path");
+ destination = new AMQQueue(randomize("LatencyTest"), true);
session = (AMQSession) connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
A a1 = new A(1, "A");
A a2 = new A(2, "a");
@@ -106,6 +69,19 @@ public class ObjectMessageTest implements MessageListener
data = new Serializable[]{a1, a2, b, c, "Hello World!", new Integer(1001)};
}
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public ObjectMessageTest()
+ {
+ }
+
+ ObjectMessageTest(String broker) throws Exception
+ {
+ _broker = broker;
+ }
public void test() throws Exception
{
@@ -116,6 +92,10 @@ public class ObjectMessageTest implements MessageListener
check();
System.out.println("All " + data.length + " items matched.");
}
+ catch (Exception e)
+ {
+ fail("This Test should succeed but failed due to: " + e);
+ }
finally
{
close();
@@ -220,19 +200,6 @@ public class ObjectMessageTest implements MessageListener
}
- @Test
- public void doJUnitTest()
- {
- try
- {
- new ObjectMessageTest("vm://:1").test();
- }
- catch (Exception e)
- {
- Assert.fail("This Test should succeed but failed due to: " + e);
- }
- }
-
public static void main(String[] argv) throws Exception
{
String broker = argv.length > 0 ? argv[0] : "vm://:1";
@@ -302,6 +269,6 @@ public class ObjectMessageTest implements MessageListener
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(ObjectMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(ObjectMessageTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
index a73e0cb6be..337b0f3bbc 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
@@ -20,37 +20,35 @@
*/
package org.apache.qpid.test.unit.client.message;
-import junit.framework.JUnit4TestAdapter;
-import org.junit.Test;
-import org.junit.Assert;
import org.apache.qpid.client.message.TestMessageHelper;
import org.apache.qpid.client.message.JMSTextMessage;
-public class TextMessageTest
+import junit.framework.TestCase;
+
+public class TextMessageTest extends TestCase
{
- @Test
public void testTextOnConstruction() throws Exception
{
JMSTextMessage tm = TestMessageHelper.newJMSTextMessage();
tm.setText("pies");
String val = tm.getText();
- Assert.assertEquals(val, "pies");
+ assertEquals(val, "pies");
}
- @Test
public void testClearBody() throws Exception
{
JMSTextMessage tm = TestMessageHelper.newJMSTextMessage();
tm.setText("pies");
tm.clearBody();
String val = tm.getText();
- Assert.assertNull(val);
+ assertNull(val);
tm.setText("Banana");
val = tm.getText();
- Assert.assertEquals(val, "Banana");
+ assertEquals(val, "Banana");
}
+
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TextMessageTest.class);
+ return new junit.framework.TestSuite(TextMessageTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
index 417d1baced..98e355b0da 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
@@ -24,14 +24,33 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.protocol.AMQProtocolHandler;
import org.apache.qpid.client.protocol.AMQProtocolSession;
import org.apache.mina.common.IoSession;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.After;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Assert;
-public class AMQProtocolSessionTest extends AMQProtocolSession
+import junit.framework.TestCase;
+
+public class AMQProtocolSessionTest extends TestCase
{
+ private static class AMQProtSession extends AMQProtocolSession
+ {
+ public AMQProtSession()
+ {
+ }
+
+ public AMQProtSession(AMQProtocolHandler protocolHandler, IoSession protocolSession, AMQConnection connection)
+ {
+ super(protocolHandler,protocolSession,connection);
+ }
+
+ public TestIoSession getMinaProtocolSession()
+ {
+ return (TestIoSession) _minaProtocolSession;
+ }
+
+ public String genQueueName()
+ {
+ return generateQueueName();
+ }
+ }
+
//private Strings for test values and expected results
private String _brokenAddress;
private String _generatedAddress;
@@ -40,28 +59,14 @@ public class AMQProtocolSessionTest extends AMQProtocolSession
private String _validAddress;
private String _generatedAddress_3;
private int _port;
- private AMQProtocolSessionTest _testSession;
-
- public AMQProtocolSessionTest()
- {
-
- }
-
- public AMQProtocolSessionTest(AMQProtocolHandler protocolHandler, IoSession protocolSession, AMQConnection connection)
- {
- super(protocolHandler,protocolSession,connection);
- }
+ private AMQProtSession _testSession;
- public TestIoSession getMinaProtocolSession()
+ protected void setUp() throws Exception
{
- return (TestIoSession) _minaProtocolSession;
- }
+ super.setUp();
- @Before
- public void setUp()
- {
//don't care about the values set here apart from the dummy IoSession
- _testSession = new AMQProtocolSessionTest(null,new TestIoSession(),null);
+ _testSession = new AMQProtSession(null,new TestIoSession(),null);
//initialise addresses for test and expected results
_port = 123;
@@ -71,11 +76,9 @@ public class AMQProtocolSessionTest extends AMQProtocolSession
_generatedAddress_2 = "tmp_localhost127.0.0.1123_2";
_validAddress = "abc";
_generatedAddress_3 = "tmp_abc123_3";
-
}
- @Test
- public void TestGenerateQueueName()
+ public void testGenerateQueueName()
{
String testAddress;
@@ -83,30 +86,24 @@ public class AMQProtocolSessionTest extends AMQProtocolSession
_testSession.getMinaProtocolSession().setStringLocalAddress(_brokenAddress);
_testSession.getMinaProtocolSession().setLocalPort(_port);
- testAddress = _testSession.generateQueueName();
- Assert.assertEquals("Failure when generating a queue name from an address with special chars",_generatedAddress,testAddress);
+ testAddress = _testSession.genQueueName();
+ assertEquals("Failure when generating a queue name from an address with special chars",_generatedAddress,testAddress);
//test empty address
_testSession.getMinaProtocolSession().setStringLocalAddress(_emptyAddress);
- testAddress = _testSession.generateQueueName();
- Assert.assertEquals("Failure when generating a queue name from an empty address",_generatedAddress_2,testAddress);
+ testAddress = _testSession.genQueueName();
+ assertEquals("Failure when generating a queue name from an empty address",_generatedAddress_2,testAddress);
//test address with no special chars
_testSession.getMinaProtocolSession().setStringLocalAddress(_validAddress);
- testAddress = _testSession.generateQueueName();
- Assert.assertEquals("Failure when generating a queue name from an address with no special chars",_generatedAddress_3,testAddress);
+ testAddress = _testSession.genQueueName();
+ assertEquals("Failure when generating a queue name from an address with no special chars",_generatedAddress_3,testAddress);
}
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(AMQProtocolSessionTest.class);
- }
-
- @After
- public void tearDown()
+ protected void tearDown() throws Exception
{
_testSession = null;
_brokenAddress = null;
@@ -115,5 +112,11 @@ public class AMQProtocolSessionTest extends AMQProtocolSession
_generatedAddress_2 = null;
_validAddress = null;
_generatedAddress_3 = null;
+ super.tearDown();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(AMQProtocolSessionTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java
index 6a03035f1e..c8d54cdcc5 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java
@@ -20,13 +20,9 @@
*/
package org.apache.qpid.test.unit.jndi;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnectionFactory;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQTopic;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -34,14 +30,16 @@ import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
import java.util.Properties;
-public class PropertiesFileInitialContextFactoryTest
+import junit.framework.TestCase;
+
+public class PropertiesFileInitialContextFactoryTest extends TestCase
{
InitialContextFactory contextFactory;
Properties _properties;
- @Before
- public void setupProperties()
+ protected void setUp() throws Exception
{
+ super.setUp();
_properties = new Properties();
_properties.put("java.naming.factory.initial", "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
_properties.put("connectionfactory.local", "amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'");
@@ -50,7 +48,6 @@ public class PropertiesFileInitialContextFactoryTest
_properties.put("destination.direct", "direct://amq.direct//directQueue");
}
- @Test
public void test()
{
Context ctx = null;
@@ -60,54 +57,52 @@ public class PropertiesFileInitialContextFactoryTest
}
catch (NamingException ne)
{
- Assert.fail("Error loading context:" + ne);
+ fail("Error loading context:" + ne);
}
try
{
AMQConnectionFactory cf = (AMQConnectionFactory) ctx.lookup("local");
- Assert.assertEquals("amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'", cf.getConnectionURL().toString());
+ assertEquals("amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'", cf.getConnectionURL().toString());
}
catch (NamingException ne)
{
- Assert.fail("Unable to create Connection Factory:" + ne);
+ fail("Unable to create Connection Factory:" + ne);
}
try
{
AMQQueue queue = (AMQQueue) ctx.lookup("MyQueue");
- Assert.assertEquals("example.MyQueue", queue.getRoutingKey());
+ assertEquals("example.MyQueue", queue.getRoutingKey());
}
catch (NamingException ne)
{
- Assert.fail("Unable to create queue:" + ne);
+ fail("Unable to create queue:" + ne);
}
try
{
AMQTopic topic = (AMQTopic) ctx.lookup("ibmStocks");
- Assert.assertEquals("stocks.nyse.ibm", topic.getTopicName());
+ assertEquals("stocks.nyse.ibm", topic.getTopicName());
}
catch (Exception ne)
{
- Assert.fail("Unable to create topic:" + ne);
+ fail("Unable to create topic:" + ne);
}
try
{
AMQQueue direct = (AMQQueue) ctx.lookup("direct");
- Assert.assertEquals("directQueue", direct.getRoutingKey());
+ assertEquals("directQueue", direct.getRoutingKey());
}
catch (NamingException ne)
{
- Assert.fail("Unable to create direct destination:" + ne);
+ fail("Unable to create direct destination:" + ne);
}
-
-
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(PropertiesFileInitialContextFactoryTest.class);
+ return new junit.framework.TestSuite(PropertiesFileInitialContextFactoryTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java
index 083d90d79d..db871281bf 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java
@@ -24,7 +24,6 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionFactory;
import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.url.URLSyntaxException;
-import org.junit.Assert;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -39,6 +38,8 @@ import javax.naming.NoInitialContextException;
import java.io.File;
import java.util.Hashtable;
+import junit.framework.TestCase;
+
/**
* Usage: To run these you need to have the sun JNDI SPI for the FileSystem.
* This can be downloaded from sun here:
@@ -49,7 +50,7 @@ import java.util.Hashtable;
* <p/>
* Also you need to create the directory /temp/qpid-jndi-test
*/
-class Bind
+class Bind extends TestCase
{
public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest" + System.currentTimeMillis();
public static final String DEFAULT_PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
@@ -124,11 +125,11 @@ class Bind
}
catch (JMSException jmsqe)
{
- Assert.fail("Unable to create Connection:" + jmsqe);
+ fail("Unable to create Connection:" + jmsqe);
}
catch (URLSyntaxException urlse)
{
- Assert.fail("Unable to create Connection:" + urlse);
+ fail("Unable to create Connection:" + urlse);
}
try
@@ -247,4 +248,3 @@ class Bind
new Bind(true);
}
}
-
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java
index c8374dead0..4731caca98 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java
@@ -20,18 +20,14 @@
*/
package org.apache.qpid.test.unit.jndi.referenceabletest;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import junit.framework.JUnit4TestAdapter;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.naming.NameAlreadyBoundException;
import javax.naming.NoInitialContextException;
+import junit.framework.TestCase;
/**
* Usage: To run these you need to have the sun JNDI SPI for the FileSystem.
@@ -43,31 +39,10 @@ import javax.naming.NoInitialContextException;
* <p/>
* Also you need to create the directory /temp/qpid-jndi-test
*/
-public class JNDIReferenceableTest
+public class JNDIReferenceableTest extends TestCase
{
- @Before
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
- }
-
- @After
- public void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
- }
-
-
- @Ignore("FSContext has been removed from repository. This needs redone with the PropertiesFileInitialContextFactory. QPID-84")
- @Test
- public void referenceable()
+ // FIXME FSContext has been removed from repository. This needs redone with the PropertiesFileInitialContextFactory. QPID-84
+ public void testReferenceable()
{
Bind b = null;
try
@@ -86,18 +61,18 @@ public class JNDIReferenceableTest
}
catch (NameAlreadyBoundException ee)
{
- Assert.fail("Unable to clear bound objects for test.");
+ fail("Unable to clear bound objects for test.");
}
}
else
{
- Assert.fail("Unable to clear bound objects for test.");
+ fail("Unable to clear bound objects for test.");
}
}
}
catch (NoInitialContextException e)
{
- Assert.fail("You don't have the File System SPI on you class path.\n" +
+ fail("You don't have the File System SPI on you class path.\n" +
"This can be downloaded from sun here:\n" +
"http://java.sun.com/products/jndi/downloads/index.html\n" +
"Click : Download JNDI 1.2.1 & More button\n" +
@@ -105,25 +80,25 @@ public class JNDIReferenceableTest
"and add the two jars in the lib dir to your class path.");
}
- Assert.assertTrue(b.bound());
+ assertTrue(b.bound());
Lookup l = new Lookup(b.getProviderURL());
- Assert.assertTrue(l.connectionFactoryValue().equals(b.connectionFactoryValue()));
+ assertTrue(l.connectionFactoryValue().equals(b.connectionFactoryValue()));
- Assert.assertTrue(l.connectionValue().equals(b.connectionValue()));
+ assertTrue(l.connectionValue().equals(b.connectionValue()));
- Assert.assertTrue(l.topicValue().equals(b.topicValue()));
+ assertTrue(l.topicValue().equals(b.topicValue()));
Unbind u = new Unbind();
- Assert.assertTrue(u.unbound());
+ assertTrue(u.unbound());
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(JNDIReferenceableTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(JNDIReferenceableTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/UnitTests.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/UnitTests.java
deleted file mode 100644
index ff7f04779c..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/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.jndi.referenceabletest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import junit.framework.JUnit4TestAdapter;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({JNDIReferenceableTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
index 57aafd7719..b20cfa046a 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
@@ -20,11 +20,6 @@
*/
package org.apache.qpid.test.unit.topic;
-import junit.framework.JUnit4TestAdapter;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
import org.apache.qpid.AMQException;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.url.URLSyntaxException;
@@ -32,6 +27,7 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -41,30 +37,11 @@ import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.TopicSubscriber;
-public class DurableSubscriptionTest
-{
+import junit.framework.TestCase;
- @Before
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
- }
-
- @After
- public void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
- }
-
- @Test
- public void unsubscribe() throws AMQException, JMSException, URLSyntaxException
+public class DurableSubscriptionTest extends TestCase
+{
+ public void testUnsubscribe() throws AMQException, JMSException, URLSyntaxException
{
AMQTopic topic = new AMQTopic("MyTopic");
AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "test", "/test");
@@ -81,32 +58,31 @@ public class DurableSubscriptionTest
Message msg;
msg = consumer1.receive();
- Assert.assertEquals("A", ((TextMessage) msg).getText());
+ assertEquals("A", ((TextMessage) msg).getText());
msg = consumer1.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
msg = consumer2.receive();
- Assert.assertEquals("A", ((TextMessage) msg).getText());
+ assertEquals("A", ((TextMessage) msg).getText());
msg = consumer2.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
session2.unsubscribe("MySubscription");
producer.send(session1.createTextMessage("B"));
msg = consumer1.receive();
- Assert.assertEquals("B", ((TextMessage) msg).getText());
+ assertEquals("B", ((TextMessage) msg).getText());
msg = consumer1.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
msg = consumer2.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
con.close();
}
- @Test
- public void durability() throws AMQException, JMSException, URLSyntaxException
+ public void testDurability() throws AMQException, JMSException, URLSyntaxException
{
AMQTopic topic = new AMQTopic("MyTopic");
AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "test", "/test");
@@ -123,14 +99,14 @@ public class DurableSubscriptionTest
Message msg;
msg = consumer1.receive();
- Assert.assertEquals("A", ((TextMessage) msg).getText());
+ assertEquals("A", ((TextMessage) msg).getText());
msg = consumer1.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
msg = consumer2.receive();
- Assert.assertEquals("A", ((TextMessage) msg).getText());
+ assertEquals("A", ((TextMessage) msg).getText());
msg = consumer2.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
consumer2.close();
@@ -140,21 +116,20 @@ public class DurableSubscriptionTest
producer.send(session1.createTextMessage("B"));
msg = consumer1.receive();
- Assert.assertEquals("B", ((TextMessage) msg).getText());
+ assertEquals("B", ((TextMessage) msg).getText());
msg = consumer1.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
msg = consumer3.receive();
- Assert.assertEquals("B", ((TextMessage) msg).getText());
+ assertEquals("B", ((TextMessage) msg).getText());
msg = consumer3.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
con.close();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(DurableSubscriptionTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(DurableSubscriptionTest.class));
}
-
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
index ecd66d99ce..8918259be3 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
@@ -20,24 +20,18 @@
*/
package org.apache.qpid.test.unit.transacted;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.*;
-public class TransactedTest
+import junit.framework.TestCase;
+
+public class TransactedTest extends TestCase
{
private AMQQueue queue1;
private AMQQueue queue2;
@@ -56,28 +50,9 @@ public class TransactedTest
private MessageConsumer testConsumer1;
private MessageConsumer testConsumer2;
-
- public void createVMBroker()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create broker: " + e);
- }
- }
-
- public void stopVmBroker()
+ protected void setup() throws Exception
{
- TransportConnection.killVMBroker(1);
- }
-
- @Before
- public void setup() throws Exception
- {
- createVMBroker();
+ super.setUp();
queue1 = new AMQQueue("Q1", false);
queue2 = new AMQQueue("Q2", false);
@@ -108,17 +83,15 @@ public class TransactedTest
testCon.start();
}
- @After
- public void shutdown() throws Exception
+ protected void tearDown() throws Exception
{
con.close();
testCon.close();
prepCon.close();
- stopVmBroker();
+ super.tearDown();
}
- @Test
- public void commit() throws Exception
+ public void testCommit() throws Exception
{
//send and receive some messages
producer2.send(session.createTextMessage("X"));
@@ -140,8 +113,7 @@ public class TransactedTest
assertTrue(null == testConsumer2.receive(1000));
}
- @Test
- public void rollback() throws Exception
+ public void testRollback() throws Exception
{
producer2.send(session.createTextMessage("X"));
producer2.send(session.createTextMessage("Y"));
@@ -170,7 +142,6 @@ public class TransactedTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TransactedTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(TransactedTest.class));
}
-
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/transacted/UnitTests.java b/java/client/src/test/java/org/apache/qpid/test/unit/transacted/UnitTests.java
deleted file mode 100644
index 24e6ace366..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/transacted/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.transacted;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({TransactedTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java b/java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java
index 447e9a498d..76b1da8754 100644
--- a/java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java
+++ b/java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java
@@ -20,13 +20,11 @@
*/
package org.apache.qpid.server.cluster;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import junit.framework.TestCase;
-public class ClusterCapabilityTest
+public class ClusterCapabilityTest extends TestCase
{
- @Test
- public void startWithNull()
+ public void testStartWithNull()
{
MemberHandle peer = new SimpleMemberHandle("myhost:9999");
String c = ClusterCapability.add(null, peer);
@@ -34,8 +32,7 @@ public class ClusterCapabilityTest
assertTrue(peer.matches(ClusterCapability.getPeer(c)));
}
- @Test
- public void startWithText()
+ public void testStartWithText()
{
MemberHandle peer = new SimpleMemberHandle("myhost:9999");
String c = ClusterCapability.add("existing text", peer);
diff --git a/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java b/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java
index 2a10a8c959..c427285f4a 100644
--- a/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java
+++ b/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.server.cluster;
-import org.junit.Test;
import org.apache.qpid.AMQException;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.client.AMQConnection;
@@ -28,10 +27,11 @@ import org.apache.qpid.client.AMQSession;
import javax.jms.JMSException;
-public class SimpleClusterTest
+import junit.framework.TestCase;
+
+public class SimpleClusterTest extends TestCase
{
- @Test
- public void declareExchange() throws AMQException, JMSException, URLSyntaxException
+ public void testDeclareExchange() throws AMQException, JMSException, URLSyntaxException
{
AMQConnection con = new AMQConnection("localhost:9000", "guest", "guest", "test", "/test");
AMQSession session = (AMQSession) con.createSession(false, AMQSession.NO_ACKNOWLEDGE);
diff --git a/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleMemberHandleTest.java b/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleMemberHandleTest.java
index bc7a8e5453..8ff8357377 100644
--- a/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleMemberHandleTest.java
+++ b/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleMemberHandleTest.java
@@ -20,23 +20,18 @@
*/
package org.apache.qpid.server.cluster;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import junit.framework.TestCase;
-public class SimpleMemberHandleTest
+public class SimpleMemberHandleTest extends TestCase
{
- @Test
- public void matches()
+ public void testMatches()
{
assertMatch(new SimpleMemberHandle("localhost", 8888), new SimpleMemberHandle("localhost", 8888));
assertNoMatch(new SimpleMemberHandle("localhost", 8889), new SimpleMemberHandle("localhost", 8888));
assertNoMatch(new SimpleMemberHandle("localhost", 8888), new SimpleMemberHandle("localhost2", 8888));
}
-
- @Test
- public void resolve()
+ public void testResolve()
{
assertEquivalent(new SimpleMemberHandle("WGLAIBD8XGR0J:9000"), new SimpleMemberHandle("localhost:9000"));
}
diff --git a/java/pom.xml b/java/pom.xml
index 18306533b1..de44ee5c16 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -411,7 +411,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.0</version>
+ <version>3.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -622,7 +622,7 @@
<mkdir dir="${full.eclipse.workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings"/>
<mkdir dir="${full.eclipse.workspace}/.metadata/.plugins/com.atlassw.tools.eclipse.checkstyle"/>
<mkdir dir="${full.eclipse.workspace}/.metadata/.plugins/net.sourceforge.pmd.eclipse"/>
- <copy file="${basedir}/${topDirectoryLocation}/checkstyle.xml" tofile="${full.eclipse.workspace}/cxf-checkstyle.xml"/>
+ <copy file="${basedir}/${topDirectoryLocation}/checkstyle.xml" tofile="${full.eclipse.workspace}/qpid-checkstyle.xml"/>
<copy file="${basedir}/${topDirectoryLocation}/etc/apache-header.txt" tofile="${full.eclipse.workspace}/apache-header.txt"/>
<!-- Add checkstyle config -->
@@ -630,7 +630,7 @@
tofile="${full.eclipse.workspace}/.metadata/.plugins/com.atlassw.tools.eclipse.checkstyle/checkstyle-config.xml"
overwrite="no">
<filterset>
- <filter token="CHECKSTYLE_CONFIG_FILE" value="${full.eclipse.workspace}/cxf-checkstyle.xml"/>
+ <filter token="CHECKSTYLE_CONFIG_FILE" value="${full.eclipse.workspace}/qpid-checkstyle.xml"/>
<filter token="APACHE_HEADER_FILE" value="${full.eclipse.workspace}/apache-header.txt"/>
</filterset>
</copy>
@@ -638,7 +638,7 @@
<xslt style="${basedir}/${topDirectoryLocation}/etc/eclipse/addcheckstyle.xsl"
in="${full.eclipse.workspace}/.metadata/.plugins/com.atlassw.tools.eclipse.checkstyle/checkstyle-config.xml"
out="${full.eclipse.workspace}/.metadata/.plugins/com.atlassw.tools.eclipse.checkstyle/checkstyle-config.xml.new">
- <param name="checkstyleconfig" expression="${full.eclipse.workspace}/cxf-checkstyle.xml"/>
+ <param name="checkstyleconfig" expression="${full.eclipse.workspace}/qpid-checkstyle.xml"/>
</xslt>
<copy
file="${full.eclipse.workspace}/.metadata/.plugins/com.atlassw.tools.eclipse.checkstyle/checkstyle-config.xml.new"
@@ -659,10 +659,10 @@
append="true" fixlastline="true">
<filelist dir="${basedir}/${topDirectoryLocation}/etc/eclipse" files="org.eclipse.jdt.core.prefs"/>
</concat>
- <loadfile property="eclipse.code.format" srcFile="${basedir}/${topDirectoryLocation}/etc/eclipse/CXFCodeFormatter.xml"/>
+ <loadfile property="eclipse.code.format" srcFile="${basedir}/${topDirectoryLocation}/etc/eclipse/QpidCodeFormatter.xml"/>
<loadfile property="eclipse.code.templates" srcFile="${basedir}/${topDirectoryLocation}/etc/eclipse/codetemplates.xml"/>
<propertyfile file="${full.eclipse.workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs">
- <entry key="formatter_profile" value="_CXF Java Conventions"/>
+ <entry key="formatter_profile" value="_Qpid Java Conventions"/>
<entry key="org.eclipse.jdt.ui.formatterprofiles" value="${eclipse.code.format}"/>
<entry key="org.eclipse.jdt.ui.text.custom_code_templates" value="${eclipse.code.templates}"/>
diff --git a/java/systests/pom.xml b/java/systests/pom.xml
index 5d4b617cee..441cb34939 100644
--- a/java/systests/pom.xml
+++ b/java/systests/pom.xml
@@ -68,6 +68,7 @@
<build>
<plugins>
+<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@@ -105,11 +106,27 @@
</execution>
</executions>
</plugin>
+-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <skip>true</skip>
+ <systemProperties>
+ <property>
+ <name>amqj.noAutoCreateVMBroker</name>
+ <value>true</value>
+ </property>
+ </systemProperties>
+ <includes>
+ <include>**/server/**/*Test.java</include>
+ <include>**/test/unit/ack/DisconnectAndRedeliver.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/Abstract*Test*</exclude>
+ <exclude>**/*PerfTest*</exclude>
+ <exclude>**/*PerformanceTest*</exclude>
+ <exclude>**/server/util/ConcurrentTest.java</exclude>
+ </excludes>
</configuration>
</plugin>
</plugins>
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/queue/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/server/queue/UnitTests.java
deleted file mode 100644
index fbdcaf7467..0000000000
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/UnitTests.java
+++ /dev/null
@@ -1,41 +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.queue;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- AckTest.class,
- DeliveryManagerTest.class,
- SubscriptionManagerTest.class,
- SubscriptionSetTest.class,
- ConcurrencyTest.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/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/broker/src/test/java/org/apache/qpid/server/configuration/UnitTests.java b/java/systests/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
index 6e39e9efd1..e859fac4af 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/configuration/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,18 +17,36 @@
* under the License.
*
*/
-package org.apache.qpid.server.configuration;
+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({TestPropertyUtils.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);
- }
-}