You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by vi...@apache.org on 2006/11/19 05:14:45 UTC
svn commit: r476701 [1/3] - in /incubator/qpid/trunk/qpid/java: ./ broker/
broker/src/test/java/org/apache/qpid/server/
broker/src/test/java/org/apache/qpid/server/configuration/
broker/src/test/java/org/apache/qpid/server/exchange/ broker/src/test/jav...
Author: vinoski
Date: Sat Nov 18 20:14:42 2006
New Revision: 476701
URL: http://svn.apache.org/viewvc?view=rev&rev=476701
Log:
convert tests to junit3
Added:
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java (with props)
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/test/VMBrokerSetup.java (with props)
Removed:
incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/UnitTests.java
incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/UnitTests.java
incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/UnitTests.java
incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/UnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/ack/UnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/UnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/AllClientUnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/UnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/UnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/UnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/UnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MessageUnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/UnitTests.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/UnitTests.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/UnitTests.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/ack/UnitTests.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/exchange/UnitTests.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/protocol/UnitTests.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/queue/UnitTests.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/store/UnitTests.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/txn/UnitTests.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/ack/UnitTests.java
Modified:
incubator/qpid/trunk/qpid/java/broker/pom.xml
incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java
incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java
incubator/qpid/trunk/qpid/java/client/pom.xml
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
incubator/qpid/trunk/qpid/java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java
incubator/qpid/trunk/qpid/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java
incubator/qpid/trunk/qpid/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleMemberHandleTest.java
incubator/qpid/trunk/qpid/java/pom.xml
incubator/qpid/trunk/qpid/java/systests/pom.xml
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/protocol/TestProtocolInitiation.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/queue/MessageTestHelper.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionManagerTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/queue/SubscriptionSetTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/store/TestReferenceCounting.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/txn/TxnBufferTest.java
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/ack/DisconnectAndRedeliverTest.java
Modified: incubator/qpid/trunk/qpid/java/broker/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/pom.xml?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/pom.xml (original)
+++ incubator/qpid/trunk/qpid/java/broker/pom.xml Sat Nov 18 20:14:42 2006
@@ -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>
Modified: incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TestPropertyUtils.java Sat Nov 18 20:14:42 2006
@@ -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 @@
assertEquals(expandedProperty, "fruity");
}
- @Test
public void testDualExpansion() throws PropertyException
{
System.setProperty("banana", "fruity");
@@ -48,6 +45,6 @@
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TestPropertyUtils.class);
+ return new junit.framework.TestSuite(TestPropertyUtils.class);
}
}
Modified: incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java Sat Nov 18 20:14:42 2006
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
assertFalse(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
+
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(HeadersBindingTest.class);
+ return new junit.framework.TestSuite(HeadersBindingTest.class);
}
-
}
Modified: incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/LoggingProxyTest.java Sat Nov 18 20:14:42 2006
@@ -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 @@
}
}
- @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);
}
}
Modified: incubator/qpid/trunk/qpid/java/client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/pom.xml?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/pom.xml (original)
+++ incubator/qpid/trunk/qpid/java/client/pom.xml Sat Nov 18 20:14:42 2006
@@ -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>
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java Sat Nov 18 20:14:42 2006
@@ -26,7 +26,6 @@
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;
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java Sat Nov 18 20:14:42 2006
@@ -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.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 @@
}
/*
- @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 static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(FieldTableTest.class);
+ return new junit.framework.TestSuite(FieldTableTest.class);
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java Sat Nov 18 20:14:42 2006
@@ -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.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 @@
}
}
- @Test
- public void startAcceptor() throws IOException
+ public void testStartAcceptor() throws IOException
{
IoAcceptor acceptor = null;
acceptor = new SocketAcceptor();
@@ -90,14 +89,14 @@
_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);
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java Sat Nov 18 20:14:42 2006
@@ -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.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 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);
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java Sat Nov 18 20:14:42 2006
@@ -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
- {
- _logger.info("All buffers sent; waiting for receipt from server");
- _notifier.await();
- }
- catch (InterruptedException e)
+ public RunnableWriterTest(Logger logger)
{
+ _logger = logger;
}
- _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)
+ ByteBuffer result = (ByteBuffer) message;
+ _totalBytesReceived += result.remaining();
+ int size = result.remaining();
+ long now = System.currentTimeMillis();
+ if (_partialBytesRead > 0)
{
- _chunkTimes[_chunksReceived++] = now;
- result.position(offset);
+ 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;
+ }
}
- 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
@@ -265,5 +262,10 @@
w.test8k();
//w.test16k();
//w.test32k();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(WriterTest.class);
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java Sat Nov 18 20:14:42 2006
@@ -22,38 +22,16 @@
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 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));
}
}
Added: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java?view=auto&rev=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java (added)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java Sat Nov 18 20:14:42 2006
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.apache.qpid.client.transport.TransportConnection;
+
+public class VMBrokerSetup extends TestSetup
+{
+ 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
+ {
+ TransportConnection.killVMBroker(1);
+ super.tearDown();
+ }
+}
Propchange: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java Sat Nov 18 20:14:42 2006
@@ -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.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 @@
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 @@
// 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 @@
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));
}
}
-
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java Sat Nov 18 20:14:42 2006
@@ -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.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 @@
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 @@
connection.start();
}
- @Test
public void test() throws Exception
{
-
try
{
send(_count);
@@ -229,6 +210,6 @@
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(BytesMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(BytesMessageTest.class));
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java Sat Nov 18 20:14:42 2006
@@ -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 @@
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 @@
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 static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(FieldTableKeyEnumeratorTest.class);
+ return new junit.framework.TestSuite(FieldTableKeyEnumeratorTest.class);
}
-
-
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java Sat Nov 18 20:14:42 2006
@@ -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.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 @@
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 @@
return result;
}
- @Test
public void test() throws Exception
{
int count = _count;
@@ -170,13 +153,13 @@
{
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));
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java Sat Nov 18 20:14:42 2006
@@ -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 @@
test.test();
}
- @Test
public void test() throws Exception
{
String broker = _connectionString;
@@ -220,28 +216,8 @@
}
}
- @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));
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java Sat Nov 18 20:14:42 2006
@@ -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.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.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 @@
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 @@
connection.start();
}
- @Test
public void test() throws Exception
{
int count = _count;
@@ -225,7 +206,7 @@
{
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 static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(ObjectMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(ObjectMessageTest.class));
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java Sat Nov 18 20:14:42 2006
@@ -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.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 @@
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 @@
{
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 @@
_connection.start();
}
- @Test
public void test() throws Exception
{
_consumer.receive(5000);
@@ -105,12 +97,12 @@
{
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);
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java Sat Nov 18 20:14:42 2006
@@ -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 @@
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 @@
_session.createConsumer(destination).setMessageListener(this);
}
- @Test
public synchronized void test() throws JMSException, InterruptedException
{
try
@@ -131,12 +106,12 @@
{
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));
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java Sat Nov 18 20:14:42 2006
@@ -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.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 @@
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 @@
connection.start();
}
- @Test
public void test() throws Exception
{
int count = _count;
@@ -197,7 +179,7 @@
{
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 static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TextMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(TextMessageTest.class));
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java?view=diff&rev=476701&r1=476700&r2=476701
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java Sat Nov 18 20:14:42 2006
@@ -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.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 @@
{
//ignore
}
- TransportConnection.killVMBroker(1);
+ super.tearDown();
}
/**
@@ -84,62 +69,137 @@
* 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));
}
}