You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2018/03/12 16:44:16 UTC
[8/8] qpid-broker-j git commit: NO-JIRA: [Broker-J] [System Tests]
Remove Rest ACL Tests
NO-JIRA: [Broker-J] [System Tests] Remove Rest ACL Tests
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/cec889db
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/cec889db
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/cec889db
Branch: refs/heads/master
Commit: cec889db6d0df6624d45a84fe5e23721a33c83f5
Parents: b21a8f5
Author: Keith Wall <kw...@apache.org>
Authored: Mon Mar 12 15:45:15 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Mon Mar 12 16:24:18 2018 +0000
----------------------------------------------------------------------
.../org/apache/qpid/systest/rest/Asserts.java | 334 ------
.../org/apache/qpid/test/utils/TestUtils.java | 22 -
.../server/SupportedProtocolVersionsTest.java | 196 ---
.../server/queue/LiveQueueOperationsTest.java | 135 ---
.../rest/AccessControlProviderRestTest.java | 234 ----
.../qpid/systest/rest/ConnectionRestTest.java | 255 ----
.../qpid/systest/rest/SessionRestTest.java | 159 ---
.../qpid/systest/rest/acl/BrokerACLTest.java | 1129 ------------------
.../systest/rest/acl/ExchangeRestACLTest.java | 317 -----
.../qpid/systest/rest/acl/GroupRestACLTest.java | 201 ----
.../qpid/systest/rest/acl/QueueRestACLTest.java | 192 ---
.../qpid/systest/rest/acl/UserRestACLTest.java | 183 ---
.../systest/rest/acl/VirtualHostACLTest.java | 188 ---
...irtualHostAccessControlProviderRestTest.java | 287 -----
.../rest/acl/VirtualHostNodeACLTest.java | 125 --
.../test/utils/BrokerCommandHelperTest.java | 57 -
.../test/utils/SpawnedBrokerHolderTest.java | 38 -
17 files changed, 4052 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cec889db/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java b/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
index c0cc77e..be0dd54 100644
--- a/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
+++ b/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
@@ -20,350 +20,16 @@
*/
package org.apache.qpid.systest.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
import java.util.Map;
-import javax.jms.JMSException;
-
import junit.framework.TestCase;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.BrokerModel;
import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.Connection;
-import org.apache.qpid.server.model.Exchange;
-import org.apache.qpid.server.model.ExclusivityPolicy;
-import org.apache.qpid.server.model.LifetimePolicy;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.model.VirtualHostNode;
-import org.apache.qpid.server.queue.LastValueQueue;
-import org.apache.qpid.server.queue.PriorityQueue;
-import org.apache.qpid.server.queue.SortedQueue;
-import org.apache.qpid.server.virtualhost.QueueManagingVirtualHost;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
public class Asserts
{
public static final String STATISTICS_ATTRIBUTE = "statistics";
- public static void assertVirtualHostNode(final String nodeName, final Map<String, Object> node)
- {
- assertNotNull("Virtualhostnode " + nodeName + " data is not found", node);
- assertEquals("Unexpected value of attribute " + VirtualHostNode.NAME,
- nodeName,
- node.get(VirtualHostNode.NAME));
- }
-
- public static void assertVirtualHost(String virtualHostName, Map<String, Object> virtualHost)
- {
- assertNotNull("Virtualhost " + virtualHostName + " data are not found", virtualHost);
- assertAttributesPresent(virtualHost,
- BrokerModel.getInstance().getTypeRegistry().getAttributeNames(VirtualHost.class),
- ConfiguredObject.CREATED_BY,
- ConfiguredObject.CREATED_TIME,
- ConfiguredObject.LAST_UPDATED_BY,
- ConfiguredObject.LAST_UPDATED_TIME,
- ConfiguredObject.DESCRIPTION,
- ConfiguredObject.CONTEXT,
- ConfiguredObject.DESIRED_STATE,
- QueueManagingVirtualHost.ENABLED_CONNECTION_VALIDATORS,
- QueueManagingVirtualHost.DISABLED_CONNECTION_VALIDATORS,
- QueueManagingVirtualHost.GLOBAL_ADDRESS_DOMAINS,
- VirtualHost.TYPE,
- VirtualHost.PREFERENCE_STORE_ATTRIBUTES);
-
- assertEquals("Unexpected value of attribute " + VirtualHost.NAME,
- virtualHostName,
- virtualHost.get(VirtualHost.NAME));
- assertNotNull("Unexpected value of attribute " + VirtualHost.ID, virtualHost.get(VirtualHost.ID));
- assertEquals("Unexpected value of attribute " + VirtualHost.STATE, State.ACTIVE.name(),
- virtualHost.get(VirtualHost.STATE));
- assertEquals("Unexpected value of attribute " + VirtualHost.DURABLE, Boolean.TRUE,
- virtualHost.get(VirtualHost.DURABLE));
- assertEquals("Unexpected value of attribute " + VirtualHost.LIFETIME_POLICY, LifetimePolicy.PERMANENT.name(),
- virtualHost.get(VirtualHost.LIFETIME_POLICY));
-
- @SuppressWarnings("unchecked")
- Map<String, Object> statistics = (Map<String, Object>) virtualHost.get(STATISTICS_ATTRIBUTE);
- Asserts.assertAttributesPresent(statistics,
- "queueCount","exchangeCount","bytesIn","bytesOut","messagesIn", "messagesOut");
-
- }
-
- public static void assertQueue(String queueName, String queueType, Map<String, Object> queueData)
- {
- assertQueue(queueName, queueType, queueData, null);
- }
-
- public static void assertQueue(String queueName,
- String queueType,
- Map<String, Object> queueData,
- Map<String, Object> expectedAttributes)
- {
- assertNotNull("Queue " + queueName + " is not found!", queueData);
- Asserts.assertAttributesPresent(queueData,
- BrokerModel.getInstance().getTypeRegistry().getAttributeNames(Queue.class),
- Queue.CREATED_BY,
- Queue.CREATED_TIME,
- Queue.LAST_UPDATED_BY,
- Queue.LAST_UPDATED_TIME,
- Queue.TYPE,
- Queue.DESCRIPTION,
- Queue.ALTERNATE_BINDING,
- Queue.OWNER,
- Queue.NO_LOCAL,
- LastValueQueue.LVQ_KEY,
- SortedQueue.SORT_KEY,
- Queue.MESSAGE_GROUP_KEY_OVERRIDE,
- Queue.MESSAGE_GROUP_TYPE,
- PriorityQueue.PRIORITIES,
- ConfiguredObject.CONTEXT,
- ConfiguredObject.DESIRED_STATE,
- Queue.DEFAULT_FILTERS,
- Queue.ENSURE_NONDESTRUCTIVE_CONSUMERS,
- Queue.CREATING_LINK_INFO);
-
- assertEquals("Unexpected value of queue attribute " + Queue.NAME, queueName, queueData.get(Queue.NAME));
- assertNotNull("Unexpected value of queue attribute " + Queue.ID, queueData.get(Queue.ID));
- assertEquals("Unexpected value of queue attribute " + Queue.STATE,
- State.ACTIVE.name(),
- queueData.get(Queue.STATE));
- assertEquals("Unexpected value of queue attribute " + Queue.LIFETIME_POLICY, LifetimePolicy.PERMANENT.name(),
- queueData.get(Queue.LIFETIME_POLICY));
- assertEquals("Unexpected value of queue attribute " + Queue.TYPE,
- queueType,
- queueData.get(Queue.TYPE));
- if (expectedAttributes == null)
- {
- assertEquals("Unexpected value of queue attribute " + Queue.EXCLUSIVE,
- ExclusivityPolicy.NONE.name(), queueData.get(Queue.EXCLUSIVE));
- assertEquals("Unexpected value of queue attribute " + Queue.MAXIMUM_DELIVERY_ATTEMPTS, 0,
- queueData.get(Queue.MAXIMUM_DELIVERY_ATTEMPTS));
- assertEquals("Unexpected value of queue attribute " + Queue.MAXIMUM_QUEUE_DEPTH_MESSAGES, -1,
- queueData.get(Queue.MAXIMUM_QUEUE_DEPTH_MESSAGES));
- assertEquals("Unexpected value of queue attribute " + Queue.QUEUE_FLOW_STOPPED, Boolean.FALSE,
- queueData.get(Queue.QUEUE_FLOW_STOPPED));
- }
- else
- {
- for (Map.Entry<String, Object> attribute : expectedAttributes.entrySet())
- {
- assertEquals("Unexpected value of " + queueName + " queue attribute " + attribute.getKey(),
- attribute.getValue(), queueData.get(attribute.getKey()));
- }
- }
-
- assertNotNull("Unexpected value of queue attribute statistics", queueData.get(Asserts.STATISTICS_ATTRIBUTE));
- @SuppressWarnings("unchecked")
- Map<String, Object> statistics = (Map<String, Object>) queueData.get(Asserts.STATISTICS_ATTRIBUTE);
-
- Asserts.assertAttributesPresent(statistics,
- "bindingCount",
- "consumerCount",
- "consumerCountWithCredit",
- "persistentDequeuedBytes",
- "persistentDequeuedMessages",
- "persistentEnqueuedBytes",
- "persistentEnqueuedMessages",
- "queueDepthBytes",
- "queueDepthMessages",
- "totalDequeuedBytes",
- "totalDequeuedMessages",
- "totalEnqueuedBytes",
- "totalEnqueuedMessages",
- "unacknowledgedBytes",
- "unacknowledgedMessages");
- }
-
- public static void assertAttributesPresent(Map<String, Object> data, String... attributes)
- {
- for (String name : attributes)
- {
- assertNotNull("Attribute " + name + " is not present", data.get(name));
- }
- }
-
- public static void assertAttributesPresent(Map<String, Object> data, Collection<String> attributes,
- String... unsupportedAttributes)
- {
- for (String name : attributes)
- {
- boolean unsupported = false;
- for (String unsupportedAttribute : unsupportedAttributes)
- {
- if (unsupportedAttribute.equals(name))
- {
- unsupported = true;
- break;
- }
- }
- if (unsupported)
- {
- continue;
- }
- assertNotNull("Attribute " + name + " is not present", data.get(name));
- }
- }
-
- public static void assertConnection(Map<String, Object> connectionData, final int sessions)
- throws JMSException
- {
- assertNotNull("Unexpected connection data", connectionData);
- assertAttributesPresent(connectionData,
- BrokerModel.getInstance().getTypeRegistry().getAttributeNames(Connection.class),
- Connection.STATE,
- Connection.DURABLE,
- Connection.LIFETIME_POLICY,
- Connection.INCOMING,
- Connection.REMOTE_PROCESS_NAME,
- Connection.REMOTE_PROCESS_PID,
- Connection.LOCAL_ADDRESS,
- Connection.PROPERTIES,
- ConfiguredObject.TYPE,
- ConfiguredObject.CREATED_BY,
- ConfiguredObject.CREATED_TIME,
- ConfiguredObject.LAST_UPDATED_BY,
- ConfiguredObject.LAST_UPDATED_TIME,
- ConfiguredObject.DESCRIPTION,
- ConfiguredObject.CONTEXT,
- ConfiguredObject.DESIRED_STATE);
-
- assertEquals("Unexpected value for connection attribute " + Connection.PORT,
- TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT, connectionData.get(Connection.PORT));
- assertEquals("Unexpected value of connection attribute " + Connection.PRINCIPAL, "guest",
- connectionData.get(Connection.PRINCIPAL));
-
- @SuppressWarnings("unchecked")
- Map<String, Object> statistics = (Map<String, Object>) connectionData.get(STATISTICS_ATTRIBUTE);
-
-
- assertAttributesPresent(statistics,
- "bytesIn",
- "bytesOut",
- "lastIoTime",
- "messagesIn",
- "messagesOut",
- "sessionCount");
- assertEquals("Unexpected value of connection statistics attribute sessionCount ", sessions,
- statistics.get("sessionCount"));
- }
-
- public static void assertPortAttributes(Map<String, Object> port)
- {
- assertPortAttributes(port, State.ACTIVE);
- }
-
- public static void assertPortAttributes(Map<String, Object> port, State state)
- {
- assertNotNull("Unexpected value of attribute " + Port.ID, port.get(Port.ID));
- assertEquals("Unexpected value of attribute " + Port.DURABLE, Boolean.TRUE, port.get(Port.DURABLE));
- assertEquals("Unexpected value of attribute " + Port.LIFETIME_POLICY, LifetimePolicy.PERMANENT.name(),
- port.get(Broker.LIFETIME_POLICY));
- assertEquals("Unexpected value of attribute " + Port.STATE, state.name(), port.get(Port.STATE));
-
- @SuppressWarnings("unchecked")
- Collection<String> protocols = (Collection<String>) port.get(Port.PROTOCOLS);
-
- if ("AMQP".equals(port.get(ConfiguredObject.TYPE)))
- {
- assertAttributesPresent(port,
- BrokerModel.getInstance().getTypeRegistry().getAttributeNames(Port.class),
- ConfiguredObject.TYPE,
- ConfiguredObject.CREATED_BY,
- ConfiguredObject.CREATED_TIME,
- ConfiguredObject.LAST_UPDATED_BY,
- ConfiguredObject.LAST_UPDATED_TIME,
- ConfiguredObject.DESCRIPTION,
- ConfiguredObject.CONTEXT,
- ConfiguredObject.DESIRED_STATE,
- Port.AUTHENTICATION_PROVIDER,
- Port.KEY_STORE,
- Port.TRUST_STORES,
- Port.PROTOCOLS,
- Port.CLIENT_CERT_RECORDER);
- assertNotNull("Unexpected value of attribute " + Port.BINDING_ADDRESS, port.get(Port.BINDING_ADDRESS));
- }
- else
- {
- assertAttributesPresent(port,
- BrokerModel.getInstance().getTypeRegistry().getAttributeNames(Port.class),
- ConfiguredObject.TYPE,
- ConfiguredObject.CREATED_BY,
- ConfiguredObject.CREATED_TIME,
- ConfiguredObject.LAST_UPDATED_BY,
- ConfiguredObject.LAST_UPDATED_TIME,
- ConfiguredObject.DESCRIPTION,
- ConfiguredObject.CONTEXT,
- ConfiguredObject.DESIRED_STATE,
- Port.AUTHENTICATION_PROVIDER,
- Port.BINDING_ADDRESS,
- Port.TCP_NO_DELAY,
- Port.NEED_CLIENT_AUTH,
- Port.WANT_CLIENT_AUTH,
- Port.KEY_STORE,
- Port.TRUST_STORES,
- Port.PROTOCOLS,
- Port.CLIENT_CERT_RECORDER);
- }
-
- @SuppressWarnings("unchecked")
- Collection<String> transports = (Collection<String>) port.get(Port.TRANSPORTS);
- assertEquals("Unexpected value of attribute " + Port.TRANSPORTS, new HashSet<String>(Arrays.asList("TCP")),
- new HashSet<String>(transports));
- }
-
- public static void assertDurableExchange(String exchangeName, String type, Map<String, Object> exchangeData)
- {
- assertExchange(exchangeName, type, exchangeData);
-
- assertEquals("Unexpected value of exchange attribute " + Exchange.DURABLE, Boolean.TRUE,
- exchangeData.get(Exchange.DURABLE));
- }
-
- public static void assertExchange(String exchangeName, String type, Map<String, Object> exchangeData)
- {
- assertNotNull("Exchange " + exchangeName + " is not found!", exchangeData);
- assertAttributesPresent(exchangeData, BrokerModel.getInstance().getTypeRegistry().getAttributeNames(Exchange.class),
- Exchange.ALTERNATE_BINDING,
- ConfiguredObject.CREATED_BY,
- ConfiguredObject.CREATED_TIME,
- ConfiguredObject.LAST_UPDATED_BY,
- ConfiguredObject.LAST_UPDATED_TIME,
- ConfiguredObject.DESCRIPTION,
- ConfiguredObject.CONTEXT,
- ConfiguredObject.DESIRED_STATE,
- Exchange.CREATING_LINK_INFO);
-
- assertEquals("Unexpected value of exchange attribute " + Exchange.NAME, exchangeName,
- exchangeData.get(Exchange.NAME));
- assertNotNull("Unexpected value of exchange attribute " + Exchange.ID, exchangeData.get(VirtualHost.ID));
- assertEquals("Unexpected value of exchange attribute " + Exchange.STATE, State.ACTIVE.name(),
- exchangeData.get(Exchange.STATE));
-
- assertEquals("Unexpected value of exchange attribute " + Exchange.LIFETIME_POLICY,
- LifetimePolicy.PERMANENT.name(),
- exchangeData.get(Exchange.LIFETIME_POLICY));
- assertEquals("Unexpected value of exchange attribute " + Exchange.TYPE, type, exchangeData.get(Exchange.TYPE));
- assertNotNull("Unexpected value of exchange attribute statistics", exchangeData.get(STATISTICS_ATTRIBUTE));
-
- @SuppressWarnings("unchecked")
- Map<String, Object> statistics = (Map<String, Object>) exchangeData.get(STATISTICS_ATTRIBUTE);
-
- assertAttributesPresent(statistics,"bindingCount",
- "bytesDropped",
- "bytesIn",
- "messagesDropped",
- "messagesIn");
- }
-
public static void assertActualAndDesiredState(final String expectedDesiredState,
final String expectedActualState,
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cec889db/systests/src/main/java/org/apache/qpid/test/utils/TestUtils.java
----------------------------------------------------------------------
diff --git a/systests/src/main/java/org/apache/qpid/test/utils/TestUtils.java b/systests/src/main/java/org/apache/qpid/test/utils/TestUtils.java
index b112601..5069e20 100644
--- a/systests/src/main/java/org/apache/qpid/test/utils/TestUtils.java
+++ b/systests/src/main/java/org/apache/qpid/test/utils/TestUtils.java
@@ -21,10 +21,6 @@
package org.apache.qpid.test.utils;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
@@ -56,22 +52,4 @@ public class TestUtils
}
return dump.toString();
}
-
- public static String writeACLFileUtil(QpidBrokerTestCase testcase, String...rules) throws IOException
- {
- File aclFile = File.createTempFile(testcase.getClass().getSimpleName(), testcase.getName());
- aclFile.deleteOnExit();
-
- testcase.getDefaultBrokerConfiguration().addAclFileConfiguration(aclFile.getAbsolutePath());
-
- try (PrintWriter out = new PrintWriter(new FileWriter(aclFile)))
- {
- out.println(String.format("# %s", testcase.getName()));
- for (String line : rules)
- {
- out.println(line);
- }
- }
- return aclFile.getCanonicalPath();
- }
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cec889db/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java b/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java
deleted file mode 100644
index 00a95d9..0000000
--- a/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *
- */
-package org.apache.qpid.server;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.configuration.ClientProperties;
-import org.apache.qpid.framing.ProtocolVersion;
-import org.apache.qpid.server.model.Protocol;
-import org.apache.qpid.server.model.port.AmqpPort;
-import org.apache.qpid.server.plugin.AMQPProtocolVersionWrapper;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-/**
- * Tests to validate it is possible to disable support for particular protocol
- * versions entirely, rather than selectively excluding them on particular ports,
- * and it is possible to configure the reply to an unsupported protocol initiation.
- *<p>
- */
-public class SupportedProtocolVersionsTest extends QpidBrokerTestCase
-{
- @Override
- public void startDefaultBroker() throws Exception
- {
- // No-op, we call super.startDefaultBroker() from test methods after appropriate config overrides
- }
-
- private void clearProtocolSupportManipulations() throws Exception
- {
- //Remove the QBTC provided protocol manipulations, giving only the protocols which default to enabled
-
- setSystemProperty(QpidBrokerTestCase.TEST_AMQP_PORT_PROTOCOLS_PROPERTY, getProtocolsAsString(getAllAmqpProtocols()));
- }
-
- private Collection<Protocol> getAllAmqpProtocols() throws Exception
- {
- Collection<Protocol> protocols = new HashSet<>();
- for(Protocol p : Protocol.values())
- {
- if(p.getProtocolType() == Protocol.ProtocolType.AMQP)
- {
- protocols.add(p);
- }
- }
-
- return protocols;
- }
-
- private String getProtocolsWithExclusions(Protocol... excludes) throws Exception
- {
- Set<Protocol> protocols = new HashSet<>(getAllAmqpProtocols());
- protocols.removeAll(Arrays.asList(excludes));
- return getProtocolsAsString(protocols);
- }
-
- private String getProtocolsAsString(final Collection<Protocol> protocols) throws IOException
- {
- ObjectMapper mapper = new ObjectMapper();
- StringWriter stringWriter = new StringWriter();
- mapper.writeValue(stringWriter, protocols);
- return stringWriter.toString();
- }
-
- /**
- * Test that 0-10, 0-9-1, 0-9, and 0-8 support is present when no
- * attempt has yet been made to disable them, and forcing the client
- * to negotiate from a particular protocol version returns a connection
- * using the expected protocol version.
- */
- public void testDefaultProtocolSupport() throws Exception
- {
- clearProtocolSupportManipulations();
-
- super.startDefaultBroker();
-
- //Verify requesting a 0-10 connection works
- setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10");
- AMQConnection connection = (AMQConnection) getConnection();
- assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_10, connection.getProtocolVersion());
- connection.close();
-
- //Verify requesting a 0-91 connection works
- setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-9-1");
- connection = (AMQConnection) getConnection();
- assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_91, connection.getProtocolVersion());
- connection.close();
-
- //Verify requesting a 0-9 connection works
- setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-9");
- connection = (AMQConnection) getConnection();
- assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_9, connection.getProtocolVersion());
- connection.close();
-
- //Verify requesting a 0-8 connection works
- setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-8");
- connection = (AMQConnection) getConnection();
- assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_8, connection.getProtocolVersion());
- connection.close();
- }
-
- public void testDisabling010and10() throws Exception
- {
- setSystemProperty(QpidBrokerTestCase.TEST_AMQP_PORT_PROTOCOLS_PROPERTY, getProtocolsWithExclusions(Protocol.AMQP_1_0, Protocol.AMQP_0_10));
-
- super.startDefaultBroker();
-
- //Verify initially requesting a 0-10 connection now negotiates a 0-91
- //connection as the broker should reply with its highest supported protocol
- setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10");
- AMQConnection connection = (AMQConnection) getConnection();
- assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_91, connection.getProtocolVersion());
- connection.close();
- }
-
- public void testConfiguringReplyingToUnsupported010ProtocolInitiationWith09insteadOf091() throws Exception
- {
- clearProtocolSupportManipulations();
-
- //disable 0-10 support, and set the default unsupported protocol initiation reply to 0-9
- setSystemProperty(QpidBrokerTestCase.TEST_AMQP_PORT_PROTOCOLS_PROPERTY, getProtocolsWithExclusions(Protocol.AMQP_1_0, Protocol.AMQP_0_10));
-
- setSystemProperty(AmqpPort.PROPERTY_DEFAULT_SUPPORTED_PROTOCOL_REPLY, "v0_9");
-
- super.startDefaultBroker();
-
- //Verify initially requesting a 0-10 connection now negotiates a 0-9 connection as the
- //broker should reply with its 'default unsupported protocol initiation reply' as opposed
- //to the previous behaviour of the highest supported protocol version.
- setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-10");
- AMQConnection connection = (AMQConnection) getConnection();
- assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_9, connection.getProtocolVersion());
- connection.close();
-
- //Verify requesting a 0-91 connection directly still works, as its support is still enabled
- setTestClientSystemProperty(ClientProperties.AMQP_VERSION, "0-9-1");
- connection = (AMQConnection) getConnection();
- assertEquals("Unexpected protocol version in use", ProtocolVersion.v0_91, connection.getProtocolVersion());
- connection.close();
- }
-
- public void testProtocolIsExpectedBasedOnTestProfile() throws Exception
- {
- super.startDefaultBroker();
- final AMQConnection connection = (AMQConnection) getConnection();
- final Protocol expectedBrokerProtocol = getBrokerProtocol();
- final AMQPProtocolVersionWrapper amqpProtocolVersionWrapper = new AMQPProtocolVersionWrapper(expectedBrokerProtocol);
- final ProtocolVersion protocolVersion = connection.getProtocolVersion();
- assertTrue("Connection AMQP protocol " + expectedBrokerProtocol + "is not the same as the test specified protocol " + protocolVersion,
- areEquivalent(amqpProtocolVersionWrapper, protocolVersion));
- connection.close();
- }
-
- private boolean areEquivalent(AMQPProtocolVersionWrapper amqpProtocolVersionWrapper, ProtocolVersion protocolVersion)
- {
- byte byteMajor = (byte)amqpProtocolVersionWrapper.getMajor();
- byte byteMinor;
- if (amqpProtocolVersionWrapper.getPatch() == 0)
- {
- byteMinor = (byte)amqpProtocolVersionWrapper.getMinor();
- }
- else
- {
- final StringBuilder sb = new StringBuilder();
- sb.append(amqpProtocolVersionWrapper.getMinor());
- sb.append(amqpProtocolVersionWrapper.getPatch());
- byteMinor = Byte.valueOf(sb.toString()).byteValue();
- }
- return (protocolVersion.getMajorVersion() == byteMajor && protocolVersion.getMinorVersion() == byteMinor);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cec889db/systests/src/test/java/org/apache/qpid/server/queue/LiveQueueOperationsTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/server/queue/LiveQueueOperationsTest.java b/systests/src/test/java/org/apache/qpid/server/queue/LiveQueueOperationsTest.java
deleted file mode 100644
index f59a723..0000000
--- a/systests/src/test/java/org/apache/qpid/server/queue/LiveQueueOperationsTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.server.queue;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.client.RejectBehaviour;
-import org.apache.qpid.configuration.ClientProperties;
-import org.apache.qpid.systest.rest.RestTestHelper;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-public class LiveQueueOperationsTest extends QpidBrokerTestCase
-{
- private static final Logger LOGGER = LoggerFactory.getLogger(LiveQueueOperationsTest.class);
-
- private static final int MAX_DELIVERY_COUNT = 2;
-
- @Override
- protected void setUp() throws Exception
- {
- getDefaultBrokerConfiguration().addHttpManagementConfiguration();
- setTestSystemProperty("queue.deadLetterQueueEnabled","true");
- setTestSystemProperty("queue.maximumDeliveryAttempts", String.valueOf(MAX_DELIVERY_COUNT));
-
- // Set client-side flag to allow the server to determine if messages
- // dead-lettered or requeued.
- if (!isBroker010())
- {
- setTestClientSystemProperty(ClientProperties.REJECT_BEHAVIOUR_PROP_NAME, RejectBehaviour.SERVER.toString());
- }
-
- super.setUp();
- }
-
- public void testClearQueueOperationWithActiveConsumerDlqAll() throws Exception
- {
- final String virtualHostName = TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST;
- RestTestHelper restTestHelper = new RestTestHelper(getDefaultBroker().getHttpPort());
-
- Connection conn = getConnection();
- conn.start();
- final Session session = conn.createSession(true, Session.SESSION_TRANSACTED);
- final Queue queue = createTestQueue(session);
- session.createConsumer(queue).close();
-
- sendMessage(session, queue, 250);
-
- MessageConsumer consumer = session.createConsumer(queue);
-
- final CountDownLatch clearQueueLatch = new CountDownLatch(10);
- final AtomicReference<Throwable> throwableAtomicReference = new AtomicReference<>();
- consumer.setMessageListener(message ->
- {
- try
- {
- clearQueueLatch.countDown();
- session.rollback();
- }
- catch (Throwable t)
- {
- LOGGER.error("Unexpected exception from rollback", t);
- throwableAtomicReference.set(t);
- }
- });
-
-
- boolean ready = clearQueueLatch.await(30, TimeUnit.SECONDS);
- assertTrue("Consumer did not reach expected point within timeout", ready);
-
- final String queueUrl = "queue/" + virtualHostName + "/" + virtualHostName + "/" + queue.getQueueName();
-
- String clearOperationUrl = queueUrl + "/clearQueue";
- restTestHelper.submitRequest(clearOperationUrl, "POST", Collections.<String,Object>emptyMap(), 200);
-
- int queueDepthMessages = 0;
- for (int i = 0; i < 20; ++i)
- {
- Map<String, Object> statistics = getStatistics(restTestHelper, queueUrl);
- queueDepthMessages = (int) statistics.get("queueDepthMessages");
- if (queueDepthMessages == 0)
- {
- break;
- }
- Thread.sleep(250);
- }
- assertEquals("Queue depth did not reach 0 within expected time", 0, queueDepthMessages);
-
- consumer.close();
-
- Map<String, Object> statistics = getStatistics(restTestHelper, queueUrl);
- queueDepthMessages = (int) statistics.get("queueDepthMessages");
- assertEquals("Unexpected queue depth after consumer close", 0, queueDepthMessages);
-
- assertEquals("Unexpected exception thrown", null, throwableAtomicReference.get());
- }
-
- private Map<String, Object> getStatistics(final RestTestHelper restTestHelper, final String objectUrl) throws Exception
- {
- Map<String, Object> object = restTestHelper.getJsonAsMap(objectUrl);
- @SuppressWarnings("unchecked")
- Map<String, Object> statistics = (Map<String, Object>) object.get("statistics");
- return statistics;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cec889db/systests/src/test/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
deleted file mode 100644
index 8ca674d..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
+++ /dev/null
@@ -1,234 +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.systest.rest;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.qpid.server.management.plugin.servlet.rest.RestServlet;
-import org.apache.qpid.server.model.AccessControlProvider;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.SystemConfig;
-import org.apache.qpid.server.security.AllowAllAccessControlProvider;
-import org.apache.qpid.server.security.access.plugins.AclFileAccessControlProvider;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-import org.apache.qpid.test.utils.TestFileUtils;
-
-public class AccessControlProviderRestTest extends QpidRestTestCase
-{
- private static final String ALLOWED_USER = "allowed";
- private static final String DENIED_USER = "denied";
- private static final String OTHER_USER = "other";
-
- private String _aclFileContent1 =
- "ACL ALLOW-LOG " + ALLOWED_USER + " ACCESS MANAGEMENT\n" +
- "ACL ALLOW-LOG " + ALLOWED_USER + " CONFIGURE BROKER\n" +
- "ACL DENY-LOG ALL ALL";
-
- private String _aclFileContent2 =
- "ACL ALLOW-LOG " + ALLOWED_USER + " ACCESS MANAGEMENT\n" +
- "ACL ALLOW-LOG " + OTHER_USER + " ACCESS MANAGEMENT\n" +
- "ACL ALLOW-LOG " + ALLOWED_USER + " CONFIGURE BROKER\n" +
- "ACL DENY-LOG ALL ALL";
-
- @Override
- protected void customizeConfiguration() throws Exception
- {
- super.customizeConfiguration();
- final TestBrokerConfiguration defaultBrokerConfiguration = getDefaultBrokerConfiguration();
- defaultBrokerConfiguration.configureTemporaryPasswordFile(ALLOWED_USER, DENIED_USER, OTHER_USER);
- }
-
- public void testCreateAccessControlProvider() throws Exception
- {
- String accessControlProviderName = getTestName();
-
- //verify that the access control provider doesn't exist, and
- //in doing so implicitly verify that the 'denied' user can
- //actually currently connect because no ACL is in effect yet
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertAccessControlProviderExistence(accessControlProviderName, false);
-
- //create the access control provider using the 'allowed' user
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- int responseCode = createAccessControlProvider(accessControlProviderName, _aclFileContent1);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
-
- //verify it exists with the 'allowed' user
- assertAccessControlProviderExistence(accessControlProviderName, true);
-
- //verify the 'denied' user can no longer access the management interface
- //due to the just-created ACL file now preventing it
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertCanAccessManagementInterface(accessControlProviderName, false);
- }
-
- public void testRemoveAccessControlProvider() throws Exception
- {
- String accessControlProviderName = getTestName();
-
- //verify that the access control provider doesn't exist, and
- //in doing so implicitly verify that the 'denied' user can
- //actually currently connect because no ACL is in effect yet
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertAccessControlProviderExistence(accessControlProviderName, false);
-
- //create the access control provider using the 'allowed' user
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- int responseCode = createAccessControlProvider(accessControlProviderName, _aclFileContent1);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
-
- //verify it exists with the 'allowed' user
- assertAccessControlProviderExistence(accessControlProviderName, true);
-
- // add a second, low priority AllowAll provider
- Map<String,Object> attributes = new HashMap<>();
- final String secondProviderName = "AllowAll";
- attributes.put(ConfiguredObject.NAME, secondProviderName);
- attributes.put(ConfiguredObject.TYPE, AllowAllAccessControlProvider.ALLOW_ALL);
- attributes.put(AccessControlProvider.PRIORITY, 9999);
- responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + secondProviderName, "PUT", attributes);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
-
-
- //verify the 'denied' user can no longer access the management interface
- //due to the just-created ACL file now preventing it
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertCanAccessManagementInterface(accessControlProviderName, false);
-
- //remove the access control provider using the 'allowed' user
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
-
- responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "DELETE");
- assertEquals("Access control provider deletion should be allowed", 200, responseCode);
- assertAccessControlProviderExistence(accessControlProviderName, false);
-
- //verify it is gone again, using the 'denied' user to implicitly confirm it is
- //now able to connect to the management interface again because the ACL was removed.
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertAccessControlProviderExistence(accessControlProviderName, false);
- }
-
- public void testReplaceAccessControlProvider() throws Exception
- {
-
-
- //create the access control provider using the 'allowed' user
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- int responseCode = createAccessControlProvider(getTestName(), _aclFileContent1);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
-
- //verify it exists with the 'allowed' user
- assertAccessControlProviderExistence(getTestName(), true);
-
- //verify the 'denied' and 'other' user can no longer access the management
- //interface due to the just-created ACL file now preventing them
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertCanAccessManagementInterface(getTestName(), false);
- getRestTestHelper().setUsernameAndPassword(OTHER_USER, OTHER_USER);
- assertCanAccessManagementInterface(getTestName(), false);
-
- //create the replacement access control provider using the 'allowed' user.
- String accessControlProviderName2 = getTestName() + "2";
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- responseCode = createAccessControlProvider(accessControlProviderName2, _aclFileContent2);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
-
- //Verify that first access control provider is used
-
- //verify the 'denied' user still can't access the management interface
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertCanAccessManagementInterface(accessControlProviderName2, false);
- getRestTestHelper().setUsernameAndPassword(OTHER_USER, OTHER_USER);
- assertCanAccessManagementInterface(accessControlProviderName2, false);
- }
-
-
-
- public void testRemovalOfAccessControlProviderInErrorStateUsingManagementMode() throws Exception
- {
- stopDefaultBroker();
-
- File file = new File(TMP_FOLDER, getTestName());
- if (file.exists())
- {
- file.delete();
- }
- assertFalse("ACL file should not exist", file.exists());
- TestBrokerConfiguration configuration = getDefaultBrokerConfiguration();
- UUID id = configuration.addAclFileConfiguration(file.getAbsolutePath());
-
- Map<String,Object> attributes = new HashMap<>();
- final String secondProviderName = "AllowAll";
- attributes.put(ConfiguredObject.NAME, secondProviderName);
- attributes.put(ConfiguredObject.TYPE, AllowAllAccessControlProvider.ALLOW_ALL);
- attributes.put(AccessControlProvider.PRIORITY, 9999);
- configuration.addObjectConfiguration(AccessControlProvider.class, attributes);
- configuration.setSaved(false);
- startDefaultBroker(true);
-
- getRestTestHelper().setUsernameAndPassword(SystemConfig.MANAGEMENT_MODE_USER_NAME, MANAGEMENT_MODE_PASSWORD);
- Map<String, Object> acl = getRestTestHelper().getJsonAsMap("accesscontrolprovider/"
- + TestBrokerConfiguration.ENTRY_NAME_ACL_FILE
- + "?"
- + RestServlet.OVERSIZE_PARAM
- + "="
- + (file.getAbsolutePath().length() + 10));
- assertEquals("Unexpected id", id.toString(), acl.get(AccessControlProvider.ID));
- assertEquals("Unexpected path", file.getAbsolutePath() , acl.get(AclFileAccessControlProvider.PATH));
- assertEquals("Unexpected state", State.ERRORED.name(), acl.get(AccessControlProvider.STATE));
-
- int status = getRestTestHelper().submitRequest("accesscontrolprovider/" + TestBrokerConfiguration.ENTRY_NAME_ACL_FILE, "DELETE");
- assertEquals("ACL was not deleted", 200, status);
-
- getRestTestHelper().submitRequest("accesscontrolprovider/" + TestBrokerConfiguration.ENTRY_NAME_ACL_FILE, "GET", HttpServletResponse.SC_NOT_FOUND);
- }
-
- private void assertCanAccessManagementInterface(String accessControlProviderName, boolean canAccess) throws Exception
- {
- int expected = canAccess ? 200 : 403;
- int responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "GET");
- assertEquals("Unexpected response code", expected, responseCode);
- }
-
- private void assertAccessControlProviderExistence(String accessControlProviderName, boolean exists) throws Exception
- {
- String path = "accesscontrolprovider/" + accessControlProviderName;
- int expectedResponseCode = exists ? HttpServletResponse.SC_OK : HttpServletResponse.SC_NOT_FOUND;
- getRestTestHelper().submitRequest(path, "GET", expectedResponseCode);
- }
-
- private int createAccessControlProvider(String accessControlProviderName, String content) throws Exception
- {
- File file = TestFileUtils.createTempFile(this, ".acl", content);
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(AccessControlProvider.NAME, accessControlProviderName);
- attributes.put(AccessControlProvider.TYPE, AclFileAccessControlProvider.ACL_FILE_PROVIDER_TYPE);
- attributes.put(AclFileAccessControlProvider.PATH, file.getAbsoluteFile());
-
- return getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "PUT", attributes);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cec889db/systests/src/test/java/org/apache/qpid/systest/rest/ConnectionRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/ConnectionRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/ConnectionRestTest.java
deleted file mode 100644
index 31ef47f..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/ConnectionRestTest.java
+++ /dev/null
@@ -1,255 +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.systest.rest;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.qpid.server.model.Connection;
-import org.apache.qpid.server.virtualhost.VirtualHostPropertiesNodeCreator;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-public class ConnectionRestTest extends QpidRestTestCase
-{
- private javax.jms.Connection _connection;
- private javax.jms.Session _session;
- private MessageProducer _producer;
- private long _startTime;
- private Destination _queue;
-
- @Override
- public void setUp() throws Exception
- {
- // disable the virtualhostPropertiesNode as it messes with the statistics counts since causes the client to
- // create a session and then it sends a message
- setTestSystemProperty("qpid.plugin.disabled:systemnodecreator." + VirtualHostPropertiesNodeCreator.TYPE,
- "true");
-
- super.setUp();
-
- javax.jms.Connection managementConnection = getConnection();
- managementConnection.start();
- _queue = createTestQueue(managementConnection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE));
- managementConnection.close();
-
- _startTime = System.currentTimeMillis();
- _connection = getConnectionBuilder().setSyncPublish(true).build();
- _session = _connection.createSession(true, javax.jms.Session.SESSION_TRANSACTED);
- _producer = _session.createProducer(_queue);
- _connection.start();
- }
-
- public void testGetAllConnections() throws Exception
- {
- List<Map<String, Object>> connections = getRestTestHelper().getJsonAsList("connection");
- assertEquals("Unexpected number of connections", 1, connections.size());
- Asserts.assertConnection(connections.get(0), isBroker10() ? 2 : 1);
- }
-
- public void testGetVirtualHostConnections() throws Exception
- {
- List<Map<String, Object>> connections =
- getRestTestHelper().getJsonAsList("virtualhost/test/test/getConnections");
- assertEquals("Unexpected number of connections", 1, connections.size());
- Asserts.assertConnection(connections.get(0), isBroker10() ? 2 : 1);
- }
-
- public void testDeleteConnection() throws Exception
- {
- String connectionName = getConnectionName();
- String portName = TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT;
-
- List<Map<String, Object>> connections = getRestTestHelper().getJsonAsList("connection/" + portName);
- assertEquals("Unexpected number of connections before deletion", 1, connections.size());
-
- String connectionUrl = "connection/" + portName + "/" + getRestTestHelper().encodeAsUTF(connectionName);
- getRestTestHelper().submitRequest(connectionUrl, "DELETE", HttpServletResponse.SC_OK);
-
- connections = getRestTestHelper().getJsonAsList("connection/" + portName);
- assertEquals("Unexpected number of connections after deletion", 0, connections.size());
-
- try
- {
- _connection.createSession(true, javax.jms.Session.SESSION_TRANSACTED);
- fail("Exception not thrown");
- }
- catch (JMSException je)
- {
- // PASS
- }
- finally
- {
- try
- {
- _connection.close();
- }
- catch (JMSException e)
- {
- // PASS
- }
- _connection = null;
- }
- }
-
- public void testConnectionTransactionCountStatistics() throws Exception
- {
- String connectionUrl = getVirtualHostConnectionUrl();
-
- _producer.send(_session.createTextMessage("Test-0"));
- _session.commit();
-
- MessageConsumer consumer = _session.createConsumer(_queue);
- Message m = consumer.receive(getReceiveTimeout());
- assertNotNull("Subsequent messages were not received", m);
-
- Map<String, Object> statistics = getConnectionStatistics(connectionUrl);
-
- assertEquals("Unexpected value of statistic attribute localTransactionBegins", 2,
- statistics.get("localTransactionBegins"));
- assertEquals("Unexpected value of statistic attribute localTransactionRollbacks", 0,
- statistics.get("localTransactionRollbacks"));
- assertEquals("Unexpected value of statistic attribute localTransactionOpen", 1,
- statistics.get("localTransactionOpen"));
-
- _session.rollback();
- m = consumer.receive(getReceiveTimeout());
- assertNotNull("Subsequent messages were not received", m);
-
- final Map<String, Object> statistics2 = getConnectionStatistics(connectionUrl);
-
- assertEquals("Unexpected value of statistic attribute localTransactionBegins", 3,
- statistics2.get("localTransactionBegins"));
- assertEquals("Unexpected value of statistic attribute localTransactionRollbacks", 1,
- statistics2.get("localTransactionRollbacks"));
- assertEquals("Unexpected value of statistic attribute localTransactionOpen", 1,
- statistics2.get("localTransactionOpen"));
-
- _producer.send(_session.createMessage());
- consumer.close();
- _session.close();
-
- final Map<String, Object> statistics3 = getConnectionStatistics(connectionUrl);
-
- assertEquals("Unexpected value of statistic attribute localTransactionBegins", 3,
- statistics3.get("localTransactionBegins"));
- assertEquals("Unexpected value of statistic attribute localTransactionRollbacks", 2,
- statistics3.get("localTransactionRollbacks"));
- assertEquals("Unexpected value of statistic attribute localTransactionOpen", 0,
- statistics3.get("localTransactionOpen"));
- }
-
- public void testConnectionMessageCountStatistics() throws Exception
- {
- _producer.send(_session.createTextMessage("Test-0"));
- _session.commit();
-
- MessageConsumer consumer = _session.createConsumer(_queue);
- Message m = consumer.receive(getReceiveTimeout());
- assertNotNull("First message was not received", m);
- _session.commit();
-
- _session.close();
-
- _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- _producer = _session.createProducer(_queue);
- _producer.send(_session.createTextMessage("Test-1"));
- consumer = _session.createConsumer(_queue);
- m = consumer.receive(getReceiveTimeout());
- assertNotNull("First message was not received", m);
-
- // close session to make sure message ack/disposition reaches the broker before rest request is made
- _session.close();
-
- String connectionUrl = getVirtualHostConnectionUrl();
-
- Map<String, Object> statistics = getConnectionStatistics(connectionUrl);
- assertTrue("Unexpected value of connection statistics attribute bytesIn",
- Long.parseLong(String.valueOf(statistics.get("bytesIn"))) > 0);
- assertTrue("Unexpected value of connection statistics attribute bytesOut",
- Long.parseLong(String.valueOf(statistics.get("bytesOut"))) > 0);
- assertEquals("Unexpected value of connection statistics attribute messagesIn", 2,
- statistics.get("messagesIn"));
- assertEquals("Unexpected value of connection statistics attribute messagesOut",
- 2, statistics.get("messagesOut"));
-
- assertEquals("Unexpected value of statistic attribute transactedMessagesIn", 1,
- statistics.get("transactedMessagesIn"));
-
- assertEquals("Unexpected value of statistic attribute transactedMessagesOut", 1,
- statistics.get("transactedMessagesOut"));
- }
-
- public void testOldestTransactionStartTime() throws Exception
- {
- String connectionUrl = getVirtualHostConnectionUrl();
-
- _producer.send(_session.createTextMessage("Test"));
-
- Map<String, Object> statistics = getConnectionStatistics(connectionUrl);
- long oldestTransactionStartTime = ((Number) statistics.get("oldestTransactionStartTime")).longValue();
- assertTrue("Unexpected transaction oldestTransactionStartTime for connection with work "
- + oldestTransactionStartTime, oldestTransactionStartTime >= _startTime);
-
- _session.commit();
- statistics = getConnectionStatistics(connectionUrl);
- assertNull(String.format(
- "Unexpected transaction oldestTransactionStartTime %s for connection with no work",
- statistics.get("oldestTransactionStartTime")), statistics.get("oldestTransactionStartTime"));
-
- _producer.send(_session.createTextMessage("Test"));
- _session.close();
-
- statistics = getConnectionStatistics(connectionUrl);
- assertNull("Unexpected transaction oldestTransactionStartTime for connection with no session",
- statistics.get("oldestTransactionStartTime"));
- }
-
- private String getConnectionName() throws IOException
- {
- List<Map<String, Object>> connections =
- getRestTestHelper().getJsonAsList("virtualhost/test/test/getConnections");
- assertEquals("Unexpected number of connections", 1, connections.size());
- Map<String, Object> connection = connections.get(0);
- String connectionName = (String) connection.get(Connection.NAME);
- return connectionName;
- }
-
- private String getVirtualHostConnectionUrl() throws IOException
- {
- String connectionName = getConnectionName();
- return "virtualhost/test/test/getConnection?name=" + getRestTestHelper().encodeAsUTF(connectionName);
- }
-
- private Map<String, Object> getConnectionStatistics(final String connectionUrl) throws IOException
- {
- Map<String, Object> connection = getRestTestHelper().getJsonAsMap(connectionUrl);
- return (Map<String, Object>) connection.get(Asserts.STATISTICS_ATTRIBUTE);
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cec889db/systests/src/test/java/org/apache/qpid/systest/rest/SessionRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/SessionRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/SessionRestTest.java
deleted file mode 100644
index 1265ae2..0000000
--- a/systests/src/test/java/org/apache/qpid/systest/rest/SessionRestTest.java
+++ /dev/null
@@ -1,159 +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.systest.rest;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.server.model.BrokerModel;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.Connection;
-import org.apache.qpid.server.model.Session;
-import org.apache.qpid.server.virtualhost.VirtualHostPropertiesNodeCreator;
-import org.apache.qpid.test.utils.TestBrokerConfiguration;
-
-public class SessionRestTest extends QpidRestTestCase
-{
-
- private javax.jms.Connection _connection;
- private javax.jms.Session _session;
- private Destination _queue;
- private MessageProducer _producer;
-
- @Override
- public void setUp() throws Exception
- {
- // disable the virtualhostPropertiesNode as it messes with the statistics counts since causes the client to
- // create a session and then it sends a message
- setTestSystemProperty("qpid.plugin.disabled:systemnodecreator."+ VirtualHostPropertiesNodeCreator.TYPE, "true");
-
- super.setUp();
-
- javax.jms.Connection managementConnection = getConnection();
- try
- {
- managementConnection.start();
- _queue = createTestQueue(managementConnection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE));
- }
- finally
- {
- managementConnection.close();
- }
- _connection = getConnection();
- _session = _connection.createSession(true, javax.jms.Session.SESSION_TRANSACTED);
- MessageConsumer consumer = _session.createConsumer(_queue);
- _producer = _session.createProducer(_queue);
- _connection.start();
-
- _producer.send(_session.createTextMessage("Test"));
- _session.commit();
-
- Message m = consumer.receive(getReceiveTimeout());
- assertNotNull("First message was not received", m);
- // Session left open with uncommitted transaction
- }
-
- public void testGetAllSessions() throws Exception
- {
- List<Map<String, Object>> sessions = getRestTestHelper().getJsonAsList("session");
- assertEquals("Unexpected number of sessions", 1, sessions.size());
- assertSession(sessions.get(0));
- }
-
- public void testGetPortSessions() throws Exception
- {
- String portName = TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT;
-
- List<Map<String, Object>> sessions = getRestTestHelper().getJsonAsList("session/" + portName);
- assertEquals("Unexpected number of sessions", 1, sessions.size());
- assertSession(sessions.get(0));
- }
-
- public void testGetConnectionSessions() throws Exception
- {
- String connectionName = getConnectionName();
- String portName = TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT;
-
- List<Map<String, Object>> sessions = getRestTestHelper().getJsonAsList("session/" + portName + "/"
- + getRestTestHelper().encodeAsUTF(connectionName));
- assertEquals("Unexpected number of sessions", 1, sessions.size());
- assertSession(sessions.get(0));
- }
-
- public void testGetSessionByName() throws Exception
- {
- String connectionName = getConnectionName();
- String portName = TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT;
-
- Map<String, Object> sessionDetails = getRestTestHelper().getJsonAsMap("session/" + portName + "/"
- + getRestTestHelper().encodeAsUTF(connectionName) + "/" + ((AMQSession<?, ?>) _session).getChannelId());
- assertSession(sessionDetails);
- }
-
- private void assertSession(Map<String, Object> sessionData)
- {
- assertNotNull("Session map cannot be null", sessionData);
- Asserts.assertAttributesPresent(sessionData, BrokerModel.getInstance().getTypeRegistry().getAttributeNames(
- Session.class),
- ConfiguredObject.TYPE,
- ConfiguredObject.CREATED_BY,
- ConfiguredObject.CREATED_TIME,
- ConfiguredObject.LAST_UPDATED_BY,
- ConfiguredObject.LAST_UPDATED_TIME,
- ConfiguredObject.DESCRIPTION,
- ConfiguredObject.CONTEXT,
- ConfiguredObject.DESIRED_STATE,
- Session.STATE,
- Session.DURABLE,
- Session.LIFETIME_POLICY);
- assertEquals("Unexpected value of attribute " + Session.PRODUCER_FLOW_BLOCKED, Boolean.FALSE,
- sessionData.get(Session.PRODUCER_FLOW_BLOCKED));
- assertNotNull("Unexpected value of attribute " + Session.NAME, sessionData.get(Session.NAME));
- assertNotNull("Unexpected value of attribute " + Session.CHANNEL_ID , sessionData.get(Session.CHANNEL_ID));
-
- @SuppressWarnings("unchecked")
- Map<String, Object> statistics = (Map<String, Object>) sessionData.get(Asserts.STATISTICS_ATTRIBUTE);
- Asserts.assertAttributesPresent(statistics, "consumerCount",
- "unacknowledgedMessages");
-
- assertEquals("Unexpected value of statistic attribute " + "unacknowledgedMessages", 1,
- statistics.get("unacknowledgedMessages"));
-
- assertEquals("Unexpected value of statistic attribute " + "consumerCount", 1,
- statistics.get("consumerCount"));
- }
-
- private String getConnectionName() throws IOException
- {
- List<Map<String, Object>> connections = getRestTestHelper().getJsonAsList("virtualhost/test/test/getConnections");
- assertEquals("Unexpected number of connections", 1, connections.size());
- Map<String, Object> connection = connections.get(0);
- String connectionName = (String) connection.get(Connection.NAME);
- return connectionName;
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org