diff options
| author | Robert Gemmell <robbie@apache.org> | 2012-09-01 12:09:54 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2012-09-01 12:09:54 +0000 |
| commit | 4df139e950abc64014511b7714734966539eb0de (patch) | |
| tree | 23c98efee768cf67131a63520fe8b967452bb32b /java/systests | |
| parent | 1c71b63af55fcd9646d91531c206777f3d756a52 (diff) | |
| download | qpid-python-4df139e950abc64014511b7714734966539eb0de.tar.gz | |
QPID-4261: extend BindingURLs to allow specifying exchange durable/autodelete/internal options, use the values when sending exchange declares during producer and consumer creation. Fix ExchangeDeclareHandler to set auto-delete properly (though we dont actually support it, and it was removed from the protocol in 0-9-1).
Isolate AMQProtocolHandler use to the 0-8/0-9/0-9-1 specific Session/Producer/Consumer implementations that actually need it instead of letting it bleed through the abstraction and 0-10 implementations that dont use it. Add some other clarifying comments.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1379748 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/systests')
2 files changed, 77 insertions, 8 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/client/DynamicQueueExchangeCreateTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/client/DynamicQueueExchangeCreateTest.java index cdb5e095b1..4e9477f4b6 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/client/DynamicQueueExchangeCreateTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/client/DynamicQueueExchangeCreateTest.java @@ -20,8 +20,11 @@ */ package org.apache.qpid.test.unit.client; +import java.io.IOException; + import org.apache.qpid.AMQException; import org.apache.qpid.configuration.ClientProperties; +import org.apache.qpid.management.common.mbeans.ManagedExchange; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.test.utils.JMXTestUtils; import org.apache.qpid.test.utils.QpidBrokerTestCase; @@ -32,12 +35,6 @@ import javax.jms.JMSException; import javax.jms.Queue; import javax.jms.Session; -/** - * QPID-155 - * - * Test to validate that setting the respective qpid.declare_queues, - * qpid.declare_exchanges system properties functions as expected. - */ public class DynamicQueueExchangeCreateTest extends QpidBrokerTestCase { private JMXTestUtils _jmxUtils; @@ -68,6 +65,11 @@ public class DynamicQueueExchangeCreateTest extends QpidBrokerTestCase } } + /* + * Tests to validate that setting the respective qpid.declare_queues, + * qpid.declare_exchanges system properties functions as expected. + */ + public void testQueueNotDeclaredDuringConsumerCreation() throws Exception { setSystemProperty(ClientProperties.QPID_DECLARE_QUEUES_PROP_NAME, "false"); @@ -162,4 +164,71 @@ public class DynamicQueueExchangeCreateTest extends QpidBrokerTestCase assertTrue("Linked exception should be an AMQException", linked instanceof AMQException); assertEquals("Error code should be " + code.getCode(), code, ((AMQException) linked).getErrorCode()); } + + /* + * Tests to validate that the custom exchanges declared by the client during + * consumer and producer creation have the expected properties. + */ + + public void testPropertiesOfCustomExchangeDeclaredDuringProducerCreation() throws Exception + { + implTestPropertiesOfCustomExchange(true, false); + } + + public void testPropertiesOfCustomExchangeDeclaredDuringConsumerCreation() throws Exception + { + implTestPropertiesOfCustomExchange(false, true); + } + + private void implTestPropertiesOfCustomExchange(boolean createProducer, boolean createConsumer) throws Exception + { + Connection connection = getConnection(); + + Session session1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + String exchangeName1 = getTestQueueName() + "1"; + String queueName1 = getTestQueueName() + "1"; + + Queue queue = session1.createQueue("direct://" + exchangeName1 + "/" + queueName1 + "/" + queueName1 + "?" + BindingURL.OPTION_EXCHANGE_AUTODELETE + "='true'"); + if(createProducer) + { + session1.createProducer(queue); + } + + if(createConsumer) + { + session1.createConsumer(queue); + } + session1.close(); + + //verify the exchange was declared to expectation + verifyDeclaredExchange(exchangeName1, true, false); + + Session session2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + String exchangeName2 = getTestQueueName() + "2"; + String queueName2 = getTestQueueName() + "2"; + + Queue queue2 = session2.createQueue("direct://" + exchangeName2 + "/" + queueName2 + "/" + queueName2 + "?" + BindingURL.OPTION_EXCHANGE_DURABLE + "='true'"); + if(createProducer) + { + session2.createProducer(queue2); + } + + if(createConsumer) + { + session2.createConsumer(queue2); + } + session2.close(); + + //verify the exchange was declared to expectation + verifyDeclaredExchange(exchangeName2, false, true); + } + + private void verifyDeclaredExchange(String exchangeName, boolean isAutoDelete, boolean isDurable) throws IOException + { + String exchangeObjectName = _jmxUtils.getExchangeObjectName("test", exchangeName); + assertTrue("exchange should exist", _jmxUtils.doesManagedObjectExist(exchangeObjectName)); + ManagedExchange exchange = _jmxUtils.getManagedExchange(exchangeName); + assertEquals(isAutoDelete, exchange.isAutoDelete()); + assertEquals(isDurable,exchange.isDurable()); + } } diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java index f2387fa99b..b43fe35a09 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java @@ -21,7 +21,7 @@ package org.apache.qpid.test.unit.close; import org.apache.qpid.client.AMQConnection; -import org.apache.qpid.client.AMQSession; +import org.apache.qpid.client.AMQSession_0_8; import org.apache.qpid.framing.AMQFrame; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.ExchangeDeclareBody; @@ -81,7 +81,7 @@ public class JavaServerCloseRaceConditionTest extends QpidBrokerTestCase AMQConnection connection = (AMQConnection) getConnection(); - AMQSession session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + AMQSession_0_8 session = (AMQSession_0_8) connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Set no wait true so that we block the connection // Also set a different exchange class string so the attempt to declare |
