Repository: qpid-broker-j Updated Branches: refs/heads/master 99fa51f01 -> 4542234d5
QPID-6933: [System Tests] Refactor node auto-creation policy tests as JMS 1.1 system test Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/4542234d Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/4542234d Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/4542234d Branch: refs/heads/master Commit: 4542234d5c7cddfd739f5cb5ea97e9fd2ff3ee05 Parents: 8d028ef Author: Alex Rudyy <[email protected]> Authored: Thu Jan 4 23:43:13 2018 +0000 Committer: Alex Rudyy <[email protected]> Committed: Thu Jan 4 23:43:53 2018 +0000 ---------------------------------------------------------------------- .../NodeAutoCreationPolicyTest.java | 470 +++++++++++++++++++ .../queue/NodeAutoCreationPolicyTest.java | 441 ----------------- test-profiles/CPPExcludes | 3 - test-profiles/Java010Excludes | 3 - test-profiles/Java10Excludes | 5 - 5 files changed, 470 insertions(+), 452 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/4542234d/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/autocreation/NodeAutoCreationPolicyTest.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/autocreation/NodeAutoCreationPolicyTest.java b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/autocreation/NodeAutoCreationPolicyTest.java new file mode 100644 index 0000000..6e36749 --- /dev/null +++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/autocreation/NodeAutoCreationPolicyTest.java @@ -0,0 +1,470 @@ +/* + * + * 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.systests.jms_1_1.extensions.autocreation; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeThat; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Test; + +import org.apache.qpid.server.exchange.ExchangeDefaults; +import org.apache.qpid.server.model.AlternateBinding; +import org.apache.qpid.server.model.Exchange; +import org.apache.qpid.server.model.Protocol; +import org.apache.qpid.server.virtualhost.NodeAutoCreationPolicy; +import org.apache.qpid.server.virtualhost.QueueManagingVirtualHost; +import org.apache.qpid.systests.JmsTestBase; + +public class NodeAutoCreationPolicyTest extends JmsTestBase +{ + private static final String DEAD_LETTER_QUEUE_SUFFIX = "_DLQ"; + private static final String DEAD_LETTER_EXCHANGE_SUFFIX = "_DLE"; + private static final String AUTO_CREATION_POLICIES = createAutoCreationPolicies(); + + + private static String createAutoCreationPolicies() + { + ObjectMapper mapper = new ObjectMapper(); + try + { + + NodeAutoCreationPolicy[] policies = new NodeAutoCreationPolicy[] { + new NodeAutoCreationPolicy() + { + @Override + public String getPattern() + { + return "fooQ.*"; + } + + @Override + public boolean isCreatedOnPublish() + { + return true; + } + + @Override + public boolean isCreatedOnConsume() + { + return true; + } + + @Override + public String getNodeType() + { + return "Queue"; + } + + @Override + public Map<String, Object> getAttributes() + { + return Collections.emptyMap(); + } + }, + new NodeAutoCreationPolicy() + { + @Override + public String getPattern() + { + return "barE.*"; + } + + @Override + public boolean isCreatedOnPublish() + { + return true; + } + + @Override + public boolean isCreatedOnConsume() + { + return false; + } + + @Override + public String getNodeType() + { + return "Exchange"; + } + + @Override + public Map<String, Object> getAttributes() + { + return Collections.singletonMap(Exchange.TYPE, "fanout"); + } + }, + + new NodeAutoCreationPolicy() + { + @Override + public String getPattern() + { + return ".*" + DEAD_LETTER_QUEUE_SUFFIX; + } + + @Override + public boolean isCreatedOnPublish() + { + return true; + } + + @Override + public boolean isCreatedOnConsume() + { + return true; + } + + @Override + public String getNodeType() + { + return "Queue"; + } + + @Override + public Map<String, Object> getAttributes() + { + return Collections.emptyMap(); + } + }, + + new NodeAutoCreationPolicy() + { + @Override + public String getPattern() + { + return ".*" + DEAD_LETTER_EXCHANGE_SUFFIX; + } + + @Override + public boolean isCreatedOnPublish() + { + return true; + } + + @Override + public boolean isCreatedOnConsume() + { + return false; + } + + @Override + public String getNodeType() + { + return "Exchange"; + } + + @Override + public Map<String, Object> getAttributes() + { + return Collections.singletonMap(Exchange.TYPE, ExchangeDefaults.FANOUT_EXCHANGE_CLASS); + } + } + }; + + return mapper.writeValueAsString(Arrays.asList(policies)); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + } + + private void updateAutoCreationPolicies() throws Exception + { + updateEntityUsingAmqpManagement(getVirtualHostName(), "org.apache.qpid.VirtualHost", Collections.singletonMap(QueueManagingVirtualHost.NODE_AUTO_CREATION_POLICIES, AUTO_CREATION_POLICIES)); + } + + @Test + public void testSendingToQueuePattern() throws Exception + { + updateAutoCreationPolicies(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + final Queue queue = session.createQueue(getProtocol() == Protocol.AMQP_1_0 + ? "fooQueue" + : "ADDR: fooQueue ; { assert: never, node: { type: queue } }"); + final MessageProducer producer = session.createProducer(queue); + producer.send(session.createTextMessage("Hello world!")); + + final MessageConsumer consumer = session.createConsumer(queue); + Message received = consumer.receive(getReceiveTimeout()); + assertNotNull(received); + assertTrue(received instanceof TextMessage); + assertEquals("Hello world!", ((TextMessage) received).getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testSendingToNonMatchingQueuePattern() throws Exception + { + updateAutoCreationPolicies(); + + Connection connection = getConnection(); + try + { + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + final Queue queue = session.createQueue(getProtocol() == Protocol.AMQP_1_0 + ? "foQueue" + : "ADDR: foQueue ; { assert: never, node: { type: queue } }"); + try + { + session.createProducer(queue); + fail("Creating producer should fail"); + } + catch (JMSException e) + { + // pass + } + } + finally + { + connection.close(); + } + } + + @Test + public void testSendingToExchangePattern() throws Exception + { + updateAutoCreationPolicies(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + final Topic topic = session.createTopic(getProtocol() == Protocol.AMQP_1_0 + ? "barExchange/foo" + : "ADDR: barExchange/foo ; { assert: never, node: { type: topic } }"); + final MessageProducer producer = session.createProducer(topic); + producer.send(session.createTextMessage("Hello world!")); + + final MessageConsumer consumer = session.createConsumer(topic); + Message received = consumer.receive(getReceiveTimeout() / 4); + assertNull(received); + + producer.send(session.createTextMessage("Hello world2!")); + received = consumer.receive(getReceiveTimeout()); + + assertNotNull(received); + + assertTrue(received instanceof TextMessage); + assertEquals("Hello world2!", ((TextMessage) received).getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testSendingToNonMatchingTopicPattern() throws Exception + { + updateAutoCreationPolicies(); + + Connection connection = getConnection(); + try + { + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + final Topic topic = session.createTopic(getProtocol() == Protocol.AMQP_1_0 + ? "baa" + : "ADDR: baa ; { assert: never, node: { type: topic } }"); + try + { + session.createProducer(topic); + fail("Creating producer should fail"); + } + catch (JMSException e) + { + // pass + } + } + finally + { + connection.close(); + } + } + + @Test + public void testSendingToQueuePatternBURL() throws Exception + { + assumeThat("Qpid JMS Client does not support BURL syntax", + getProtocol(), + is(not(equalTo(Protocol.AMQP_1_0)))); + updateAutoCreationPolicies(); + + Connection connection = getConnection(); + try + { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + final Queue queue = session.createQueue("BURL:direct:///fooQ/fooQ"); + final MessageProducer producer = session.createProducer(queue); + producer.send(session.createTextMessage("Hello world!")); + + final MessageConsumer consumer = session.createConsumer(queue); + Message received = consumer.receive(getReceiveTimeout()); + assertNotNull(received); + assertTrue(received instanceof TextMessage); + assertEquals("Hello world!", ((TextMessage) received).getText()); + } + finally + { + connection.close(); + } + } + + @Test + public void testSendingToNonMatchingQueuePatternBURL() throws Exception + { + assumeThat("Using AMQP 0-8..0-9-1 to test BURL syntax", + getProtocol(), + is(not(anyOf(equalTo(Protocol.AMQP_1_0), equalTo(Protocol.AMQP_0_10))))); + updateAutoCreationPolicies(); + + Connection connection = getConnectionBuilder().setSyncPublish(true).build(); + try + { + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + final Queue queue = session.createQueue("BURL:direct:///fo/fo"); + try + { + final MessageProducer producer = session.createProducer(queue); + producer.send(session.createTextMessage("Hello world!")); + + fail("Sending a message should fail"); + } + catch (JMSException e) + { + // pass + } + } + finally + { + connection.close(); + } + } + + @Test + public void testQueueAlternateBindingCreation() throws Exception + { + updateAutoCreationPolicies(); + + String queueName = getTestName(); + String deadLetterQueueName = queueName + DEAD_LETTER_QUEUE_SUFFIX; + + final Map<String, Object> attributes = new HashMap<>(); + Map<String, Object> expectedAlternateBinding = + Collections.singletonMap(AlternateBinding.DESTINATION, deadLetterQueueName); + attributes.put(org.apache.qpid.server.model.Queue.ALTERNATE_BINDING, + new ObjectMapper().writeValueAsString(expectedAlternateBinding)); + createEntityUsingAmqpManagement(queueName, "org.apache.qpid.Queue", attributes); + + Map<String, Object> queueAttributes = readEntityUsingAmqpManagement(queueName, "org.apache.qpid.Queue", true); + + Object actualAlternateBinding = queueAttributes.get(org.apache.qpid.server.model.Queue.ALTERNATE_BINDING); + Map<String, Object> actualAlternateBindingMap = convertIfNecessary(actualAlternateBinding); + assertEquals("Unexpected alternate binding", + new HashMap<>(expectedAlternateBinding), + new HashMap<>(actualAlternateBindingMap)); + + Map<String, Object> dlqAttributes = + readEntityUsingAmqpManagement(deadLetterQueueName, "org.apache.qpid.Queue", true); + assertNotNull("Cannot get dead letter queue", dlqAttributes); + } + + @Test + public void testExchangeAlternateBindingCreation() throws Exception + { + updateAutoCreationPolicies(); + + String exchangeName = getTestName(); + String deadLetterExchangeName = exchangeName + DEAD_LETTER_EXCHANGE_SUFFIX; + + final Map<String, Object> attributes = new HashMap<>(); + Map<String, Object> expectedAlternateBinding = + Collections.singletonMap(AlternateBinding.DESTINATION, deadLetterExchangeName); + attributes.put(Exchange.ALTERNATE_BINDING, new ObjectMapper().writeValueAsString(expectedAlternateBinding)); + attributes.put(Exchange.TYPE, ExchangeDefaults.DIRECT_EXCHANGE_CLASS); + createEntityUsingAmqpManagement(exchangeName, "org.apache.qpid.DirectExchange", attributes); + + Map<String, Object> exchangeAttributes = readEntityUsingAmqpManagement(exchangeName, "org.apache.qpid.Exchange", true); + + Object actualAlternateBinding = exchangeAttributes.get(Exchange.ALTERNATE_BINDING); + Map<String, Object> actualAlternateBindingMap = convertIfNecessary(actualAlternateBinding); + assertEquals("Unexpected alternate binding", + new HashMap<>(expectedAlternateBinding), + new HashMap<>(actualAlternateBindingMap)); + + Map<String, Object> dlqExchangeAttributes = readEntityUsingAmqpManagement( + deadLetterExchangeName, + "org.apache.qpid.FanoutExchange", + true); + assertNotNull("Cannot get dead letter exchange", dlqExchangeAttributes); + } + + @SuppressWarnings("unchecked") + private Map<String, Object> convertIfNecessary(final Object actualAlternateBinding) throws IOException + { + Map<String, Object> actualAlternateBindingMap; + if (actualAlternateBinding instanceof String) + { + actualAlternateBindingMap = new ObjectMapper().readValue((String)actualAlternateBinding, Map.class); + } + else + { + actualAlternateBindingMap = (Map<String, Object>) actualAlternateBinding; + } + return actualAlternateBindingMap; + } +} http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/4542234d/systests/src/test/java/org/apache/qpid/server/queue/NodeAutoCreationPolicyTest.java ---------------------------------------------------------------------- diff --git a/systests/src/test/java/org/apache/qpid/server/queue/NodeAutoCreationPolicyTest.java b/systests/src/test/java/org/apache/qpid/server/queue/NodeAutoCreationPolicyTest.java deleted file mode 100644 index 608f54d..0000000 --- a/systests/src/test/java/org/apache/qpid/server/queue/NodeAutoCreationPolicyTest.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.queue; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import javax.jms.Connection; -import javax.jms.InvalidDestinationException; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.apache.qpid.client.AMQSession; -import org.apache.qpid.server.exchange.ExchangeDefaults; -import org.apache.qpid.server.model.AlternateBinding; -import org.apache.qpid.server.model.Exchange; -import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.virtualhost.NodeAutoCreationPolicy; -import org.apache.qpid.server.virtualhost.QueueManagingVirtualHost; -import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.test.utils.TestBrokerConfiguration; - -public class NodeAutoCreationPolicyTest extends QpidBrokerTestCase -{ - private static final String DEAD_LETTER_QUEUE_SUFFIX = "_DLQ"; - private static final String DEAD_LETTER_EXCHANGE_SUFFIX = "_DLE"; - - private Connection _connection; - private Session _session; - - - @Override - public String getTestProfileVirtualHostNodeBlueprint() - { - String blueprint = super.getTestProfileVirtualHostNodeBlueprint(); - ObjectMapper mapper = new ObjectMapper(); - try - { - Map blueprintMap = mapper.readValue(blueprint, Map.class); - - NodeAutoCreationPolicy[] policies = new NodeAutoCreationPolicy[] { - new NodeAutoCreationPolicy() - { - @Override - public String getPattern() - { - return "fooQ.*"; - } - - @Override - public boolean isCreatedOnPublish() - { - return true; - } - - @Override - public boolean isCreatedOnConsume() - { - return true; - } - - @Override - public String getNodeType() - { - return "Queue"; - } - - @Override - public Map<String, Object> getAttributes() - { - return Collections.emptyMap(); - } - }, - new NodeAutoCreationPolicy() - { - @Override - public String getPattern() - { - return "barE.*"; - } - - @Override - public boolean isCreatedOnPublish() - { - return true; - } - - @Override - public boolean isCreatedOnConsume() - { - return false; - } - - @Override - public String getNodeType() - { - return "Exchange"; - } - - @Override - public Map<String, Object> getAttributes() - { - return Collections.singletonMap(Exchange.TYPE, "fanout"); - } - }, - - new NodeAutoCreationPolicy() - { - @Override - public String getPattern() - { - return ".*" + DEAD_LETTER_QUEUE_SUFFIX; - } - - @Override - public boolean isCreatedOnPublish() - { - return true; - } - - @Override - public boolean isCreatedOnConsume() - { - return true; - } - - @Override - public String getNodeType() - { - return "Queue"; - } - - @Override - public Map<String, Object> getAttributes() - { - return Collections.emptyMap(); - } - }, - - new NodeAutoCreationPolicy() - { - @Override - public String getPattern() - { - return ".*" + DEAD_LETTER_EXCHANGE_SUFFIX; - } - - @Override - public boolean isCreatedOnPublish() - { - return true; - } - - @Override - public boolean isCreatedOnConsume() - { - return false; - } - - @Override - public String getNodeType() - { - return "Exchange"; - } - - @Override - public Map<String, Object> getAttributes() - { - return Collections.singletonMap(Exchange.TYPE, ExchangeDefaults.FANOUT_EXCHANGE_CLASS); - } - } - }; - - blueprintMap.put(QueueManagingVirtualHost.NODE_AUTO_CREATION_POLICIES, Arrays.asList(policies)); - String newprint = mapper.writeValueAsString(blueprintMap); - return newprint; - } - catch (IOException e) - { - throw new RuntimeException(e); - } - } - - - @Override - protected void setUp() throws Exception - { - getDefaultBrokerConfiguration().removeObjectConfiguration(VirtualHostNode.class, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST); - - createTestVirtualHostNode(TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST); - - super.setUp(); - - _connection = getConnection(); - _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - _connection.start(); - } - - public void testSendingToQueuePattern() throws Exception - { - final Queue queue = _session.createQueue(isBroker10() ? "fooQueue" : "ADDR: fooQueue ; { assert: never, node: { type: queue } }"); - final MessageProducer producer = _session.createProducer(queue); - producer.send(_session.createTextMessage("Hello world!")); - - final MessageConsumer consumer = _session.createConsumer(queue); - Message received = consumer.receive(getReceiveTimeout()); - assertNotNull(received); - assertTrue(received instanceof TextMessage); - assertEquals("Hello world!", ((TextMessage)received).getText()); - } - - - public void testSendingToNonMatchingQueuePattern() throws Exception - { - final Queue queue = _session.createQueue(isBroker10() ? "foQueue" : "ADDR: foQueue ; { assert: never, node: { type: queue } }"); - try - { - final MessageProducer producer = _session.createProducer(queue); - fail("Creating producer should fail"); - } - catch(JMSException e) - { - if(isBroker10()) - { - assertTrue(e instanceof InvalidDestinationException); - } - else - { - assertNotNull(e.getLinkedException()); - assertEquals("The name 'foQueue' supplied in the address doesn't resolve to an exchange or a queue", - e.getLinkedException().getMessage()); - } - } - } - - - public void testSendingToExchangePattern() throws Exception - { - final Topic topic = _session.createTopic(isBroker10() ? "barExchange/foo" : "ADDR: barExchange/foo ; { assert: never, node: { type: topic } }"); - final MessageProducer producer = _session.createProducer(topic); - producer.send(_session.createTextMessage("Hello world!")); - - final MessageConsumer consumer = _session.createConsumer(topic); - Message received = consumer.receive(getShortReceiveTimeout()); - assertNull(received); - - producer.send(_session.createTextMessage("Hello world2!")); - received = consumer.receive(getReceiveTimeout()); - - assertNotNull(received); - - assertTrue(received instanceof TextMessage); - assertEquals("Hello world2!", ((TextMessage)received).getText()); - } - - - public void testSendingToNonMatchingTopicPattern() throws Exception - { - final Topic topic = _session.createTopic(isBroker10() ? "baa" : "ADDR: baa ; { assert: never, node: { type: topic } }"); - try - { - final MessageProducer producer = _session.createProducer(topic); - fail("Creating producer should fail"); - } - catch(JMSException e) - { - if(isBroker10()) - { - assertTrue(e instanceof InvalidDestinationException); - } - else - { - assertNotNull(e.getLinkedException()); - assertEquals("The name 'baa' supplied in the address doesn't resolve to an exchange or a queue", - e.getLinkedException().getMessage()); - } - } - } - - - public void testSendingToQueuePatternBURL() throws Exception - { - final Queue queue = _session.createQueue("BURL:direct:///fooQ/fooQ"); - final MessageProducer producer = _session.createProducer(queue); - producer.send(_session.createTextMessage("Hello world!")); - - final MessageConsumer consumer = _session.createConsumer(queue); - Message received = consumer.receive(getReceiveTimeout()); - assertNotNull(received); - assertTrue(received instanceof TextMessage); - assertEquals("Hello world!", ((TextMessage)received).getText()); - } - - - public void testSendingToNonMatchingQueuePatternBURL() throws Exception - { - final Queue queue = _session.createQueue("BURL:direct:///fo/fo"); - try - { - _connection.close(); - _connection = getConnectionWithSyncPublishing(); - _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - _connection.start(); - final MessageProducer producer = _session.createProducer(queue); - producer.send(_session.createTextMessage("Hello world!")); - - fail("Sending a message should fail"); - } - catch(JMSException e) - { - // pass - } - } - - public void testQueueAlternateBindingCreation() throws Exception - { - Connection connection = getConnection(); - connection.start(); - Session session = connection.createSession(true, Session.SESSION_TRANSACTED); - - String queueName = getTestQueueName(); - String deadLetterQueueName = queueName + DEAD_LETTER_QUEUE_SUFFIX; - - final Map<String, Object> attributes = new HashMap<>(); - Map<String, Object> expectedAlternateBinding = - Collections.singletonMap(AlternateBinding.DESTINATION, deadLetterQueueName); - attributes.put(org.apache.qpid.server.model.Queue.ALTERNATE_BINDING, - new ObjectMapper().writeValueAsString(expectedAlternateBinding)); - createEntityUsingAmqpManagement(queueName, - session, - "org.apache.qpid.Queue", attributes); - - Map<String, Object> queueAttributes = - managementReadObject(connection.createSession(false, Session.AUTO_ACKNOWLEDGE), "org.apache.qpid.Queue", queueName, true); - - Object actualAlternateBinding = queueAttributes.get(org.apache.qpid.server.model.Queue.ALTERNATE_BINDING); - Map<String, Object> actualAlternateBindingMap = convertIfNecessary(actualAlternateBinding); - assertEquals("Unexpected alternate binding", - new HashMap<>(expectedAlternateBinding), - new HashMap<>(actualAlternateBindingMap)); - - assertNotNull("Cannot get dead letter queue", - managementReadObject(connection.createSession(false, Session.AUTO_ACKNOWLEDGE), "org.apache.qpid.Queue", deadLetterQueueName, true)); - } - - public void testExchangeAlternateBindingCreation() throws Exception - { - Connection connection = getConnection(); - connection.start(); - Session session = connection.createSession(true, Session.SESSION_TRANSACTED); - - String exchangeName = getTestQueueName(); - String deadLetterExchangeName = exchangeName + DEAD_LETTER_EXCHANGE_SUFFIX; - - final Map<String, Object> attributes = new HashMap<>(); - Map<String, Object> expectedAlternateBinding = - Collections.singletonMap(AlternateBinding.DESTINATION, deadLetterExchangeName); - attributes.put(Exchange.ALTERNATE_BINDING, new ObjectMapper().writeValueAsString(expectedAlternateBinding)); - attributes.put(Exchange.TYPE, ExchangeDefaults.DIRECT_EXCHANGE_CLASS); - createEntityUsingAmqpManagement(exchangeName, - session, - "org.apache.qpid.DirectExchange", attributes); - - Map<String, Object> exchangeAttributes = - managementReadObject(connection.createSession(false, Session.AUTO_ACKNOWLEDGE), "org.apache.qpid.Exchange", exchangeName, true); - - Object actualAlternateBinding = exchangeAttributes.get(Exchange.ALTERNATE_BINDING); - Map<String, Object> actualAlternateBindingMap = convertIfNecessary(actualAlternateBinding); - assertEquals("Unexpected alternate binding", - new HashMap<>(expectedAlternateBinding), - new HashMap<>(actualAlternateBindingMap)); - - assertNotNull("Cannot get dead letter exchange", - managementReadObject(connection.createSession(false, Session.AUTO_ACKNOWLEDGE), "org.apache.qpid.FanoutExchange", deadLetterExchangeName, true)); - } - - public void testLegacyQueueDeclareArgumentAlternateBindingCreation() throws Exception - { - Connection connection = getConnection(); - connection.start(); - Session session = connection.createSession(true, Session.SESSION_TRANSACTED); - - final Map<String, Object> arguments = Collections.singletonMap(QueueArgumentsConverter.X_QPID_DLQ_ENABLED, true); - String testQueueName = getTestQueueName(); - ((AMQSession<?,?>) session).createQueue(testQueueName, false, true, false, arguments); - - - Map<String, Object> queueAttributes = - managementReadObject(connection.createSession(false, Session.AUTO_ACKNOWLEDGE), "org.apache.qpid.Queue", testQueueName, true); - - Object actualAlternateBinding = queueAttributes.get(Exchange.ALTERNATE_BINDING); - assertTrue("Unexpected alternate binding", actualAlternateBinding instanceof Map); - Object deadLetterQueueName = ((Map<String, Object>) actualAlternateBinding).get(AlternateBinding.DESTINATION); - - assertNotNull("Cannot get dead letter queue", - managementReadObject(connection.createSession(false, Session.AUTO_ACKNOWLEDGE), "org.apache.qpid.Queue", String.valueOf(deadLetterQueueName), true)); - } - - private Map<String, Object> convertIfNecessary(final Object actualAlternateBinding) throws IOException - { - Map<String, Object> actualAlternateBindingMap; - if (actualAlternateBinding instanceof String) - { - actualAlternateBindingMap = new ObjectMapper().readValue((String)actualAlternateBinding, Map.class); - } - else - { - actualAlternateBindingMap = (Map<String, Object>) actualAlternateBinding; - } - return actualAlternateBindingMap; - } -} http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/4542234d/test-profiles/CPPExcludes ---------------------------------------------------------------------- diff --git a/test-profiles/CPPExcludes b/test-profiles/CPPExcludes index 182de05..4d8fe5c 100755 --- a/test-profiles/CPPExcludes +++ b/test-profiles/CPPExcludes @@ -162,9 +162,6 @@ org.apache.qpid.server.store.derby.* # QPID-7156: Test requires a Broker with a virtualhost org.apache.qpid.test.unit.client.connection.BrokerClosesClientConnectionTest#testClientCloseOnVirtualHostStop -#Node Creation Policy Tests use Qpid Broker-J Specific Config -org.apache.qpid.server.queue.NodeAutoCreationPolicyTest#* - #The C++ broker does not implement AMQP management org.apache.qpid.systest.management.amqp.* http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/4542234d/test-profiles/Java010Excludes ---------------------------------------------------------------------- diff --git a/test-profiles/Java010Excludes b/test-profiles/Java010Excludes index 0911088..db3316c 100755 --- a/test-profiles/Java010Excludes +++ b/test-profiles/Java010Excludes @@ -56,9 +56,6 @@ org.apache.qpid.test.unit.client.AMQSessionTest#testQueueDepthForQueueThatDoesNo org.apache.qpid.client.failover.FailoverBehaviourTest#testConnectionCloseInterruptsFailover org.apache.qpid.client.failover.AddressBasedFailoverBehaviourTest#testConnectionCloseInterruptsFailover -// There is no way in the 0-10 client to cause a send to fail when the message does not reach any queue -org.apache.qpid.server.queue.NodeAutoCreationPolicyTest#testSendingToNonMatchingQueuePatternBURL - # Exclude the JMS 2.0 test suite org.apache.qpid.systests.jms_2_0.* http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/4542234d/test-profiles/Java10Excludes ---------------------------------------------------------------------- diff --git a/test-profiles/Java10Excludes b/test-profiles/Java10Excludes index eb7f81f..7e62311 100644 --- a/test-profiles/Java10Excludes +++ b/test-profiles/Java10Excludes @@ -75,11 +75,6 @@ org.apache.qpid.test.client.failover.FailoverTest#* // Tests the issue of connection exceptions being generated for unroutable messages in the 0-x client org.apache.qpid.test.unit.client.connection.ExceptionListenerTest#testExceptionListenerConnectionStopDeadlock -// These tests specifically test BURL behaviour -org.apache.qpid.server.queue.NodeAutoCreationPolicyTest#testSendingToQueuePatternBURL -org.apache.qpid.server.queue.NodeAutoCreationPolicyTest#testSendingToNonMatchingQueuePatternBURL -org.apache.qpid.server.queue.NodeAutoCreationPolicyTest#testLegacyQueueDeclareArgumentAlternateBindingCreation - // Message encryption not currently supported by the 1.0 client org.apache.qpid.systest.messageencryption.MessageEncryptionTest#* // Message compression not currently supported by the 1.0 client --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
