Author: rupertlssmith
Date: Thu Nov 29 04:07:25 2007
New Revision: 599400
URL: http://svn.apache.org/viewvc?rev=599400&view=rev
Log:
Changed in vm broker creation so that it is an injected set task. This means
the in vm broker is created on every test. Threaded tests can optionally do it
on a per-thread basis instead using this approach.
Added:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkTestContext.java
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/MessageIdentityVector.java
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestCaseVector.java
Modified:
incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java
incubator/qpid/branches/M2.1/java/pom.xml
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java
Modified:
incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java?rev=599400&r1=599399&r2=599400&view=diff
==============================================================================
---
incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java
(original)
+++
incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java
Thu Nov 29 04:07:25 2007
@@ -24,6 +24,7 @@
import junit.framework.TestSuite;
import org.apache.log4j.Logger;
+import org.apache.log4j.NDC;
import org.apache.qpid.test.framework.Assertion;
import org.apache.qpid.test.framework.Circuit;
@@ -45,7 +46,7 @@
*
* <p/><table id="crc"><caption>CRC Card</caption>
* <tr><th> Responsibilities <th> Collaborations
- * <tr><td>
+ * <tr><td> Measure message throughput accross a test circuit. <td> [EMAIL
PROTECTED] Circuit}
* </table>
*
* @todo Check that all of the messages were sent. Check that the receiving
end got the same number of messages as
@@ -117,10 +118,33 @@
}
/**
+ * Overrides the parent setUp method so that the in-vm broker creation is
not done on a per test basis.
+ *
+ * @throws Exception Any exceptions allowed to fall through and fail the
test.
+ */
+ protected void setUp() throws Exception
+ {
+ NDC.push(getName());
+
+ testProps =
TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
+ }
+
+ /**
+ * Overrides the parent setUp method so that the in-vm broker clean-up is
not done on a per test basis.
+ */
+ protected void tearDown()
+ {
+ NDC.pop();
+ }
+
+ /**
* Performs test fixture creation on a per thread basis. This will only be
called once for each test thread.
*/
public void threadSetUp()
{
+ // Run the test setup tasks. This may create an in-vm broker, if a
decorator has injected a task for this.
+ taskHandler.runSetupTasks();
+
// Get the test parameters, any overrides on the command line will
have been applied.
ParsedProperties testProps =
TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
@@ -144,7 +168,10 @@
* Called when a test thread is destroyed.
*/
public void threadTearDown()
- { }
+ {
+ // Run the test teardown tasks. This may destroy the in-vm broker, if
a decorator has injected a task for this.
+ taskHandler.runSetupTasks();
+ }
/**
* Holds the per-thread test configurations.
Modified: incubator/qpid/branches/M2.1/java/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/pom.xml?rev=599400&r1=599399&r2=599400&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/java/pom.xml (original)
+++ incubator/qpid/branches/M2.1/java/pom.xml Thu Nov 29 04:07:25 2007
@@ -399,7 +399,7 @@
<plugin>
<groupId>uk.co.thebadgerset</groupId>
<artifactId>junit-toolkit-maven-plugin</artifactId>
- <version>0.7-SNAPSHOT</version>
+ <version>0.7.1-SNAPSHOT</version>
</plugin>
@@ -547,7 +547,7 @@
<dependency>
<groupId>uk.co.thebadgerset</groupId>
<artifactId>junit-toolkit</artifactId>
- <version>0.7-SNAPSHOT</version>
+ <version>0.7.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
Modified:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java?rev=599400&r1=599399&r2=599400&view=diff
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
(original)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
Thu Nov 29 04:07:25 2007
@@ -26,6 +26,10 @@
import org.apache.qpid.test.framework.sequencers.CircuitFactory;
import uk.co.thebadgerset.junit.extensions.AsymptoticTestCase;
+import uk.co.thebadgerset.junit.extensions.SetupTaskAware;
+import uk.co.thebadgerset.junit.extensions.SetupTaskHandler;
+import uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
+import uk.co.thebadgerset.junit.extensions.util.TestContextProperties;
import java.util.ArrayList;
import java.util.List;
@@ -42,7 +46,7 @@
* <tr><td> Convert failed assertions to error messages.
* </table>
*/
-public class FrameworkBaseCase extends AsymptoticTestCase
+public class FrameworkBaseCase extends AsymptoticTestCase implements
FrameworkTestContext, SetupTaskAware
{
/** Used for debugging purposes. */
private static final Logger log =
Logger.getLogger(FrameworkBaseCase.class);
@@ -50,6 +54,12 @@
/** Holds the test sequencer to create and run test circuits with. */
protected CircuitFactory circuitFactory = new LocalCircuitFactory();
+ /** Used to read the tests configurable properties through. */
+ protected ParsedProperties testProps;
+
+ /** A default setup task processor to delegate setup tasks to. */
+ protected SetupTaskHandler taskHandler = new SetupTaskHandler();
+
/**
* Creates a new test case with the specified name.
*
@@ -84,6 +94,26 @@
}
/**
+ * Reports the current test case name.
+ *
+ * @return The current test case name.
+ */
+ public TestCaseVector getTestCaseVector()
+ {
+ return new TestCaseVector(this.getName(), 0);
+ }
+
+ /**
+ * Reports the current test case parameters.
+ *
+ * @return The current test case parameters.
+ */
+ public MessagingTestConfigProperties getTestParameters()
+ {
+ return new MessagingTestConfigProperties(testProps);
+ }
+
+ /**
* Creates a list of assertions.
*
* @param asserts The assertions to compile in a list.
@@ -152,6 +182,11 @@
protected void setUp() throws Exception
{
NDC.push(getName());
+
+ testProps =
TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
+
+ // Process all optional setup tasks. This may include in-vm broker
creation, if a decorator has added it.
+ taskHandler.runSetupTasks();
}
/**
@@ -160,6 +195,29 @@
protected void tearDown()
{
NDC.pop();
+
+ // Process all optional tear down tasks. This may include in-vm broker
clean up, if a decorator has added it.
+ taskHandler.runTearDownTasks();
+ }
+
+ /**
+ * Adds the specified task to the tests setup.
+ *
+ * @param task The task to add to the tests setup.
+ */
+ public void chainSetupTask(Runnable task)
+ {
+ taskHandler.chainSetupTask(task);
+ }
+
+ /**
+ * Adds the specified task to the tests tear down.
+ *
+ * @param task The task to add to the tests tear down.
+ */
+ public void chainTearDownTask(Runnable task)
+ {
+ taskHandler.chainTearDownTask(task);
}
/**
Added:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkTestContext.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkTestContext.java?rev=599400&view=auto
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkTestContext.java
(added)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkTestContext.java
Thu Nov 29 04:07:25 2007
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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.framework;
+
+/**
+ * A FrameworkTestContext provides context information to test code about the
current test case being run; its name, its
+ * parameters.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Provide the name of the current test case.
+ * <tr><td> Provide the test parameters.
+ * </table>
+ */
+public interface FrameworkTestContext
+{
+ /**
+ * Reports the current test case name.
+ *
+ * @return The current test case name.
+ */
+ TestCaseVector getTestCaseVector();
+
+ /**
+ * Reports the current test case parameters.
+ *
+ * @return The current test case parameters.
+ */
+ MessagingTestConfigProperties getTestParameters();
+}
Modified:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java?rev=599400&r1=599399&r2=599400&view=diff
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java
(original)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/LocalCircuitFactory.java
Thu Nov 29 04:07:25 2007
@@ -75,6 +75,7 @@
* Creates a test circuit for the test, configered by the test parameters
specified.
*
* @param testProperties The test parameters.
+ *
* @return A test circuit.
*/
public Circuit createCircuit(ParsedProperties testProperties)
Added:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/MessageIdentityVector.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/MessageIdentityVector.java?rev=599400&view=auto
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/MessageIdentityVector.java
(added)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/MessageIdentityVector.java
Thu Nov 29 04:07:25 2007
@@ -0,0 +1,167 @@
+/*
+ *
+ * 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.framework;
+
+/**
+ * MessageIdentityVector provides a message identification scheme, that
matches individual messages with test cases.
+ * Test messages are being sent by a number of test clients, sending messages
over a set of routes, and being received
+ * by another set of test clients. Each test is itself, being run within a
test cycle, of which there could be many. It
+ * is the job of the test coordinator to request and receive reports from the
available test clients, on what has been
+ * sent, what has been received, and what errors may have occurred, and to
reconcile this information against the
+ * assertions being applied by the test case. In order to be able to figure
out which messages belong to which test,
+ * there needs to be an identification scheme, that the coordinator can use to
correlate messages in senders and
+ * receiver reports. Every message sent in a test can be associated with this
information.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Identify a test case, a handling client id, a circuit end within
the client, and a test cycle number.
+ * </table>
+ */
+public class MessageIdentityVector
+{
+ /** Holds the test case vector component of the message identity vector. */
+ private TestCaseVector testCaseVector;
+
+ /** The unique client id. */
+ private String clientId;
+
+ /** The unique circuit end number within the client id. */
+ private int circuitEndId;
+
+ /**
+ * Creates a new identity vector for test messages.
+ *
+ * @param testCase The name of the test case generating the
messages.
+ * @param clientId The unique id of the client implementing a
circuit end that is handling the messages.
+ * @param circuitEndId The unique id number of the circuit end within
the client.
+ * @param testCycleNumber The cycle iteration number of the test case.
+ */
+ public MessageIdentityVector(String testCase, String clientId, int
circuitEndId, int testCycleNumber)
+ {
+ this.testCaseVector = new TestCaseVector(testCase, testCycleNumber);
+ this.clientId = clientId;
+ this.circuitEndId = circuitEndId;
+ }
+
+ /**
+ * Reports the test case vector component of the message identity vector.
+ *
+ * @return The test case vector component of the message identity vector.
+ */
+ public TestCaseVector getTestCaseVector()
+ {
+ return testCaseVector;
+ }
+
+ /**
+ * Reports the name of the test case.
+ *
+ * @return The name of the test case.
+ */
+ public String getTestCase()
+ {
+ return testCaseVector.getTestCase();
+ }
+
+ /**
+ * Reports the test iteration cycle number within the test case.
+ *
+ * @return The test iteration cycle number within the test case.
+ */
+ public int getTestCycleNumber()
+ {
+ return testCaseVector.getTestCycleNumber();
+ }
+
+ /**
+ * Resports the client id.
+ *
+ * @return The client id.
+ */
+ public String getClientId()
+ {
+ return clientId;
+ }
+
+ /**
+ * Reports the circuit end number within the test client.
+ *
+ * @return The circuit end number within the test client.
+ */
+ public int getCircuitEndId()
+ {
+ return circuitEndId;
+ }
+
+ /**
+ * Compares this identity vector with another for equality. All fields
must match.
+ *
+ * @param o The identity vector to compare with.
+ *
+ * @return <tt>true</tt> if the identity vector is identical to this one
by all fields, <tt>false</tt> otherwise.
+ */
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+
+ if ((o == null) || (getClass() != o.getClass()))
+ {
+ return false;
+ }
+
+ MessageIdentityVector that = (MessageIdentityVector) o;
+
+ if (circuitEndId != that.circuitEndId)
+ {
+ return false;
+ }
+
+ if ((clientId != null) ? (!clientId.equals(that.clientId)) :
(that.clientId != null))
+ {
+ return false;
+ }
+
+ if ((testCaseVector != null) ?
(!testCaseVector.equals(that.testCaseVector)) : (that.testCaseVector != null))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Computes a hash code for this identity vector based on all fields.
+ *
+ * @return A hash code for this identity vector based on all fields.
+ */
+ public int hashCode()
+ {
+ int result;
+ result = ((testCaseVector != null) ? testCaseVector.hashCode() : 0);
+ result = (31 * result) + ((clientId != null) ? clientId.hashCode() :
0);
+ result = (31 * result) + circuitEndId;
+
+ return result;
+ }
+}
Added:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestCaseVector.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestCaseVector.java?rev=599400&view=auto
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestCaseVector.java
(added)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestCaseVector.java
Thu Nov 29 04:07:25 2007
@@ -0,0 +1,88 @@
+/*
+ *
+ * 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.framework;
+
+/**
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td>
+ * </table>
+ */
+public class TestCaseVector
+{
+ /** The test case name. */
+ private String testCase;
+
+ /** The test cycle number within the test case. */
+ private int testCycleNumber;
+
+ public TestCaseVector(String testCase, int testCycleNumber)
+ {
+ this.testCase = testCase;
+ this.testCycleNumber = testCycleNumber;
+ }
+
+ public String getTestCase()
+ {
+ return testCase;
+ }
+
+ public int getTestCycleNumber()
+ {
+ return testCycleNumber;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+
+ if ((o == null) || (getClass() != o.getClass()))
+ {
+ return false;
+ }
+
+ TestCaseVector that = (TestCaseVector) o;
+
+ if (testCycleNumber != that.testCycleNumber)
+ {
+ return false;
+ }
+
+ if ((testCase != null) ? (!testCase.equals(that.testCase)) :
(that.testCase != null))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = ((testCase != null) ? testCase.hashCode() : 0);
+ result = (31 * result) + testCycleNumber;
+
+ return result;
+ }
+}
Modified:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java?rev=599400&r1=599399&r2=599400&view=diff
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java
(original)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java
Thu Nov 29 04:07:25 2007
@@ -1,23 +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
- * 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.
- *
- */
+/* Copyright Rupert Smith, 2005 to 2007, all rights reserved. */
package org.apache.qpid.test.framework.qpid;
import junit.framework.Test;
@@ -65,7 +46,7 @@
}
/**
- * Runs the tests with a LocalAMQPCircuitFactory.
+ * Runs the tests with a LocalAMQPCircuitFactory. Only tests that extend
FrameworkBaseCase are decorated.
*
* @param testResult The the results object to monitor the test results
with.
*/
@@ -73,11 +54,24 @@
{
for (Test test : getAllUnderlyingTests())
{
- FrameworkBaseCase frameworkTest = (FrameworkBaseCase) test;
- frameworkTest.setCircuitFactory(new LocalAMQPCircuitFactory());
+ if (test instanceof FrameworkBaseCase)
+ {
+ FrameworkBaseCase frameworkTest = (FrameworkBaseCase)test;
+ frameworkTest.setCircuitFactory(new LocalAMQPCircuitFactory());
+ }
}
// Run the test.
test.run(testResult);
+ }
+
+ /**
+ * Prints the name of the test for debugging purposes.
+ *
+ * @return The name of the test.
+ */
+ public String toString()
+ {
+ return "AMQPFeatureDecorator: [test = \"" + test + "\"]";
}
}
Modified:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java?rev=599400&r1=599399&r2=599400&view=diff
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java
(original)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java
Thu Nov 29 04:07:25 2007
@@ -1,34 +1,15 @@
-/*
- *
- * 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.
- *
- */
+/* Copyright Rupert Smith, 2005 to 2007, all rights reserved. */
package org.apache.qpid.test.framework.qpid;
import junit.framework.Test;
import junit.framework.TestResult;
-import junit.framework.TestSuite;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.test.framework.FrameworkBaseCase;
+import uk.co.thebadgerset.junit.extensions.SetupTaskAware;
import uk.co.thebadgerset.junit.extensions.WrappedSuiteTestDecorator;
/**
@@ -41,7 +22,7 @@
* <tr><td> Create/Destroy an in-vm broker on every test run.
* </table>
*
- * @todo May need to add a more fine grained injection point for the in-vm
broker management, as this may act at the
+ * @todo May need to add a more fine grained injection point for the in-vm
broker management, as this acts at the
* suite level, rather than the individual test level.
*/
public class InVMBrokerDecorator extends WrappedSuiteTestDecorator
@@ -61,32 +42,59 @@
}
/**
- * Runs the tests with in-vm broker management.
+ * Runs the tests with in-vm broker creation and clean-up added to the
tests task stack.
*
* @param testResult The the results object to monitor the test results
with.
*/
public void run(TestResult testResult)
{
- /*for (Test test : getAllUnderlyingTests())
- {
- FrameworkBaseCase frameworkTest = (FrameworkBaseCase) test;
- }*/
-
- // Ensure that the in-vm broker is created.
- try
+ for (Test test : getAllUnderlyingTests())
{
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- throw new RuntimeException("In-VM broker creation failed: " +
e.getMessage(), e);
+ // Check that the test to have an in-vm broker setup/teardown task
added to it, is actually a framework
+ // test that can handle setup tasks.
+ if ((test instanceof FrameworkBaseCase) && (test instanceof
SetupTaskAware))
+ {
+ SetupTaskAware frameworkTest = (SetupTaskAware)test;
+
+ frameworkTest.chainSetupTask(new Runnable()
+ {
+ public void run()
+ {
+ // Ensure that the in-vm broker is created.
+ try
+ {
+ TransportConnection.createVMBroker(1);
+ }
+ catch (AMQVMBrokerCreationException e)
+ {
+ throw new RuntimeException("In-VM broker
creation failed: " + e.getMessage(), e);
+ }
+ }
+ });
+
+ frameworkTest.chainTearDownTask(new Runnable()
+ {
+ public void run()
+ {
+ // Ensure that the in-vm broker is cleaned up so
that the next test starts afresh.
+ TransportConnection.killVMBroker(1);
+ ApplicationRegistry.remove(1);
+ }
+ });
+ }
}
// Run the test.
test.run(testResult);
+ }
- // Ensure that the in-vm broker is cleaned up so that the next test
starts afresh.
- TransportConnection.killVMBroker(1);
- ApplicationRegistry.remove(1);
+ /**
+ * Prints the name of the test for debugging purposes.
+ *
+ * @return The name of the test.
+ */
+ public String toString()
+ {
+ return "InVMBrokerDecorator: [test = " + test + "]";
}
}
Modified:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java?rev=599400&r1=599399&r2=599400&view=diff
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java
(original)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java
Thu Nov 29 04:07:25 2007
@@ -65,9 +65,6 @@
*/
public class ImmediateMessageTest extends FrameworkBaseCase
{
- /** Used to read the tests configurable properties through. */
- ParsedProperties testProps;
-
/**
* Creates a new test case with the specified name.
*