You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ru...@apache.org on 2007/11/26 12:38:31 UTC

svn commit: r598233 [3/3] - in /incubator/qpid/branches/M2.1/java: ./ integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/ perftests/src/main/java/org/apache/qpid/perftests/ perftests/src/main/java/org/apache/qpid/test/ per...

Added: 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=598233&view=auto
==============================================================================
--- incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java (added)
+++ incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/ImmediateMessageTest.java Mon Nov 26 03:38:27 2007
@@ -0,0 +1,307 @@
+/*
+ *
+ * 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.testcases;
+
+import org.apache.qpid.test.framework.AMQPPublisher;
+import org.apache.qpid.test.framework.Circuit;
+import org.apache.qpid.test.framework.FrameworkBaseCase;
+import org.apache.qpid.test.framework.MessagingTestConfigProperties;
+import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
+import org.apache.qpid.test.framework.sequencers.CircuitFactory;
+
+import uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
+import uk.co.thebadgerset.junit.extensions.util.TestContextProperties;
+
+/**
+ * ImmediateMessageTest tests for the desired behaviour of immediate messages. Immediate messages are a non-JMS
+ * feature. A message may be marked with an immediate delivery flag, which means that a consumer must be connected
+ * to receive the message, through a valid route, when it is sent, or when its transaction is committed in the case
+ * of transactional messaging. If this is not the case, the broker should return the message with a NO_CONSUMERS code.
+ *
+ * <p><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Check that an immediate message is sent succesfully not using transactions when a consumer is connected.
+ * <tr><td> Check that an immediate message is committed succesfully in a transaction when a consumer is connected.
+ * <tr><td> Check that an immediate message results in no consumers code, not using transactions, when a consumer is
+ *          disconnected.
+ * <tr><td> Check that an immediate message results in no consumers code, in a transaction, when a consumer is
+ *          disconnected.
+ * <tr><td> Check that an immediate message results in no route code, not using transactions, when no outgoing route is
+ *          connected.
+ * <tr><td> Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is
+ *          connected.
+ * <tr><td> Check that an immediate message is sent succesfully not using transactions when a consumer is connected.
+ * <tr><td> Check that an immediate message is committed succesfully in a transaction when a consumer is connected.
+ * <tr><td> Check that an immediate message results in no consumers code, not using transactions, when a consumer is
+ *          disconnected.
+ * <tr><td> Check that an immediate message results in no consumers code, in a transaction, when a consumer is
+ *          disconnected.
+ * <tr><td> Check that an immediate message results in no route code, not using transactions, when no outgoing route is
+ *          connected.
+ * <tr><td> Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is
+ *          connected.
+ * </table>
+ *
+ * @todo All of these test cases will be generated by a test generator that thoroughly tests all combinations of test
+ *       circuits.
+ */
+public class ImmediateMessageTest extends FrameworkBaseCase
+{
+    /** Used to read the tests configurable properties through. */
+    ParsedProperties testProps;
+
+    /**
+     * Creates a new test case with the specified name.
+     *
+     * @param name The test case name.
+     */
+    public ImmediateMessageTest(String name)
+    {
+        super(name);
+    }
+
+    /** Check that an immediate message is sent succesfully not using transactions when a consumer is connected. */
+    public void test_QPID_517_ImmediateOkNoTxP2P()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Run the default test sequence over the test circuit checking for no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps))));
+    }
+
+    /** Check that an immediate message is committed succesfully in a transaction when a consumer is connected. */
+    public void test_QPID_517_ImmediateOkTxP2P()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Send one message with no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps))));
+    }
+
+    /** Check that an immediate message results in no consumers code, not using transactions, when a consumer is disconnected. */
+    public void test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxP2P()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Disconnect the consumer.
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
+
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        // Send one message and get a linked no consumers exception.
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noConsumersAssertion(testProps))));
+    }
+
+    /** Check that an immediate message results in no consumers code, in a transaction, when a consumer is disconnected. */
+    public void test_QPID_517_ImmediateFailsConsumerDisconnectedTxP2P()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Disconnect the consumer.
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
+
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        // Send one message and get a linked no consumers exception.
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noConsumersAssertion(testProps))));
+    }
+
+    /** Check that an immediate message results in no route code, not using transactions, when no outgoing route is connected. */
+    public void test_QPID_517_ImmediateFailsNoRouteNoTxP2P()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
+        // collect its messages).
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
+
+        // Send one message and get a linked no route exception.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
+    }
+
+    /** Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is connected. */
+    public void test_QPID_517_ImmediateFailsNoRouteTxP2P()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
+        // collect its messages).
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
+
+        // Send one message and get a linked no route exception.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
+    }
+
+    /** Check that an immediate message is sent succesfully not using transactions when a consumer is connected. */
+    public void test_QPID_517_ImmediateOkNoTxPubSub()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Send one message with no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /** Check that an immediate message is committed succesfully in a transaction when a consumer is connected. */
+    public void test_QPID_517_ImmediateOkTxPubSub()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Send one message with no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /** Check that an immediate message results in no consumers code, not using transactions, when a consumer is disconnected. */
+    public void test_QPID_517_ImmediateFailsConsumerDisconnectedNoTxPubSub()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Use durable subscriptions, so that the route remains open with no subscribers.
+        testProps.setProperty(DURABLE_SUBSCRIPTION_PROPNAME, true);
+
+        // Disconnect the consumer.
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
+
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        // Send one message and get a linked no consumers exception.
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noConsumersAssertion(testProps))));
+    }
+
+    /** Check that an immediate message results in no consumers code, in a transaction, when a consumer is disconnected. */
+    public void test_QPID_517_ImmediateFailsConsumerDisconnectedTxPubSub()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Use durable subscriptions, so that the route remains open with no subscribers.
+        testProps.setProperty(DURABLE_SUBSCRIPTION_PROPNAME, true);
+
+        // Disconnect the consumer.
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
+
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        // Send one message and get a linked no consumers exception.
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noConsumersAssertion(testProps))));
+    }
+
+    /** Check that an immediate message results in no route code, not using transactions, when no outgoing route is connected. */
+    public void test_QPID_517_ImmediateFailsNoRouteNoTxPubSub()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
+        // collect its messages).
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
+
+        // Send one message and get a linked no route exception.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
+    }
+
+    /** Check that an immediate message results in no route code, upon transaction commit, when no outgoing route is connected. */
+    public void test_QPID_517_ImmediateFailsNoRouteTxPubSub()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
+        // collect its messages).
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
+
+        // Send one message and get a linked no route exception.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
+
+        /** All these tests should have the immediate flag on. */
+        testProps.setProperty(IMMEDIATE_PROPNAME, true);
+        testProps.setProperty(MANDATORY_PROPNAME, false);
+
+        /** Bind the receivers consumer by default. */
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, true);
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, true);
+    }
+}

