You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2017/11/28 23:09:05 UTC
[1/2] qpid-broker-j git commit: QPID-6933: [System Tests] Move JMS
common test functionality into a separate module
Repository: qpid-broker-j
Updated Branches:
refs/heads/master 0a7368ecb -> 49cd2c1d6
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_2.0/src/main/java/org/apache/qpid/systests/jms_2_0/Jms2TestBase.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_2.0/src/main/java/org/apache/qpid/systests/jms_2_0/Jms2TestBase.java b/systests/qpid-systests-jms_2.0/src/main/java/org/apache/qpid/systests/jms_2_0/Jms2TestBase.java
deleted file mode 100644
index e13a9d9..0000000
--- a/systests/qpid-systests-jms_2.0/src/main/java/org/apache/qpid/systests/jms_2_0/Jms2TestBase.java
+++ /dev/null
@@ -1,144 +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.systests.jms_2_0;
-
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.JMSRuntimeException;
-import javax.jms.Session;
-import javax.naming.NamingException;
-
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-
-import org.apache.qpid.test.utils.AmqpManagementFacade;
-import org.apache.qpid.test.utils.ConnectionBuilder;
-import org.apache.qpid.test.utils.JmsProvider;
-import org.apache.qpid.test.utils.QpidJmsClientProvider;
-import org.apache.qpid.tests.utils.BrokerAdmin;
-import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
-import org.apache.qpid.url.URLSyntaxException;
-
-public abstract class Jms2TestBase extends BrokerAdminUsingTestBase
-{
- private static JmsProvider _jmsProvider;
- private static final AmqpManagementFacade _managementFacade = new AmqpManagementFacade("$management");
-
- @Rule
- public final TestName _testName = new TestName();
- private final List<Connection> _connections = new ArrayList<>();
-
- @BeforeClass
- public static void setUpTestBase()
- {
- _jmsProvider = new QpidJmsClientProvider(_managementFacade);
- }
-
- @After
- public void tearDown()
- {
- List<JMSException> exceptions = new ArrayList<>();
- for (Connection connection : _connections)
- {
- try
- {
- connection.close();
- }
- catch (JMSException e)
- {
- exceptions.add(e);
- }
- }
- if (!exceptions.isEmpty())
- {
- JMSRuntimeException jmsRuntimeException = new JMSRuntimeException("Exception(s) occurred during closing of JMS connections.");
- for (JMSException exception : exceptions)
- {
- jmsRuntimeException.addSuppressed(exception);
- }
- throw jmsRuntimeException;
- }
- }
-
- protected ConnectionBuilder getConnectionBuilder()
- {
- InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
- return _jmsProvider.getConnectionBuilder()
- .setHost(brokerAddress.getHostName())
- .setPort(brokerAddress.getPort())
- .setUsername(getBrokerAdmin().getValidUsername())
- .setPassword(getBrokerAdmin().getValidPassword());
- }
-
- protected void createEntityUsingAmqpManagement(final String entityName,
- final String entityType,
- final Map<String, Object> attributes)
- throws Exception
- {
- try (Connection connection = getConnection())
- {
- connection.start();
- Session session = connection.createSession(Session.CLIENT_ACKNOWLEDGE);
- _managementFacade.createEntityUsingAmqpManagement(entityName, session, entityType, attributes);
- }
- }
-
- protected Object performOperationUsingAmqpManagement(final String name,
- final String operation,
- final String type,
- Map<String, Object> arguments)
- throws Exception
- {
- try (Connection connection = getConnection())
- {
- connection.start();
- Session session = connection.createSession(Session.CLIENT_ACKNOWLEDGE);
- return _managementFacade.performOperationUsingAmqpManagement(name, operation, session, type, arguments);
- }
- }
-
- protected Connection getConnection() throws JMSException, NamingException, URLSyntaxException
- {
- return getConnectionBuilder().build();
- }
-
- protected long getReceiveTimeout()
- {
- return Long.getLong("qpid.test_receive_timeout", 1000L);
- }
-
- protected String getVirtualHostName()
- {
- return getClass().getSimpleName() + "_" + _testName.getMethodName();
- }
-
- protected String getTestName()
- {
- return _testName.getMethodName();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_2.0/src/main/java/org/apache/qpid/systests/jms_2_0/Utils.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_2.0/src/main/java/org/apache/qpid/systests/jms_2_0/Utils.java b/systests/qpid-systests-jms_2.0/src/main/java/org/apache/qpid/systests/jms_2_0/Utils.java
deleted file mode 100644
index 4e5f76f..0000000
--- a/systests/qpid-systests-jms_2.0/src/main/java/org/apache/qpid/systests/jms_2_0/Utils.java
+++ /dev/null
@@ -1,97 +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.systests.jms_2_0;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.BytesMessage;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-
-public class Utils
-{
- private static final int DEFAULT_MESSAGE_SIZE = 1024;
- public static final String INDEX = "index";
- private static final String DEFAULT_MESSAGE_PAYLOAD = createString(DEFAULT_MESSAGE_SIZE);
-
- public static List<Message> sendMessage(Session session, Destination destination, int count) throws Exception
- {
- List<Message> messages = new ArrayList<>(count);
- MessageProducer producer = session.createProducer(destination);
-
- for (int i = 0; i < (count); i++)
- {
- Message next = createNextMessage(session, i);
- producer.send(next);
- messages.add(next);
- }
-
- if (session.getTransacted())
- {
- session.commit();
- }
-
- return messages;
- }
-
- public static Message createNextMessage(Session session, int msgCount) throws JMSException
- {
- Message message = createMessage(session, DEFAULT_MESSAGE_SIZE);
- message.setIntProperty(INDEX, msgCount);
-
- return message;
- }
-
- public static Message createMessage(Session session, int messageSize) throws JMSException
- {
- String payload;
- if (messageSize == DEFAULT_MESSAGE_SIZE)
- {
- payload = DEFAULT_MESSAGE_PAYLOAD;
- }
- else
- {
- payload = createString(messageSize);
- }
-
- return session.createTextMessage(payload);
- }
-
- private static String createString(final int stringSize)
- {
- final String payload;
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < stringSize; ++i)
- {
- stringBuilder.append("x");
- }
- payload = stringBuilder.toString();
- return payload;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_2.0/src/main/resources/config-jms2-tests.json
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_2.0/src/main/resources/config-jms2-tests.json b/systests/qpid-systests-jms_2.0/src/main/resources/config-jms2-tests.json
deleted file mode 100644
index 764ff89..0000000
--- a/systests/qpid-systests-jms_2.0/src/main/resources/config-jms2-tests.json
+++ /dev/null
@@ -1,98 +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.
- *
- */
-{
- "name" : "${broker.name}",
- "modelVersion" : "7.0",
- "authenticationproviders" : [ {
- "name" : "anon",
- "type" : "Anonymous"
- }, {
- "name" : "plain",
- "type" : "Plain",
- "secureOnlyMechanisms" : [],
- "users" : [ {
- "name" : "admin",
- "type" : "managed",
- "password" : "admin"
- }, {
- "name" : "guest",
- "type" : "managed",
- "password" : "guest"
- } ]
- } ],
- "ports" : [ {
- "name" : "AMQP",
- "type" : "AMQP",
- "authenticationProvider" : "plain",
- "port" : "0",
- "protocols" : [ "AMQP_1_0" ],
- "virtualhostaliases" : [ {
- "name" : "defaultAlias",
- "type" : "defaultAlias"
- }, {
- "name" : "hostnameAlias",
- "type" : "hostnameAlias"
- }, {
- "name" : "nameAlias",
- "type" : "nameAlias"
- } ]
- }, {
- "name" : "ANONYMOUS_AMQP",
- "type" : "AMQP",
- "authenticationProvider" : "anon",
- "port" : "0",
- "protocols" : [ "AMQP_1_0" ],
- "virtualhostaliases" : [ {
- "name" : "defaultAlias",
- "type" : "defaultAlias",
- "durable" : true
- }, {
- "name" : "hostnameAlias",
- "type" : "hostnameAlias",
- "durable" : true
- }, {
- "name" : "nameAlias",
- "type" : "nameAlias",
- "durable" : true
- } ]
- }, {
- "name" : "ANONYMOUS_AMQPWS",
- "type" : "AMQP",
- "authenticationProvider" : "anon",
- "port" : "0",
- "transports" : ["WS"],
- "protocols" : [ "AMQP_1_0" ],
- "virtualhostaliases" : [ {
- "name" : "defaultAlias",
- "type" : "defaultAlias",
- "durable" : true
- }, {
- "name" : "hostnameAlias",
- "type" : "hostnameAlias",
- "durable" : true
- }, {
- "name" : "nameAlias",
- "type" : "nameAlias",
- "durable" : true
- } ]
- } ],
- "virtualhostnodes" : []
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/connection/ConnectionTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/connection/ConnectionTest.java b/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/connection/ConnectionTest.java
index 3472620..8012bdc 100644
--- a/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/connection/ConnectionTest.java
+++ b/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/connection/ConnectionTest.java
@@ -26,9 +26,9 @@ import javax.jms.Connection;
import org.junit.Test;
-import org.apache.qpid.systests.jms_2_0.Jms2TestBase;
+import org.apache.qpid.systests.JmsTestBase;
-public class ConnectionTest extends Jms2TestBase
+public class ConnectionTest extends JmsTestBase
{
@Test
public void testConnection() throws Exception
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverycount/DeliveryCountTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverycount/DeliveryCountTest.java b/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverycount/DeliveryCountTest.java
index 85a6bad..39e3322 100644
--- a/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverycount/DeliveryCountTest.java
+++ b/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverycount/DeliveryCountTest.java
@@ -37,12 +37,11 @@ import javax.jms.Session;
import org.junit.Before;
import org.junit.Test;
-import org.apache.qpid.systests.jms_2_0.Jms2TestBase;
-import org.apache.qpid.systests.jms_2_0.Utils;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.systests.JmsTestBase;
+import org.apache.qpid.systests.Utils;
import org.apache.qpid.tests.utils.BrokerAdmin;
-public class DeliveryCountTest extends Jms2TestBase
+public class DeliveryCountTest extends JmsTestBase
{
private static final int MAX_DELIVERY_ATTEMPTS = 3;
private static final String JMSX_DELIVERY_COUNT = "JMSXDeliveryCount";
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverydelay/DeliveryDelayTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverydelay/DeliveryDelayTest.java b/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverydelay/DeliveryDelayTest.java
index 20b36c1..cae2b05 100644
--- a/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverydelay/DeliveryDelayTest.java
+++ b/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/deliverydelay/DeliveryDelayTest.java
@@ -41,10 +41,10 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.apache.qpid.systests.jms_2_0.Jms2TestBase;
+import org.apache.qpid.systests.JmsTestBase;
import org.apache.qpid.tests.utils.BrokerAdmin;
-public class DeliveryDelayTest extends Jms2TestBase
+public class DeliveryDelayTest extends JmsTestBase
{
private static final int DELIVERY_DELAY = 3000;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/subscription/SharedSubscriptionTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/subscription/SharedSubscriptionTest.java b/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/subscription/SharedSubscriptionTest.java
index 7de96b0..32c60f5 100644
--- a/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/subscription/SharedSubscriptionTest.java
+++ b/systests/qpid-systests-jms_2.0/src/test/java/org/apache/qpid/systests/jms_2_0/subscription/SharedSubscriptionTest.java
@@ -37,10 +37,10 @@ import javax.jms.Topic;
import org.junit.Test;
-import org.apache.qpid.systests.jms_2_0.Jms2TestBase;
-import org.apache.qpid.systests.jms_2_0.Utils;
+import org.apache.qpid.systests.JmsTestBase;
+import org.apache.qpid.systests.Utils;
-public class SharedSubscriptionTest extends Jms2TestBase
+public class SharedSubscriptionTest extends JmsTestBase
{
@Test
public void testSharedNonDurableSubscription() throws Exception
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/src/main/java/org/apache/qpid/test/utils/AmqpManagementFacade.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/test/utils/AmqpManagementFacade.java b/systests/src/main/java/org/apache/qpid/test/utils/AmqpManagementFacade.java
deleted file mode 100644
index e7408ba..0000000
--- a/systests/src/main/java/org/apache/qpid/test/utils/AmqpManagementFacade.java
+++ /dev/null
@@ -1,363 +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.test.utils;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-import javax.jms.TemporaryQueue;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class AmqpManagementFacade
-{
- private final String _managementAddress;
-
- public AmqpManagementFacade(final String managementAddress)
- {
- _managementAddress = managementAddress;
- }
-
- public void createEntityUsingAmqpManagement(final String name, final Session session, final String type)
- throws JMSException
- {
- createEntityUsingAmqpManagement(name, session, type, Collections.<String, Object>emptyMap());
- }
-
- public void createEntityUsingAmqpManagement(final String name,
- final Session session,
- final String type,
- Map<String, Object> attributes)
- throws JMSException
- {
- MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
-
- MapMessage createMessage = session.createMapMessage();
- createMessage.setStringProperty("type", type);
- createMessage.setStringProperty("operation", "CREATE");
- createMessage.setString("name", name);
- createMessage.setString("object-path", name);
- for (Map.Entry<String, Object> entry : attributes.entrySet())
- {
- createMessage.setObject(entry.getKey(), entry.getValue());
- }
- producer.send(createMessage);
- if (session.getTransacted())
- {
- session.commit();
- }
- producer.close();
- }
-
- public void updateEntityUsingAmqpManagement(final String name,
- final Session session,
- final String type,
- Map<String, Object> attributes)
- throws JMSException
- {
- MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
-
- MapMessage createMessage = session.createMapMessage();
- createMessage.setStringProperty("type", type);
- createMessage.setStringProperty("operation", "UPDATE");
- createMessage.setStringProperty("index", "object-path");
- createMessage.setStringProperty("key", name);
- for (Map.Entry<String, Object> entry : attributes.entrySet())
- {
- createMessage.setObject(entry.getKey(), entry.getValue());
- }
- producer.send(createMessage);
- if (session.getTransacted())
- {
- session.commit();
- }
- producer.close();
- }
-
- public void deleteEntityUsingAmqpManagement(final String name, final Session session, final String type)
- throws JMSException
- {
- MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
-
- MapMessage createMessage = session.createMapMessage();
- createMessage.setStringProperty("type", type);
- createMessage.setStringProperty("operation", "DELETE");
- createMessage.setStringProperty("index", "object-path");
-
- createMessage.setStringProperty("key", name);
- producer.send(createMessage);
- if (session.getTransacted())
- {
- session.commit();
- }
- }
-
- public Object performOperationUsingAmqpManagement(final String name,
- final String operation,
- final Session session,
- final String type,
- Map<String, Object> arguments)
- throws JMSException
- {
- MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
- final TemporaryQueue responseQ = session.createTemporaryQueue();
- MessageConsumer consumer = session.createConsumer(responseQ);
- MapMessage opMessage = session.createMapMessage();
- opMessage.setStringProperty("type", type);
- opMessage.setStringProperty("operation", operation);
- opMessage.setStringProperty("index", "object-path");
- opMessage.setJMSReplyTo(responseQ);
-
- opMessage.setStringProperty("key", name);
- for (Map.Entry<String, Object> argument : arguments.entrySet())
- {
- Object value = argument.getValue();
- if (value.getClass().isPrimitive() || value instanceof String)
- {
- opMessage.setObjectProperty(argument.getKey(), value);
- }
- else
- {
- ObjectMapper objectMapper = new ObjectMapper();
- String jsonifiedValue = null;
- try
- {
- jsonifiedValue = objectMapper.writeValueAsString(value);
- }
- catch (JsonProcessingException e)
- {
- throw new IllegalArgumentException(String.format(
- "Cannot convert the argument '%s' to JSON to meet JMS type restrictions", argument.getKey()));
- }
- opMessage.setObjectProperty(argument.getKey(), jsonifiedValue);
- }
- }
-
- producer.send(opMessage);
- if (session.getTransacted())
- {
- session.commit();
- }
-
- Message response = consumer.receive(5000);
- try
- {
- int statusCode = response.getIntProperty("statusCode");
- if (statusCode < 200 || statusCode > 299)
- {
- throw new OperationUnsuccessfulException(statusCode);
- }
- if (response instanceof MapMessage)
- {
- MapMessage bodyMap = (MapMessage) response;
- Map<String, Object> result = new TreeMap<>();
- Enumeration mapNames = bodyMap.getMapNames();
- while (mapNames.hasMoreElements())
- {
- String key = (String) mapNames.nextElement();
- result.put(key, bodyMap.getObject(key));
- }
- return result;
- }
- else if (response instanceof ObjectMessage)
- {
- return ((ObjectMessage) response).getObject();
- }
- else if (response instanceof BytesMessage)
- {
- BytesMessage bytesMessage = (BytesMessage) response;
- if (bytesMessage.getBodyLength() == 0)
- {
- return null;
- }
- else
- {
- byte[] buf = new byte[(int) bytesMessage.getBodyLength()];
- bytesMessage.readBytes(buf);
- return buf;
- }
- }
- throw new IllegalArgumentException("Cannot parse the results from a management operation. JMS response message : " + response);
- }
- finally
- {
- if (session.getTransacted())
- {
- session.commit();
- }
- consumer.close();
- responseQ.delete();
- }
- }
-
- public List<Map<String, Object>> managementQueryObjects(final Session session, final String type) throws JMSException
- {
- MessageProducer producer = session.createProducer(session.createQueue("$management"));
- final TemporaryQueue responseQ = session.createTemporaryQueue();
- MessageConsumer consumer = session.createConsumer(responseQ);
- MapMessage message = session.createMapMessage();
- message.setStringProperty("identity", "self");
- message.setStringProperty("type", "org.amqp.management");
- message.setStringProperty("operation", "QUERY");
- message.setStringProperty("entityType", type);
- message.setString("attributeNames", "[]");
- message.setJMSReplyTo(responseQ);
-
- producer.send(message);
-
- Message response = consumer.receive(5000);
- try
- {
- if (response instanceof MapMessage)
- {
- MapMessage bodyMap = (MapMessage) response;
- List<String> attributeNames = (List<String>) bodyMap.getObject("attributeNames");
- List<List<Object>> attributeValues = (List<List<Object>>) bodyMap.getObject("results");
- return getResultsAsMaps(attributeNames, attributeValues);
- }
- else if (response instanceof ObjectMessage)
- {
- Object body = ((ObjectMessage) response).getObject();
- if (body instanceof Map)
- {
- Map<String, ?> bodyMap = (Map<String, ?>) body;
- List<String> attributeNames = (List<String>) bodyMap.get("attributeNames");
- List<List<Object>> attributeValues = (List<List<Object>>) bodyMap.get("results");
- return getResultsAsMaps(attributeNames, attributeValues);
- }
- }
- throw new IllegalArgumentException("Cannot parse the results from a management query");
- }
- finally
- {
- consumer.close();
- responseQ.delete();
- }
- }
-
- public Map<String, Object> readEntityUsingAmqpManagement(final Session session,
- final String type,
- final String name,
- final boolean actuals) throws JMSException
- {
- MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
-
- final TemporaryQueue responseQueue = session.createTemporaryQueue();
- MessageConsumer consumer = session.createConsumer(responseQueue);
-
- MapMessage request = session.createMapMessage();
- request.setStringProperty("type", type);
- request.setStringProperty("operation", "READ");
- request.setString("name", name);
- request.setString("object-path", name);
- request.setStringProperty("index", "object-path");
- request.setStringProperty("key", name);
- request.setBooleanProperty("actuals", actuals);
- request.setJMSReplyTo(responseQueue);
-
- producer.send(request);
- if (session.getTransacted())
- {
- session.commit();
- }
-
- Message response = consumer.receive(5000);
- if (session.getTransacted())
- {
- session.commit();
- }
- try
- {
- if (response instanceof MapMessage)
- {
- MapMessage bodyMap = (MapMessage) response;
- Map<String, Object> data = new HashMap<>();
- Enumeration<String> keys = bodyMap.getMapNames();
- while (keys.hasMoreElements())
- {
- String key = keys.nextElement();
- data.put(key, bodyMap.getObject(key));
- }
- return data;
- }
- else if (response instanceof ObjectMessage)
- {
- Object body = ((ObjectMessage) response).getObject();
- if (body instanceof Map)
- {
- Map<String, ?> bodyMap = (Map<String, ?>) body;
- return new HashMap<>(bodyMap);
- }
- }
- throw new IllegalArgumentException("Management read failed : " + response.getStringProperty("statusCode") + " - " + response.getStringProperty("statusDescription"));
- }
- finally
- {
- consumer.close();
- responseQueue.delete();
- }
- }
-
- private List<Map<String, Object>> getResultsAsMaps(final List<String> attributeNames, final List<List<Object>> attributeValues)
- {
- List<Map<String, Object>> results = new ArrayList<>();
- for (List<Object> resultObject : attributeValues)
- {
- Map<String, Object> result = new HashMap<>();
- for (int i = 0; i < attributeNames.size(); ++i)
- {
- result.put(attributeNames.get(i), resultObject.get(i));
- }
- results.add(result);
- }
- return results;
- }
-
- public static class OperationUnsuccessfulException extends RuntimeException
- {
- private final int _statusCode;
-
- private OperationUnsuccessfulException(final int statusCode)
- {
- super();
- _statusCode = statusCode;
- }
-
- public int getStatusCode()
- {
- return _statusCode;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/src/main/java/org/apache/qpid/test/utils/ConnectionBuilder.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/test/utils/ConnectionBuilder.java b/systests/src/main/java/org/apache/qpid/test/utils/ConnectionBuilder.java
deleted file mode 100644
index 70fd7fb..0000000
--- a/systests/src/main/java/org/apache/qpid/test/utils/ConnectionBuilder.java
+++ /dev/null
@@ -1,49 +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.test.utils;
-
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.naming.NamingException;
-
-public interface ConnectionBuilder
-{
- ConnectionBuilder setHost(String host);
- ConnectionBuilder setPort(int port);
- ConnectionBuilder setSslPort(int port);
- ConnectionBuilder setPrefetch(int prefetch);
- ConnectionBuilder setClientId(String clientId);
- ConnectionBuilder setUsername(String username);
- ConnectionBuilder setPassword(String password);
- ConnectionBuilder setVirtualHost(String virtualHostName);
- ConnectionBuilder setFailover(boolean enableFailover);
- ConnectionBuilder setFailoverReconnectAttempts(int reconnectAttempts);
- ConnectionBuilder setTls(boolean enableTls);
- ConnectionBuilder setSyncPublish(boolean syncPublish);
- ConnectionBuilder setOptions(Map<String, String> options);
- ConnectionBuilder setPopulateJMSXUserID(boolean populateJMSXUserID);
-
- Connection build() throws NamingException, JMSException;
- ConnectionFactory buildConnectionFactory() throws NamingException;
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/src/main/java/org/apache/qpid/test/utils/JmsProvider.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/test/utils/JmsProvider.java b/systests/src/main/java/org/apache/qpid/test/utils/JmsProvider.java
deleted file mode 100644
index 1dbd289..0000000
--- a/systests/src/main/java/org/apache/qpid/test/utils/JmsProvider.java
+++ /dev/null
@@ -1,64 +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.test.utils;
-
-import java.net.URISyntaxException;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.NamingException;
-
-
-public interface JmsProvider
-{
- ConnectionFactory getConnectionFactory() throws NamingException;
-
- ConnectionFactory getConnectionFactory(Map<String, String> options) throws NamingException;
-
- Connection getConnection(String urlString) throws Exception;
-
- Queue getTestQueue(String testQueueName) throws NamingException;
-
- Queue getQueueFromName(Session session, String name) throws JMSException;
-
- Queue createTestQueue(Session session, String queueName) throws JMSException;
-
- Topic getTestTopic(String testQueueName);
-
- Topic createTopic(Connection con, String topicName) throws JMSException;
-
- Topic createTopicOnDirect(Connection con, String topicName) throws JMSException, URISyntaxException;
-
- Topic createTopicOnFanout(Connection con, String topicName) throws JMSException, URISyntaxException;
-
- long getQueueDepth(Queue destination) throws Exception;
-
- boolean isQueueExist(Queue destination) throws Exception;
-
- String getBrokerDetailsFromDefaultConnectionUrl();
-
- ConnectionBuilder getConnectionBuilder();
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
index 4aec884..c0297c8 100755
--- a/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
+++ b/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
@@ -18,13 +18,12 @@
package org.apache.qpid.test.utils;
import java.io.File;
-import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URISyntaxException;
-import java.net.URLEncoder;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
@@ -32,7 +31,21 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-import javax.jms.*;
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
import javax.naming.NamingException;
import ch.qos.logback.classic.sift.SiftingAppender;
@@ -44,6 +57,11 @@ import org.slf4j.LoggerFactory;
import org.apache.qpid.server.model.Protocol;
import org.apache.qpid.server.store.MemoryConfigurationStore;
+import org.apache.qpid.systests.AmqpManagementFacade;
+import org.apache.qpid.systests.ConnectionBuilder;
+import org.apache.qpid.systests.JmsProvider;
+import org.apache.qpid.systests.QpidJmsClient0xProvider;
+import org.apache.qpid.systests.QpidJmsClientProvider;
/**
* Qpid base class for system testing test cases.
@@ -89,7 +107,7 @@ public class QpidBrokerTestCase extends QpidTestCase
try
{
_managementFacade = new AmqpManagementFacade(isBroker10() ? "$management" : "ADDR:$management");
- _jmsProvider = isBroker10() ? new QpidJmsClientProvider(_managementFacade) : new QpidJmsClient0xProvider(_managementFacade);
+ _jmsProvider = isBroker10() ? new QpidJmsClientProvider(_managementFacade) : new QpidJmsClient0xProvider();
_defaultBroker = new BrokerHolderFactory().create(DEFAULT_BROKER_TYPE, DEFAULT_PORT, this);
super.runBare();
@@ -199,35 +217,11 @@ public class QpidBrokerTestCase extends QpidTestCase
getDefaultBroker().restart();
}
- protected void appendOptions(final Map<String, String> actualOptions, final StringBuilder stem)
- {
- boolean first = true;
- for(Map.Entry<String, String> option : actualOptions.entrySet())
- {
- if(first)
- {
- stem.append('?');
- first = false;
- }
- else
- {
- stem.append('&');
- }
- try
- {
- stem.append(option.getKey()).append('=').append(URLEncoder.encode(option.getValue(), "UTF-8"));
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException(e);
- }
- }
- }
-
-
public ConnectionBuilder getConnectionBuilder()
{
final ConnectionBuilder connectionBuilder = _jmsProvider.getConnectionBuilder()
+ .setPort(Integer.getInteger("test.port"))
+ .setSslPort(Integer.getInteger("test.port.ssl"))
.setVirtualHost("test")
.setTls(Boolean.getBoolean(PROFILE_USE_SSL))
.setPopulateJMSXUserID(true)
@@ -248,12 +242,12 @@ public class QpidBrokerTestCase extends QpidTestCase
*/
public ConnectionFactory getConnectionFactory() throws NamingException
{
- return _jmsProvider.getConnectionFactory();
+ return getConnectionFactory(Collections.emptyMap());
}
public ConnectionFactory getConnectionFactory(final Map<String, String> options) throws NamingException
{
- return _jmsProvider.getConnectionFactory(options);
+ return getConnectionBuilder().setOptions(options).buildConnectionFactory();
}
public Connection getConnection() throws JMSException, NamingException
@@ -319,7 +313,7 @@ public class QpidBrokerTestCase extends QpidTestCase
* Return a Topic specific for this test.
* Uses getTestQueueName() as the name of the topic
*/
- public Topic getTestTopic()
+ public Topic getTestTopic() throws NamingException
{
return _jmsProvider.getTestTopic(getTestQueueName());
}
@@ -384,12 +378,48 @@ public class QpidBrokerTestCase extends QpidTestCase
public long getQueueDepth(final Connection con, final Queue destination) throws Exception
{
- return _jmsProvider.getQueueDepth(destination);
+ Connection connection = getConnection();
+ try
+ {
+ connection.start();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try
+ {
+ return _managementFacade.getQueueDepth(destination, session);
+ }
+
+ finally
+ {
+ session.close();
+ }
+ }
+ finally
+ {
+ connection.close();
+ }
}
public boolean isQueueExist(final Connection con, final Queue destination) throws Exception
{
- return _jmsProvider.isQueueExist(destination);
+ Connection connection = getConnection();
+ try
+ {
+ connection.start();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try
+ {
+ return _managementFacade.isQueueExist(destination, session);
+ }
+
+ finally
+ {
+ session.close();
+ }
+ }
+ finally
+ {
+ connection.close();
+ }
}
/**
@@ -524,7 +554,9 @@ public class QpidBrokerTestCase extends QpidTestCase
public String getBrokerDetailsFromDefaultConnectionUrl()
{
- return _jmsProvider.getBrokerDetailsFromDefaultConnectionUrl();
+ return "tcp://localhost:" + (getDefaultBroker().getAmqpTlsPort() > 0
+ ? getDefaultBroker().getAmqpTlsPort()
+ : getDefaultBroker().getAmqpPort());
}
/**
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClient0xConnectionBuilder.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClient0xConnectionBuilder.java b/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClient0xConnectionBuilder.java
deleted file mode 100644
index 2962c19..0000000
--- a/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClient0xConnectionBuilder.java
+++ /dev/null
@@ -1,243 +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.test.utils;
-
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-public class QpidJmsClient0xConnectionBuilder implements ConnectionBuilder
-{
- private String _clientId = "clientid";
- private String _username = "guest";
- private String _password = "guest";
- private String _virtualHost;
- private boolean _enableTls;
- private boolean _enableFailover;
- private final Map<String, Object> _options = new TreeMap<>();
- private int _reconnectAttempts = 20;
- private String _host = "localhost";
- private int _port = Integer.getInteger("test.port");
- private int _sslPort = Integer.getInteger("test.port.ssl");
-
- @Override
- public ConnectionBuilder setHost(final String host)
- {
- _host = host;
- return this;
- }
-
- @Override
- public ConnectionBuilder setPort(final int port)
- {
- _port = port;
- return this;
- }
-
- @Override
- public ConnectionBuilder setSslPort(final int port)
- {
- _sslPort = port;
- return this;
- }
-
- @Override
- public ConnectionBuilder setPrefetch(final int prefetch)
- {
- _options.put("maxprefetch", prefetch);
- return this;
- }
-
- @Override
- public ConnectionBuilder setClientId(final String clientId)
- {
- _clientId = clientId;
- return this;
- }
-
- @Override
- public ConnectionBuilder setUsername(final String username)
- {
- _username = username;
- return this;
- }
-
- @Override
- public ConnectionBuilder setPassword(final String password)
- {
- _password = password;
- return this;
- }
-
- @Override
- public ConnectionBuilder setVirtualHost(final String virtualHostName)
- {
- _virtualHost = virtualHostName;
- return this;
- }
-
- @Override
- public ConnectionBuilder setFailover(final boolean enableFailover)
- {
- _enableFailover = enableFailover;
- return this;
- }
-
- @Override
- public ConnectionBuilder setFailoverReconnectAttempts(final int reconnectAttempts)
- {
- _reconnectAttempts = reconnectAttempts;
- return this;
- }
-
- @Override
- public ConnectionBuilder setTls(final boolean enableTls)
- {
- _enableTls = enableTls;
- return this;
- }
-
- @Override
- public ConnectionBuilder setSyncPublish(final boolean syncPublish)
- {
- if (syncPublish)
- {
- _options.put("sync_publish", "all");
- }
- else
- {
- _options.remove("sync_publish");
- }
- return this;
- }
-
- @Override
- public ConnectionBuilder setOptions(final Map<String, String> options)
- {
- _options.putAll(options);
- return this;
- }
-
- @Override
- public ConnectionBuilder setPopulateJMSXUserID(final boolean populateJMSXUserID)
- {
- _options.put("populateJMSXUserID", String.valueOf(populateJMSXUserID));
- return this;
- }
-
- @Override
- public Connection build() throws JMSException, NamingException
- {
- return buildConnectionFactory().createConnection(_username, _password);
- }
-
- @Override
- public ConnectionFactory buildConnectionFactory() throws NamingException
- {
- StringBuilder cUrlBuilder = new StringBuilder("amqp://");
- if (_username != null)
- {
- cUrlBuilder.append(_username);
- }
-
- if (_username != null || _password != null)
- {
- cUrlBuilder.append(":");
- }
-
- if (_password != null)
- {
- cUrlBuilder.append(_password);
- }
-
- if (_username != null || _password != null)
- {
- cUrlBuilder.append("@");
- }
-
- if (_clientId != null)
- {
- cUrlBuilder.append(_clientId);
- }
-
- cUrlBuilder.append("/");
-
- if (_virtualHost != null)
- {
- cUrlBuilder.append(_virtualHost);
- }
-
- cUrlBuilder.append("?brokerlist='tcp://").append(_host).append(":");
- if (_enableTls)
- {
- cUrlBuilder.append(_sslPort).append("?ssl='true'");
- }
- else
- {
- cUrlBuilder.append(_port);
- }
-
- if (_enableFailover)
- {
- cUrlBuilder.append(";tcp://").append(_host).append(":");
- if (_enableTls)
- {
- cUrlBuilder.append(System.getProperty("test.port.alt.ssl")).append("?ssl='true'");
- }
- else
- {
- cUrlBuilder.append(System.getProperty("test.port.alt"));
- }
- cUrlBuilder.append("'")
- .append("&sync_ack='true'&sync_publish='all'&failover='roundrobin?cyclecount='")
- .append(_reconnectAttempts)
- .append("''");
- }
- else
- {
- cUrlBuilder.append("'");
- }
-
- for (Map.Entry<String, Object> entry : _options.entrySet())
- {
- cUrlBuilder.append("&").append(entry.getKey()).append("='").append(entry.getValue()).append("'");
- }
-
- final Hashtable<Object, Object> initialContextEnvironment = new Hashtable<>();
- initialContextEnvironment.put(Context.INITIAL_CONTEXT_FACTORY,
- "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
- final String factoryName = "connectionFactory";
- initialContextEnvironment.put("connectionfactory." + factoryName, cUrlBuilder.toString());
- return (ConnectionFactory) new InitialContext(initialContextEnvironment).lookup(factoryName);
- }
-
- String getBrokerDetails()
- {
- return "tcp://" + _host + ":" + _port;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClient0xProvider.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClient0xProvider.java b/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClient0xProvider.java
deleted file mode 100644
index f582321..0000000
--- a/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClient0xProvider.java
+++ /dev/null
@@ -1,257 +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.test.utils;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URISyntaxException;
-import java.security.AccessControlException;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-
-public class QpidJmsClient0xProvider implements JmsProvider
-{
- private final AmqpManagementFacade _managementFacade;
-
- public QpidJmsClient0xProvider(AmqpManagementFacade managementFacade)
- {
- _managementFacade = managementFacade;
- }
-
- @Override
- public ConnectionFactory getConnectionFactory() throws NamingException
- {
- return getConnectionBuilder().setTls(Boolean.getBoolean(QpidBrokerTestCase.PROFILE_USE_SSL))
- .buildConnectionFactory();
- }
-
- @Override
- public ConnectionFactory getConnectionFactory(final Map<String, String> options) throws NamingException
- {
- throw new UnsupportedOperationException();
- }
-
- private Connection getConnection() throws JMSException, NamingException
- {
- return getConnection(QpidBrokerTestCase.GUEST_USERNAME, QpidBrokerTestCase.GUEST_PASSWORD);
- }
-
- private Connection getConnection(String username, String password) throws JMSException, NamingException
- {
- return getConnectionBuilder().setUsername(username).setPassword(password).build();
- }
-
- @Override
- public Connection getConnection(String urlString) throws Exception
- {
- final Hashtable<Object, Object> initialContextEnvironment = new Hashtable<>();
- initialContextEnvironment.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
- final String factoryName = "connectionFactory";
- initialContextEnvironment.put("connectionfactory." + factoryName, urlString);
- ConnectionFactory connectionFactory =
- (ConnectionFactory) new InitialContext(initialContextEnvironment).lookup(factoryName);
- return connectionFactory.createConnection();
- }
-
-
- @Override
- public Queue getTestQueue(final String testQueueName) throws NamingException
- {
- return createReflectively("org.apache.qpid.client.AMQQueue", "amq.direct", testQueueName);
- }
-
- @Override
- public Queue getQueueFromName(Session session, String name) throws JMSException
- {
- return createReflectively("org.apache.qpid.client.AMQQueue", "", name);
- }
-
- @Override
- public Queue createTestQueue(Session session, String queueName) throws JMSException
- {
-
- Queue amqQueue = null;
- try
- {
- amqQueue = getTestQueue(queueName);
- }
- catch (NamingException e)
- {
- throw new RuntimeException(e);
- }
- session.createConsumer(amqQueue).close();
- return amqQueue;
- }
-
- @Override
- public Topic getTestTopic(final String testQueueName)
- {
- return createReflectively("org.apache.qpid.client.AMQTopic", "amq.topic", testQueueName);
- }
-
- @Override
- public Topic createTopic(final Connection con, final String topicName) throws JMSException
- {
- return getTestTopic(topicName);
- }
-
- @Override
- public Topic createTopicOnDirect(final Connection con, String topicName) throws JMSException, URISyntaxException
- {
- return createReflectively("org.apache.qpid.client.AMQTopic",
- "direct://amq.direct/"
- + topicName
- + "/"
- + topicName
- + "?routingkey='"
- + topicName
- + "',exclusive='true',autodelete='true'");
- }
-
- private <T> T createReflectively(String className, Object ...args)
- {
- try
- {
- Class<?> topicClass = Class.forName(className);
- Class[] classes = new Class[args.length];
- for (int i = 0; i < args.length; ++i)
- {
- classes[i] = args[i].getClass();
- }
- Constructor<?> constructor = topicClass.getConstructor(classes);
- return (T) constructor.newInstance(args);
- }
- catch (IllegalAccessException | AccessControlException | InvocationTargetException | InstantiationException | NoSuchMethodException | ClassNotFoundException e)
- {
- throw new RuntimeException(e);
- }
-
- }
-
- @Override
- public Topic createTopicOnFanout(final Connection con, String topicName) throws JMSException, URISyntaxException
- {
- return createReflectively("org.apache.qpid.client.AMQTopic", "fanout://amq.fanout/"
- + topicName
- + "/"
- + topicName
- + "?routingkey='"
- + topicName
- + "',exclusive='true',autodelete='true'");
- }
-
- @Override
- public long getQueueDepth(final Queue destination) throws Exception
- {
- final String escapedName = destination.getQueueName().replaceAll("([/\\\\])", "\\\\$1");
- Connection connection = getConnection();
- try
- {
- connection.start();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- try
- {
- Map<String, Object> arguments = Collections.singletonMap("statistics",
- Collections.singletonList("queueDepthMessages"));
- Object statistics = _managementFacade.performOperationUsingAmqpManagement(escapedName,
- "getStatistics",
- session,
- "org.apache.qpid.Queue",
- arguments);
-
- Map<String, Object> statisticsMap = (Map<String, Object>) statistics;
- return ((Number) statisticsMap.get("queueDepthMessages")).intValue();
- }
- finally
- {
- session.close();
- }
- }
- finally
- {
- connection.close();
- }
- }
-
- @Override
- public boolean isQueueExist(final Queue destination) throws Exception
- {
- final String escapedName = destination.getQueueName().replaceAll("([/\\\\])", "\\\\$1");
- Connection connection = getConnection();
- try
- {
- connection.start();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- try
- {
- _managementFacade.performOperationUsingAmqpManagement(escapedName,
- "READ",
- session,
- "org.apache.qpid.Queue",
- Collections.emptyMap());
- return true;
- }
- catch (AmqpManagementFacade.OperationUnsuccessfulException e)
- {
- if (e.getStatusCode() == 404)
- {
- return false;
- }
- else
- {
- throw e;
- }
- }
- finally
- {
- session.close();
- }
- }
- finally
- {
- connection.close();
- }
- }
-
- @Override
- public String getBrokerDetailsFromDefaultConnectionUrl()
- {
- return getConnectionBuilder().getBrokerDetails();
- }
-
- @Override
- public QpidJmsClient0xConnectionBuilder getConnectionBuilder()
- {
- return new QpidJmsClient0xConnectionBuilder();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClientConnectionBuilder.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClientConnectionBuilder.java b/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClientConnectionBuilder.java
deleted file mode 100644
index 096b854..0000000
--- a/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClientConnectionBuilder.java
+++ /dev/null
@@ -1,257 +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.test.utils;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-public class QpidJmsClientConnectionBuilder implements ConnectionBuilder
-{
-
- private static final AtomicInteger CLIENTID_COUNTER = new AtomicInteger();
- private String _host;
- private int _port;
- private int _sslPort;
- private Map<String, Object> _options;
- private boolean _enableTls;
- private boolean _enableFailover;
-
- public QpidJmsClientConnectionBuilder()
- {
- _options = new TreeMap<>();
- _options.put("jms.clientID", getNextClientId());
- _options.put("jms.username", "guest");
- _options.put("jms.password", "guest");
- _port = Integer.getInteger("test.port");
- _sslPort = Integer.getInteger("test.port.ssl");
- _host = "localhost";
- }
-
- @Override
- public ConnectionBuilder setHost(final String host)
- {
- _host = host;
- return this;
- }
-
- @Override
- public ConnectionBuilder setPort(final int port)
- {
- _port = port;
- return this;
- }
-
- @Override
- public ConnectionBuilder setSslPort(final int port)
- {
- _sslPort = port;
- return this;
- }
-
- @Override
- public ConnectionBuilder setPrefetch(final int prefetch)
- {
- _options.put("jms.prefetchPolicy.all", prefetch);
- return this;
- }
-
- @Override
- public ConnectionBuilder setClientId(final String clientId)
- {
- if (clientId == null)
- {
- _options.remove("jms.clientID");
- }
- else
- {
- _options.put("jms.clientID", clientId);
- }
- return this;
- }
-
- @Override
- public ConnectionBuilder setUsername(final String username)
- {
- if (username == null)
- {
- _options.remove("jms.username");
- }
- else
- {
- _options.put("jms.username", username);
- }
- return this;
- }
-
- @Override
- public ConnectionBuilder setPassword(final String password)
- {
- if (password == null)
- {
- _options.remove("jms.password");
- }
- else
- {
- _options.put("jms.password", password);
- }
- return this;
- }
-
- @Override
- public ConnectionBuilder setVirtualHost(final String virtualHostName)
- {
- _options.put("amqp.vhost", virtualHostName);
- return this;
- }
-
- @Override
- public ConnectionBuilder setFailover(final boolean enableFailover)
- {
- _enableFailover = enableFailover;
- return this;
- }
-
- @Override
- public ConnectionBuilder setFailoverReconnectAttempts(final int reconnectAttempts)
- {
- _options.put("failover.maxReconnectAttempts", reconnectAttempts);
- return this;
- }
-
- @Override
- public ConnectionBuilder setTls(final boolean enableTls)
- {
- _enableTls = enableTls;
- return this;
- }
-
- @Override
- public ConnectionBuilder setSyncPublish(final boolean syncPublish)
- {
- _options.put("jms.forceSyncSend", syncPublish);
- return this;
- }
-
- @Override
- public ConnectionBuilder setOptions(final Map<String, String> options)
- {
- _options.putAll(options);
- return this;
- }
-
- @Override
- public ConnectionBuilder setPopulateJMSXUserID(final boolean populateJMSXUserID)
- {
- _options.put("jms.populateJMSXUserID", String.valueOf(populateJMSXUserID));
- return this;
- }
-
- @Override
- public Connection build() throws NamingException, JMSException
- {
- return buildConnectionFactory().createConnection();
- }
-
- @Override
- public ConnectionFactory buildConnectionFactory() throws NamingException
- {
- final Hashtable<Object, Object> initialContextEnvironment = new Hashtable<>();
- initialContextEnvironment.put(Context.INITIAL_CONTEXT_FACTORY,
- "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
-
- final StringBuilder connectionUrlBuilder = new StringBuilder();
-
- final Map<String, Object> options = new TreeMap<>();
- options.putAll(_options);
- if (_enableFailover)
- {
- if (!options.containsKey("failover.maxReconnectAttempts"))
- {
- options.put("failover.maxReconnectAttempts", "2");
- }
- connectionUrlBuilder.append("failover:(amqp://")
- .append(_host)
- .append(":")
- .append(_port)
- .append(",amqp://localhost:")
- .append(System.getProperty("test.port.alt"))
- .append(")");
- appendOptions(options, connectionUrlBuilder);
- }
- else if (!_enableTls)
- {
- connectionUrlBuilder.append("amqp://").append(_host).append(":").append(_port);
-
- appendOptions(options, connectionUrlBuilder);
- }
- else
- {
- connectionUrlBuilder.append("amqps://").append(_host).append(":").append(_sslPort);
- appendOptions(options, connectionUrlBuilder);
- }
-
- final String factoryName = "connection";
- initialContextEnvironment.put("connectionfactory." + factoryName, connectionUrlBuilder.toString());
-
- return (ConnectionFactory) new InitialContext(initialContextEnvironment).lookup(factoryName);
- }
-
- private void appendOptions(final Map<String, Object> actualOptions, final StringBuilder stem)
- {
- boolean first = true;
- for(Map.Entry<String, Object> option : actualOptions.entrySet())
- {
- if(first)
- {
- stem.append('?');
- first = false;
- }
- else
- {
- stem.append('&');
- }
- try
- {
- stem.append(option.getKey()).append('=').append(URLEncoder.encode(String.valueOf(option.getValue()), "UTF-8"));
- }
- catch (UnsupportedEncodingException e)
- {
- throw new RuntimeException(e);
- }
- }
- }
-
- private String getNextClientId()
- {
- return "builderClientId-" + CLIENTID_COUNTER.getAndIncrement();
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClientProvider.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClientProvider.java b/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClientProvider.java
deleted file mode 100644
index 1e590be..0000000
--- a/systests/src/main/java/org/apache/qpid/test/utils/QpidJmsClientProvider.java
+++ /dev/null
@@ -1,283 +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.test.utils;
-
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.NamingException;
-
-public class QpidJmsClientProvider implements JmsProvider
-{
- private static final AtomicInteger CLIENTID_COUNTER = new AtomicInteger();
- private final AmqpManagementFacade _managementFacade;
-
- public QpidJmsClientProvider(AmqpManagementFacade managementFacade)
- {
- _managementFacade = managementFacade;
- }
-
- @Override
- public ConnectionFactory getConnectionFactory() throws NamingException
- {
- return getConnectionFactory(Collections.emptyMap());
- }
-
- @Override
- public ConnectionFactory getConnectionFactory(Map<String, String> options) throws NamingException
- {
- boolean useSsl = Boolean.getBoolean(QpidBrokerTestCase.PROFILE_USE_SSL);
- if (!options.containsKey("amqp.vhost"))
- {
- options = new HashMap<>(options);
- options.put("amqp.vhost", "test");
- }
- if (!options.containsKey("jms.clientID"))
- {
- options = new HashMap<>(options);
- options.put("jms.clientID", getNextClientId());
- }
- else if (options.get("jms.clientID") == null)
- {
- options.remove("jms.clientID");
- }
- if (!options.containsKey("amqp.forceSyncSend"))
- {
- options = new HashMap<>(options);
- options.put("jms.forceSyncSend", "true");
- }
- if (!options.containsKey("amqp.populateJMSXUserID"))
- {
- options = new HashMap<>(options);
- options.put("jms.populateJMSXUserID", "true");
- }
-
- return getConnectionBuilder().setTls(useSsl).setOptions(options).buildConnectionFactory();
- }
-
- private Connection getConnection() throws JMSException, NamingException
- {
- return getConnection(QpidBrokerTestCase.GUEST_USERNAME, QpidBrokerTestCase.GUEST_PASSWORD);
- }
-
-
- private Connection getConnection(String username, String password) throws JMSException, NamingException
- {
- return getConnectionFactory().createConnection(username, password);
- }
-
- @Override
- public Connection getConnection(String urlString) throws Exception
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Queue getTestQueue(final String testQueueName)
- {
- Connection con = null;
- try
- {
- con = getConnection();
- Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
- return session.createQueue(testQueueName);
- }
- catch (JMSException | NamingException e)
- {
- throw new RuntimeException("Failed to create a test queue name : " + testQueueName, e);
- }
- finally
- {
- if (con != null)
- {
- try
- {
- con.close();
- }
- catch (JMSException e)
- {
- }
- }
- }
- }
-
- @Override
- public Queue getQueueFromName(Session session, String name) throws JMSException
- {
- return session.createQueue(name);
- }
-
- @Override
- public Queue createTestQueue(Session session, String queueName) throws JMSException
- {
- _managementFacade.createEntityUsingAmqpManagement(queueName, session, "org.apache.qpid.Queue");
-
- return session.createQueue(queueName);
- }
-
- @Override
- public Topic getTestTopic(final String testTopicName)
- {
- Connection con = null;
- try
- {
- con = getConnection();
- Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
- return session.createTopic(testTopicName);
- }
- catch (JMSException | NamingException e)
- {
- throw new RuntimeException("Failed to create a test topic name : " + testTopicName, e);
- }
- finally
- {
- if (con != null)
- {
- try
- {
- con.close();
- }
- catch (JMSException e)
- {
- }
- }
- }
- }
-
- @Override
- public Topic createTopic(final Connection con, final String topicName) throws JMSException
- {
- Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
- _managementFacade.createEntityUsingAmqpManagement(topicName, session, "org.apache.qpid.TopicExchange");
-
- return session.createTopic(topicName);
- }
-
- @Override
- public Topic createTopicOnDirect(final Connection con, String topicName) throws JMSException, URISyntaxException
- {
- Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
- return session.createTopic("amq.direct/" + topicName);
- }
-
- @Override
- public Topic createTopicOnFanout(final Connection con, String topicName) throws JMSException, URISyntaxException
- {
- Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
- return session.createTopic("amq.fanout/" + topicName);
- }
-
- @Override
- public long getQueueDepth(final Queue destination) throws Exception
- {
- final String escapedName = destination.getQueueName().replaceAll("([/\\\\])", "\\\\$1");
- Connection connection = getConnection();
- try
- {
- connection.start();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- try
- {
- Map<String, Object> arguments = Collections.singletonMap("statistics",
- Collections.singletonList("queueDepthMessages"));
- Object statistics = _managementFacade.performOperationUsingAmqpManagement(escapedName,
- "getStatistics",
- session,
- "org.apache.qpid.Queue",
- arguments);
-
- Map<String, Object> statisticsMap = (Map<String, Object>) statistics;
- return ((Number) statisticsMap.get("queueDepthMessages")).intValue();
- }
- finally
- {
- session.close();
- }
- }
- finally
- {
- connection.close();
- }
- }
-
- @Override
- public boolean isQueueExist(final Queue destination) throws Exception
- {
- final String escapedName = destination.getQueueName().replaceAll("([/\\\\])", "\\\\$1");
- Connection connection = getConnection();
- try
- {
- connection.start();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- try
- {
- _managementFacade.performOperationUsingAmqpManagement(escapedName,
- "READ",
- session,
- "org.apache.qpid.Queue",
- Collections.emptyMap());
- return true;
- }
- catch (AmqpManagementFacade.OperationUnsuccessfulException e)
- {
- if (e.getStatusCode() == 404)
- {
- return false;
- }
- else
- {
- throw e;
- }
- }
- }
- finally
- {
- connection.close();
- }
-
- }
-
- @Override
- public String getBrokerDetailsFromDefaultConnectionUrl()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ConnectionBuilder getConnectionBuilder()
- {
- return new QpidJmsClientConnectionBuilder();
- }
-
- private String getNextClientId()
- {
- return "clientid-" + CLIENTID_COUNTER.getAndIncrement();
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/2] qpid-broker-j git commit: QPID-6933: [System Tests] Move JMS
common test functionality into a separate module
Posted by or...@apache.org.
QPID-6933: [System Tests] Move JMS common test functionality into a separate module
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/49cd2c1d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/49cd2c1d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/49cd2c1d
Branch: refs/heads/master
Commit: 49cd2c1d698b5da11967505f20df1d5a21bf6c33
Parents: 0a7368e
Author: Alex Rudyy <or...@apache.org>
Authored: Tue Nov 28 23:08:27 2017 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Tue Nov 28 23:08:53 2017 +0000
----------------------------------------------------------------------
pom.xml | 19 +
.../systest/disttest/endtoend/EndToEndTest.java | 27 ++
systests/pom.xml | 5 +
systests/qpid-systests-jms-core/pom.xml | 124 ++++++
.../qpid/systests/AmqpManagementFacade.java | 416 +++++++++++++++++++
.../apache/qpid/systests/ConnectionBuilder.java | 52 +++
.../org/apache/qpid/systests/JmsProvider.java | 52 +++
.../org/apache/qpid/systests/JmsTestBase.java | 142 +++++++
.../QpidJmsClient0xConnectionBuilder.java | 251 +++++++++++
.../qpid/systests/QpidJmsClient0xProvider.java | 151 +++++++
.../QpidJmsClientConnectionBuilder.java | 262 ++++++++++++
.../qpid/systests/QpidJmsClientProvider.java | 123 ++++++
.../java/org/apache/qpid/systests/Utils.java | 92 ++++
.../src/main/resources/config-jms-tests.json | 97 +++++
systests/qpid-systests-jms_1.1/pom.xml | 5 +-
.../qpid/systests/jms_1_1/Jms1TestBase.java | 147 -------
.../src/main/resources/config-jms1-tests.json | 98 -----
.../jms_1_1/topic/DurableSubscribtionTest.java | 4 +-
systests/qpid-systests-jms_2.0/pom.xml | 18 +-
.../qpid/systests/jms_2_0/Jms2TestBase.java | 144 -------
.../org/apache/qpid/systests/jms_2_0/Utils.java | 97 -----
.../src/main/resources/config-jms2-tests.json | 98 -----
.../jms_2_0/connection/ConnectionTest.java | 4 +-
.../deliverycount/DeliveryCountTest.java | 7 +-
.../deliverydelay/DeliveryDelayTest.java | 4 +-
.../subscription/SharedSubscriptionTest.java | 6 +-
.../qpid/test/utils/AmqpManagementFacade.java | 363 ----------------
.../qpid/test/utils/ConnectionBuilder.java | 49 ---
.../org/apache/qpid/test/utils/JmsProvider.java | 64 ---
.../qpid/test/utils/QpidBrokerTestCase.java | 104 +++--
.../utils/QpidJmsClient0xConnectionBuilder.java | 243 -----------
.../test/utils/QpidJmsClient0xProvider.java | 257 ------------
.../utils/QpidJmsClientConnectionBuilder.java | 257 ------------
.../qpid/test/utils/QpidJmsClientProvider.java | 283 -------------
34 files changed, 1899 insertions(+), 2166 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b53c5ee..7856f07 100644
--- a/pom.xml
+++ b/pom.xml
@@ -193,6 +193,7 @@
<module>qpid-test-utils</module>
<module>systests</module>
<module>systests/systests-utils</module>
+ <module>systests/qpid-systests-jms-core</module>
<module>systests/qpid-systests-jms_1.1</module>
<module>systests/qpid-systests-jms_2.0</module>
<module>systests/protocol-tests-core</module>
@@ -433,6 +434,24 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-jms-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-jms_1.1</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-jms_2.0</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- External dependencies -->
<dependency>
<groupId>org.apache.qpid</groupId>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/qpid-perftests-systests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java
----------------------------------------------------------------------
diff --git a/qpid-perftests-systests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java b/qpid-perftests-systests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java
index 661fae5..74e5ddd 100644
--- a/qpid-perftests-systests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java
+++ b/qpid-perftests-systests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java
@@ -32,6 +32,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
@@ -371,4 +373,29 @@ public class EndToEndTest extends QpidBrokerTestCase
return new File(JNDI_CONFIG_FILE);
}
}
+
+ private void appendOptions(final Map<String, String> actualOptions, final StringBuilder stem)
+ {
+ boolean first = true;
+ for(Map.Entry<String, String> option : actualOptions.entrySet())
+ {
+ if(first)
+ {
+ stem.append('?');
+ first = false;
+ }
+ else
+ {
+ stem.append('&');
+ }
+ try
+ {
+ stem.append(option.getKey()).append('=').append(URLEncoder.encode(option.getValue(), "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/pom.xml
----------------------------------------------------------------------
diff --git a/systests/pom.xml b/systests/pom.xml
index 985d639..50e729c 100644
--- a/systests/pom.xml
+++ b/systests/pom.xml
@@ -36,6 +36,11 @@
<artifactId>qpid-test-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-jms-core</artifactId>
+ </dependency>
+
<!-- Many systests have a compile/runtime dependency on qpid-client -->
<dependency>
<groupId>org.apache.qpid</groupId>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/pom.xml
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/pom.xml b/systests/qpid-systests-jms-core/pom.xml
new file mode 100644
index 0000000..40456dc
--- /dev/null
+++ b/systests/qpid-systests-jms-core/pom.xml
@@ -0,0 +1,124 @@
+<?xml version="1.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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-parent</artifactId>
+ <version>7.1.0-SNAPSHOT</version>
+ <relativePath>../../qpid-systests-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>qpid-systests-jms-core</artifactId>
+ <name>Apache Qpid Broker-J JMS System Tests Core</name>
+ <description>JMS System Tests Core Classes</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-utils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-amqp-1-0-protocol</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-amqp-0-8-protocol</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-amqp-0-10-protocol</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-websocket</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-derby-store</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-bdbstore</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-amqp-1-0-protocol-jdbc-link-store</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-management-amqp</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <qpid.initialConfigurationLocation>classpath:config-jms-tests.json</qpid.initialConfigurationLocation>
+ <qpid.amqp.version>${profile.broker.version}</qpid.amqp.version>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/AmqpManagementFacade.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/AmqpManagementFacade.java b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/AmqpManagementFacade.java
new file mode 100644
index 0000000..39707eb
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/AmqpManagementFacade.java
@@ -0,0 +1,416 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class AmqpManagementFacade
+{
+ private final String _managementAddress;
+
+ public AmqpManagementFacade(final String managementAddress)
+ {
+ _managementAddress = managementAddress;
+ }
+
+ public void createEntityUsingAmqpManagement(final String name, final Session session, final String type)
+ throws JMSException
+ {
+ createEntityUsingAmqpManagement(name, session, type, Collections.<String, Object>emptyMap());
+ }
+
+ public void createEntityUsingAmqpManagement(final String name,
+ final Session session,
+ final String type,
+ Map<String, Object> attributes)
+ throws JMSException
+ {
+ MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
+
+ MapMessage createMessage = session.createMapMessage();
+ createMessage.setStringProperty("type", type);
+ createMessage.setStringProperty("operation", "CREATE");
+ createMessage.setString("name", name);
+ createMessage.setString("object-path", name);
+ for (Map.Entry<String, Object> entry : attributes.entrySet())
+ {
+ createMessage.setObject(entry.getKey(), entry.getValue());
+ }
+ producer.send(createMessage);
+ if (session.getTransacted())
+ {
+ session.commit();
+ }
+ producer.close();
+ }
+
+ public void updateEntityUsingAmqpManagement(final String name,
+ final Session session,
+ final String type,
+ Map<String, Object> attributes)
+ throws JMSException
+ {
+ MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
+
+ MapMessage createMessage = session.createMapMessage();
+ createMessage.setStringProperty("type", type);
+ createMessage.setStringProperty("operation", "UPDATE");
+ createMessage.setStringProperty("index", "object-path");
+ createMessage.setStringProperty("key", name);
+ for (Map.Entry<String, Object> entry : attributes.entrySet())
+ {
+ createMessage.setObject(entry.getKey(), entry.getValue());
+ }
+ producer.send(createMessage);
+ if (session.getTransacted())
+ {
+ session.commit();
+ }
+ producer.close();
+ }
+
+ public void deleteEntityUsingAmqpManagement(final String name, final Session session, final String type)
+ throws JMSException
+ {
+ MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
+
+ MapMessage createMessage = session.createMapMessage();
+ createMessage.setStringProperty("type", type);
+ createMessage.setStringProperty("operation", "DELETE");
+ createMessage.setStringProperty("index", "object-path");
+
+ createMessage.setStringProperty("key", name);
+ producer.send(createMessage);
+ if (session.getTransacted())
+ {
+ session.commit();
+ }
+ }
+
+ public Object performOperationUsingAmqpManagement(final String name,
+ final String operation,
+ final Session session,
+ final String type,
+ Map<String, Object> arguments)
+ throws JMSException
+ {
+ MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
+ final TemporaryQueue responseQ = session.createTemporaryQueue();
+ MessageConsumer consumer = session.createConsumer(responseQ);
+ MapMessage opMessage = session.createMapMessage();
+ opMessage.setStringProperty("type", type);
+ opMessage.setStringProperty("operation", operation);
+ opMessage.setStringProperty("index", "object-path");
+ opMessage.setJMSReplyTo(responseQ);
+
+ opMessage.setStringProperty("key", name);
+ for (Map.Entry<String, Object> argument : arguments.entrySet())
+ {
+ Object value = argument.getValue();
+ if (value.getClass().isPrimitive() || value instanceof String)
+ {
+ opMessage.setObjectProperty(argument.getKey(), value);
+ }
+ else
+ {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String jsonifiedValue = null;
+ try
+ {
+ jsonifiedValue = objectMapper.writeValueAsString(value);
+ }
+ catch (JsonProcessingException e)
+ {
+ throw new IllegalArgumentException(String.format(
+ "Cannot convert the argument '%s' to JSON to meet JMS type restrictions",
+ argument.getKey()));
+ }
+ opMessage.setObjectProperty(argument.getKey(), jsonifiedValue);
+ }
+ }
+
+ producer.send(opMessage);
+ if (session.getTransacted())
+ {
+ session.commit();
+ }
+
+ Message response = consumer.receive(5000);
+ try
+ {
+ int statusCode = response.getIntProperty("statusCode");
+ if (statusCode < 200 || statusCode > 299)
+ {
+ throw new OperationUnsuccessfulException(statusCode);
+ }
+ if (response instanceof MapMessage)
+ {
+ MapMessage bodyMap = (MapMessage) response;
+ Map<String, Object> result = new TreeMap<>();
+ Enumeration mapNames = bodyMap.getMapNames();
+ while (mapNames.hasMoreElements())
+ {
+ String key = (String) mapNames.nextElement();
+ result.put(key, bodyMap.getObject(key));
+ }
+ return result;
+ }
+ else if (response instanceof ObjectMessage)
+ {
+ return ((ObjectMessage) response).getObject();
+ }
+ else if (response instanceof BytesMessage)
+ {
+ BytesMessage bytesMessage = (BytesMessage) response;
+ if (bytesMessage.getBodyLength() == 0)
+ {
+ return null;
+ }
+ else
+ {
+ byte[] buf = new byte[(int) bytesMessage.getBodyLength()];
+ bytesMessage.readBytes(buf);
+ return buf;
+ }
+ }
+ throw new IllegalArgumentException(
+ "Cannot parse the results from a management operation. JMS response message : " + response);
+ }
+ finally
+ {
+ if (session.getTransacted())
+ {
+ session.commit();
+ }
+ consumer.close();
+ responseQ.delete();
+ }
+ }
+
+ public List<Map<String, Object>> managementQueryObjects(final Session session, final String type)
+ throws JMSException
+ {
+ MessageProducer producer = session.createProducer(session.createQueue("$management"));
+ final TemporaryQueue responseQ = session.createTemporaryQueue();
+ MessageConsumer consumer = session.createConsumer(responseQ);
+ MapMessage message = session.createMapMessage();
+ message.setStringProperty("identity", "self");
+ message.setStringProperty("type", "org.amqp.management");
+ message.setStringProperty("operation", "QUERY");
+ message.setStringProperty("entityType", type);
+ message.setString("attributeNames", "[]");
+ message.setJMSReplyTo(responseQ);
+
+ producer.send(message);
+
+ Message response = consumer.receive(5000);
+ try
+ {
+ if (response instanceof MapMessage)
+ {
+ MapMessage bodyMap = (MapMessage) response;
+ List<String> attributeNames = (List<String>) bodyMap.getObject("attributeNames");
+ List<List<Object>> attributeValues = (List<List<Object>>) bodyMap.getObject("results");
+ return getResultsAsMaps(attributeNames, attributeValues);
+ }
+ else if (response instanceof ObjectMessage)
+ {
+ Object body = ((ObjectMessage) response).getObject();
+ if (body instanceof Map)
+ {
+ Map<String, ?> bodyMap = (Map<String, ?>) body;
+ List<String> attributeNames = (List<String>) bodyMap.get("attributeNames");
+ List<List<Object>> attributeValues = (List<List<Object>>) bodyMap.get("results");
+ return getResultsAsMaps(attributeNames, attributeValues);
+ }
+ }
+ throw new IllegalArgumentException("Cannot parse the results from a management query");
+ }
+ finally
+ {
+ consumer.close();
+ responseQ.delete();
+ }
+ }
+
+ public Map<String, Object> readEntityUsingAmqpManagement(final Session session,
+ final String type,
+ final String name,
+ final boolean actuals) throws JMSException
+ {
+ MessageProducer producer = session.createProducer(session.createQueue(_managementAddress));
+
+ final TemporaryQueue responseQueue = session.createTemporaryQueue();
+ MessageConsumer consumer = session.createConsumer(responseQueue);
+
+ MapMessage request = session.createMapMessage();
+ request.setStringProperty("type", type);
+ request.setStringProperty("operation", "READ");
+ request.setString("name", name);
+ request.setString("object-path", name);
+ request.setStringProperty("index", "object-path");
+ request.setStringProperty("key", name);
+ request.setBooleanProperty("actuals", actuals);
+ request.setJMSReplyTo(responseQueue);
+
+ producer.send(request);
+ if (session.getTransacted())
+ {
+ session.commit();
+ }
+
+ Message response = consumer.receive(5000);
+ if (session.getTransacted())
+ {
+ session.commit();
+ }
+ try
+ {
+ if (response instanceof MapMessage)
+ {
+ MapMessage bodyMap = (MapMessage) response;
+ Map<String, Object> data = new HashMap<>();
+ Enumeration<String> keys = bodyMap.getMapNames();
+ while (keys.hasMoreElements())
+ {
+ String key = keys.nextElement();
+ data.put(key, bodyMap.getObject(key));
+ }
+ return data;
+ }
+ else if (response instanceof ObjectMessage)
+ {
+ Object body = ((ObjectMessage) response).getObject();
+ if (body instanceof Map)
+ {
+ Map<String, ?> bodyMap = (Map<String, ?>) body;
+ return new HashMap<>(bodyMap);
+ }
+ }
+ throw new IllegalArgumentException("Management read failed : "
+ + response.getStringProperty("statusCode")
+ + " - "
+ + response.getStringProperty("statusDescription"));
+ }
+ finally
+ {
+ consumer.close();
+ responseQueue.delete();
+ }
+ }
+
+ public long getQueueDepth(final Queue destination, final Session session) throws Exception
+ {
+ final String escapedName = getEscapedName(destination);
+ Map<String, Object> arguments = Collections.singletonMap("statistics",
+ Collections.singletonList("queueDepthMessages"));
+ Object statistics = performOperationUsingAmqpManagement(escapedName,
+ "getStatistics",
+ session,
+ "org.apache.qpid.Queue",
+ arguments);
+
+ Map<String, Object> statisticsMap = (Map<String, Object>) statistics;
+ return ((Number) statisticsMap.get("queueDepthMessages")).intValue();
+ }
+
+ public boolean isQueueExist(final Queue destination, final Session session) throws Exception
+ {
+ final String escapedName = getEscapedName(destination);
+ try
+ {
+ performOperationUsingAmqpManagement(escapedName,
+ "READ",
+ session,
+ "org.apache.qpid.Queue",
+ Collections.emptyMap());
+ return true;
+ }
+ catch (AmqpManagementFacade.OperationUnsuccessfulException e)
+ {
+ if (e.getStatusCode() == 404)
+ {
+ return false;
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+
+ private String getEscapedName(final Queue destination) throws JMSException
+ {
+ return destination.getQueueName().replaceAll("([/\\\\])", "\\\\$1");
+ }
+
+ private List<Map<String, Object>> getResultsAsMaps(final List<String> attributeNames,
+ final List<List<Object>> attributeValues)
+ {
+ List<Map<String, Object>> results = new ArrayList<>();
+ for (List<Object> resultObject : attributeValues)
+ {
+ Map<String, Object> result = new HashMap<>();
+ for (int i = 0; i < attributeNames.size(); ++i)
+ {
+ result.put(attributeNames.get(i), resultObject.get(i));
+ }
+ results.add(result);
+ }
+ return results;
+ }
+
+ public static class OperationUnsuccessfulException extends RuntimeException
+ {
+ private final int _statusCode;
+
+ private OperationUnsuccessfulException(final int statusCode)
+ {
+ super();
+ _statusCode = statusCode;
+ }
+
+ public int getStatusCode()
+ {
+ return _statusCode;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/ConnectionBuilder.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/ConnectionBuilder.java b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/ConnectionBuilder.java
new file mode 100644
index 0000000..6e385b0
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/ConnectionBuilder.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.systests;
+
+import java.util.Map;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.naming.NamingException;
+
+public interface ConnectionBuilder
+{
+ String USERNAME = "guest";
+ String PASSWORD = "guest";
+
+ ConnectionBuilder setHost(String host);
+ ConnectionBuilder setPort(int port);
+ ConnectionBuilder setSslPort(int port);
+ ConnectionBuilder setPrefetch(int prefetch);
+ ConnectionBuilder setClientId(String clientId);
+ ConnectionBuilder setUsername(String username);
+ ConnectionBuilder setPassword(String password);
+ ConnectionBuilder setVirtualHost(String virtualHostName);
+ ConnectionBuilder setFailover(boolean enableFailover);
+ ConnectionBuilder setFailoverReconnectAttempts(int reconnectAttempts);
+ ConnectionBuilder setTls(boolean enableTls);
+ ConnectionBuilder setSyncPublish(boolean syncPublish);
+ ConnectionBuilder setOptions(Map<String, String> options);
+ ConnectionBuilder setPopulateJMSXUserID(boolean populateJMSXUserID);
+
+ Connection build() throws NamingException, JMSException;
+ ConnectionFactory buildConnectionFactory() throws NamingException;
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/JmsProvider.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/JmsProvider.java b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/JmsProvider.java
new file mode 100644
index 0000000..6686b2a
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/JmsProvider.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.systests;
+
+import java.net.URISyntaxException;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.naming.NamingException;
+
+
+public interface JmsProvider
+{
+ Connection getConnection(String urlString) throws Exception;
+
+ Queue getTestQueue(String testQueueName) throws NamingException;
+
+ Queue getQueueFromName(Session session, String name) throws JMSException;
+
+ Queue createTestQueue(Session session, String queueName) throws JMSException;
+
+ Topic getTestTopic(String testQueueName) throws NamingException;
+
+ Topic createTopic(Connection con, String topicName) throws JMSException;
+
+ Topic createTopicOnDirect(Connection con, String topicName) throws JMSException, URISyntaxException;
+
+ Topic createTopicOnFanout(Connection con, String topicName) throws JMSException, URISyntaxException;
+
+ ConnectionBuilder getConnectionBuilder();
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/JmsTestBase.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/JmsTestBase.java b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/JmsTestBase.java
new file mode 100644
index 0000000..ca3be01
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/JmsTestBase.java
@@ -0,0 +1,142 @@
+/*
+ *
+ * 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;
+
+import java.net.InetSocketAddress;
+import java.util.Map;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.naming.NamingException;
+
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+import org.apache.qpid.tests.utils.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
+
+public abstract class JmsTestBase extends BrokerAdminUsingTestBase
+{
+ private static JmsProvider _jmsProvider;
+ private static AmqpManagementFacade _managementFacade;
+
+ @Rule
+ public final TestName _testName = new TestName();
+
+ @BeforeClass
+ public static void setUpTestBase()
+ {
+ if ("1.0".equals(System.getProperty("broker.version", "1.0")))
+ {
+ _managementFacade = new AmqpManagementFacade("$management");
+ _jmsProvider = new QpidJmsClientProvider(_managementFacade);
+ }
+ else
+ {
+ _managementFacade = new AmqpManagementFacade("ADDR:$management");
+ _jmsProvider = new QpidJmsClient0xProvider();
+ }
+ }
+
+ protected ConnectionBuilder getConnectionBuilder()
+ {
+ InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
+ return _jmsProvider.getConnectionBuilder()
+ .setHost(brokerAddress.getHostName())
+ .setPort(brokerAddress.getPort())
+ .setUsername(getBrokerAdmin().getValidUsername())
+ .setPassword(getBrokerAdmin().getValidPassword())
+ ;
+ }
+
+ protected void createEntityUsingAmqpManagement(final String entityName,
+ final String entityType,
+ final Map<String, Object> attributes)
+ throws Exception
+ {
+ Connection connection = getConnection();
+ try
+ {
+ connection.start();
+ Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ _managementFacade.createEntityUsingAmqpManagement(entityName, session, entityType, attributes);
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+
+ protected Object performOperationUsingAmqpManagement(final String name,
+ final String operation,
+ final String type,
+ Map<String, Object> arguments)
+ throws Exception
+ {
+ Connection connection = getConnection();
+ try
+ {
+ connection.start();
+ Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ return _managementFacade.performOperationUsingAmqpManagement(name, operation, session, type, arguments);
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+
+ protected Connection getConnection() throws JMSException, NamingException
+ {
+ return getConnectionBuilder().build();
+ }
+
+ protected long getReceiveTimeout()
+ {
+ return Long.getLong("qpid.test_receive_timeout", 1000L);
+ }
+
+ protected String getVirtualHostName()
+ {
+ return getClass().getSimpleName() + "_" + _testName.getMethodName();
+ }
+
+ protected String getTestName()
+ {
+ return _testName.getMethodName();
+ }
+
+ protected Topic createTopic(final String topicName) throws Exception
+ {
+ Connection connection = getConnection();
+ try
+ {
+ return _jmsProvider.createTopic(connection, topicName);
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClient0xConnectionBuilder.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClient0xConnectionBuilder.java b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClient0xConnectionBuilder.java
new file mode 100644
index 0000000..b5902eb
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClient0xConnectionBuilder.java
@@ -0,0 +1,251 @@
+/*
+ * 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;
+
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class QpidJmsClient0xConnectionBuilder implements ConnectionBuilder
+{
+ private String _clientId = "clientid";
+ private String _username = USERNAME;
+ private String _password = PASSWORD;
+ private String _virtualHost;
+ private boolean _enableTls;
+ private boolean _enableFailover;
+ private final Map<String, Object> _options = new TreeMap<>();
+ private int _reconnectAttempts = 20;
+ private String _host = "localhost";
+ private int _port;
+ private int _sslPort;
+
+ @Override
+ public ConnectionBuilder setHost(final String host)
+ {
+ _host = host;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setPort(final int port)
+ {
+ _port = port;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setSslPort(final int port)
+ {
+ _sslPort = port;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setPrefetch(final int prefetch)
+ {
+ _options.put("maxprefetch", prefetch);
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setClientId(final String clientId)
+ {
+ _clientId = clientId;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setUsername(final String username)
+ {
+ _username = username;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setPassword(final String password)
+ {
+ _password = password;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setVirtualHost(final String virtualHostName)
+ {
+ _virtualHost = virtualHostName;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setFailover(final boolean enableFailover)
+ {
+ _enableFailover = enableFailover;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setFailoverReconnectAttempts(final int reconnectAttempts)
+ {
+ _reconnectAttempts = reconnectAttempts;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setTls(final boolean enableTls)
+ {
+ _enableTls = enableTls;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setSyncPublish(final boolean syncPublish)
+ {
+ if (syncPublish)
+ {
+ _options.put("sync_publish", "all");
+ }
+ else
+ {
+ _options.remove("sync_publish");
+ }
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setOptions(final Map<String, String> options)
+ {
+ _options.putAll(options);
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setPopulateJMSXUserID(final boolean populateJMSXUserID)
+ {
+ _options.put("populateJMSXUserID", String.valueOf(populateJMSXUserID));
+ return this;
+ }
+
+ @Override
+ public Connection build() throws JMSException, NamingException
+ {
+ return buildConnectionFactory().createConnection(_username, _password);
+ }
+
+ @Override
+ public ConnectionFactory buildConnectionFactory() throws NamingException
+ {
+ StringBuilder cUrlBuilder = new StringBuilder("amqp://");
+ if (_username != null)
+ {
+ cUrlBuilder.append(_username);
+ }
+
+ if (_username != null || _password != null)
+ {
+ cUrlBuilder.append(":");
+ }
+
+ if (_password != null)
+ {
+ cUrlBuilder.append(_password);
+ }
+
+ if (_username != null || _password != null)
+ {
+ cUrlBuilder.append("@");
+ }
+
+ if (_clientId != null)
+ {
+ cUrlBuilder.append(_clientId);
+ }
+
+ cUrlBuilder.append("/");
+
+ if (_virtualHost != null)
+ {
+ cUrlBuilder.append(_virtualHost);
+ }
+
+ cUrlBuilder.append("?brokerlist='tcp://").append(_host).append(":");
+ if (_enableTls)
+ {
+ cUrlBuilder.append(_sslPort).append("?ssl='true'");
+ }
+ else
+ {
+ cUrlBuilder.append(_port);
+ }
+
+ if (_enableFailover)
+ {
+ cUrlBuilder.append(";tcp://").append(_host).append(":");
+ if (_enableTls)
+ {
+ cUrlBuilder.append(System.getProperty("test.port.alt.ssl")).append("?ssl='true'");
+ }
+ else
+ {
+ cUrlBuilder.append(System.getProperty("test.port.alt"));
+ }
+ cUrlBuilder.append("'")
+ .append("&sync_ack='true'&sync_publish='all'&failover='roundrobin?cyclecount='")
+ .append(_reconnectAttempts)
+ .append("''");
+ }
+ else
+ {
+ cUrlBuilder.append("'");
+ }
+
+ for (Map.Entry<String, Object> entry : _options.entrySet())
+ {
+ cUrlBuilder.append("&").append(entry.getKey()).append("='").append(entry.getValue()).append("'");
+ }
+
+ final Hashtable<Object, Object> initialContextEnvironment = new Hashtable<>();
+ initialContextEnvironment.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
+ final String factoryName = "connectionFactory";
+ initialContextEnvironment.put("connectionfactory." + factoryName, cUrlBuilder.toString());
+ InitialContext initialContext = new InitialContext(initialContextEnvironment);
+ try
+ {
+ return (ConnectionFactory) initialContext.lookup(factoryName);
+ }
+ finally
+ {
+ initialContext.close();
+ }
+ }
+
+ String getBrokerDetails()
+ {
+ return "tcp://" + _host + ":" + _port;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClient0xProvider.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClient0xProvider.java b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClient0xProvider.java
new file mode 100644
index 0000000..82549c0
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClient0xProvider.java
@@ -0,0 +1,151 @@
+/*
+ * 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;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URISyntaxException;
+import java.security.AccessControlException;
+import java.util.Hashtable;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+
+public class QpidJmsClient0xProvider implements JmsProvider
+{
+
+ public QpidJmsClient0xProvider()
+ {
+ }
+
+ @Override
+ public Connection getConnection(String urlString) throws Exception
+ {
+ final Hashtable<Object, Object> initialContextEnvironment = new Hashtable<>();
+ initialContextEnvironment.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
+ final String factoryName = "connectionFactory";
+ initialContextEnvironment.put("connectionfactory." + factoryName, urlString);
+ ConnectionFactory connectionFactory =
+ (ConnectionFactory) new InitialContext(initialContextEnvironment).lookup(factoryName);
+ return connectionFactory.createConnection();
+ }
+
+
+ @Override
+ public Queue getTestQueue(final String testQueueName) throws NamingException
+ {
+ return createReflectively("org.apache.qpid.client.AMQQueue", "amq.direct", testQueueName);
+ }
+
+ @Override
+ public Queue getQueueFromName(Session session, String name) throws JMSException
+ {
+ return createReflectively("org.apache.qpid.client.AMQQueue", "", name);
+ }
+
+ @Override
+ public Queue createTestQueue(Session session, String queueName) throws JMSException
+ {
+
+ Queue amqQueue = null;
+ try
+ {
+ amqQueue = getTestQueue(queueName);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ session.createConsumer(amqQueue).close();
+ return amqQueue;
+ }
+
+ @Override
+ public Topic getTestTopic(final String testQueueName)
+ {
+ return createReflectively("org.apache.qpid.client.AMQTopic", "amq.topic", testQueueName);
+ }
+
+ @Override
+ public Topic createTopic(final Connection con, final String topicName) throws JMSException
+ {
+ return getTestTopic(topicName);
+ }
+
+ @Override
+ public Topic createTopicOnDirect(final Connection con, String topicName) throws JMSException, URISyntaxException
+ {
+ return createReflectively("org.apache.qpid.client.AMQTopic",
+ "direct://amq.direct/"
+ + topicName
+ + "/"
+ + topicName
+ + "?routingkey='"
+ + topicName
+ + "',exclusive='true',autodelete='true'");
+ }
+
+ private <T> T createReflectively(String className, Object ...args)
+ {
+ try
+ {
+ Class<?> topicClass = Class.forName(className);
+ Class[] classes = new Class[args.length];
+ for (int i = 0; i < args.length; ++i)
+ {
+ classes[i] = args[i].getClass();
+ }
+ Constructor<?> constructor = topicClass.getConstructor(classes);
+ return (T) constructor.newInstance(args);
+ }
+ catch (IllegalAccessException | AccessControlException | InvocationTargetException | InstantiationException | NoSuchMethodException | ClassNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ @Override
+ public Topic createTopicOnFanout(final Connection con, String topicName) throws JMSException, URISyntaxException
+ {
+ return createReflectively("org.apache.qpid.client.AMQTopic", "fanout://amq.fanout/"
+ + topicName
+ + "/"
+ + topicName
+ + "?routingkey='"
+ + topicName
+ + "',exclusive='true',autodelete='true'");
+ }
+
+ @Override
+ public QpidJmsClient0xConnectionBuilder getConnectionBuilder()
+ {
+ return new QpidJmsClient0xConnectionBuilder();
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClientConnectionBuilder.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClientConnectionBuilder.java b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClientConnectionBuilder.java
new file mode 100644
index 0000000..1917937
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClientConnectionBuilder.java
@@ -0,0 +1,262 @@
+/*
+ * 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;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class QpidJmsClientConnectionBuilder implements ConnectionBuilder
+{
+ private static final AtomicInteger CLIENTID_COUNTER = new AtomicInteger();
+ private String _host;
+ private int _port;
+ private int _sslPort;
+ private Map<String, Object> _options;
+ private boolean _enableTls;
+ private boolean _enableFailover;
+
+ QpidJmsClientConnectionBuilder()
+ {
+ _options = new TreeMap<>();
+ _options.put("jms.clientID", getNextClientId());
+ _options.put("jms.username", USERNAME);
+ _options.put("jms.password", PASSWORD);
+ _host = "localhost";
+ }
+
+ @Override
+ public ConnectionBuilder setHost(final String host)
+ {
+ _host = host;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setPort(final int port)
+ {
+ _port = port;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setSslPort(final int port)
+ {
+ _sslPort = port;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setPrefetch(final int prefetch)
+ {
+ _options.put("jms.prefetchPolicy.all", prefetch);
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setClientId(final String clientId)
+ {
+ if (clientId == null)
+ {
+ _options.remove("jms.clientID");
+ }
+ else
+ {
+ _options.put("jms.clientID", clientId);
+ }
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setUsername(final String username)
+ {
+ if (username == null)
+ {
+ _options.remove("jms.username");
+ }
+ else
+ {
+ _options.put("jms.username", username);
+ }
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setPassword(final String password)
+ {
+ if (password == null)
+ {
+ _options.remove("jms.password");
+ }
+ else
+ {
+ _options.put("jms.password", password);
+ }
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setVirtualHost(final String virtualHostName)
+ {
+ _options.put("amqp.vhost", virtualHostName);
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setFailover(final boolean enableFailover)
+ {
+ _enableFailover = enableFailover;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setFailoverReconnectAttempts(final int reconnectAttempts)
+ {
+ _options.put("failover.maxReconnectAttempts", reconnectAttempts);
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setTls(final boolean enableTls)
+ {
+ _enableTls = enableTls;
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setSyncPublish(final boolean syncPublish)
+ {
+ _options.put("jms.forceSyncSend", syncPublish);
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setOptions(final Map<String, String> options)
+ {
+ _options.putAll(options);
+ return this;
+ }
+
+ @Override
+ public ConnectionBuilder setPopulateJMSXUserID(final boolean populateJMSXUserID)
+ {
+ _options.put("jms.populateJMSXUserID", String.valueOf(populateJMSXUserID));
+ return this;
+ }
+
+ @Override
+ public Connection build() throws NamingException, JMSException
+ {
+ return buildConnectionFactory().createConnection();
+ }
+
+ @Override
+ public ConnectionFactory buildConnectionFactory() throws NamingException
+ {
+ final Hashtable<Object, Object> initialContextEnvironment = new Hashtable<>();
+ initialContextEnvironment.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
+
+ final StringBuilder connectionUrlBuilder = new StringBuilder();
+
+ final Map<String, Object> options = new TreeMap<>();
+ options.putAll(_options);
+ if (_enableFailover)
+ {
+ if (!options.containsKey("failover.maxReconnectAttempts"))
+ {
+ options.put("failover.maxReconnectAttempts", "2");
+ }
+ connectionUrlBuilder.append("failover:(amqp://")
+ .append(_host)
+ .append(":")
+ .append(_port)
+ .append(",amqp://localhost:")
+ .append(System.getProperty("test.port.alt"))
+ .append(")");
+ appendOptions(options, connectionUrlBuilder);
+ }
+ else if (!_enableTls)
+ {
+ connectionUrlBuilder.append("amqp://").append(_host).append(":").append(_port);
+
+ appendOptions(options, connectionUrlBuilder);
+ }
+ else
+ {
+ connectionUrlBuilder.append("amqps://").append(_host).append(":").append(_sslPort);
+ appendOptions(options, connectionUrlBuilder);
+ }
+
+ final String factoryName = "connection";
+ initialContextEnvironment.put("connectionfactory." + factoryName, connectionUrlBuilder.toString());
+
+ InitialContext initialContext = new InitialContext(initialContextEnvironment);
+ try
+ {
+ return (ConnectionFactory) initialContext.lookup(factoryName);
+ }
+ finally
+ {
+ initialContext.close();
+ }
+ }
+
+ private void appendOptions(final Map<String, Object> actualOptions, final StringBuilder stem)
+ {
+ boolean first = true;
+ for(Map.Entry<String, Object> option : actualOptions.entrySet())
+ {
+ if(first)
+ {
+ stem.append('?');
+ first = false;
+ }
+ else
+ {
+ stem.append('&');
+ }
+ try
+ {
+ stem.append(option.getKey()).append('=').append(URLEncoder.encode(String.valueOf(option.getValue()), "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private String getNextClientId()
+ {
+ return "builderClientId-" + CLIENTID_COUNTER.getAndIncrement();
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClientProvider.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClientProvider.java b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClientProvider.java
new file mode 100644
index 0000000..9a22204
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/QpidJmsClientProvider.java
@@ -0,0 +1,123 @@
+/*
+ * 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;
+
+import java.net.URISyntaxException;
+import java.util.Properties;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class QpidJmsClientProvider implements JmsProvider
+{
+ private final AmqpManagementFacade _managementFacade;
+
+ public QpidJmsClientProvider(AmqpManagementFacade managementFacade)
+ {
+ _managementFacade = managementFacade;
+ }
+
+ @Override
+ public Connection getConnection(String urlString) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Queue getTestQueue(final String testQueueName) throws NamingException
+ {
+ return (Queue) getDestination("queue", testQueueName);
+ }
+
+ @Override
+ public Queue getQueueFromName(Session session, String name) throws JMSException
+ {
+ return session.createQueue(name);
+ }
+
+ @Override
+ public Queue createTestQueue(Session session, String queueName) throws JMSException
+ {
+ _managementFacade.createEntityUsingAmqpManagement(queueName, session, "org.apache.qpid.Queue");
+
+ return session.createQueue(queueName);
+ }
+
+ @Override
+ public Topic getTestTopic(final String testTopicName) throws NamingException
+ {
+ return (Topic) getDestination("topic", testTopicName);
+ }
+
+ @Override
+ public Topic createTopic(final Connection con, final String topicName) throws JMSException
+ {
+ Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ _managementFacade.createEntityUsingAmqpManagement(topicName, session, "org.apache.qpid.TopicExchange");
+
+ return session.createTopic(topicName);
+ }
+
+ @Override
+ public Topic createTopicOnDirect(final Connection con, String topicName) throws JMSException, URISyntaxException
+ {
+ Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ return session.createTopic("amq.direct/" + topicName);
+ }
+
+ @Override
+ public Topic createTopicOnFanout(final Connection con, String topicName) throws JMSException, URISyntaxException
+ {
+ Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ return session.createTopic("amq.fanout/" + topicName);
+ }
+
+ @Override
+ public ConnectionBuilder getConnectionBuilder()
+ {
+ return new QpidJmsClientConnectionBuilder();
+ }
+
+ private Destination getDestination(String type, String name) throws NamingException
+ {
+ final String jndiName = "test";
+ final Properties initialContextProperties = new Properties();
+ initialContextProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
+ initialContextProperties.put(type + "." + jndiName, name);
+
+ InitialContext initialContext = new InitialContext(initialContextProperties);
+ try
+ {
+ return (Destination) initialContext.lookup(jndiName);
+ }
+ finally
+ {
+ initialContext.close();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/Utils.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/Utils.java b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/Utils.java
new file mode 100644
index 0000000..dc975d6
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/java/org/apache/qpid/systests/Utils.java
@@ -0,0 +1,92 @@
+/*
+ *
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+public class Utils
+{
+ private static final int DEFAULT_MESSAGE_SIZE = 1024;
+ public static final String INDEX = "index";
+ private static final String DEFAULT_MESSAGE_PAYLOAD = createString(DEFAULT_MESSAGE_SIZE);
+
+ public static List<Message> sendMessage(Session session, Destination destination, int count) throws Exception
+ {
+ List<Message> messages = new ArrayList<>(count);
+ MessageProducer producer = session.createProducer(destination);
+
+ for (int i = 0; i < (count); i++)
+ {
+ Message next = createNextMessage(session, i);
+ producer.send(next);
+ messages.add(next);
+ }
+
+ if (session.getTransacted())
+ {
+ session.commit();
+ }
+
+ return messages;
+ }
+
+ public static Message createNextMessage(Session session, int msgCount) throws JMSException
+ {
+ Message message = createMessage(session, DEFAULT_MESSAGE_SIZE);
+ message.setIntProperty(INDEX, msgCount);
+
+ return message;
+ }
+
+ public static Message createMessage(Session session, int messageSize) throws JMSException
+ {
+ String payload;
+ if (messageSize == DEFAULT_MESSAGE_SIZE)
+ {
+ payload = DEFAULT_MESSAGE_PAYLOAD;
+ }
+ else
+ {
+ payload = createString(messageSize);
+ }
+
+ return session.createTextMessage(payload);
+ }
+
+ private static String createString(final int stringSize)
+ {
+ final String payload;
+ StringBuilder stringBuilder = new StringBuilder();
+ for (int i = 0; i < stringSize; ++i)
+ {
+ stringBuilder.append("x");
+ }
+ payload = stringBuilder.toString();
+ return payload;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms-core/src/main/resources/config-jms-tests.json
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms-core/src/main/resources/config-jms-tests.json b/systests/qpid-systests-jms-core/src/main/resources/config-jms-tests.json
new file mode 100644
index 0000000..7fc0416
--- /dev/null
+++ b/systests/qpid-systests-jms-core/src/main/resources/config-jms-tests.json
@@ -0,0 +1,97 @@
+/*
+ *
+ * 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.
+ *
+ */
+{
+ "name" : "${broker.name}",
+ "modelVersion" : "7.0",
+ "authenticationproviders" : [ {
+ "name" : "anon",
+ "type" : "Anonymous"
+ }, {
+ "name" : "plain",
+ "type" : "Plain",
+ "secureOnlyMechanisms" : [],
+ "users" : [ {
+ "name" : "admin",
+ "type" : "managed",
+ "password" : "admin"
+ }, {
+ "name" : "guest",
+ "type" : "managed",
+ "password" : "guest"
+ } ]
+ } ],
+ "ports" : [ {
+ "name" : "AMQP",
+ "type" : "AMQP",
+ "authenticationProvider" : "plain",
+ "port" : "0",
+ "virtualhostaliases" : [ {
+ "name" : "defaultAlias",
+ "type" : "defaultAlias"
+ }, {
+ "name" : "hostnameAlias",
+ "type" : "hostnameAlias"
+ }, {
+ "name" : "nameAlias",
+ "type" : "nameAlias"
+ } ]
+ }, {
+ "name" : "ANONYMOUS_AMQP",
+ "type" : "AMQP",
+ "authenticationProvider" : "anon",
+ "port" : "0",
+ "protocols" : [ "AMQP_0_8", "AMQP_0_9", "AMQP_0_9_1", "AMQP_0_10", "AMQP_1_0" ],
+ "virtualhostaliases" : [ {
+ "name" : "defaultAlias",
+ "type" : "defaultAlias",
+ "durable" : true
+ }, {
+ "name" : "hostnameAlias",
+ "type" : "hostnameAlias",
+ "durable" : true
+ }, {
+ "name" : "nameAlias",
+ "type" : "nameAlias",
+ "durable" : true
+ } ]
+ }, {
+ "name" : "ANONYMOUS_AMQPWS",
+ "type" : "AMQP",
+ "authenticationProvider" : "anon",
+ "port" : "0",
+ "transports" : ["WS"],
+ "protocols" : [ "AMQP_1_0" ],
+ "virtualhostaliases" : [ {
+ "name" : "defaultAlias",
+ "type" : "defaultAlias",
+ "durable" : true
+ }, {
+ "name" : "hostnameAlias",
+ "type" : "hostnameAlias",
+ "durable" : true
+ }, {
+ "name" : "nameAlias",
+ "type" : "nameAlias",
+ "durable" : true
+ } ]
+ } ],
+ "virtualhostnodes" : []
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_1.1/pom.xml
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/pom.xml b/systests/qpid-systests-jms_1.1/pom.xml
index a4b455d..6dbb47f 100644
--- a/systests/qpid-systests-jms_1.1/pom.xml
+++ b/systests/qpid-systests-jms_1.1/pom.xml
@@ -29,9 +29,10 @@
<description>JMS 1.1 system tests</description>
<dependencies>
+
<dependency>
<groupId>org.apache.qpid</groupId>
- <artifactId>qpid-systests</artifactId>
+ <artifactId>qpid-systests-jms-core</artifactId>
</dependency>
<dependency>
@@ -106,7 +107,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
- <qpid.initialConfigurationLocation>classpath:config-jms1-tests.json</qpid.initialConfigurationLocation>
+ <qpid.initialConfigurationLocation>classpath:config-jms-tests.json</qpid.initialConfigurationLocation>
<qpid.amqp.version>${profile.broker.version}</qpid.amqp.version>
</systemPropertyVariables>
</configuration>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_1.1/src/main/java/org/apache/qpid/systests/jms_1_1/Jms1TestBase.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/src/main/java/org/apache/qpid/systests/jms_1_1/Jms1TestBase.java b/systests/qpid-systests-jms_1.1/src/main/java/org/apache/qpid/systests/jms_1_1/Jms1TestBase.java
deleted file mode 100644
index a19bc08..0000000
--- a/systests/qpid-systests-jms_1.1/src/main/java/org/apache/qpid/systests/jms_1_1/Jms1TestBase.java
+++ /dev/null
@@ -1,147 +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.systests.jms_1_1;
-
-import java.net.InetSocketAddress;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.NamingException;
-
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-
-import org.apache.qpid.test.utils.AmqpManagementFacade;
-import org.apache.qpid.test.utils.ConnectionBuilder;
-import org.apache.qpid.test.utils.JmsProvider;
-import org.apache.qpid.test.utils.QpidJmsClient0xProvider;
-import org.apache.qpid.test.utils.QpidJmsClientProvider;
-import org.apache.qpid.tests.utils.BrokerAdmin;
-import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
-
-public abstract class Jms1TestBase extends BrokerAdminUsingTestBase
-{
- private static JmsProvider _jmsProvider;
- private static AmqpManagementFacade _managementFacade;
-
- @Rule
- public final TestName _testName = new TestName();
-
- @BeforeClass
- public static void setUpTestBase()
- {
- if ("1.0".equals(System.getProperty("broker.version", "1.0")))
- {
- _managementFacade = new AmqpManagementFacade("$management");
- _jmsProvider = new QpidJmsClientProvider(_managementFacade);
- }
- else
- {
- _managementFacade = new AmqpManagementFacade("ADDR:$management");
- _jmsProvider = new QpidJmsClient0xProvider(_managementFacade);
- }
- }
-
- protected ConnectionBuilder getConnectionBuilder()
- {
- InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
- return _jmsProvider.getConnectionBuilder()
- .setHost(brokerAddress.getHostName())
- .setPort(brokerAddress.getPort())
- .setUsername(getBrokerAdmin().getValidUsername())
- .setPassword(getBrokerAdmin().getValidPassword())
- ;
- }
-
- protected void createEntityUsingAmqpManagement(final String entityName,
- final String entityType,
- final Map<String, Object> attributes)
- throws Exception
- {
- Connection connection = getConnection();
- try
- {
- connection.start();
- Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- _managementFacade.createEntityUsingAmqpManagement(entityName, session, entityType, attributes);
- }
- finally
- {
- connection.close();
- }
- }
-
- protected Object performOperationUsingAmqpManagement(final String name,
- final String operation,
- final String type,
- Map<String, Object> arguments)
- throws Exception
- {
- Connection connection = getConnection();
- try
- {
- connection.start();
- Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- return _managementFacade.performOperationUsingAmqpManagement(name, operation, session, type, arguments);
- }
- finally
- {
- connection.close();
- }
- }
-
- protected Connection getConnection() throws JMSException, NamingException
- {
- return getConnectionBuilder().build();
- }
-
- protected long getReceiveTimeout()
- {
- return Long.getLong("qpid.test_receive_timeout", 1000L);
- }
-
- protected String getVirtualHostName()
- {
- return getClass().getSimpleName() + "_" + _testName.getMethodName();
- }
-
- protected String getTestName()
- {
- return _testName.getMethodName();
- }
-
- protected Topic createTopic(final String topicName) throws Exception
- {
- Connection connection = getConnection();
- try
- {
- return _jmsProvider.createTopic(connection, topicName);
- }
- finally
- {
- connection.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_1.1/src/main/resources/config-jms1-tests.json
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/src/main/resources/config-jms1-tests.json b/systests/qpid-systests-jms_1.1/src/main/resources/config-jms1-tests.json
deleted file mode 100644
index a578f3b..0000000
--- a/systests/qpid-systests-jms_1.1/src/main/resources/config-jms1-tests.json
+++ /dev/null
@@ -1,98 +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.
- *
- */
-{
- "name" : "${broker.name}",
- "modelVersion" : "7.0",
- "authenticationproviders" : [ {
- "name" : "anon",
- "type" : "Anonymous"
- }, {
- "name" : "plain",
- "type" : "Plain",
- "secureOnlyMechanisms" : [],
- "users" : [ {
- "name" : "admin",
- "type" : "managed",
- "password" : "admin"
- }, {
- "name" : "guest",
- "type" : "managed",
- "password" : "guest"
- } ]
- } ],
- "ports" : [ {
- "name" : "AMQP",
- "type" : "AMQP",
- "authenticationProvider" : "plain",
- "port" : "0",
- "protocols" : [ "AMQP_0_8", "AMQP_0_9", "AMQP_0_9_1", "AMQP_0_10", "AMQP_1_0" ],
- "virtualhostaliases" : [ {
- "name" : "defaultAlias",
- "type" : "defaultAlias"
- }, {
- "name" : "hostnameAlias",
- "type" : "hostnameAlias"
- }, {
- "name" : "nameAlias",
- "type" : "nameAlias"
- } ]
- }, {
- "name" : "ANONYMOUS_AMQP",
- "type" : "AMQP",
- "authenticationProvider" : "anon",
- "port" : "0",
- "protocols" : [ "AMQP_0_8", "AMQP_0_9", "AMQP_0_9_1", "AMQP_0_10", "AMQP_1_0" ],
- "virtualhostaliases" : [ {
- "name" : "defaultAlias",
- "type" : "defaultAlias",
- "durable" : true
- }, {
- "name" : "hostnameAlias",
- "type" : "hostnameAlias",
- "durable" : true
- }, {
- "name" : "nameAlias",
- "type" : "nameAlias",
- "durable" : true
- } ]
- }, {
- "name" : "ANONYMOUS_AMQPWS",
- "type" : "AMQP",
- "authenticationProvider" : "anon",
- "port" : "0",
- "transports" : ["WS"],
- "protocols" : [ "AMQP_1_0" ],
- "virtualhostaliases" : [ {
- "name" : "defaultAlias",
- "type" : "defaultAlias",
- "durable" : true
- }, {
- "name" : "hostnameAlias",
- "type" : "hostnameAlias",
- "durable" : true
- }, {
- "name" : "nameAlias",
- "type" : "nameAlias",
- "durable" : true
- } ]
- } ],
- "virtualhostnodes" : []
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/DurableSubscribtionTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/DurableSubscribtionTest.java b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/DurableSubscribtionTest.java
index c71b118..f96662b 100644
--- a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/DurableSubscribtionTest.java
+++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/DurableSubscribtionTest.java
@@ -45,9 +45,9 @@ import javax.jms.TopicSubscriber;
import org.junit.Test;
-import org.apache.qpid.systests.jms_1_1.Jms1TestBase;
+import org.apache.qpid.systests.JmsTestBase;
-public class DurableSubscribtionTest extends Jms1TestBase
+public class DurableSubscribtionTest extends JmsTestBase
{
@Test
public void publishedMessagesAreSavedAfterSubscriberClose() throws Exception
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/49cd2c1d/systests/qpid-systests-jms_2.0/pom.xml
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_2.0/pom.xml b/systests/qpid-systests-jms_2.0/pom.xml
index b293574..ec60b23 100644
--- a/systests/qpid-systests-jms_2.0/pom.xml
+++ b/systests/qpid-systests-jms_2.0/pom.xml
@@ -29,9 +29,10 @@
<description>JMS 2.0 system tests</description>
<dependencies>
+
<dependency>
<groupId>org.apache.qpid</groupId>
- <artifactId>qpid-systests</artifactId>
+ <artifactId>qpid-systests-jms-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
@@ -41,25 +42,12 @@
</dependency>
<dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>qpid-bdbstore</artifactId>
- <scope>test</scope>
- <optional>true</optional>
- </dependency>
-
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
- <artifactId>qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store</artifactId>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.apache.qpid</groupId>
<artifactId>qpid-systests-utils</artifactId>
</dependency>
@@ -112,7 +100,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
- <qpid.initialConfigurationLocation>classpath:config-jms2-tests.json</qpid.initialConfigurationLocation>
+ <qpid.initialConfigurationLocation>classpath:config-jms-tests.json</qpid.initialConfigurationLocation>
</systemPropertyVariables>
</configuration>
</plugin>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org