http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupCreator.java ---------------------------------------------------------------------- diff --git a/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupCreator.java b/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupCreator.java deleted file mode 100644 index d7e6b7f..0000000 --- a/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupCreator.java +++ /dev/null @@ -1,514 +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.store.berkeleydb.replication; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.StringWriter; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.concurrent.Callable; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import javax.jms.Connection; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.sleepycat.je.rep.ReplicationConfig; -import org.junit.Assert; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.server.model.Port; -import org.apache.qpid.server.model.Protocol; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.virtualhost.berkeleydb.BDBHAVirtualHostImpl; -import org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode; -import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHARemoteReplicationNode; -import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNode; -import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNodeImpl; -import org.apache.qpid.systest.rest.RestTestHelper; -import org.apache.qpid.systests.ConnectionBuilder; -import org.apache.qpid.test.utils.BrokerHolder; -import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.test.utils.TestBrokerConfiguration; - -public class GroupCreator -{ - private static final Logger LOGGER = LoggerFactory.getLogger(GroupCreator.class); - - private static final int FAILOVER_CYCLECOUNT = 40; - private static final int FAILOVER_CONNECTDELAY = 1000; - - private final QpidBrokerTestCase _testcase; - private final String _virtualHostName; - - private final String _ipAddressOfBroker; - private final String _groupName ; - private final int _numberOfNodes; - private int _bdbHelperPort; - private int _primaryBrokerPort; - private Map<Integer, GroupMember> _members; - - public GroupCreator(QpidBrokerTestCase testcase, String virtualHostName, int numberOfNodes) - { - _members = new TreeMap<>(); - _testcase = testcase; - _virtualHostName = virtualHostName; - _groupName = virtualHostName; - _ipAddressOfBroker = getIpAddressOfBrokerHost(); - _numberOfNodes = numberOfNodes; - _bdbHelperPort = 0; - } - - public void configureClusterNodes() throws Exception - { - int[] bdbPorts = new int[_numberOfNodes]; - int httpPort = 0; - for (int i = 0; i < _numberOfNodes; i++) - { - int brokerPort = i==0 ? _testcase.findFreePort() : _testcase.getNextAvailable(httpPort + 1); - int bdbPort = _testcase.getNextAvailable(brokerPort + 1); - httpPort = _testcase.getNextAvailable(bdbPort + 1); - GroupMember member = new GroupMember(); - member._amqpPort = brokerPort; - member._bdbPort = bdbPort; - member._httpPort = httpPort; - bdbPorts[i] = bdbPort; - _members.put(member._amqpPort, member); - } - - String bluePrintJson = getBlueprint(); - List<String> permittedNodes = getPermittedNodes(_ipAddressOfBroker, bdbPorts); - - String helperName = null; - for (GroupMember member: _members.values()) - { - int brokerPort = member._amqpPort; - int bdbPort = member._bdbPort; - LOGGER.debug("Cluster broker port " + brokerPort + ", bdb replication port " + bdbPort); - if (_bdbHelperPort == 0) - { - _bdbHelperPort = bdbPort; - _primaryBrokerPort = brokerPort; - } - - String nodeName = getNodeNameForNodeAt(bdbPort); - if (helperName == null) - { - helperName = nodeName; - } - - Map<String, Object> virtualHostNodeAttributes = new HashMap<>(); - virtualHostNodeAttributes.put(BDBHAVirtualHostNode.GROUP_NAME, _groupName); - virtualHostNodeAttributes.put(BDBHAVirtualHostNode.NAME, nodeName); - virtualHostNodeAttributes.put(BDBHAVirtualHostNode.ADDRESS, getNodeHostPortForNodeAt(bdbPort)); - virtualHostNodeAttributes.put(BDBHAVirtualHostNode.HELPER_ADDRESS, getHelperHostPort()); - virtualHostNodeAttributes.put(BDBHAVirtualHostNode.TYPE, BDBHAVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE); - virtualHostNodeAttributes.put(BDBHAVirtualHostNode.HELPER_NODE_NAME, helperName); - virtualHostNodeAttributes.put(BDBHAVirtualHostNode.PERMITTED_NODES, permittedNodes); - - Map<String, String> context = new HashMap<>(); - context.put(ReplicationConfig.INSUFFICIENT_REPLICAS_TIMEOUT, "2 s"); - context.put(ReplicationConfig.ELECTIONS_PRIMARY_RETRIES, "0"); - context.put(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_CONTEXT_VAR, bluePrintJson); - virtualHostNodeAttributes.put(BDBHAVirtualHostNode.CONTEXT, context); - - BrokerHolder broker = _testcase.createSpawnedBroker(brokerPort); - member._brokerHolder = broker; - TestBrokerConfiguration brokerConfiguration = broker.getConfiguration(); - brokerConfiguration.addHttpManagementConfiguration(); - brokerConfiguration.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, Port.PORT, member._httpPort); - brokerConfiguration.setObjectAttributes(VirtualHostNode.class, _virtualHostName, virtualHostNodeAttributes); - } - } - - public void setDesignatedPrimaryOnFirstBroker(boolean designatedPrimary) throws Exception - { - if (_numberOfNodes != 2) - { - throw new IllegalArgumentException("Only two nodes groups have the concept of primary"); - } - final GroupMember groupMember = _members.get(_primaryBrokerPort); - TestBrokerConfiguration config = groupMember._brokerHolder.getConfiguration(); - String nodeName = getNodeNameForNodeAt(groupMember._bdbPort); - config.setObjectAttribute(VirtualHostNode.class, nodeName, BDBHAVirtualHostNode.DESIGNATED_PRIMARY, designatedPrimary); - config.setSaved(false); - } - - public void startNode(final int brokerPortNumber) throws Exception - { - _members.get(brokerPortNumber)._brokerHolder.start(); - } - - public void startCluster() throws Exception - { - for (final GroupMember member : _members.values()) - { - member._brokerHolder.start(); - } - } - - public void startClusterParallel() throws Exception - { - final ExecutorService executor = Executors.newFixedThreadPool(_members.size()); - try - { - List<Future<Object>> brokerStartFutures = new CopyOnWriteArrayList<>(); - for (final GroupMember member : _members.values()) - { - Future<Object> future = executor.submit(new Callable<Object>() - { - @Override - public Object call() - { - try - { - member._brokerHolder.start(); - return "OK"; - } - catch (Exception e) - { - return e; - } - } - }); - brokerStartFutures.add(future); - } - for (Future<Object> future : brokerStartFutures) - { - Object result = future.get(30, TimeUnit.SECONDS); - LOGGER.debug("Node startup result:" + result); - if (result instanceof Exception) - { - throw (Exception) result; - } - else if (!"OK".equals(result)) - { - throw new Exception("One of the cluster nodes is not started"); - } - } - } - catch (Exception e) - { - stopCluster(); - throw e; - } - finally - { - executor.shutdown(); - } - - } - - public void stopNode(final int brokerPortNumber) - { - _members.get(brokerPortNumber)._brokerHolder.kill(); - } - - public void stopCluster() throws Exception - { - for (final GroupMember member : _members.values()) - { - try - { - member._brokerHolder.kill(); - } - catch(Exception e) - { - LOGGER.warn("Failed to stop node on port: " + member._amqpPort); - } - } - } - - public int getBrokerPortNumberFromConnection(Connection connection) - { - return _testcase.getJmsProvider().getConnectedURI(connection).getPort(); - } - - public int getPortNumberOfAnInactiveBroker(final Connection activeConnection) - { - final Set<Integer> allBrokerPorts = new HashSet<>(_members.keySet()); - LOGGER.debug("Broker ports:" + allBrokerPorts); - final int activeBrokerPort = getBrokerPortNumberFromConnection(activeConnection); - allBrokerPorts.remove(activeBrokerPort); - LOGGER.debug("Broker ports:" + allBrokerPorts); - return allBrokerPorts.iterator().next(); - } - - public Set<Integer> getBdbPortNumbers() - { - HashSet<Integer> ports = new HashSet<>(); - for (final GroupMember member : _members.values()) - { - ports.add(member._bdbPort); - } - return ports; - } - - public ConnectionBuilder getConnectionBuilderForAllClusterNodes() throws Exception - { - return getConnectionBuilderForAllClusterNodes(FAILOVER_CONNECTDELAY, FAILOVER_CYCLECOUNT); - } - - public ConnectionBuilder getConnectionBuilderForAllClusterNodes(int connectDelay, final int cyclecount) throws Exception - { - final ConnectionBuilder connectionBuilder = _testcase.getConnectionBuilder(); - connectionBuilder.setFailoverReconnectDelay(connectDelay); - connectionBuilder.setVirtualHost(_virtualHostName); - connectionBuilder.setFailover(true); - - final int reconnectAttempts = cyclecount == 0 ? 1 : cyclecount; - connectionBuilder.setFailoverReconnectAttempts(reconnectAttempts); - - final Iterator<Integer> iterator = _members.keySet().iterator(); - if (iterator.hasNext()) - { - final int firstBroker = iterator.next(); - connectionBuilder.setPort(firstBroker); - } - - while (iterator.hasNext()) - { - int brokerPortNumber = iterator.next(); - connectionBuilder.addFailoverPort(brokerPortNumber); - } - - return connectionBuilder; - } - - public String getGroupName() - { - return _groupName; - } - - public String getNodeNameForNodeAt(final int bdbPort) - { - return "node" + _testcase.getName() + bdbPort; - } - - public String getNodeHostPortForNodeAt(final int bdbPort) - { - return _ipAddressOfBroker + ":" + bdbPort; - } - - public String getHelperHostPort() - { - if (_bdbHelperPort == 0) - { - throw new IllegalStateException("Helper port not yet assigned."); - } - - return _ipAddressOfBroker + ":" + _bdbHelperPort; - } - - public int getBrokerPortNumberOfPrimary() - { - if (_numberOfNodes != 2) - { - throw new IllegalArgumentException("Only two nodes groups have the concept of primary"); - } - - return _primaryBrokerPort; - } - - public int getBrokerPortNumberOfSecondaryNode() - { - final Set<Integer> portNumbers = getBrokerPortNumbersForNodes(); - portNumbers.remove(getBrokerPortNumberOfPrimary()); - return portNumbers.iterator().next(); - } - - public Set<Integer> getBrokerPortNumbersForNodes() - { - return new HashSet<>(_members.keySet()); - } - - - public String getIpAddressOfBrokerHost() - { - String brokerHost = "localhost"; - try - { - return InetAddress.getByName(brokerHost).getHostAddress(); - } - catch (UnknownHostException e) - { - throw new RuntimeException("Could not determine IP address of host : " + brokerHost, e); - } - } - - public String getNodeNameForBrokerPort(final int brokerPort) - { - return getNodeNameForNodeAt(_members.get(brokerPort)._bdbPort); - } - - public void setNodeAttributes(int brokerPort, Map<String, Object> attributeMap) - throws Exception - { - setNodeAttributes(brokerPort, brokerPort, attributeMap); - } - - public void setNodeAttributes(int localNodePort, int remoteNodePort, Map<String, Object> attributeMap) - throws Exception - { - RestTestHelper restHelper = createRestTestHelper(localNodePort); - String url = getNodeRestUrl(localNodePort, remoteNodePort); - int status = restHelper.submitRequest(url, "PUT", attributeMap); - if (status != 200) - { - throw new Exception("Unexpected http status when updating " + getNodeNameForBrokerPort(remoteNodePort) + " attribute(s) : " + status); - } - } - - private String getNodeRestUrl(int localNodePort, int remoteNodePort) - { - String remoteNodeName = getNodeNameForBrokerPort(remoteNodePort); - String localNodeName = getNodeNameForBrokerPort(localNodePort); - String url; - if (localNodePort == remoteNodePort) - { - url = "/api/latest/virtualhostnode/" + localNodeName; - } - else - { - url = "/api/latest/remotereplicationnode/" + localNodeName + "/" + remoteNodeName; - } - return url; - } - - public Map<String, Object> getNodeAttributes(int brokerPort) throws IOException - { - return getNodeAttributes(brokerPort, brokerPort); - } - - public Map<String, Object> getNodeAttributes(int localNodePort, int remoteNodePort) throws IOException - { - RestTestHelper restHelper = createRestTestHelper(localNodePort); - try - { - return restHelper.getJsonAsMap(getNodeRestUrl(localNodePort, remoteNodePort)); - } - catch (FileNotFoundException e) - { - return Collections.emptyMap(); - } - } - - public void awaitNodeToAttainRole(int brokerPort, String... desiredRole) throws Exception - { - awaitNodeToAttainRole(brokerPort, brokerPort, desiredRole); - } - - public void awaitNodeToAttainRole(int localNodePort, int remoteNodePort, String... desiredRole) throws Exception - { - awaitNodeToAttainAttributeValue(localNodePort, remoteNodePort, BDBHARemoteReplicationNode.ROLE, desiredRole); - } - - public void awaitNodeToAttainAttributeValue(int localNodePort, int remoteNodePort, String attributeName, String... desiredValue) throws Exception - { - final long startTime = System.currentTimeMillis(); - List<String> desiredValues = Arrays.asList( desiredValue ); - String attributeValue = null; - while((System.currentTimeMillis() - startTime) < 30000) - { - LOGGER.debug("Awaiting node '" + getNodeNameForBrokerPort(remoteNodePort) + "' attribute " + - attributeName + " to have value set to any of " + desiredValues); - Map<String, Object> data = getNodeAttributes(localNodePort, remoteNodePort); - attributeValue = String.valueOf(data.get(attributeName)); - if (desiredValues.contains(attributeValue)) - { - break; - } - else - { - Thread.sleep(1000); - } - } - LOGGER.debug("Node '{}' attribute '{}' value '{}'", getNodeNameForBrokerPort(remoteNodePort), attributeName, attributeValue); - Assert.assertTrue(String.format("Node port %d: Attribute '%s' has unexpected value '%s', desired values [%s]", - localNodePort, - attributeName, - attributeValue, - desiredValues), - desiredValues.contains(attributeValue)); - } - - public RestTestHelper createRestTestHelper(int brokerPort) - { - int httpPort = _members.get(brokerPort)._httpPort; - return new RestTestHelper(httpPort); - } - - public static String getBlueprint() throws Exception - { - Map<String,Object> bluePrint = new HashMap<>(); - bluePrint.put(VirtualHost.TYPE, BDBHAVirtualHostImpl.VIRTUAL_HOST_TYPE); - - StringWriter writer = new StringWriter(); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.INDENT_OUTPUT, true); - mapper.writeValue(writer, bluePrint); - return writer.toString(); - } - - public static List<String> getPermittedNodes(String hostName, int... ports) - { - List<String> permittedNodes = new ArrayList<>(); - for (int port: ports) - { - permittedNodes.add(hostName + ":" + port); - } - return permittedNodes; - } - - public Map<Integer, String> groupThreadumps() - { - Map<Integer,String> threadDumps = new HashMap<>(); - for(GroupMember m: _members.values()) - { - threadDumps.put(m._amqpPort, m._brokerHolder.dumpThreads()); - } - return threadDumps; - } - - private class GroupMember - { - int _amqpPort; - int _bdbPort; - int _httpPort; - BrokerHolder _brokerHolder; - } -}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupJmsTestBase.java ---------------------------------------------------------------------- diff --git a/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupJmsTestBase.java b/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupJmsTestBase.java index 1c2e6fc..e209dd2 100644 --- a/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupJmsTestBase.java +++ b/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupJmsTestBase.java @@ -23,12 +23,15 @@ package org.apache.qpid.server.store.berkeleydb.replication; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeThat; import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Queue; import javax.jms.Session; +import org.junit.BeforeClass; + import org.apache.qpid.systests.ConnectionBuilder; import org.apache.qpid.systests.JmsProvider; import org.apache.qpid.systests.JmsTestBase; @@ -43,6 +46,12 @@ public class GroupJmsTestBase extends JmsTestBase static final int SHORT_FAILOVER_CYCLECOUNT = 2; static final int SHORT_FAILOVER_CONNECTDELAY = 200; + @BeforeClass + public static void verify() + { + assumeThat(System.getProperty("virtualhostnode.type", "BDB"), is(equalTo("BDB"))); + } + @Override public GroupBrokerAdmin getBrokerAdmin() { http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 93ee991..5b56477 100644 --- a/pom.xml +++ b/pom.xml @@ -460,6 +460,12 @@ <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.qpid</groupId> + <artifactId>qpid-systests-http</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/3a6893e4/qpid-perftests-systests/pom.xml ---------------------------------------------------------------------- diff --git a/qpid-perftests-systests/pom.xml b/qpid-perftests-systests/pom.xml index eec0c5d..57b724f 100644 --- a/qpid-perftests-systests/pom.xml +++ b/qpid-perftests-systests/pom.xml @@ -65,17 +65,15 @@ <optional>true</optional> </dependency> + <dependency> + <groupId>org.apache.qpid</groupId> + <artifactId>qpid-systests-http</artifactId> + <scope>test</scope> + </dependency> + </dependencies> <build> - <resources> - <resource> - <directory>src/main/resources</directory> - </resource> - <resource> - <directory>${test.resource.directory}/test-profiles/test_resources</directory> - </resource> - </resources> <testResources> <testResource> <directory>src/test/java</directory> @@ -86,6 +84,12 @@ <testResource> <directory>src/test/resources</directory> </testResource> + <testResource> + <directory>${basedir}/../test-profiles/test_resources/ssl</directory> + <includes> + <include>*.jks</include> + </includes> + </testResource> </testResources> </build> http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/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 74e5ddd..ceeb585 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 @@ -21,27 +21,35 @@ package org.apache.qpid.systest.disttest.endtoend; import static org.apache.qpid.disttest.AbstractRunner.JNDI_CONFIG_PROP; import static org.apache.qpid.disttest.ControllerRunner.HILL_CLIMB; import static org.apache.qpid.disttest.ControllerRunner.HILL_CLIMBER_CONSUMPTION_TO_PRODUCTION_RATIO_SUCCESS_THRESHOLD; -import static org.apache.qpid.disttest.ControllerRunner.HILL_CLIMBER_MINIMUM_DELTA; import static org.apache.qpid.disttest.ControllerRunner.HILL_CLIMBER_MAX_NUMBER_OF_RUNS; +import static org.apache.qpid.disttest.ControllerRunner.HILL_CLIMBER_MINIMUM_DELTA; import static org.apache.qpid.disttest.ControllerRunner.HILL_CLIMBER_PRODUCTION_TO_TARGET_RATIO_SUCCESS_THRESHOLD; import static org.apache.qpid.disttest.ControllerRunner.HILL_CLIMBER_START_TARGET_RATE; import static org.apache.qpid.disttest.ControllerRunner.OUTPUT_DIR_PROP; import static org.apache.qpid.disttest.ControllerRunner.TEST_CONFIG_PROP; +import static org.apache.qpid.tests.http.HttpTestBase.DEFAULT_BROKER_CONFIG; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeThat; 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.Files; import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import org.apache.qpid.disttest.ControllerRunner; import org.apache.qpid.disttest.DistributedTestException; import org.apache.qpid.disttest.controller.config.QueueConfig; @@ -49,60 +57,66 @@ import org.apache.qpid.disttest.jms.QpidQueueCreatorFactory; import org.apache.qpid.disttest.jms.QpidRestAPIQueueCreator; import org.apache.qpid.disttest.message.ParticipantAttribute; import org.apache.qpid.disttest.results.aggregation.TestResultAggregator; -import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.test.utils.TestFileUtils; +import org.apache.qpid.server.model.Protocol; +import org.apache.qpid.tests.http.HttpTestBase; +import org.apache.qpid.tests.utils.BrokerAdmin; +import org.apache.qpid.tests.utils.ConfigItem; import org.apache.qpid.util.FileUtils; -public class EndToEndTest extends QpidBrokerTestCase +@ConfigItem(name = "qpid.initialConfigurationLocation", value = DEFAULT_BROKER_CONFIG ) +public class EndToEndTest extends HttpTestBase { private static final String TEST_CONFIG_ITERATIONS = "qpid-perftests-systests/src/test/resources/org/apache/qpid/systest/disttest/endtoend/iterations.json"; private static final String TEST_CONFIG_MANYPARTICIPANTS = "qpid-perftests-systests/src/test/resources/org/apache/qpid/systest/disttest/endtoend/manyparticipants.json"; private static final String TEST_CONFIG_HILLCLIMBING = "qpid-perftests-systests/src/test/resources/org/apache/qpid/systest/disttest/endtoend/hillclimbing.js"; private static final String TEST_CONFIG_ERROR = "qpid-perftests-systests/src/test/resources/org/apache/qpid/systest/disttest/endtoend/error.json"; - private static final String JNDI_CONFIG_FILE = "qpid-perftests-systests/src/test/resources/org/apache/qpid/systest/disttest/perftests.systests.properties"; + private static final int NUMBER_OF_HEADERS = 1; private static final int NUMBER_OF_SUMMARIES = 3; private File _outputDir; private File _jndiConfigFile; - @Override + @Before public void setUp() throws Exception { - getDefaultBrokerConfiguration().addHttpManagementConfiguration(); - super.setUp(); - setSystemProperty("perftests.manangement-url", String.format("http://localhost:%d", getDefaultBroker().getHttpPort())); - setSystemProperty("perftests.broker-virtualhostnode", "test"); - setSystemProperty("perftests.broker-virtualhost", "test"); - setSystemProperty(QpidQueueCreatorFactory.QUEUE_CREATOR_CLASS_NAME_SYSTEM_PROPERTY, QpidRestAPIQueueCreator.class.getName()); + System.setProperty("perftests.manangement-url", String.format("http://localhost:%d", getBrokerAdmin().getBrokerAddress( + BrokerAdmin.PortType.HTTP).getPort())); + System.setProperty("perftests.broker-virtualhostnode", getVirtualHost()); + System.setProperty("perftests.broker-virtualhost", getVirtualHost()); + System.setProperty(QpidQueueCreatorFactory.QUEUE_CREATOR_CLASS_NAME_SYSTEM_PROPERTY, QpidRestAPIQueueCreator.class.getName()); _outputDir = createTemporaryOutputDirectory(); - assertTrue("Output dir must not exist", _outputDir.isDirectory()); + assumeThat("Output dir must not exist", _outputDir.isDirectory(), is(equalTo(true))); _jndiConfigFile = getJNDIPropertiesFile(); QpidRestAPIQueueCreator queueCreator = new QpidRestAPIQueueCreator(); QueueConfig queueConfig = new QueueConfig("controllerqueue", true, Collections.<String, Object>emptyMap()); queueCreator.createQueues(null, null, Collections.<QueueConfig>singletonList(queueConfig)); } - @Override - public void tearDown() throws Exception + @After + public void tearDown() { try { if (_outputDir != null && _outputDir.exists()) { - FileUtils.delete(_outputDir, true); + FileUtils.delete(_outputDir, true); } - if (_jndiConfigFile != null && !new File(JNDI_CONFIG_FILE).equals(_jndiConfigFile)) + if (_jndiConfigFile != null) { FileUtils.delete(_jndiConfigFile, true); } } finally { - super.tearDown(); + System.clearProperty("perftests.manangement-url"); + System.clearProperty("perftests.broker-virtualhostnode"); + System.clearProperty("perftests.broker-virtualhost"); + System.clearProperty(QpidQueueCreatorFactory.QUEUE_CREATOR_CLASS_NAME_SYSTEM_PROPERTY); } } + @Test public void testIterations() throws Exception { Map<String, String> arguments = new HashMap<>(); @@ -120,7 +134,7 @@ public class EndToEndTest extends QpidBrokerTestCase int dataRowsPerIteration = numberOfParticipants + NUMBER_OF_SUMMARIES; int numberOfExpectedRows = NUMBER_OF_HEADERS + dataRowsPerIteration * numberOfIterations; - assertEquals("Unexpected number of lines in CSV", numberOfExpectedRows, csvLines.length); + assertThat("Unexpected number of lines in CSV", csvLines.length, is(equalTo(numberOfExpectedRows))); final String testName = "Iterations"; assertDataRowsForIterationArePresent(csvLines, testName, 0, dataRowsPerIteration); @@ -129,6 +143,7 @@ public class EndToEndTest extends QpidBrokerTestCase assertDataRowHasCorrectTestAndClientName(testName, "", TestResultAggregator.ALL_PARTICIPANTS_NAME, csvLines[4 + dataRowsPerIteration]); } + @Test public void testManyParticipants() throws Exception { Map<String, String> arguments = new HashMap<>(); @@ -145,7 +160,7 @@ public class EndToEndTest extends QpidBrokerTestCase int dataRowsPerIteration = numberOfParticipants + NUMBER_OF_SUMMARIES; int numberOfExpectedRows = NUMBER_OF_HEADERS + dataRowsPerIteration; - assertEquals("Unexpected number of lines in CSV", numberOfExpectedRows, csvLines.length); + assertThat("Unexpected number of lines in CSV", csvLines.length, is(equalTo(numberOfExpectedRows))); int actualMessagesSent = 0; int reportedTotalMessagesSent = 0; @@ -180,15 +195,14 @@ public class EndToEndTest extends QpidBrokerTestCase } } - assertEquals("Reported total messages sent does not match total sent by producers", - reportedTotalMessagesSent, - actualMessagesSent); - assertEquals("Reported total messages received does not match total received by consumers", - reportedTotalMessagesReceived, - actualMessagesReceived); + assertThat("Reported total messages sent does not match total sent by producers", + actualMessagesSent, is(equalTo(reportedTotalMessagesSent))); + assertThat("Reported total messages received does not match total received by consumers", + actualMessagesReceived, is(equalTo(reportedTotalMessagesReceived))); } + @Test public void testHillClimbing() throws Exception { Map<String, String> arguments = new HashMap<>(); @@ -212,7 +226,7 @@ public class EndToEndTest extends QpidBrokerTestCase int numberOfParticipants = 2; int numberOfExpectedRows = NUMBER_OF_HEADERS + numberOfParticipants + NUMBER_OF_SUMMARIES; - assertEquals("Unexpected number of lines in CSV", numberOfExpectedRows, csvLines.length); + assertThat("Unexpected number of lines in CSV", csvLines.length, is(equalTo(numberOfExpectedRows))); final String testName = "HillClimbing"; assertDataRowHasCorrectTestAndClientName(testName, "producingClient", "Producer1", csvLines[1]); @@ -229,6 +243,7 @@ public class EndToEndTest extends QpidBrokerTestCase } + @Test public void testTestScriptCausesError() throws Exception { Map<String, String> arguments = new HashMap<>(); @@ -267,7 +282,7 @@ public class EndToEndTest extends QpidBrokerTestCase String expectedCsvFilename = buildOutputFilename(testConfig, ".csv"); File expectedCsvOutputFile = new File(_outputDir, expectedCsvFilename); - assertTrue("CSV output file must exist", expectedCsvOutputFile.exists()); + assertThat("CSV output file must exist", expectedCsvOutputFile.exists(), is(equalTo(true))); final String csvContents = FileUtils.readFileAsString(expectedCsvOutputFile); return csvContents.split("\n"); } @@ -278,7 +293,7 @@ public class EndToEndTest extends QpidBrokerTestCase String expectedXmlFilename = buildOutputFilename(testConfig, ".xml"); File expectedXmlOutputFile = new File(_outputDir, expectedXmlFilename); - assertTrue("XML output file must exist", expectedXmlOutputFile.exists()); + assertThat("XML output file must exist", expectedXmlOutputFile.exists(), is(equalTo(true))); } private String buildOutputFilename(final String testConfig, final String extension) @@ -303,7 +318,9 @@ public class EndToEndTest extends QpidBrokerTestCase } } - assertEquals("Unexpected number of data rows for test name " + testName + " iteration nunber " + iterationNumber, expectedCount, actualCount); + assertThat(String.format("Unexpected number of data rows for test name %s iteration number %d", + testName, + iterationNumber), actualCount, is(equalTo(expectedCount))); } private void assertDataRowHasThroughputValues(String csvLine) @@ -312,21 +329,34 @@ public class EndToEndTest extends QpidBrokerTestCase double throughput = Double.valueOf(cells[ParticipantAttribute.THROUGHPUT.ordinal()]); int messageThroughput = Integer.valueOf(cells[ParticipantAttribute.MESSAGE_THROUGHPUT.ordinal()]); - assertTrue("Throughput in line " + csvLine + " is not greater than zero : " + throughput, throughput > 0); - assertTrue("Message throughput in line " + csvLine + " is not greater than zero : " + messageThroughput, messageThroughput > 0); - + assertThat("Throughput in line " + csvLine + " is not greater than zero : " + throughput, + throughput > 0, + is(equalTo(true))); + assertThat("Message throughput in line " + csvLine + " is not greater than zero : " + messageThroughput, + messageThroughput > 0, + is(equalTo(true))); } - private void assertDataRowHasCorrectTestAndClientName(String testName, String clientName, String participantName, String csvLine) + private void assertDataRowHasCorrectTestAndClientName(String testName, + String clientName, + String participantName, + String csvLine) { String[] cells = splitCsvCells(csvLine); // All attributes become cells in the CSV, so this will be true - assertEquals("Unexpected number of cells in CSV line " + csvLine, ParticipantAttribute.values().length, cells.length); - assertEquals("Unexpected test name in CSV line " + csvLine, testName, cells[ParticipantAttribute.TEST_NAME.ordinal()]); - assertEquals("Unexpected client name in CSV line " + csvLine, clientName, cells[ParticipantAttribute.CONFIGURED_CLIENT_NAME.ordinal()]); - assertEquals("Unexpected participant name in CSV line " + csvLine, participantName, cells[ParticipantAttribute.PARTICIPANT_NAME.ordinal()]); - + assertThat("Unexpected number of cells in CSV line " + csvLine, + cells.length, + is(equalTo(ParticipantAttribute.values().length))); + assertThat("Unexpected test name in CSV line " + csvLine, + cells[ParticipantAttribute.TEST_NAME.ordinal()], + is(equalTo(testName))); + assertThat("Unexpected client name in CSV line " + csvLine, + cells[ParticipantAttribute.CONFIGURED_CLIENT_NAME.ordinal()], + is(equalTo(clientName))); + assertThat("Unexpected participant name in CSV line " + csvLine, + cells[ParticipantAttribute.PARTICIPANT_NAME.ordinal()], + is(equalTo(participantName))); } private String[] splitCsvCells(String csvLine) @@ -346,56 +376,22 @@ public class EndToEndTest extends QpidBrokerTestCase private File getJNDIPropertiesFile() throws Exception { - if (isBroker10()) - { - Map<String,String> options = new LinkedHashMap<>(); - options.put("amqp.vhost", "test"); - options.put("jms.username", GUEST_USERNAME); - options.put("jms.password", GUEST_PASSWORD); - - StringBuilder stem = new StringBuilder("amqp://localhost:").append(System.getProperty("test.port")); - appendOptions(options, stem); - - Properties properties = new Properties(); - properties.put("connectionfactory.connectionfactory", stem.toString()); - properties.put("java.naming.factory.initial", "org.apache.qpid.jms.jndi.JmsInitialContextFactory"); - properties.put("queue.controllerqueue", "controllerqueue"); - - File propertiesFile = TestFileUtils.createTempFile(this, ".jndi.properties"); - try(OutputStream os = new FileOutputStream(propertiesFile)) - { - properties.store(os, null); - } - return propertiesFile; - } - else + String connectionUrl = getConnectionBuilder().setClientId(null).buildConnectionURL(); + String factoryClass = getProtocol() == Protocol.AMQP_1_0 + ? "org.apache.qpid.jms.jndi.JmsInitialContextFactory" + : "org.apache.qpid.jndi.PropertiesFileInitialContextFactory"; + + Properties properties = new Properties(); + properties.put("connectionfactory.connectionfactory", connectionUrl); + properties.put("java.naming.factory.initial", factoryClass); + properties.put("queue.controllerqueue", "controllerqueue"); + + File propertiesFile = Files.createTempFile("perftests", ".jndi.properties").toFile(); + try (OutputStream os = new FileOutputStream(propertiesFile)) { - return new File(JNDI_CONFIG_FILE); + properties.store(os, null); } + return propertiesFile; } - 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/3a6893e4/qpid-perftests-systests/src/test/resources/org/apache/qpid/systest/disttest/perftests.systests.properties ---------------------------------------------------------------------- diff --git a/qpid-perftests-systests/src/test/resources/org/apache/qpid/systest/disttest/perftests.systests.properties b/qpid-perftests-systests/src/test/resources/org/apache/qpid/systest/disttest/perftests.systests.properties deleted file mode 100644 index 23f101f..0000000 --- a/qpid-perftests-systests/src/test/resources/org/apache/qpid/systest/disttest/perftests.systests.properties +++ /dev/null @@ -1,29 +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. - -# this file is used for running system tests of the performance test framework, -# (i.e. not for running the performance tests themselves!) - -java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory - -# use QpidBrokerTestCase's default port -connectionfactory.connectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:${test.port}' - -destination.controllerqueue = direct://amq.direct//controllerqueue - -jdbcDriverClass=org.apache.derby.jdbc.EmbeddedDriver -jdbcUrl=jdbc:derby:/tmp/tempDbDirectory/perftestResultsDb;create=true http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java b/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java index 91255ef..04f37ea 100644 --- a/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java +++ b/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestBase.java @@ -42,6 +42,8 @@ import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase; public abstract class HttpTestBase extends BrokerAdminUsingTestBase { + public static final String DEFAULT_BROKER_CONFIG = "classpath:config-http-management-tests.json"; + @Rule public final TestName _testName = new TestName(); http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/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 index 5ac57cf..1d54210 100644 --- 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 @@ -132,13 +132,20 @@ public class AmqpManagementFacade } producer.close(); + return receiveManagementResponse(consumer, replyToDestination, 201); + } + + private Map<String, Object> receiveManagementResponse(final MessageConsumer consumer, + final Destination replyToDestination, + final int responseStatus) throws JMSException + { Message response = consumer.receive(5000); try { if (response != null) { int statusCode = response.getIntProperty("statusCode"); - if (statusCode == 201) + if (statusCode == responseStatus) { if (response instanceof MapMessage) { @@ -163,6 +170,10 @@ public class AmqpManagementFacade return new HashMap<>(bodyMap); } } + else + { + return Collections.emptyMap(); + } } else { @@ -170,7 +181,7 @@ public class AmqpManagementFacade } } - throw new IllegalArgumentException("Cannot parse the results from a management query"); + throw new IllegalArgumentException("Cannot parse the results from a management response"); } finally { @@ -182,12 +193,50 @@ public class AmqpManagementFacade } } + public Map<String,Object> updateEntityUsingAmqpManagementAndReceiveResponse(final String name, + final String type, + Map<String, Object> attributes, + final Session session) + throws JMSException + { + + Destination replyToDestination; + Destination replyConsumerDestination; + if (_protocol == Protocol.AMQP_1_0) + { + replyToDestination = session.createTemporaryQueue(); + replyConsumerDestination = replyToDestination; + } + else + { + replyToDestination = session.createQueue(AMQP_0_X_REPLY_TO_DESTINATION); + replyConsumerDestination = session.createQueue(AMQP_0_X_CONSUMER_REPLY_DESTINATION); + } + + MessageConsumer consumer = session.createConsumer(replyConsumerDestination); + + updateEntityUsingAmqpManagement(name, type, attributes, replyToDestination, session); + + return receiveManagementResponse(consumer, replyToDestination, 200); + } + + public void updateEntityUsingAmqpManagement(final String name, final Session session, final String type, Map<String, Object> attributes) throws JMSException { + updateEntityUsingAmqpManagement(name, type, attributes, null, session); + } + + private void updateEntityUsingAmqpManagement(final String name, + final String type, + Map<String, Object> attributes, + Destination replyToDestination, + final Session session) + throws JMSException + { MessageProducer producer = session.createProducer(session.createQueue(_managementAddress)); MapMessage createMessage = session.createMapMessage(); @@ -195,6 +244,7 @@ public class AmqpManagementFacade createMessage.setStringProperty("operation", "UPDATE"); createMessage.setStringProperty("index", "object-path"); createMessage.setStringProperty("key", name); + createMessage.setJMSReplyTo(replyToDestination); for (Map.Entry<String, Object> entry : attributes.entrySet()) { createMessage.setObject(entry.getKey(), entry.getValue()); http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/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 index 2fa7b16..4f113b4 100644 --- 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 @@ -67,4 +67,5 @@ public interface ConnectionBuilder Connection build() throws NamingException, JMSException; ConnectionFactory buildConnectionFactory() throws NamingException; + String buildConnectionURL(); } http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/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 index e654672..c264b6b 100644 --- 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 @@ -52,6 +52,8 @@ import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase; public abstract class JmsTestBase extends BrokerAdminUsingTestBase { + public static final String DEFAULT_BROKER_CONFIG = "classpath:config-jms-tests.json"; + private static final Logger LOGGER = LoggerFactory.getLogger(JmsTestBase.class); private static JmsProvider _jmsProvider; private static AmqpManagementFacade _managementFacade; @@ -232,7 +234,7 @@ public abstract class JmsTestBase extends BrokerAdminUsingTestBase Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); try { - _managementFacade.updateEntityUsingAmqpManagement(entityName, session, entityType, attributes); + _managementFacade.updateEntityUsingAmqpManagementAndReceiveResponse(entityName, entityType, attributes, session); } finally { http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/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 index 262d20b..b9590f6 100644 --- 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 @@ -273,6 +273,27 @@ public class QpidJmsClient0xConnectionBuilder implements ConnectionBuilder @Override public ConnectionFactory buildConnectionFactory() throws NamingException { + String connectionUrl = buildConnectionURL(); + + 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, connectionUrl); + InitialContext initialContext = new InitialContext(initialContextEnvironment); + try + { + return (ConnectionFactory) initialContext.lookup(factoryName); + } + finally + { + initialContext.close(); + } + } + + @Override + public String buildConnectionURL() + { StringBuilder cUrlBuilder = new StringBuilder("amqp://"); if (_username != null) { @@ -352,21 +373,7 @@ public class QpidJmsClient0xConnectionBuilder implements ConnectionBuilder { 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(); - } + return cUrlBuilder.toString(); } private String buildTransportQuery() http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/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 index b5be7d2..b5cb304 100644 --- 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 @@ -280,6 +280,25 @@ public class QpidJmsClientConnectionBuilder implements ConnectionBuilder initialContextEnvironment.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory"); + final String connectionUrl = buildConnectionURL(); + + final String factoryName = "connection"; + initialContextEnvironment.put("connectionfactory." + factoryName, connectionUrl); + + InitialContext initialContext = new InitialContext(initialContextEnvironment); + try + { + return (ConnectionFactory) initialContext.lookup(factoryName); + } + finally + { + initialContext.close(); + } + } + + @Override + public String buildConnectionURL() + { final StringBuilder connectionUrlBuilder = new StringBuilder(); final Map<String, Object> options = new TreeMap<>(); @@ -344,19 +363,7 @@ public class QpidJmsClientConnectionBuilder implements ConnectionBuilder 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(); - } + return connectionUrlBuilder.toString(); } private void appendOptions(final Map<String, Object> actualOptions, final StringBuilder stem) http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/systests/qpid-systests-spawn-admin/src/main/java/org/apache/qpid/systests/admin/SpawnBrokerAdmin.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-spawn-admin/src/main/java/org/apache/qpid/systests/admin/SpawnBrokerAdmin.java b/systests/qpid-systests-spawn-admin/src/main/java/org/apache/qpid/systests/admin/SpawnBrokerAdmin.java index 16e26e2..350a431 100644 --- a/systests/qpid-systests-spawn-admin/src/main/java/org/apache/qpid/systests/admin/SpawnBrokerAdmin.java +++ b/systests/qpid-systests-spawn-admin/src/main/java/org/apache/qpid/systests/admin/SpawnBrokerAdmin.java @@ -339,10 +339,11 @@ public class SpawnBrokerAdmin implements BrokerAdmin, Closeable throw new BrokerAdminException("Virtual host is not created"); } invokeManagementOperation(true, (amqpManagementFacade, session) -> { - amqpManagementFacade.updateEntityUsingAmqpManagement(_virtualHostNodeName, - session, - AMQP_NODE_TYPE, - Collections.singletonMap("desiredState", "ACTIVE")); + amqpManagementFacade.updateEntityUsingAmqpManagementAndReceiveResponse(_virtualHostNodeName, + AMQP_NODE_TYPE, + Collections.singletonMap( + "desiredState", + "ACTIVE"), session); return null; }); } @@ -354,10 +355,12 @@ public class SpawnBrokerAdmin implements BrokerAdmin, Closeable throw new BrokerAdminException("Virtual host is not created"); } invokeManagementOperation(true, (amqpManagementFacade, session) -> { - amqpManagementFacade.updateEntityUsingAmqpManagement(_virtualHostNodeName, - session, - AMQP_NODE_TYPE, - Collections.singletonMap("desiredState", "STOPPED")); + amqpManagementFacade.updateEntityUsingAmqpManagementAndReceiveResponse(_virtualHostNodeName, + AMQP_NODE_TYPE, + Collections.singletonMap( + "desiredState", + "STOPPED"), + session); return null; }); } http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/3a6893e4/systests/qpid-systests-spawn-admin/src/main/resources/spawn-broker.json ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-spawn-admin/src/main/resources/spawn-broker.json b/systests/qpid-systests-spawn-admin/src/main/resources/spawn-broker.json index 029457f..3d4df12 100644 --- a/systests/qpid-systests-spawn-admin/src/main/resources/spawn-broker.json +++ b/systests/qpid-systests-spawn-admin/src/main/resources/spawn-broker.json @@ -70,6 +70,9 @@ "name" : "defaultAlias", "type" : "defaultAlias" }, { + "name" : "hostnameAlias", + "type" : "hostnameAlias" + }, { "name" : "nameAlias", "type" : "nameAlias" } ] --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org