Added: incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java?rev=598233&view=auto
==============================================================================
--- incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java (added)
+++ incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/MandatoryMessageTest.java Mon Nov 26 03:38:27 2007
@@ -0,0 +1,321 @@
+/*
+ *
+ * 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.testcases;
+
+import org.apache.qpid.test.framework.AMQPPublisher;
+import org.apache.qpid.test.framework.Circuit;
+import org.apache.qpid.test.framework.FrameworkBaseCase;
+import org.apache.qpid.test.framework.MessagingTestConfigProperties;
+import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
+import org.apache.qpid.test.framework.sequencers.CircuitFactory;
+
+import uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
+import uk.co.thebadgerset.junit.extensions.util.TestContextProperties;
+
+/**
+ * MandatoryMessageTest tests for the desired behaviour of mandatory messages. Mandatory messages are a non-JMS
+ * feature. A message may be marked with a mandatory delivery flag, which means that a valid route for the message
+ * must exist, when it is sent, or when its transaction is committed in the case of transactional messaging. If this
+ * is not the case, the broker should return the message with a NO_CONSUMERS code.
+ *
+ * <p><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Check that an mandatory message is sent succesfully not using transactions when a consumer is connected.
+ * <tr><td> Check that an mandatory message is committed succesfully in a transaction when a consumer is connected.
+ * <tr><td> Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected
+ *          but the route exists.
+ * <tr><td> Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but
+ *          the route exists.
+ * <tr><td> Check that an mandatory message results in no route code, not using transactions, when no consumer is
+ *          connected.
+ * <tr><td> Check that an mandatory message results in no route code, upon transaction commit, when a consumer is
+ *          connected.
+ * <tr><td> Check that an mandatory message is sent succesfully not using transactions when a consumer is connected.
+ * <tr><td> Check that an mandatory message is committed succesfully in a transaction when a consumer is connected.
+ * <tr><td> Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected
+ *          but the route exists.
+ * <tr><td> Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but
+ *          the route exists.
+ * <tr><td> Check that an mandatory message results in no route code, not using transactions, when no consumer is
+ *          connected.
+ * <tr><td> Check that an mandatory message results in no route code, upon transaction commit, when a consumer is
+ *          connected.
+ * </table>
+ *
+ * @todo All of these test cases will be generated by a test generator that thoroughly tests all combinations of test
+ *       circuits.
+ */
+public class MandatoryMessageTest extends FrameworkBaseCase
+{
+    /** Used to read the tests configurable properties through. */
+    ParsedProperties testProps;
+
+    /**
+     * Creates a new test case with the specified name.
+     *
+     * @param name The test case name.
+     */
+    public MandatoryMessageTest(String name)
+    {
+        super(name);
+    }
+
+    /** Check that an mandatory message is sent succesfully not using transactions when a consumer is connected. */
+    public void test_QPID_508_MandatoryOkNoTxP2P()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Run the default test sequence over the test circuit checking for no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /** Check that an mandatory message is committed succesfully in a transaction when a consumer is connected. */
+    public void test_QPID_508_MandatoryOkTxP2P()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Run the default test sequence over the test circuit checking for no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /**
+     * Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected but
+     * the route exists.
+     */
+    public void test_QPID_517_MandatoryOkConsumerDisconnectedNoTxP2P()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Disconnect the consumer.
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
+
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        // Send one message with no errors.
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /**
+     * Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but
+     * the route exists.
+     */
+    public void test_QPID_517_MandatoryOkConsumerDisconnectedTxP2P()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Disconnect the consumer.
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
+
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        // Send one message with no errors.
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /** Check that an mandatory message results in no route code, not using transactions, when no consumer is connected. */
+    public void test_QPID_508_MandatoryFailsNoRouteNoTxP2P()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
+        // collect its messages).
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
+
+        // Send one message and get a linked no route exception.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
+    }
+
+    /** Check that an mandatory message results in no route code, upon transaction commit, when a consumer is connected. */
+    public void test_QPID_508_MandatoryFailsNoRouteTxP2P()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, false);
+
+        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
+        // collect its messages).
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
+
+        // Send one message and get a linked no route exception.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
+    }
+
+    /** Check that an mandatory message is sent succesfully not using transactions when a consumer is connected. */
+    public void test_QPID_508_MandatoryOkNoTxPubSub()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Run the default test sequence over the test circuit checking for no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /** Check that an mandatory message is committed succesfully in a transaction when a consumer is connected. */
+    public void test_QPID_508_MandatoryOkTxPubSub()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Run the default test sequence over the test circuit checking for no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /**
+     * Check that a mandatory message is sent succesfully, not using transactions, when a consumer is disconnected but
+     * the route exists.
+     */
+    public void test_QPID_517_MandatoryOkConsumerDisconnectedNoTxPubSub()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Use durable subscriptions, so that the route remains open with no subscribers.
+        testProps.setProperty(DURABLE_SUBSCRIPTION_PROPNAME, true);
+
+        // Disconnect the consumer.
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
+
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        // Send one message with no errors.
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /**
+     * Check that a mandatory message is sent succesfully, in a transaction, when a consumer is disconnected but
+     * the route exists.
+     */
+    public void test_QPID_517_MandatoryOkConsumerDisconnectedTxPubSub()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Use durable subscriptions, so that the route remains open with no subscribers.
+        testProps.setProperty(DURABLE_SUBSCRIPTION_PROPNAME, true);
+
+        // Disconnect the consumer.
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, false);
+
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        // Send one message with no errors.
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noExceptionsAssertion(testProps))));
+    }
+
+    /** Check that an mandatory message results in no route code, not using transactions, when no consumer is connected. */
+    public void test_QPID_508_MandatoryFailsNoRouteNoTxPubSub()
+    {
+        // Ensure transactional sessions are off.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
+        // collect its messages).
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
+
+        // Send one message and get a linked no route exception.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
+    }
+
+    /** Check that an mandatory message results in no route code, upon transaction commit, when a consumer is connected. */
+    public void test_QPID_508_MandatoryFailsNoRouteTxPubSub()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(PUBSUB_PROPNAME, true);
+
+        // Set up the messaging topology so that only the publishers producer is bound (do not set up the receivers to
+        // collect its messages).
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, false);
+
+        // Send one message and get a linked no route exception.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(((AMQPPublisher) testCircuit.getPublisher()).noRouteAssertion(testProps))));
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
+
+        /** All these tests should have the mandatory flag on. */
+        testProps.setProperty(IMMEDIATE_PROPNAME, false);
+        testProps.setProperty(MANDATORY_PROPNAME, true);
+
+        /** Bind the receivers consumer by default. */
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, true);
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, true);
+    }
+}

Added: incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java?rev=598233&view=auto
==============================================================================
--- incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java (added)
+++ incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/RollbackTest.java Mon Nov 26 03:38:27 2007
@@ -0,0 +1,132 @@
+/*
+ *
+ * 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.testcases;
+
+import org.apache.qpid.test.framework.Circuit;
+import org.apache.qpid.test.framework.FrameworkBaseCase;
+import org.apache.qpid.test.framework.MessagingTestConfigProperties;
+import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
+import org.apache.qpid.test.framework.sequencers.CircuitFactory;
+
+import uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
+import uk.co.thebadgerset.junit.extensions.util.TestContextProperties;
+
+/**
+ * RollbackTest tests the rollback ability of transactional messaging.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Check messages sent but rolled back are never received.
+ * <tr><td> Check messages received but rolled back are redelivered on subsequent receives.
+ * <tr><td> Attempting to rollback outside of a transaction results in an IllegalStateException.
+ * </table>
+ */
+public class RollbackTest extends FrameworkBaseCase
+{
+    /** Used to read the tests configurable properties through. */
+    ParsedProperties testProps;
+
+    /**
+     * Creates a new test case with the specified name.
+     *
+     * @param name The test case name.
+     */
+    public RollbackTest(String name)
+    {
+        super(name);
+    }
+
+    /** Check messages sent but rolled back are never received. */
+    public void testRolledbackMessageNotDelivered()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+        testProps.setProperty(ROLLBACK_PUBLISHER_PROPNAME, true);
+
+        // Run the default test sequence over the test circuit checking for no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps),
+                    testCircuit.getReceiver().noMessagesReceivedAssertion(testProps))));
+    }
+
+    /** Check messages received but rolled back are redelivered on subsequent receives. */
+    public void testRolledbackMessagesSubsequentlyReceived()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_RECEIVER_PROPNAME, true);
+        testProps.setProperty(ROLLBACK_RECEIVER_PROPNAME, true);
+
+        // Run the default test sequence over the test circuit checking for no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1,
+                assertionList(testCircuit.getPublisher().noExceptionsAssertion(testProps),
+                    testCircuit.getReceiver().allMessagesReceivedAssertion(testProps))));
+    }
+
+    /** Attempting to rollback outside of a transaction results in an IllegalStateException. */
+    public void testRollbackUnavailableOutsideTransactionPublisher()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, false);
+        testProps.setProperty(ROLLBACK_PUBLISHER_PROPNAME, true);
+
+        // Run the default test sequence over the test circuit checking for no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getPublisher().channelClosedAssertion(testProps))));
+    }
+
+    /** Attempting to rollback outside of a transaction results in an IllegalStateException. */
+    public void testRollbackUnavailableOutsideTransactionReceiver()
+    {
+        // Ensure transactional sessions are on.
+        testProps.setProperty(TRANSACTED_RECEIVER_PROPNAME, false);
+        testProps.setProperty(ROLLBACK_RECEIVER_PROPNAME, true);
+
+        // Run the default test sequence over the test circuit checking for no errors.
+        CircuitFactory circuitFactory = getCircuitFactory();
+        Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+        assertNoFailures(testCircuit.test(1, assertionList(testCircuit.getReceiver().channelClosedAssertion(testProps))));
+    }
+
+    /**
+     * Sets up all tests to have an active outward route and consumer by default.
+     *
+     * @throws Exception Any exceptions are allowed to fall through and fail the test.
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);
+
+        /** Bind the receivers consumer by default. */
+        testProps.setProperty(RECEIVER_CONSUMER_BIND_PROPNAME, true);
+        testProps.setProperty(RECEIVER_CONSUMER_ACTIVE_PROPNAME, true);
+    }
+}

Modified: incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/util/ConversationFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/util/ConversationFactory.java?rev=598233&r1=598232&r2=598233&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/util/ConversationFactory.java (original)
+++ incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/util/ConversationFactory.java Mon Nov 26 03:38:27 2007
@@ -92,7 +92,7 @@
  *
  * <p/><table id="crc"><caption>CRC Card</caption>
  * <tr><th> Responsibilities <th> Collaborations
- * <tr><th> Associate messages to an ongoing conversation using correlation ids.
+ * <tr><td> Associate messages to an ongoing conversation using correlation ids.
  * <tr><td> Auto manage sessions for conversations.
  * <tr><td> Store messages not in a conversation in dead letter box.
  * </table>