diff options
author | Robert Gemmell <robbie@apache.org> | 2011-07-07 15:16:33 +0000 |
---|---|---|
committer | Robert Gemmell <robbie@apache.org> | 2011-07-07 15:16:33 +0000 |
commit | f49bc309288098d2ab4858a6555fc30e014e949c (patch) | |
tree | 589cb21e49ea88c106b75104f2828827ec35f1dc | |
parent | aa709d3871daac1a0cd36fb52e2e3bc90074113c (diff) | |
download | qpid-python-f49bc309288098d2ab4858a6555fc30e014e949c.tar.gz |
QPID-3343: refactor test profiles to allow testing within the same JVM for all protocols, remove vm:// transport support and associated forked Mina classes
Applied patch by Keith Wall and myself
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1143874 13f79535-47bb-0310-9956-ffa450edef68
86 files changed, 374 insertions, 3764 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java index 124c2a7d08..78217c36ac 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java @@ -47,7 +47,7 @@ import org.apache.qpid.server.logging.management.LoggingManagementMBean; import org.apache.qpid.server.logging.messages.BrokerMessages; import org.apache.qpid.server.protocol.AMQProtocolEngineFactory; import org.apache.qpid.server.protocol.MultiVersionProtocolEngineFactory; -import org.apache.qpid.server.protocol.MultiVersionProtocolEngineFactory.VERSION; +import org.apache.qpid.server.protocol.AmqpProtocolVersion; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; import org.apache.qpid.server.transport.QpidAcceptor; @@ -192,24 +192,24 @@ public class Broker { for(int port : ports) { - Set<VERSION> supported = EnumSet.allOf(VERSION.class); + Set<AmqpProtocolVersion> supported = EnumSet.allOf(AmqpProtocolVersion.class); if(exclude_0_10.contains(port)) { - supported.remove(VERSION.v0_10); + supported.remove(AmqpProtocolVersion.v0_10); } if(exclude_0_9_1.contains(port)) { - supported.remove(VERSION.v0_9_1); + supported.remove(AmqpProtocolVersion.v0_9_1); } if(exclude_0_9.contains(port)) { - supported.remove(VERSION.v0_9); + supported.remove(AmqpProtocolVersion.v0_9); } if(exclude_0_8.contains(port)) { - supported.remove(VERSION.v0_8); + supported.remove(AmqpProtocolVersion.v0_8); } NetworkTransportConfiguration settings = diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java index bf554c526f..5bea33e5f3 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java @@ -39,10 +39,9 @@ public class BrokerOptions public static final String SSL_PORTS = "s"; public static final String BIND = "b"; public static final String MANAGEMENT = "m"; - public static final String LOG4J = "l"; + public static final String LOG_CONFIG = "l"; public static final String WATCH = "w"; public static final String CONFIG = "c"; - public static final String PROTOCOL = "protocol"; private final Set<Integer> _ports = new HashSet<Integer>(); private final Set<Integer> _sslPorts = new HashSet<Integer>(); @@ -51,7 +50,6 @@ public class BrokerOptions private String _configFile; private String _logConfigFile; private String _bind; - private String _transport = Transport.TCP; private Integer _jmxPort; private Integer _logWatchFrequency = 0; @@ -147,14 +145,4 @@ public class BrokerOptions { _logWatchFrequency = logWatchFrequency; } - - public String getTransport() - { - return _transport; - } - - public void setTransport(final String transport) - { - _transport = transport; - } }
\ No newline at end of file diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java index 317459942a..b9a1106b44 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java @@ -133,21 +133,21 @@ public class Main Option bind = OptionBuilder.withArgName("bind").hasArg() .withDescription("bind to the specified address. Overrides any value in the config file") - .withLongOpt("bind").create("b"); + .withLongOpt("bind").create(BrokerOptions.BIND); Option logconfig = OptionBuilder.withArgName("logconfig").hasArg() .withDescription("use the specified log4j xml configuration file. By " + "default looks for a file named " + BrokerOptions.DEFAULT_LOG_CONFIG_FILE - + " in the same directory as the configuration file").withLongOpt("logconfig").create("l"); + + " in the same directory as the configuration file").withLongOpt("logconfig").create(BrokerOptions.LOG_CONFIG); Option logwatchconfig = OptionBuilder.withArgName("logwatch").hasArg() .withDescription("monitor the log file configuration file for changes. Units are seconds. " - + "Zero means do not check for changes.").withLongOpt("logwatch").create("w"); + + "Zero means do not check for changes.").withLongOpt("logwatch").create(BrokerOptions.WATCH); Option sslport = OptionBuilder.withArgName("sslport").hasArg() .withDescription("SSL port. Overrides any value in the config file") - .withLongOpt("sslport").create("s"); + .withLongOpt("sslport").create(BrokerOptions.SSL_PORTS); options.addOption(help); options.addOption(version); @@ -179,7 +179,7 @@ public class Main options.setLogWatchFrequency(Integer.parseInt(logWatchConfig) * 1000); } - String logConfig = commandLine.getOptionValue(BrokerOptions.LOG4J); + String logConfig = commandLine.getOptionValue(BrokerOptions.LOG_CONFIG); if(logConfig != null) { options.setLogConfigFile(logConfig); diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java index 9c02cd9d2f..08f276ae72 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java @@ -40,7 +40,6 @@ import javax.management.JMException; import javax.security.sasl.SaslServer; import org.apache.log4j.Logger; -import org.apache.mina.transport.vmpipe.VmPipeAddress; import org.apache.qpid.AMQChannelException; import org.apache.qpid.AMQConnectionException; import org.apache.qpid.AMQException; @@ -830,16 +829,10 @@ public class AMQProtocolEngine implements ProtocolEngine, Managable, AMQProtocol public String getLocalFQDN() { SocketAddress address = _network.getLocalAddress(); - // we use the vmpipe address in some tests hence the need for this rather ugly test. The host - // information is used by SASL primary. if (address instanceof InetSocketAddress) { return ((InetSocketAddress) address).getHostName(); } - else if (address instanceof VmPipeAddress) - { - return "vmpipe:" + ((VmPipeAddress) address).getPort(); - } else { throw new IllegalArgumentException("Unsupported socket address class: " + address); diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/VMBrokerMap.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AmqpProtocolVersion.java index acc55c2e2d..e925d7a1ec 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/VMBrokerMap.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AmqpProtocolVersion.java @@ -18,34 +18,6 @@ * under the License. * */ -package org.apache.qpid.transport.network; +package org.apache.qpid.server.protocol; -import java.util.HashMap; -import java.util.Map; - -import org.apache.mina.transport.vmpipe.VmPipeAddress; - -public class VMBrokerMap -{ - private static final Map<Integer, VmPipeAddress> _map = new HashMap<Integer, VmPipeAddress>(); - - public static void add(int port, VmPipeAddress pipe) - { - _map.put(port, pipe); - } - - public static VmPipeAddress remove(int port) - { - return _map.remove(port); - } - - public static void clear() - { - _map.clear(); - } - - public static boolean contains(int port) - { - return _map.containsKey(port); - } -} +public enum AmqpProtocolVersion { v0_8, v0_9, v0_9_1, v0_10 }
\ No newline at end of file diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngine.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngine.java index 064d8f19a6..01b12b44ce 100755 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngine.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngine.java @@ -23,7 +23,6 @@ package org.apache.qpid.server.protocol; import org.apache.log4j.Logger; import org.apache.qpid.protocol.ProtocolEngine; -import org.apache.qpid.server.protocol.MultiVersionProtocolEngineFactory.VERSION; import org.apache.qpid.server.registry.IApplicationRegistry; import org.apache.qpid.server.transport.ServerConnection; import org.apache.qpid.transport.ConnectionDelegate; @@ -38,7 +37,7 @@ public class MultiVersionProtocolEngine implements ProtocolEngine { private static final Logger _logger = Logger.getLogger(MultiVersionProtocolEngine.class); - private Set<VERSION> _supported; + private Set<AmqpProtocolVersion> _supported; private String _fqdn; private IApplicationRegistry _appRegistry; private NetworkConnection _network; @@ -48,7 +47,7 @@ public class MultiVersionProtocolEngine implements ProtocolEngine public MultiVersionProtocolEngine(IApplicationRegistry appRegistry, String fqdn, - Set<VERSION> supported, + Set<AmqpProtocolVersion> supported, NetworkConnection network) { _appRegistry = appRegistry; @@ -152,7 +151,7 @@ private static final byte[] AMQP_0_9_1_HEADER = private static interface DelegateCreator { - VERSION getVersion(); + AmqpProtocolVersion getVersion(); byte[] getHeaderIdentifier(); ProtocolEngine getProtocolEngine(); } @@ -160,9 +159,9 @@ private static final byte[] AMQP_0_9_1_HEADER = private DelegateCreator creator_0_8 = new DelegateCreator() { - public VERSION getVersion() + public AmqpProtocolVersion getVersion() { - return VERSION.v0_8; + return AmqpProtocolVersion.v0_8; } public byte[] getHeaderIdentifier() @@ -179,9 +178,9 @@ private static final byte[] AMQP_0_9_1_HEADER = private DelegateCreator creator_0_9 = new DelegateCreator() { - public VERSION getVersion() + public AmqpProtocolVersion getVersion() { - return VERSION.v0_9; + return AmqpProtocolVersion.v0_9; } @@ -199,9 +198,9 @@ private static final byte[] AMQP_0_9_1_HEADER = private DelegateCreator creator_0_9_1 = new DelegateCreator() { - public VERSION getVersion() + public AmqpProtocolVersion getVersion() { - return VERSION.v0_9_1; + return AmqpProtocolVersion.v0_9_1; } @@ -220,9 +219,9 @@ private static final byte[] AMQP_0_9_1_HEADER = private DelegateCreator creator_0_10 = new DelegateCreator() { - public VERSION getVersion() + public AmqpProtocolVersion getVersion() { - return VERSION.v0_10; + return AmqpProtocolVersion.v0_10; } diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java index 5ccd4ff188..96d46353c6 100755 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java @@ -20,8 +20,7 @@ */ package org.apache.qpid.server.protocol; -import java.util.Arrays; -import java.util.HashSet; +import java.util.EnumSet; import java.util.Set; import org.apache.qpid.protocol.ProtocolEngine; @@ -32,13 +31,11 @@ import org.apache.qpid.transport.network.NetworkConnection; public class MultiVersionProtocolEngineFactory implements ProtocolEngineFactory { - public enum VERSION { v0_8, v0_9, v0_9_1, v0_10 }; - - private static final Set<VERSION> ALL_VERSIONS = new HashSet<VERSION>(Arrays.asList(VERSION.values())); + private static final Set<AmqpProtocolVersion> ALL_VERSIONS = EnumSet.allOf(AmqpProtocolVersion.class); private final IApplicationRegistry _appRegistry; private final String _fqdn; - private final Set<VERSION> _supported; + private final Set<AmqpProtocolVersion> _supported; public MultiVersionProtocolEngineFactory() @@ -46,7 +43,7 @@ public class MultiVersionProtocolEngineFactory implements ProtocolEngineFactory this(1, "localhost", ALL_VERSIONS); } - public MultiVersionProtocolEngineFactory(String fqdn, Set<VERSION> versions) + public MultiVersionProtocolEngineFactory(String fqdn, Set<AmqpProtocolVersion> versions) { this(1, fqdn, versions); } @@ -57,7 +54,7 @@ public class MultiVersionProtocolEngineFactory implements ProtocolEngineFactory this(1, fqdn, ALL_VERSIONS); } - public MultiVersionProtocolEngineFactory(int instance, String fqdn, Set<VERSION> supportedVersions) + public MultiVersionProtocolEngineFactory(int instance, String fqdn, Set<AmqpProtocolVersion> supportedVersions) { _appRegistry = ApplicationRegistry.getInstance(); _fqdn = fqdn; diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java index 35ab28656b..63423cbaa7 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java @@ -21,8 +21,6 @@ package org.apache.qpid.server; import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS; -import static org.apache.qpid.transport.network.Transport.TCP; -import static org.apache.qpid.transport.network.Transport.VM; import static org.apache.qpid.server.configuration.ServerConfiguration.DEFAULT_PORT; import static org.apache.qpid.server.configuration.ServerConfiguration.DEFAULT_JMXPORT; @@ -195,16 +193,4 @@ public class BrokerOptionsTest extends QpidTestCase _options.setLogWatchFrequency(myFreq); assertEquals(myFreq, _options.getLogWatchFrequency()); } - - public void testDefaultTransport() - { - assertEquals(TCP, _options.getTransport()); - } - - public void testOverriddenTransport() - { - _options.setTransport(VM); - - assertEquals(VM, _options.getTransport()); - } } diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/ConnectionSetup.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/ConnectionSetup.java index 88ee9ed2c5..0734704e59 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/ConnectionSetup.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/pubsub/ConnectionSetup.java @@ -33,7 +33,6 @@ import java.util.Properties; * It is equivalent to a PropertyFile of value: * * connectionfactory.local=amqp://guest:guest@clientid/test?brokerlist='localhost' - * connectionfactory.vm=amqp://guest:guest@clientid/test?brokerlist='vm://:1' * * queue.queue=example.MyQueue * topic.topic=example.hierarical.topic @@ -61,7 +60,6 @@ public class ConnectionSetup Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY); properties.put("connectionfactory." + CONNECTION_JNDI_NAME, CONNECTION_NAME); - properties.put("connectionfactory." + "vm", "amqp://guest:guest@clientid/test?brokerlist='vm://:1'"); properties.put("queue." + QUEUE_JNDI_NAME, QUEUE_NAME); properties.put("topic." + TOPIC_JNDI_NAME, TOPIC_NAME); diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java index ed37a69b82..c8576bf00d 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java @@ -56,8 +56,7 @@ public class AMQBrokerDetails implements BrokerDetails if (transport != null) { //todo this list of valid transports should be enumerated somewhere - if (!(transport.equalsIgnoreCase(BrokerDetails.VM) || - transport.equalsIgnoreCase(BrokerDetails.TCP))) + if (!(transport.equalsIgnoreCase(BrokerDetails.TCP))) { if (transport.equalsIgnoreCase("localhost")) { @@ -297,12 +296,7 @@ public class AMQBrokerDetails implements BrokerDetails sb.append(_transport); sb.append("://"); - - if (!(_transport.equalsIgnoreCase(VM))) - { - sb.append(_host); - } - + sb.append(_host); sb.append(':'); sb.append(_port); diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java index 94a55ef52c..5b6a986997 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java @@ -328,7 +328,7 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect _failoverPolicy = new FailoverPolicy(connectionURL, this); BrokerDetails brokerDetails = _failoverPolicy.getCurrentBrokerDetails(); - if (brokerDetails.getTransport().equals(BrokerDetails.VM) || "0-8".equals(amqpVersion)) + if ("0-8".equals(amqpVersion)) { _delegate = new AMQConnectionDelegate_8_0(this); } diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java index b0242210d8..a837975304 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java @@ -39,7 +39,6 @@ import org.apache.qpid.client.failover.FailoverRetrySupport; import org.apache.qpid.client.protocol.AMQProtocolSession; import org.apache.qpid.client.state.AMQState; import org.apache.qpid.client.state.StateWaiter; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.framing.BasicQosBody; import org.apache.qpid.framing.BasicQosOkBody; import org.apache.qpid.framing.ChannelOpenBody; diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java index 93b4c51a8f..f9f50d9150 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java @@ -27,18 +27,14 @@ import java.util.Map; import org.apache.qpid.client.url.URLParser; import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.ConnectionURL; import org.apache.qpid.url.URLHelper; import org.apache.qpid.url.URLSyntaxException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class AMQConnectionURL implements ConnectionURL { - private static final Logger _logger = LoggerFactory.getLogger(AMQConnectionURL.class); - + private String _url; private String _failoverMethod; private Map<String, String> _failoverOptions; @@ -295,17 +291,4 @@ public class AMQConnectionURL implements ConnectionURL return sb.toString(); } - - public static void main(String[] args) throws URLSyntaxException - { - String url2 = - "amqp://ritchiem:bob@temp/testHost?brokerlist='tcp://localhost:5672;tcp://fancyserver:3000/',failover='roundrobin'"; - // "amqp://user:pass@clientid/virtualhost?brokerlist='tcp://host:1?option1=\'value\',option2=\'value\';vm://:3?option1=\'value\'',failover='method?option1=\'value\',option2='value''"; - - ConnectionURL connectionurl2 = new AMQConnectionURL(url2); - - System.out.println(url2); - System.out.println(connectionurl2); - - } } diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/TransportConnection.java b/qpid/java/client/src/main/java/org/apache/qpid/client/transport/TransportConnection.java deleted file mode 100644 index 3e03f88341..0000000000 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/transport/TransportConnection.java +++ /dev/null @@ -1,214 +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.client.transport; - -import java.io.IOException; -import java.net.Socket; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.mina.common.IoHandlerAdapter; -import org.apache.mina.common.IoServiceConfig; -import org.apache.mina.transport.vmpipe.VmPipeAcceptor; -import org.apache.mina.transport.vmpipe.VmPipeAddress; -import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException; -import org.apache.qpid.protocol.ProtocolEngineFactory; -import org.apache.qpid.transport.network.VMBrokerMap; -import org.apache.qpid.transport.network.mina.MinaNetworkHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The TransportConnection is a helper class responsible for connecting to an AMQ server. It sets up the underlying - * connector, which currently always uses TCP/IP sockets. It creates the "protocol handler" which deals with MINA - * protocol events. <p/> Could be extended in future to support different transport types by turning this into concrete - * class/interface combo. - */ -public class TransportConnection -{ - private static ITransportConnection _instance; - - private static VmPipeAcceptor _acceptor; - private static int _currentInstance = -1; - private static int _currentVMPort = -1; - - private static Logger _logger = LoggerFactory.getLogger(TransportConnection.class); - - private static final String DEFAULT_QPID_SERVER = "org.apache.qpid.server.protocol.AMQProtocolEngineFactory"; - - public static final int DEFAULT_VM_PORT = 1; - - public static void createVMBroker(int port) throws AMQVMBrokerCreationException - { - synchronized(TransportConnection.class) - { - if (_acceptor == null) - { - _acceptor = new VmPipeAcceptor(); - - IoServiceConfig config = _acceptor.getDefaultConfig(); - } - } - synchronized (VMBrokerMap.class) - { - - if (!VMBrokerMap.contains(port)) - { - _logger.info("Creating InVM Qpid.AMQP listening on port " + port); - IoHandlerAdapter provider = null; - try - { - VmPipeAddress pipe = new VmPipeAddress(port); - - provider = createBrokerInstance(port); - - _acceptor.bind(pipe, provider); - - VMBrokerMap.add(port, pipe); - _logger.info("Created InVM Qpid.AMQP listening on port " + port); - } - catch (IOException e) - { - _logger.error("Got IOException.", e); - - // Try and unbind provider - try - { - VmPipeAddress pipe = new VmPipeAddress(port); - - try - { - _acceptor.unbind(pipe); - } - catch (Exception ignore) - { - // ignore - } - - if (provider == null) - { - provider = createBrokerInstance(port); - } - - _acceptor.bind(pipe, provider); - VMBrokerMap.add(port, pipe); - _logger.info("Created InVM Qpid.AMQP listening on port " + port); - } - catch (IOException justUseFirstException) - { - String because; - if (e.getCause() == null) - { - because = e.toString(); - } - else - { - because = e.getCause().toString(); - } - - throw new AMQVMBrokerCreationException(null, port, because + " Stopped binding of InVM Qpid.AMQP", e); - } - } - - } - else - { - _logger.info("InVM Qpid.AMQP on port " + port + " already exits."); - } - } - } - - private static IoHandlerAdapter createBrokerInstance(int port) throws AMQVMBrokerCreationException - { - String protocolProviderClass = System.getProperty("amqj.protocolprovider.class", DEFAULT_QPID_SERVER); - _logger.info("Creating Qpid protocol provider: " + protocolProviderClass); - - // can't use introspection to get Provider as it is a server class. - // need to go straight to IoHandlerAdapter but that requries the queues and exchange from the ApplicationRegistry which we can't access. - - // get right constructor and pass in instancec ID - "port" - IoHandlerAdapter provider; - try - { - Class[] cnstr = {Integer.class}; - Object[] params = {port}; - - ProtocolEngineFactory engineFactory = (ProtocolEngineFactory) Class.forName(protocolProviderClass).getConstructor(cnstr).newInstance(params); - provider = new MinaNetworkHandler(null, engineFactory); - - _logger.info("Created VMBroker Instance:" + port); - } - catch (Exception e) - { - _logger.info("Unable to create InVM Qpid.AMQP on port " + port + ". Because: " + e.getCause()); - String because; - if (e.getCause() == null) - { - because = e.toString(); - } - else - { - because = e.getCause().toString(); - } - - AMQVMBrokerCreationException amqbce = - new AMQVMBrokerCreationException(null, port, because + " Stopped InVM Qpid.AMQP creation", e); - throw amqbce; - } - - return provider; - } - - public static void killAllVMBrokers() - { - _logger.info("Killing all VM Brokers"); - synchronized(TransportConnection.class) - { - if (_acceptor != null) - { - _acceptor.unbindAll(); - } - synchronized (VMBrokerMap.class) - { - VMBrokerMap.clear(); - } - _acceptor = null; - } - _currentInstance = -1; - _currentVMPort = -1; - } - - public static void killVMBroker(int port) - { - synchronized (VMBrokerMap.class) - { - if (VMBrokerMap.contains(port)) - { - _logger.info("Killing VM Broker:" + port); - VmPipeAddress address = VMBrokerMap.remove(port); - // This does need to be sychronized as otherwise mina can hang - // if a new connection is made - _acceptor.unbind(address); - } - } - } - -} diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java index f3f74dd332..03167561ef 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser.java @@ -45,7 +45,7 @@ public class URLParser private void parseURL(String fullURL) throws URLSyntaxException { // Connection URL format - // amqp://[user:pass@][clientid]/virtualhost?brokerlist='tcp://host:port?option=\'value\',option=\'value\';vm://:3/virtualpath?option=\'value\'',failover='method?option=\'value\',option='value''" + // amqp://[user:pass@][clientid]/virtualhost?brokerlist='tcp://host:port?option=\'value\',option=\'value\';tcp://host:port?option=\'value\'',failover='method?option=\'value\',option='value''" // Options are of course optional except for requiring a single broker in the broker list. try { @@ -195,7 +195,7 @@ public class URLParser { String brokerlist = _url.getOptions().get(AMQConnectionURL.OPTIONS_BROKERLIST); - // brokerlist tcp://host:port?option='value',option='value';vm://:3/virtualpath?option='value' + // brokerlist tcp://host:port?option='value',option='value';tcp://host:port/virtualpath?option='value' StringTokenizer st = new StringTokenizer(brokerlist, "" + URLHelper.BROKER_SEPARATOR); while (st.hasMoreTokens()) diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/vmbroker/AMQVMBrokerCreationException.java b/qpid/java/client/src/main/java/org/apache/qpid/client/vmbroker/AMQVMBrokerCreationException.java deleted file mode 100644 index dc0d9b8c78..0000000000 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/vmbroker/AMQVMBrokerCreationException.java +++ /dev/null @@ -1,60 +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.client.vmbroker; - -import org.apache.qpid.client.transport.AMQTransportConnectionException; -import org.apache.qpid.protocol.AMQConstant; - -/** - * AMQVMBrokerCreationException represents failure to create an in VM broker on the vm transport medium. - * - * <p/><table id="crc"><caption>CRC Card</caption> - * <tr><th> Responsibilities <th> Collaborations - * <tr><td> Represent failure to create an in VM broker. - * </table> - * - * @todo Error code never used. This is not an AMQException. - */ -public class AMQVMBrokerCreationException extends AMQTransportConnectionException -{ - private int _port; - - /** - * @param port - * - * @deprecated - */ - public AMQVMBrokerCreationException(int port) - { - this(null, port, "Unable to create vm broker", null); - } - - public AMQVMBrokerCreationException(AMQConstant errorCode, int port, String message, Throwable cause) - { - super(errorCode, message, cause); - _port = port; - } - - public String toString() - { - return super.toString() + " on port " + _port; - } -} diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java index 1aca28aa3a..4db6a11e4d 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java @@ -53,7 +53,6 @@ public interface BrokerDetails public static final int DEFAULT_PORT = 5672; public static final String TCP = "tcp"; - public static final String VM = "vm"; public static final String DEFAULT_TRANSPORT = TCP; diff --git a/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java b/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java index 0e8ca60686..26641982d7 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java @@ -27,7 +27,7 @@ import java.util.List; /** Connection URL format - amqp://[user:pass@][clientid]/virtualhost?brokerlist='tcp://host:port?option=\'value\'&option=\'value\';vm://:3/virtualpath?option=\'value\''&failover='method?option=\'value\'&option='value''" + amqp://[user:pass@][clientid]/virtualhost?brokerlist='tcp://host:port?option=\'value\'&option=\'value\';tcp://host:port/virtualpath?option=\'value\''&failover='method?option=\'value\'&option='value''" Options are of course optional except for requiring a single broker in the broker list. The option seperator is defined to be either '&' or ',' */ diff --git a/qpid/java/client/src/test/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java b/qpid/java/client/src/test/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java deleted file mode 100644 index 5323ad28bf..0000000000 --- a/qpid/java/client/src/test/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java +++ /dev/null @@ -1,125 +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.mina.transport.vmpipe.support; - -import org.apache.mina.common.IdleStatus; - -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * This file is a patch to override MINA, because of the IdentityHashMap bug. Workaround to be supplied in MINA 1.0.7. - * This patched file will be removed once upgraded onto a newer MINA. - * - * Dectects idle sessions and fires <tt>sessionIdle</tt> events to them. - * - * @author The Apache Directory Project (mina-dev@directory.apache.org) - */ -public class VmPipeIdleStatusChecker -{ - private static final VmPipeIdleStatusChecker INSTANCE = new VmPipeIdleStatusChecker(); - - public static VmPipeIdleStatusChecker getInstance() - { - return INSTANCE; - } - - private final Map sessions = new HashMap(); // will use as a set - - private final Worker worker = new Worker(); - - private VmPipeIdleStatusChecker() - { - worker.start(); - } - - public void addSession(VmPipeSessionImpl session) - { - synchronized (sessions) - { - sessions.put(session, session); - } - } - - private class Worker extends Thread - { - private Worker() - { - super("VmPipeIdleStatusChecker"); - setDaemon(true); - } - - public void run() - { - for (;;) - { - try - { - Thread.sleep(1000); - } - catch (InterruptedException e) - { } - - long currentTime = System.currentTimeMillis(); - - synchronized (sessions) - { - Iterator it = sessions.keySet().iterator(); - while (it.hasNext()) - { - VmPipeSessionImpl session = (VmPipeSessionImpl) it.next(); - if (!session.isConnected()) - { - it.remove(); - } - else - { - notifyIdleSession(session, currentTime); - } - } - } - } - } - } - - private void notifyIdleSession(VmPipeSessionImpl session, long currentTime) - { - notifyIdleSession0(session, currentTime, session.getIdleTimeInMillis(IdleStatus.BOTH_IDLE), IdleStatus.BOTH_IDLE, - Math.max(session.getLastIoTime(), session.getLastIdleTime(IdleStatus.BOTH_IDLE))); - notifyIdleSession0(session, currentTime, session.getIdleTimeInMillis(IdleStatus.READER_IDLE), IdleStatus.READER_IDLE, - Math.max(session.getLastReadTime(), session.getLastIdleTime(IdleStatus.READER_IDLE))); - notifyIdleSession0(session, currentTime, session.getIdleTimeInMillis(IdleStatus.WRITER_IDLE), IdleStatus.WRITER_IDLE, - Math.max(session.getLastWriteTime(), session.getLastIdleTime(IdleStatus.WRITER_IDLE))); - } - - private void notifyIdleSession0(VmPipeSessionImpl session, long currentTime, long idleTime, IdleStatus status, - long lastIoTime) - { - if ((idleTime > 0) && (lastIoTime != 0) && ((currentTime - lastIoTime) >= idleTime)) - { - session.increaseIdleCount(status); - session.getFilterChain().fireSessionIdle(session, status); - } - } - -} diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java index e54b8ef369..e159ceb148 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java +++ b/qpid/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java @@ -73,7 +73,7 @@ public class AMQProtocolHandlerTest extends TestCase public void setUp() throws Exception { //Create a new ProtocolHandler with a fake connection. - _handler = new AMQProtocolHandler(new MockAMQConnection("amqp://guest:guest@client/test?brokerlist='vm://:1'")); + _handler = new AMQProtocolHandler(new MockAMQConnection("amqp://guest:guest@client/test?brokerlist='tcp://localhost:1'")); _handler.setNetworkConnection(new TestNetworkConnection()); AMQBody body = BasicRecoverOkBodyImpl.getFactory().newInstance(null, 1); _blockFrame = new AMQFrame(0, body); diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandlerTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandlerTest.java index 98fc09c25b..9e23f722eb 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandlerTest.java +++ b/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernameHashedPasswordCallbackHandlerTest.java @@ -50,7 +50,7 @@ public class UsernameHashedPasswordCallbackHandlerTest extends TestCase { super.setUp(); - final String url = "amqp://username:password@client/test?brokerlist='vm://:1'"; + final String url = "amqp://username:password@client/test?brokerlist='tcp://localhost:1'"; _callbackHandler.initialise(new AMQConnectionURL(url)); } diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandlerTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandlerTest.java index 05a60fbef7..83ddfd72fa 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandlerTest.java +++ b/qpid/java/client/src/test/java/org/apache/qpid/client/security/UsernamePasswordCallbackHandlerTest.java @@ -46,7 +46,7 @@ public class UsernamePasswordCallbackHandlerTest extends TestCase { super.setUp(); - final String url = "amqp://username:password@client/test?brokerlist='vm://:1'"; + final String url = "amqp://username:password@client/test?brokerlist='tcp://localhost:1'"; _callbackHandler.initialise(new AMQConnectionURL(url)); } diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java index 1b27ff6300..9095f94960 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java +++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java @@ -43,15 +43,6 @@ public class BrokerDetailsTest extends TestCase assertTrue(broker.getProperty("immediatedelivery").equals("true")); } - public void testVMBroker() throws URLSyntaxException - { - String url = "vm://:2"; - - AMQBrokerDetails broker = new AMQBrokerDetails(url); - assertTrue(broker.getTransport().equals("vm")); - assertEquals(broker.getPort(), 2); - } - public void testTransportsDefaultToTCP() throws URLSyntaxException { String url = "localhost:5672"; diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java index a3dfff45f9..4624b36fea 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java +++ b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java @@ -300,53 +300,6 @@ public class ConnectionURLTest extends TestCase assertTrue(connectionurl.getOption("immediatedelivery").equals("true")); } - public void testSinglevmURL() throws URLSyntaxException - { - String url = "amqp://guest:guest@/test?brokerlist='vm://:2'"; - - ConnectionURL connectionurl = new AMQConnectionURL(url); - - assertTrue(connectionurl.getFailoverMethod() == null); - assertTrue(connectionurl.getUsername().equals("guest")); - assertTrue(connectionurl.getPassword().equals("guest")); - assertTrue(connectionurl.getVirtualHost().equals("/test")); - - assertTrue(connectionurl.getBrokerCount() == 1); - - BrokerDetails service = connectionurl.getBrokerDetails(0); - - assertTrue(service.getTransport().equals("vm")); - assertTrue(service.getHost().equals("")); - assertTrue(service.getPort() == 2); - - } - - public void testFailoverVMURL() throws URLSyntaxException - { - String url = "amqp://ritchiem:bob@/test?brokerlist='vm://:2;vm://:3',failover='roundrobin'"; - - ConnectionURL connectionurl = new AMQConnectionURL(url); - - assertTrue(connectionurl.getFailoverMethod().equals("roundrobin")); - assertTrue(connectionurl.getUsername().equals("ritchiem")); - assertTrue(connectionurl.getPassword().equals("bob")); - assertTrue(connectionurl.getVirtualHost().equals("/test")); - - assertTrue(connectionurl.getBrokerCount() == 2); - - BrokerDetails service = connectionurl.getBrokerDetails(0); - - assertTrue(service.getTransport().equals("vm")); - assertTrue(service.getHost().equals("")); - assertTrue(service.getPort() == 2); - - service = connectionurl.getBrokerDetails(1); - assertTrue(service.getTransport().equals("vm")); - assertTrue(service.getHost().equals("")); - assertTrue(service.getPort() == 3); - } - - public void testNoVirtualHostURL() { String url = "amqp://user@?brokerlist='tcp://localhost:5672'"; diff --git a/qpid/java/common/src/main/java/org/apache/mina/common/FixedSizeByteBufferAllocator.java b/qpid/java/common/src/main/java/org/apache/mina/common/FixedSizeByteBufferAllocator.java deleted file mode 100644 index 0c311b6645..0000000000 --- a/qpid/java/common/src/main/java/org/apache/mina/common/FixedSizeByteBufferAllocator.java +++ /dev/null @@ -1,467 +0,0 @@ -package org.apache.mina.common; - -import org.apache.mina.common.ByteBuffer; - -import java.nio.*; - -/* -* -* 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. -* -*/ -public class FixedSizeByteBufferAllocator implements ByteBufferAllocator -{ - - - private static final int MINIMUM_CAPACITY = 1; - - public FixedSizeByteBufferAllocator () - { - } - - public ByteBuffer allocate( int capacity, boolean direct ) - { - java.nio.ByteBuffer nioBuffer; - if( direct ) - { - nioBuffer = java.nio.ByteBuffer.allocateDirect( capacity ); - } - else - { - nioBuffer = java.nio.ByteBuffer.allocate( capacity ); - } - return new FixedSizeByteBuffer( nioBuffer ); - } - - public ByteBuffer wrap( java.nio.ByteBuffer nioBuffer ) - { - return new FixedSizeByteBuffer( nioBuffer ); - } - - public void dispose() - { - } - - - - private static final class FixedSizeByteBuffer extends ByteBuffer - { - private java.nio.ByteBuffer buf; - private int mark = -1; - - - protected FixedSizeByteBuffer( java.nio.ByteBuffer buf ) - { - this.buf = buf; - buf.order( ByteOrder.BIG_ENDIAN ); - } - - public synchronized void acquire() - { - } - - public void release() - { - } - - public java.nio.ByteBuffer buf() - { - return buf; - } - - public boolean isPooled() - { - return false; - } - - public void setPooled( boolean pooled ) - { - } - - public ByteBuffer duplicate() { - return new FixedSizeByteBuffer( this.buf.duplicate() ); - } - - public ByteBuffer slice() { - return new FixedSizeByteBuffer( this.buf.slice() ); - } - - public ByteBuffer asReadOnlyBuffer() { - return new FixedSizeByteBuffer( this.buf.asReadOnlyBuffer() ); - } - - public byte[] array() - { - return buf.array(); - } - - public int arrayOffset() - { - return buf.arrayOffset(); - } - - public boolean isDirect() - { - return buf.isDirect(); - } - - public boolean isReadOnly() - { - return buf.isReadOnly(); - } - - public int capacity() - { - return buf.capacity(); - } - - public ByteBuffer capacity( int newCapacity ) - { - if( newCapacity > capacity() ) - { - throw new IllegalArgumentException(); - } - - return this; - } - - - - public boolean isAutoExpand() - { - return false; - } - - public ByteBuffer setAutoExpand( boolean autoExpand ) - { - if(autoExpand) throw new IllegalArgumentException(); - else return this; - } - - public ByteBuffer expand( int pos, int expectedRemaining ) - { - int end = pos + expectedRemaining; - if( end > capacity() ) - { - // The buffer needs expansion. - capacity( end ); - } - - if( end > limit() ) - { - // We call limit() directly to prevent StackOverflowError - buf.limit( end ); - } - return this; - } - - public int position() - { - return buf.position(); - } - - public ByteBuffer position( int newPosition ) - { - - buf.position( newPosition ); - if( mark > newPosition ) - { - mark = -1; - } - return this; - } - - public int limit() - { - return buf.limit(); - } - - public ByteBuffer limit( int newLimit ) - { - buf.limit( newLimit ); - if( mark > newLimit ) - { - mark = -1; - } - return this; - } - - public ByteBuffer mark() - { - buf.mark(); - mark = position(); - return this; - } - - public int markValue() - { - return mark; - } - - public ByteBuffer reset() - { - buf.reset(); - return this; - } - - public ByteBuffer clear() - { - buf.clear(); - mark = -1; - return this; - } - - public ByteBuffer flip() - { - buf.flip(); - mark = -1; - return this; - } - - public ByteBuffer rewind() - { - buf.rewind(); - mark = -1; - return this; - } - - public byte get() - { - return buf.get(); - } - - public ByteBuffer put( byte b ) - { - buf.put( b ); - return this; - } - - public byte get( int index ) - { - return buf.get( index ); - } - - public ByteBuffer put( int index, byte b ) - { - buf.put( index, b ); - return this; - } - - public ByteBuffer get( byte[] dst, int offset, int length ) - { - buf.get( dst, offset, length ); - return this; - } - - public ByteBuffer put( java.nio.ByteBuffer src ) - { - buf.put( src ); - return this; - } - - public ByteBuffer put( byte[] src, int offset, int length ) - { - buf.put( src, offset, length ); - return this; - } - - public ByteBuffer compact() - { - buf.compact(); - mark = -1; - return this; - } - - public ByteOrder order() - { - return buf.order(); - } - - public ByteBuffer order( ByteOrder bo ) - { - buf.order( bo ); - return this; - } - - public char getChar() - { - return buf.getChar(); - } - - public ByteBuffer putChar( char value ) - { - buf.putChar( value ); - return this; - } - - public char getChar( int index ) - { - return buf.getChar( index ); - } - - public ByteBuffer putChar( int index, char value ) - { - buf.putChar( index, value ); - return this; - } - - public CharBuffer asCharBuffer() - { - return buf.asCharBuffer(); - } - - public short getShort() - { - return buf.getShort(); - } - - public ByteBuffer putShort( short value ) - { - buf.putShort( value ); - return this; - } - - public short getShort( int index ) - { - return buf.getShort( index ); - } - - public ByteBuffer putShort( int index, short value ) - { - buf.putShort( index, value ); - return this; - } - - public ShortBuffer asShortBuffer() - { - return buf.asShortBuffer(); - } - - public int getInt() - { - return buf.getInt(); - } - - public ByteBuffer putInt( int value ) - { - buf.putInt( value ); - return this; - } - - public int getInt( int index ) - { - return buf.getInt( index ); - } - - public ByteBuffer putInt( int index, int value ) - { - buf.putInt( index, value ); - return this; - } - - public IntBuffer asIntBuffer() - { - return buf.asIntBuffer(); - } - - public long getLong() - { - return buf.getLong(); - } - - public ByteBuffer putLong( long value ) - { - buf.putLong( value ); - return this; - } - - public long getLong( int index ) - { - return buf.getLong( index ); - } - - public ByteBuffer putLong( int index, long value ) - { - buf.putLong( index, value ); - return this; - } - - public LongBuffer asLongBuffer() - { - return buf.asLongBuffer(); - } - - public float getFloat() - { - return buf.getFloat(); - } - - public ByteBuffer putFloat( float value ) - { - buf.putFloat( value ); - return this; - } - - public float getFloat( int index ) - { - return buf.getFloat( index ); - } - - public ByteBuffer putFloat( int index, float value ) - { - buf.putFloat( index, value ); - return this; - } - - public FloatBuffer asFloatBuffer() - { - return buf.asFloatBuffer(); - } - - public double getDouble() - { - return buf.getDouble(); - } - - public ByteBuffer putDouble( double value ) - { - buf.putDouble( value ); - return this; - } - - public double getDouble( int index ) - { - return buf.getDouble( index ); - } - - public ByteBuffer putDouble( int index, double value ) - { - buf.putDouble( index, value ); - return this; - } - - public DoubleBuffer asDoubleBuffer() - { - return buf.asDoubleBuffer(); - } - - - } - - -} diff --git a/qpid/java/common/src/main/java/org/apache/mina/common/support/DefaultIoFuture.java b/qpid/java/common/src/main/java/org/apache/mina/common/support/DefaultIoFuture.java deleted file mode 100644 index 4fd28c4eb5..0000000000 --- a/qpid/java/common/src/main/java/org/apache/mina/common/support/DefaultIoFuture.java +++ /dev/null @@ -1,227 +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.mina.common.support; - -import org.apache.mina.common.IoFuture; -import org.apache.mina.common.IoSession; -import org.apache.mina.common.IoFutureListener; - -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; - -/** - * A default implementation of {@link org.apache.mina.common.IoFuture}. - * - * @author The Apache Directory Project (mina-dev@directory.apache.org) - */ -public class DefaultIoFuture implements IoFuture -{ - private final IoSession session; - private final Object lock; - private List listeners; - private Object result; - private boolean ready; - - - /** - * Creates a new instance. - * - * @param session an {@link IoSession} which is associated with this future - */ - public DefaultIoFuture( IoSession session ) - { - this.session = session; - this.lock = this; - } - - /** - * Creates a new instance which uses the specified object as a lock. - */ - public DefaultIoFuture( IoSession session, Object lock ) - { - if( lock == null ) - { - throw new NullPointerException( "lock" ); - } - this.session = session; - this.lock = lock; - } - - public IoSession getSession() - { - return session; - } - - public Object getLock() - { - return lock; - } - - public void join() - { - synchronized( lock ) - { - while( !ready ) - { - try - { - lock.wait(); - } - catch( InterruptedException e ) - { - } - } - } - } - - public boolean join( long timeoutInMillis ) - { - long startTime = ( timeoutInMillis <= 0 ) ? 0 : System - .currentTimeMillis(); - long waitTime = timeoutInMillis; - - synchronized( lock ) - { - if( ready ) - { - return ready; - } - else if( waitTime <= 0 ) - { - return ready; - } - - for( ;; ) - { - try - { - lock.wait( waitTime ); - } - catch( InterruptedException e ) - { - } - - if( ready ) - return true; - else - { - waitTime = timeoutInMillis - ( System.currentTimeMillis() - startTime ); - if( waitTime <= 0 ) - { - return ready; - } - } - } - } - } - - public boolean isReady() - { - synchronized( lock ) - { - return ready; - } - } - - /** - * Sets the result of the asynchronous operation, and mark it as finished. - */ - protected void setValue( Object newValue ) - { - synchronized( lock ) - { - // Allow only once. - if( ready ) - { - return; - } - - result = newValue; - ready = true; - lock.notifyAll(); - - notifyListeners(); - } - } - - /** - * Returns the result of the asynchronous operation. - */ - protected Object getValue() - { - synchronized( lock ) - { - return result; - } - } - - public void addListener( IoFutureListener listener ) - { - if( listener == null ) - { - throw new NullPointerException( "listener" ); - } - - synchronized( lock ) - { - if(listeners == null) - { - listeners = new ArrayList(); - } - listeners.add( listener ); - if( ready ) - { - listener.operationComplete( this ); - } - } - } - - public void removeListener( IoFutureListener listener ) - { - if( listener == null ) - { - throw new NullPointerException( "listener" ); - } - - synchronized( lock ) - { - listeners.remove( listener ); - } - } - - private void notifyListeners() - { - synchronized( lock ) - { - - if(listeners != null) - { - - for( Iterator i = listeners.iterator(); i.hasNext(); ) { - ( ( IoFutureListener ) i.next() ).operationComplete( this ); - } - } - } - } -} - - - diff --git a/qpid/java/common/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java b/qpid/java/common/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java deleted file mode 100644 index 5723ffbaa9..0000000000 --- a/qpid/java/common/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java +++ /dev/null @@ -1,351 +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.mina.common.support; - -import java.net.SocketAddress; -import java.util.ArrayList; -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.concurrent.CountDownLatch; - -import org.apache.mina.common.IoAcceptorConfig; -import org.apache.mina.common.IoConnector; -import org.apache.mina.common.IoFuture; -import org.apache.mina.common.IoFutureListener; -import org.apache.mina.common.IoHandler; -import org.apache.mina.common.IoService; -import org.apache.mina.common.IoServiceConfig; -import org.apache.mina.common.IoServiceListener; -import org.apache.mina.common.IoSession; -import org.apache.mina.util.IdentityHashSet; - -/** - * A helper which provides addition and removal of {@link IoServiceListener}s and firing - * events. - * - * @author The Apache Directory Project (mina-dev@directory.apache.org) - * @version $Rev: 446526 $, $Date: 2006-09-15 01:44:11 -0400 (Fri, 15 Sep 2006) $ - */ -public class IoServiceListenerSupport -{ - /** - * A list of {@link IoServiceListener}s. - */ - private final List listeners = new ArrayList(); - - /** - * Tracks managed <tt>serviceAddress</tt>es. - */ - private final Set managedServiceAddresses = new HashSet(); - - /** - * Tracks managed sesssions with <tt>serviceAddress</tt> as a key. - */ - private final Map managedSessions = new HashMap(); - - /** - * Creates a new instance. - */ - public IoServiceListenerSupport() - { - } - - /** - * Adds a new listener. - */ - public void add( IoServiceListener listener ) - { - synchronized( listeners ) - { - listeners.add( listener ); - } - } - - /** - * Removes an existing listener. - */ - public void remove( IoServiceListener listener ) - { - synchronized( listeners ) - { - listeners.remove( listener ); - } - } - - public Set getManagedServiceAddresses() - { - return Collections.unmodifiableSet( managedServiceAddresses ); - } - - public boolean isManaged( SocketAddress serviceAddress ) - { - synchronized( managedServiceAddresses ) - { - return managedServiceAddresses.contains( serviceAddress ); - } - } - - public Set getManagedSessions( SocketAddress serviceAddress ) - { - Set sessions; - synchronized( managedSessions ) - { - sessions = ( Set ) managedSessions.get( serviceAddress ); - if( sessions == null ) - { - sessions = new IdentityHashSet(); - } - } - - synchronized( sessions ) - { - return new IdentityHashSet( sessions ); - } - } - - /** - * Calls {@link IoServiceListener#serviceActivated(IoService, SocketAddress, IoHandler, IoServiceConfig)} - * for all registered listeners. - */ - public void fireServiceActivated( - IoService service, SocketAddress serviceAddress, - IoHandler handler, IoServiceConfig config ) - { - synchronized( managedServiceAddresses ) - { - if( !managedServiceAddresses.add( serviceAddress ) ) - { - return; - } - } - - synchronized( listeners ) - { - for( Iterator i = listeners.iterator(); i.hasNext(); ) - { - ( ( IoServiceListener ) i.next() ).serviceActivated( - service, serviceAddress, handler, config ); - } - } - } - - /** - * Calls {@link IoServiceListener#serviceDeactivated(IoService, SocketAddress, IoHandler, IoServiceConfig)} - * for all registered listeners. - */ - public synchronized void fireServiceDeactivated( - IoService service, SocketAddress serviceAddress, - IoHandler handler, IoServiceConfig config ) - { - synchronized( managedServiceAddresses ) - { - if( !managedServiceAddresses.remove( serviceAddress ) ) - { - return; - } - } - - try - { - synchronized( listeners ) - { - for( Iterator i = listeners.iterator(); i.hasNext(); ) - { - ( ( IoServiceListener ) i.next() ).serviceDeactivated( - service, serviceAddress, handler, config ); - } - } - } - finally - { - disconnectSessions( serviceAddress, config ); - } - } - - - /** - * Calls {@link IoServiceListener#sessionCreated(IoSession)} for all registered listeners. - */ - public void fireSessionCreated( IoSession session ) - { - SocketAddress serviceAddress = session.getServiceAddress(); - - // Get the session set. - boolean firstSession = false; - Set sessions; - synchronized( managedSessions ) - { - sessions = ( Set ) managedSessions.get( serviceAddress ); - if( sessions == null ) - { - sessions = new IdentityHashSet(); - managedSessions.put( serviceAddress, sessions ); - firstSession = true; - } - } - - // If already registered, ignore. - synchronized( sessions ) - { - if ( !sessions.add( session ) ) - { - return; - } - } - - // If the first connector session, fire a virtual service activation event. - if( session.getService() instanceof IoConnector && firstSession ) - { - fireServiceActivated( - session.getService(), session.getServiceAddress(), - session.getHandler(), session.getServiceConfig() ); - } - - // Fire session events. - session.getFilterChain().fireSessionCreated( session ); - session.getFilterChain().fireSessionOpened( session); - - // Fire listener events. - synchronized( listeners ) - { - for( Iterator i = listeners.iterator(); i.hasNext(); ) - { - ( ( IoServiceListener ) i.next() ).sessionCreated( session ); - } - } - } - - /** - * Calls {@link IoServiceListener#sessionDestroyed(IoSession)} for all registered listeners. - */ - public void fireSessionDestroyed( IoSession session ) - { - SocketAddress serviceAddress = session.getServiceAddress(); - - // Get the session set. - Set sessions; - boolean lastSession = false; - synchronized( managedSessions ) - { - sessions = ( Set ) managedSessions.get( serviceAddress ); - // Ignore if unknown. - if( sessions == null ) - { - return; - } - - // Try to remove the remaining empty seession set after removal. - synchronized( sessions ) - { - sessions.remove( session ); - if( sessions.isEmpty() ) - { - managedSessions.remove( serviceAddress ); - lastSession = true; - } - } - } - - // Fire session events. - session.getFilterChain().fireSessionClosed( session ); - - // Fire listener events. - try - { - synchronized( listeners ) - { - for( Iterator i = listeners.iterator(); i.hasNext(); ) - { - ( ( IoServiceListener ) i.next() ).sessionDestroyed( session ); - } - } - } - finally - { - // Fire a virtual service deactivation event for the last session of the connector. - //TODO double-check that this is *STILL* the last session. May not be the case - if( session.getService() instanceof IoConnector && lastSession ) - { - fireServiceDeactivated( - session.getService(), session.getServiceAddress(), - session.getHandler(), session.getServiceConfig() ); - } - } - } - - private void disconnectSessions( SocketAddress serviceAddress, IoServiceConfig config ) - { - if( !( config instanceof IoAcceptorConfig ) ) - { - return; - } - - if( !( ( IoAcceptorConfig ) config ).isDisconnectOnUnbind() ) - { - return; - } - - Set sessions; - synchronized( managedSessions ) - { - sessions = ( Set ) managedSessions.get( serviceAddress ); - } - - if( sessions == null ) - { - return; - } - - Set sessionsCopy; - - // Create a copy to avoid ConcurrentModificationException - synchronized( sessions ) - { - sessionsCopy = new IdentityHashSet( sessions ); - } - - final CountDownLatch latch = new CountDownLatch(sessionsCopy.size()); - - for( Iterator i = sessionsCopy.iterator(); i.hasNext(); ) - { - ( ( IoSession ) i.next() ).close().addListener( new IoFutureListener() - { - public void operationComplete( IoFuture future ) - { - latch.countDown(); - } - } ); - } - - try - { - latch.await(); - } - catch( InterruptedException ie ) - { - // Ignored - } - } -} diff --git a/qpid/java/common/src/main/java/org/apache/mina/filter/codec/OurCumulativeProtocolDecoder.java b/qpid/java/common/src/main/java/org/apache/mina/filter/codec/OurCumulativeProtocolDecoder.java deleted file mode 100644 index 3f7e206cb4..0000000000 --- a/qpid/java/common/src/main/java/org/apache/mina/filter/codec/OurCumulativeProtocolDecoder.java +++ /dev/null @@ -1,197 +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.mina.filter.codec; - -import org.apache.mina.common.ByteBuffer; -import org.apache.mina.common.IoSession; - -/** - * A {@link ProtocolDecoder} that cumulates the content of received - * buffers to a <em>cumulative buffer</em> to help users implement decoders. - * <p> - * If the received {@link ByteBuffer} is only a part of a message. - * decoders should cumulate received buffers to make a message complete or - * to postpone decoding until more buffers arrive. - * <p> - * Here is an example decoder that decodes CRLF terminated lines into - * <code>Command</code> objects: - * <pre> - * public class CRLFTerminatedCommandLineDecoder - * extends CumulativeProtocolDecoder { - * - * private Command parseCommand(ByteBuffer in) { - * // Convert the bytes in the specified buffer to a - * // Command object. - * ... - * } - * - * protected boolean doDecode(IoSession session, ByteBuffer in, - * ProtocolDecoderOutput out) - * throws Exception { - * - * // Remember the initial position. - * int start = in.position(); - * - * // Now find the first CRLF in the buffer. - * byte previous = 0; - * while (in.hasRemaining()) { - * byte current = in.get(); - * - * if (previous == '\r' && current == '\n') { - * // Remember the current position and limit. - * int position = in.position(); - * int limit = in.limit(); - * try { - * in.position(start); - * in.limit(position); - * // The bytes between in.position() and in.limit() - * // now contain a full CRLF terminated line. - * out.write(parseCommand(in.slice())); - * } finally { - * // Set the position to point right after the - * // detected line and set the limit to the old - * // one. - * in.position(position); - * in.limit(limit); - * } - * // Decoded one line; CumulativeProtocolDecoder will - * // call me again until I return false. So just - * // return true until there are no more lines in the - * // buffer. - * return true; - * } - * - * previous = current; - * } - * - * // Could not find CRLF in the buffer. Reset the initial - * // position to the one we recorded above. - * in.position(start); - * - * return false; - * } - * } - * </pre> - * - * @author The Apache Directory Project (mina-dev@directory.apache.org) - * @version $Rev: 619823 $, $Date: 2008-02-08 10:09:37 +0000 (Fri, 08 Feb 2008) $ - */ -public abstract class OurCumulativeProtocolDecoder extends ProtocolDecoderAdapter { - - private static final String BUFFER = OurCumulativeProtocolDecoder.class - .getName() - + ".Buffer"; - - /** - * Creates a new instance. - */ - protected OurCumulativeProtocolDecoder() { - } - - /** - * Cumulates content of <tt>in</tt> into internal buffer and forwards - * decoding request to {@link #doDecode(IoSession, ByteBuffer, ProtocolDecoderOutput)}. - * <tt>doDecode()</tt> is invoked repeatedly until it returns <tt>false</tt> - * and the cumulative buffer is NOT compacted after decoding ends. - * - * @throws IllegalStateException if your <tt>doDecode()</tt> returned - * <tt>true</tt> not consuming the cumulative buffer. - */ - public void decode(IoSession session, ByteBuffer in, - ProtocolDecoderOutput out) throws Exception { - boolean usingSessionBuffer = true; - ByteBuffer buf = (ByteBuffer) session.getAttribute(BUFFER); - // If we have a session buffer, append data to that; otherwise - // use the buffer read from the network directly. - if (buf != null) { - buf.put(in); - buf.flip(); - } else { - buf = in; - usingSessionBuffer = false; - } - - for (;;) { - int oldPos = buf.position(); - boolean decoded = doDecode(session, buf, out); - if (decoded) { - if (buf.position() == oldPos) { - throw new IllegalStateException( - "doDecode() can't return true when buffer is not consumed."); - } - - if (!buf.hasRemaining()) { - break; - } - } else { - break; - } - } - - - // if there is any data left that cannot be decoded, we store - // it in a buffer in the session and next time this decoder is - // invoked the session buffer gets appended to - if (buf.hasRemaining()) { - storeRemainingInSession(buf, session); - } else { - if (usingSessionBuffer) - removeSessionBuffer(session); - } - } - - /** - * Implement this method to consume the specified cumulative buffer and - * decode its content into message(s). - * - * @param in the cumulative buffer - * @return <tt>true</tt> if and only if there's more to decode in the buffer - * and you want to have <tt>doDecode</tt> method invoked again. - * Return <tt>false</tt> if remaining data is not enough to decode, - * then this method will be invoked again when more data is cumulated. - * @throws Exception if cannot decode <tt>in</tt>. - */ - protected abstract boolean doDecode(IoSession session, ByteBuffer in, - ProtocolDecoderOutput out) throws Exception; - - /** - * Releases the cumulative buffer used by the specified <tt>session</tt>. - * Please don't forget to call <tt>super.dispose( session )</tt> when - * you override this method. - */ - public void dispose(IoSession session) throws Exception { - removeSessionBuffer(session); - } - - private void removeSessionBuffer(IoSession session) { - ByteBuffer buf = (ByteBuffer) session.removeAttribute(BUFFER); - if (buf != null) { - buf.release(); - } - } - - private void storeRemainingInSession(ByteBuffer buf, IoSession session) { - ByteBuffer remainingBuf = ByteBuffer.allocate(buf.capacity()); - remainingBuf.setAutoExpand(true); - remainingBuf.order(buf.order()); - remainingBuf.put(buf); - session.setAttribute(BUFFER, remainingBuf); - } -} diff --git a/qpid/java/common/src/main/java/org/apache/mina/filter/codec/QpidProtocolCodecFilter.java b/qpid/java/common/src/main/java/org/apache/mina/filter/codec/QpidProtocolCodecFilter.java deleted file mode 100644 index b8c6f29720..0000000000 --- a/qpid/java/common/src/main/java/org/apache/mina/filter/codec/QpidProtocolCodecFilter.java +++ /dev/null @@ -1,440 +0,0 @@ -package org.apache.mina.filter.codec; - - -/* -* -* 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. -* -*/ - -import org.apache.mina.common.*; -import org.apache.mina.common.support.DefaultWriteFuture; -import org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput; -import org.apache.mina.util.SessionLog; -import org.apache.mina.util.Queue; - - -public class QpidProtocolCodecFilter extends IoFilterAdapter -{ - public static final String ENCODER = QpidProtocolCodecFilter.class.getName() + ".encoder"; - public static final String DECODER = QpidProtocolCodecFilter.class.getName() + ".decoder"; - - private static final Class[] EMPTY_PARAMS = new Class[0]; - private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.wrap( new byte[0] ); - - private final ProtocolCodecFactory factory; - - public QpidProtocolCodecFilter( ProtocolCodecFactory factory ) - { - if( factory == null ) - { - throw new NullPointerException( "factory" ); - } - this.factory = factory; - } - - public QpidProtocolCodecFilter( final ProtocolEncoder encoder, final ProtocolDecoder decoder ) - { - if( encoder == null ) - { - throw new NullPointerException( "encoder" ); - } - if( decoder == null ) - { - throw new NullPointerException( "decoder" ); - } - - this.factory = new ProtocolCodecFactory() - { - public ProtocolEncoder getEncoder() - { - return encoder; - } - - public ProtocolDecoder getDecoder() - { - return decoder; - } - }; - } - - public QpidProtocolCodecFilter( final Class encoderClass, final Class decoderClass ) - { - if( encoderClass == null ) - { - throw new NullPointerException( "encoderClass" ); - } - if( decoderClass == null ) - { - throw new NullPointerException( "decoderClass" ); - } - if( !ProtocolEncoder.class.isAssignableFrom( encoderClass ) ) - { - throw new IllegalArgumentException( "encoderClass: " + encoderClass.getName() ); - } - if( !ProtocolDecoder.class.isAssignableFrom( decoderClass ) ) - { - throw new IllegalArgumentException( "decoderClass: " + decoderClass.getName() ); - } - try - { - encoderClass.getConstructor( EMPTY_PARAMS ); - } - catch( NoSuchMethodException e ) - { - throw new IllegalArgumentException( "encoderClass doesn't have a public default constructor." ); - } - try - { - decoderClass.getConstructor( EMPTY_PARAMS ); - } - catch( NoSuchMethodException e ) - { - throw new IllegalArgumentException( "decoderClass doesn't have a public default constructor." ); - } - - this.factory = new ProtocolCodecFactory() - { - public ProtocolEncoder getEncoder() throws Exception - { - return ( ProtocolEncoder ) encoderClass.newInstance(); - } - - public ProtocolDecoder getDecoder() throws Exception - { - return ( ProtocolDecoder ) decoderClass.newInstance(); - } - }; - } - - public void onPreAdd( IoFilterChain parent, String name, IoFilter.NextFilter nextFilter ) throws Exception - { - if( parent.contains( ProtocolCodecFilter.class ) ) - { - throw new IllegalStateException( "A filter chain cannot contain more than one QpidProtocolCodecFilter." ); - } - } - - public void messageReceived( IoFilter.NextFilter nextFilter, IoSession session, Object message ) throws Exception - { - if( !( message instanceof ByteBuffer ) ) - { - nextFilter.messageReceived( session, message ); - return; - } - - ByteBuffer in = ( ByteBuffer ) message; - ProtocolDecoder decoder = getDecoder( session ); - ProtocolDecoderOutput decoderOut = getDecoderOut( session, nextFilter ); - - try - { - decoder.decode( session, in, decoderOut ); - } - catch( Throwable t ) - { - ProtocolDecoderException pde; - if( t instanceof ProtocolDecoderException ) - { - pde = ( ProtocolDecoderException ) t; - } - else - { - pde = new ProtocolDecoderException( t ); - } - pde.setHexdump( in.getHexDump() ); - throw pde; - } - finally - { - // Dispose the decoder if this session is connectionless. - if( session.getTransportType().isConnectionless() ) - { - disposeDecoder( session ); - } - - // Release the read buffer. - in.release(); - - decoderOut.flush(); - } - } - - public void messageSent( IoFilter.NextFilter nextFilter, IoSession session, Object message ) throws Exception - { - if( message instanceof HiddenByteBuffer ) - { - return; - } - - if( !( message instanceof MessageByteBuffer ) ) - { - nextFilter.messageSent( session, message ); - return; - } - - nextFilter.messageSent( session, ( ( MessageByteBuffer ) message ).message ); - } - - public void filterWrite( IoFilter.NextFilter nextFilter, IoSession session, IoFilter.WriteRequest writeRequest ) throws Exception - { - Object message = writeRequest.getMessage(); - if( message instanceof ByteBuffer ) - { - nextFilter.filterWrite( session, writeRequest ); - return; - } - - ProtocolEncoder encoder = getEncoder( session ); - ProtocolEncoderOutputImpl encoderOut = getEncoderOut( session, nextFilter, writeRequest ); - - try - { - encoder.encode( session, message, encoderOut ); - encoderOut.flush(); - nextFilter.filterWrite( - session, - new IoFilter.WriteRequest( - new MessageByteBuffer( writeRequest.getMessage() ), - writeRequest.getFuture(), writeRequest.getDestination() ) ); - } - catch( Throwable t ) - { - ProtocolEncoderException pee; - if( t instanceof ProtocolEncoderException ) - { - pee = ( ProtocolEncoderException ) t; - } - else - { - pee = new ProtocolEncoderException( t ); - } - throw pee; - } - finally - { - // Dispose the encoder if this session is connectionless. - if( session.getTransportType().isConnectionless() ) - { - disposeEncoder( session ); - } - } - } - - public void sessionClosed( IoFilter.NextFilter nextFilter, IoSession session ) throws Exception - { - // Call finishDecode() first when a connection is closed. - ProtocolDecoder decoder = getDecoder( session ); - ProtocolDecoderOutput decoderOut = getDecoderOut( session, nextFilter ); - try - { - decoder.finishDecode( session, decoderOut ); - } - catch( Throwable t ) - { - ProtocolDecoderException pde; - if( t instanceof ProtocolDecoderException ) - { - pde = ( ProtocolDecoderException ) t; - } - else - { - pde = new ProtocolDecoderException( t ); - } - throw pde; - } - finally - { - // Dispose all. - disposeEncoder( session ); - disposeDecoder( session ); - - decoderOut.flush(); - } - - nextFilter.sessionClosed( session ); - } - - private ProtocolEncoder getEncoder( IoSession session ) throws Exception - { - ProtocolEncoder encoder = ( ProtocolEncoder ) session.getAttribute( ENCODER ); - if( encoder == null ) - { - encoder = factory.getEncoder(); - session.setAttribute( ENCODER, encoder ); - } - return encoder; - } - - private ProtocolEncoderOutputImpl getEncoderOut( IoSession session, IoFilter.NextFilter nextFilter, IoFilter.WriteRequest writeRequest ) - { - return new ProtocolEncoderOutputImpl( session, nextFilter, writeRequest ); - } - - private ProtocolDecoder getDecoder( IoSession session ) throws Exception - { - ProtocolDecoder decoder = ( ProtocolDecoder ) session.getAttribute( DECODER ); - if( decoder == null ) - { - decoder = factory.getDecoder(); - session.setAttribute( DECODER, decoder ); - } - return decoder; - } - - private ProtocolDecoderOutput getDecoderOut( IoSession session, IoFilter.NextFilter nextFilter ) - { - return new SimpleProtocolDecoderOutput( session, nextFilter ); - } - - private void disposeEncoder( IoSession session ) - { - ProtocolEncoder encoder = ( ProtocolEncoder ) session.removeAttribute( ENCODER ); - if( encoder == null ) - { - return; - } - - try - { - encoder.dispose( session ); - } - catch( Throwable t ) - { - SessionLog.warn( - session, - "Failed to dispose: " + encoder.getClass().getName() + - " (" + encoder + ')' ); - } - } - - private void disposeDecoder( IoSession session ) - { - ProtocolDecoder decoder = ( ProtocolDecoder ) session.removeAttribute( DECODER ); - if( decoder == null ) - { - return; - } - - try - { - decoder.dispose( session ); - } - catch( Throwable t ) - { - SessionLog.warn( - session, - "Falied to dispose: " + decoder.getClass().getName() + - " (" + decoder + ')' ); - } - } - - private static class HiddenByteBuffer extends ByteBufferProxy - { - private HiddenByteBuffer( ByteBuffer buf ) - { - super( buf ); - } - } - - private static class MessageByteBuffer extends ByteBufferProxy - { - private final Object message; - - private MessageByteBuffer( Object message ) - { - super( EMPTY_BUFFER ); - this.message = message; - } - - public void acquire() - { - // no-op since we are wraping a zero-byte buffer, this instance is to just curry the message - } - - public void release() - { - // no-op since we are wraping a zero-byte buffer, this instance is to just curry the message - } - } - - private static class ProtocolEncoderOutputImpl implements ProtocolEncoderOutput - { - private ByteBuffer buffer; - - private final IoSession session; - private final IoFilter.NextFilter nextFilter; - private final IoFilter.WriteRequest writeRequest; - - public ProtocolEncoderOutputImpl( IoSession session, IoFilter.NextFilter nextFilter, IoFilter.WriteRequest writeRequest ) - { - this.session = session; - this.nextFilter = nextFilter; - this.writeRequest = writeRequest; - } - - - - public void write( ByteBuffer buf ) - { - if(buffer != null) - { - flush(); - } - buffer = buf; - } - - public void mergeAll() - { - } - - public WriteFuture flush() - { - WriteFuture future = null; - if( buffer == null ) - { - return null; - } - else - { - ByteBuffer buf = buffer; - // Flush only when the buffer has remaining. - if( buf.hasRemaining() ) - { - future = doFlush( buf ); - } - - } - - return future; - } - - - protected WriteFuture doFlush( ByteBuffer buf ) - { - WriteFuture future = new DefaultWriteFuture( session ); - nextFilter.filterWrite( - session, - new IoFilter.WriteRequest( - buf, - future, writeRequest.getDestination() ) ); - return future; - } - } -} - diff --git a/qpid/java/common/src/main/java/org/apache/mina/transport/vmpipe/QpidVmPipeConnector.java b/qpid/java/common/src/main/java/org/apache/mina/transport/vmpipe/QpidVmPipeConnector.java deleted file mode 100644 index a23e546af5..0000000000 --- a/qpid/java/common/src/main/java/org/apache/mina/transport/vmpipe/QpidVmPipeConnector.java +++ /dev/null @@ -1,151 +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.mina.transport.vmpipe; - -import java.io.IOException; -import java.net.SocketAddress; - -import org.apache.mina.common.ConnectFuture; -import org.apache.mina.common.ExceptionMonitor; -import org.apache.mina.common.IoFilterChain; -import org.apache.mina.common.IoHandler; -import org.apache.mina.common.IoServiceConfig; -import org.apache.mina.common.IoSessionConfig; -import org.apache.mina.common.support.AbstractIoFilterChain; -import org.apache.mina.common.support.BaseIoConnector; -import org.apache.mina.common.support.BaseIoConnectorConfig; -import org.apache.mina.common.support.BaseIoSessionConfig; -import org.apache.mina.common.support.DefaultConnectFuture; -import org.apache.mina.transport.vmpipe.support.VmPipe; -import org.apache.mina.transport.vmpipe.support.VmPipeIdleStatusChecker; -import org.apache.mina.transport.vmpipe.support.VmPipeSessionImpl; -import org.apache.mina.util.AnonymousSocketAddress; - -/** - * Connects to {@link IoHandler}s which is bound on the specified - * {@link VmPipeAddress}. - * - * @author The Apache Directory Project (mina-dev@directory.apache.org) - * @version $Rev: 619823 $, $Date: 2008-02-08 10:09:37 +0000 (Fri, 08 Feb 2008) $ - */ -public class QpidVmPipeConnector extends VmPipeConnector -{ - private static final IoSessionConfig CONFIG = new BaseIoSessionConfig() {}; - private final IoServiceConfig defaultConfig = new BaseIoConnectorConfig() - { - public IoSessionConfig getSessionConfig() - { - return CONFIG; - } - }; - - /** - * Creates a new instance. - */ - public QpidVmPipeConnector() - { - } - - public ConnectFuture connect( SocketAddress address, IoHandler handler, IoServiceConfig config ) - { - return connect( address, null, handler, config ); - } - - public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, IoHandler handler, IoServiceConfig config ) - { - if( address == null ) - throw new NullPointerException( "address" ); - if( handler == null ) - throw new NullPointerException( "handler" ); - if( ! ( address instanceof VmPipeAddress ) ) - throw new IllegalArgumentException( - "address must be VmPipeAddress." ); - - if( config == null ) - { - config = getDefaultConfig(); - } - - VmPipe entry = ( VmPipe ) VmPipeAcceptor.boundHandlers.get( address ); - if( entry == null ) - { - return DefaultConnectFuture.newFailedFuture( - new IOException( "Endpoint unavailable: " + address ) ); - } - - DefaultConnectFuture future = new DefaultConnectFuture(); - VmPipeSessionImpl localSession = - new VmPipeSessionImpl( - this, - config, - getListeners(), - new Object(), // lock - new AnonymousSocketAddress(), - handler, - entry ); - - // initialize acceptor session - VmPipeSessionImpl remoteSession = localSession.getRemoteSession(); - try - { - IoFilterChain filterChain = remoteSession.getFilterChain(); - entry.getAcceptor().getFilterChainBuilder().buildFilterChain( filterChain ); - entry.getConfig().getFilterChainBuilder().buildFilterChain( filterChain ); - entry.getConfig().getThreadModel().buildFilterChain( filterChain ); - - // The following sentences don't throw any exceptions. - entry.getListeners().fireSessionCreated( remoteSession ); - VmPipeIdleStatusChecker.getInstance().addSession( remoteSession ); - } - catch( Throwable t ) - { - ExceptionMonitor.getInstance().exceptionCaught( t ); - remoteSession.close(); - } - - - // initialize connector session - try - { - IoFilterChain filterChain = localSession.getFilterChain(); - this.getFilterChainBuilder().buildFilterChain( filterChain ); - config.getFilterChainBuilder().buildFilterChain( filterChain ); - config.getThreadModel().buildFilterChain( filterChain ); - - // The following sentences don't throw any exceptions. - localSession.setAttribute( AbstractIoFilterChain.CONNECT_FUTURE, future ); - getListeners().fireSessionCreated( localSession ); - VmPipeIdleStatusChecker.getInstance().addSession( localSession); - } - catch( Throwable t ) - { - future.setException( t ); - } - - - - return future; - } - - public IoServiceConfig getDefaultConfig() - { - return defaultConfig; - } -}
\ No newline at end of file diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java index 4b8a0baf75..742d6575df 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java @@ -23,5 +23,4 @@ package org.apache.qpid.transport.network; public class Transport { public static final String TCP = "tcp"; - public static final String VM = "vm"; } diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/mina/MinaNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/mina/MinaNetworkTransport.java index 62f9429f30..d0367b82f4 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/mina/MinaNetworkTransport.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/mina/MinaNetworkTransport.java @@ -36,8 +36,6 @@ import org.apache.mina.transport.socket.nio.SocketConnector; import org.apache.mina.transport.socket.nio.SocketConnectorConfig; import org.apache.mina.transport.socket.nio.SocketSessionConfig; import org.apache.mina.util.NewThreadExecutor; -import org.apache.mina.transport.vmpipe.QpidVmPipeConnector; -import org.apache.mina.transport.vmpipe.VmPipeAddress; import org.apache.qpid.protocol.ProtocolEngineFactory; import org.apache.qpid.ssl.SSLContextFactory; @@ -51,7 +49,6 @@ import org.apache.qpid.transport.network.IncomingNetworkTransport; import org.apache.qpid.transport.network.NetworkConnection; import org.apache.qpid.transport.network.OutgoingNetworkTransport; import org.apache.qpid.transport.network.Transport; -import org.apache.qpid.transport.network.VMBrokerMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,7 +56,6 @@ public class MinaNetworkTransport implements OutgoingNetworkTransport, IncomingN { private static final int UNKNOWN = -1; private static final int TCP = 0; - private static final int VM = 1; public NetworkConnection _connection; private SocketAcceptor _acceptor; @@ -83,16 +79,6 @@ public class MinaNetworkTransport implements OutgoingNetworkTransport, IncomingN }); _connection = stc.connect(delegate, settings, sslFactory); break; - case VM: - stc = new IoConnectorCreator(new SocketConnectorFactory() - { - public IoConnector newConnector() - { - return new QpidVmPipeConnector(); - } - }); - _connection = stc.connect(delegate, settings, sslFactory); - break; case UNKNOWN: default: throw new TransportException("Unknown protocol: " + settings.getProtocol()); @@ -108,12 +94,7 @@ public class MinaNetworkTransport implements OutgoingNetworkTransport, IncomingN return TCP; } - if (transport.equals(Transport.VM)) - { - return VM; - } - - return -1; + return UNKNOWN; } public void close() @@ -198,18 +179,6 @@ public class MinaNetworkTransport implements OutgoingNetworkTransport, IncomingN { address = new InetSocketAddress(settings.getHost(), port); } - else if(Transport.VM.equalsIgnoreCase(protocol)) - { - synchronized (VMBrokerMap.class) - { - if(!VMBrokerMap.contains(port)) - { - throw new TransportException("VM broker on port " + port + " does not exist."); - } - } - - address = new VmPipeAddress(port); - } else { throw new TransportException("Unknown transport: " + protocol); diff --git a/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java b/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java index 6f21c327e7..e261860bf3 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java @@ -31,9 +31,6 @@ public class URLHelper public static void parseOptions(Map<String, String> optionMap, String options) throws URLSyntaxException { - // options looks like this - // brokerlist='tcp://host:port?option='value',option='value';vm://:3/virtualpath?option='value'',failover='method?option='value',option='value'' - if ((options == null) || (options.indexOf('=') == -1)) { return; diff --git a/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java b/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java index 8b470d555e..808374b06e 100644 --- a/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java +++ b/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java @@ -31,6 +31,7 @@ import junit.framework.TestCase; import junit.framework.TestResult; import org.apache.log4j.Logger; +import org.apache.mina.util.AvailablePortFinder; public class QpidTestCase extends TestCase { @@ -127,4 +128,9 @@ public class QpidTestCase extends TestCase return storeClass != null ? storeClass : MEMORY_STORE_CLASS_NAME ; } + + public int findFreePort() + { + return AvailablePortFinder.getNextAvailable(10000); + } } diff --git a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkHandlerTest.java b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkHandlerTest.java index a4292d9009..1a1b5af805 100644 --- a/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkHandlerTest.java +++ b/qpid/java/common/src/test/java/org/apache/qpid/transport/network/mina/MinaNetworkHandlerTest.java @@ -31,7 +31,6 @@ import java.util.ArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.mina.util.AvailablePortFinder; import org.apache.qpid.framing.AMQDataBlock; import org.apache.qpid.protocol.ProtocolEngine; import org.apache.qpid.protocol.ProtocolEngineFactory; @@ -61,7 +60,7 @@ public class MinaNetworkHandlerTest extends QpidTestCase public void setUp() throws Exception { String host = InetAddress.getLocalHost().getHostName(); - _testPort = AvailablePortFinder.getNextAvailable(10000); + _testPort = findFreePort(); _clientSettings = new ConnectionSettings(); _clientSettings.setHost(host); diff --git a/qpid/java/module.xml b/qpid/java/module.xml index 8c6a05e035..c7819febf4 100644 --- a/qpid/java/module.xml +++ b/qpid/java/module.xml @@ -295,7 +295,7 @@ </target> - <property name="profile" value="default"/> + <property name="profile" value="java-mms.0-10"/> <property name="testprofile.file" value="${test.profiles}/${profile}.testprofile"/> <available file="${testprofile.file}" property="testprofile.file.present"/> @@ -303,15 +303,14 @@ <property file="${testprofile.file}" prefix="preload"/> <property name="preload.include" value=""/> - <condition property="profiles" - value="${preload.include} ${profile}" - else="default ${preload.include} ${profile}"> - <equals arg1="${profile}" arg2="default"/> - </condition> + <property name="profiles" value="${preload.include} ${profile}"/> <map property="_profile_files" value="${profiles}" join=" "> <globmapper from="*" to="*.testprofile"/> </map> + + <delete file="${build.scratch}/test-${profile}.properties" quiet="true"/> <concat destfile="${build.scratch}/test-${profile}.properties" force="no" fixlastline="yes"> + <filelist dir="${test.profiles}" files="testprofile.defaults"/> <filelist dir="${test.profiles}" files="${_profile_files}"/> </concat> <property file="${build.scratch}/test-${profile}.properties"/> @@ -320,7 +319,6 @@ <globmapper from="*" to="${test.profiles}/*"/> </map> - <condition property="dontruntest" value="dontruntest" else="runtest"> <contains substring="${module.name}" string="${exclude.modules}" /> </condition> @@ -348,15 +346,6 @@ <sysproperty key="log4j.configuration" value="${log4j.configuration}"/> <sysproperty key="java.naming.factory.initial" value="${java.naming.factory.initial}"/> <sysproperty key="java.naming.provider.url" value="${java.naming.provider.url}"/> - <sysproperty key="broker" value="${broker}"/> - <sysproperty key="broker.clean" value="${broker.clean}"/> - <sysproperty key="broker.clean.between.tests" value="${broker.clean.between.tests}"/> - <sysproperty key="broker.existing.qpid.work" value="${broker.existing.qpid.work}"/> - <sysproperty key="broker.persistent" value="${broker.persistent}"/> - <sysproperty key="broker.version" value="${broker.version}"/> - <sysproperty key="broker.ready" value="${broker.ready}" /> - <sysproperty key="broker.stopped" value="${broker.stopped}" /> - <sysproperty key="broker.config" value="${broker.config}" /> <sysproperty key="messagestore.class.name" value="${messagestore.class.name}" /> <sysproperty key="test.output" value="${module.results}"/> <sysproperty key="qpid.amqp.version" value="${qpid.amqp.version}"/> diff --git a/qpid/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java b/qpid/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java deleted file mode 100644 index e2e97ab6f8..0000000000 --- a/qpid/java/perftests/src/main/java/org/apache/qpid/test/testcases/MessageThroughputPerf.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.testcases; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.apache.log4j.Logger; -import org.apache.log4j.NDC; - -import org.apache.qpid.test.framework.Assertion; -import org.apache.qpid.test.framework.Circuit; -import org.apache.qpid.test.framework.FrameworkBaseCase; -import org.apache.qpid.test.framework.MessagingTestConfigProperties; -import org.apache.qpid.test.framework.sequencers.CircuitFactory; - -import org.apache.qpid.junit.extensions.TestThreadAware; -import org.apache.qpid.junit.extensions.TimingController; -import org.apache.qpid.junit.extensions.TimingControllerAware; -import org.apache.qpid.junit.extensions.util.ParsedProperties; -import org.apache.qpid.junit.extensions.util.TestContextProperties; - -import java.util.LinkedList; - -/** - * MessageThroughputPerf runs a test over a {@link Circuit} controlled by the test parameters. It logs timings of - * the time required to receive samples consisting of batches of messages. - * - * <p/><table id="crc"><caption>CRC Card</caption> - * <tr><th> Responsibilities <th> Collaborations - * <tr><td> Measure message throughput accross a test circuit. <td> {@link Circuit} - * </table> - * - * @todo Check that all of the messages were sent. Check that the receiving end got the same number of messages as - * the publishing end. - * - * @todo Set this up to run with zero sized tests. Size zero means send forever. Continuous sending to be interrupted - * by completion of the test duration, or shutdown hook when the user presses Ctrl-C. - */ -public class MessageThroughputPerf extends FrameworkBaseCase implements TimingControllerAware, TestThreadAware -{ - /** Used for debugging. */ - private static final Logger log = Logger.getLogger(MessageThroughputPerf.class); - - /** Holds the timing controller, used to log test timings from self-timed tests. */ - private TimingController timingController; - - /** Thread local to hold the per-thread test setup fields. */ - ThreadLocal<PerThreadSetup> threadSetup = new ThreadLocal<PerThreadSetup>(); - - /** - * Creates a new test case with the specified name. - * - * @param name The test case name. - */ - public MessageThroughputPerf(String name) - { - super(name); - } - - /** - * Performs the a basic P2P test case. - * - * @param numMessages The number of messages to send in the test. - */ - public void testThroughput(int numMessages) - { - log.debug("public void testThroughput(): called"); - - PerThreadSetup setup = threadSetup.get(); - assertNoFailures(setup.testCircuit.test(numMessages, new LinkedList<Assertion>())); - } - - /** - * Should provide a translation from the junit method name of a test to its test case name as known to the test - * clients that will run the test. The purpose of this is to convert the JUnit method name into the correct test - * case name to place into the test invite. For example the method "testP2P" might map onto the interop test case - * name "TC2_BasicP2P". - * - * @param methodName The name of the JUnit test method. - * - * @return The name of the corresponding interop test case. - */ - public String getTestCaseNameForTestMethod(String methodName) - { - log.debug("public String getTestCaseNameForTestMethod(String methodName = " + methodName + "): called"); - - return "DEFAULT_CIRCUIT_TEST"; - } - - /** - * Used by test runners that can supply a {@link org.apache.qpid.junit.extensions.TimingController} to set the - * controller on an aware test. - * - * @param controller The timing controller. - */ - public void setTimingController(TimingController controller) - { - timingController = controller; - } - - /** - * Overrides the parent setUp method so that the in-vm broker creation is not done on a per test basis. - * - * @throws Exception Any exceptions allowed to fall through and fail the test. - */ - protected void setUp() throws Exception - { - NDC.push(getName()); - - setTestProps(TestContextProperties.getInstance(MessagingTestConfigProperties.defaults)); - } - - /** - * Overrides the parent setUp method so that the in-vm broker clean-up is not done on a per test basis. - */ - protected void tearDown() - { - NDC.pop(); - } - - /** - * Performs test fixture creation on a per thread basis. This will only be called once for each test thread. - */ - public void threadSetUp() - { - // Run the test setup tasks. This may create an in-vm broker, if a decorator has injected a task for this. - getTaskHandler().runSetupTasks(); - - // Get the test parameters, any overrides on the command line will have been applied. - ParsedProperties testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults); - - // Customize the test parameters. - testProps.setProperty("TEST_NAME", "DEFAULT_CIRCUIT_TEST"); - testProps.setProperty(MessagingTestConfigProperties.SEND_DESTINATION_NAME_ROOT_PROPNAME, "testqueue"); - - // Get the test circuit factory to create test circuits and run the standard test procedure through. - CircuitFactory circuitFactory = getCircuitFactory(); - - // Create the test circuit. This projects the circuit onto the available test nodes and connects it up. - Circuit testCircuit = circuitFactory.createCircuit(null, testProps); - - // Store the test configuration for the thread. - PerThreadSetup setup = new PerThreadSetup(); - setup.testCircuit = testCircuit; - threadSetup.set(setup); - } - - /** - * Called after all threads have completed their setup. - */ - public void postThreadSetUp() - { - //Nothing to do here, potentially implement preFill as per PingTestPerf. - } - - /** - * Called when a test thread is destroyed. - */ - public void threadTearDown() - { - // Run the test teardown tasks. This may destroy the in-vm broker, if a decorator has injected a task for this. - getTaskHandler().runSetupTasks(); - } - - /** - * Holds the per-thread test configurations. - */ - protected static class PerThreadSetup - { - /** Holds the test circuit to run tests on. */ - Circuit testCircuit; - } - - /** - * Compiles all the tests in this class into a suite. - * - * @return The test suite. - */ - public static Test suite() - { - // Build a new test suite - TestSuite suite = new TestSuite("Qpid Throughput Performance Tests"); - - suite.addTest(new MessageThroughputPerf("testThroughput")); - - return suite; - } -} diff --git a/qpid/java/systests/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java b/qpid/java/systests/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java deleted file mode 100644 index 5323ad28bf..0000000000 --- a/qpid/java/systests/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java +++ /dev/null @@ -1,125 +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.mina.transport.vmpipe.support; - -import org.apache.mina.common.IdleStatus; - -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * This file is a patch to override MINA, because of the IdentityHashMap bug. Workaround to be supplied in MINA 1.0.7. - * This patched file will be removed once upgraded onto a newer MINA. - * - * Dectects idle sessions and fires <tt>sessionIdle</tt> events to them. - * - * @author The Apache Directory Project (mina-dev@directory.apache.org) - */ -public class VmPipeIdleStatusChecker -{ - private static final VmPipeIdleStatusChecker INSTANCE = new VmPipeIdleStatusChecker(); - - public static VmPipeIdleStatusChecker getInstance() - { - return INSTANCE; - } - - private final Map sessions = new HashMap(); // will use as a set - - private final Worker worker = new Worker(); - - private VmPipeIdleStatusChecker() - { - worker.start(); - } - - public void addSession(VmPipeSessionImpl session) - { - synchronized (sessions) - { - sessions.put(session, session); - } - } - - private class Worker extends Thread - { - private Worker() - { - super("VmPipeIdleStatusChecker"); - setDaemon(true); - } - - public void run() - { - for (;;) - { - try - { - Thread.sleep(1000); - } - catch (InterruptedException e) - { } - - long currentTime = System.currentTimeMillis(); - - synchronized (sessions) - { - Iterator it = sessions.keySet().iterator(); - while (it.hasNext()) - { - VmPipeSessionImpl session = (VmPipeSessionImpl) it.next(); - if (!session.isConnected()) - { - it.remove(); - } - else - { - notifyIdleSession(session, currentTime); - } - } - } - } - } - } - - private void notifyIdleSession(VmPipeSessionImpl session, long currentTime) - { - notifyIdleSession0(session, currentTime, session.getIdleTimeInMillis(IdleStatus.BOTH_IDLE), IdleStatus.BOTH_IDLE, - Math.max(session.getLastIoTime(), session.getLastIdleTime(IdleStatus.BOTH_IDLE))); - notifyIdleSession0(session, currentTime, session.getIdleTimeInMillis(IdleStatus.READER_IDLE), IdleStatus.READER_IDLE, - Math.max(session.getLastReadTime(), session.getLastIdleTime(IdleStatus.READER_IDLE))); - notifyIdleSession0(session, currentTime, session.getIdleTimeInMillis(IdleStatus.WRITER_IDLE), IdleStatus.WRITER_IDLE, - Math.max(session.getLastWriteTime(), session.getLastIdleTime(IdleStatus.WRITER_IDLE))); - } - - private void notifyIdleSession0(VmPipeSessionImpl session, long currentTime, long idleTime, IdleStatus status, - long lastIoTime) - { - if ((idleTime > 0) && (lastIoTime != 0) && ((currentTime - lastIoTime) >= idleTime)) - { - session.increaseIdleCount(status); - session.getFilterChain().fireSessionIdle(session, status); - } - } - -} diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java index ca10126aa7..986297bfe1 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java @@ -30,7 +30,6 @@ import javax.jms.TextMessage; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.client.transport.TransportConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java index a8a23c2c41..29a44ecec3 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java @@ -36,7 +36,6 @@ import javax.jms.Session; import javax.naming.Context; import javax.naming.spi.InitialContextFactory; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.jndi.PropertiesFileInitialContextFactory; import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.slf4j.Logger; diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java deleted file mode 100644 index b50643583e..0000000000 --- a/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java +++ /dev/null @@ -1,82 +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.client; - -import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.client.transport.TransportConnection; - -import java.io.File; -import java.security.Provider; -import java.security.Security; -import java.util.List; -import java.util.LinkedList; - -/** - * QPID-1394 : Test to ensure that the client can register their custom JCAProviders after the broker to ensure that - * the Qpid custom authentication SASL plugins are used. - */ -public class MultipleJCAProviderRegistrationTest extends QpidBrokerTestCase -{ - - public void setUp() throws Exception - { - _brokerType = VM; - - super.setUp(); - } - - public void test() throws Exception - { - // Get the providers before connection - Provider[] providers = Security.getProviders(); - - // Force the client to load the providers - getConnection(); - - Provider[] afterConnectionCreation = Security.getProviders(); - - // Find the additions - List additions = new LinkedList(); - for (Provider afterCreation : afterConnectionCreation) - { - boolean found = false; - for (Provider provider : providers) - { - if (provider == afterCreation) - { - found=true; - break; - } - } - - // Record added registies - if (!found) - { - additions.add(afterCreation); - } - } - - assertTrue("Client did not register any providers", additions.size() > 0); - } - -} diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java index 7cc5d5995a..383c4c00a8 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java @@ -55,12 +55,9 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas assertEquals("Incorrect vhost data", 0, vhost.getTotalDataReceived()); assertFalse("Vhost statistics should not be enabled", vhost.isStatisticsEnabled()); - if (!_brokerType.equals(VM)) - { - assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived()); - assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived()); - assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); - } + assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived()); + assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived()); + assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); } /** @@ -83,12 +80,9 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas assertEquals("Incorrect vhost data", 1000, vhost.getTotalDataReceived()); assertTrue("Vhost statistics should be enabled", vhost.isStatisticsEnabled()); - if (!_brokerType.equals(VM)) - { - assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessagesReceived()); - assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalDataReceived()); - assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); - } + assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessagesReceived()); + assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalDataReceived()); + assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); } /** @@ -111,12 +105,9 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas assertEquals("Incorrect vhost data", 0, vhost.getTotalDataReceived()); assertFalse("Vhost statistics should not be enabled", vhost.isStatisticsEnabled()); - if (!_brokerType.equals(VM)) - { - assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessagesReceived()); - assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalDataReceived()); - assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); - } + assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessagesReceived()); + assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalDataReceived()); + assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); } /** @@ -139,12 +130,9 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas assertEquals("Incorrect vhost data", 1000, vhost.getTotalDataReceived()); assertTrue("Vhost statistics should be enabled", vhost.isStatisticsEnabled()); - if (!_brokerType.equals(VM)) - { - assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived()); - assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived()); - assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); - } + assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived()); + assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived()); + assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); } /** @@ -167,11 +155,8 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas assertEquals("Incorrect vhost data", 1000, vhost.getTotalDataReceived()); assertTrue("Vhost statistics should be enabled", vhost.isStatisticsEnabled()); - if (!_brokerType.equals(VM)) - { - assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived()); - assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived()); - assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); - } + assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived()); + assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived()); + assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled()); } } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java index f1953d1eba..824ae41b97 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java @@ -66,11 +66,8 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase assertEquals("Incorrect connection total", 45, total); assertEquals("Incorrect connection data", 4500, data); } - if (!_brokerType.equals(VM)) - { - assertEquals("Incorrect server total", 45, _jmxUtils.getServerInformation().getTotalMessagesReceived()); - assertEquals("Incorrect server data", 4500, _jmxUtils.getServerInformation().getTotalDataReceived()); - } + assertEquals("Incorrect server total", 45, _jmxUtils.getServerInformation().getTotalMessagesReceived()); + assertEquals("Incorrect server data", 4500, _jmxUtils.getServerInformation().getTotalDataReceived()); if (!isBroker010()) { @@ -147,11 +144,8 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase assertEquals("Incorrect active connection total", 20, total); assertEquals("Incorrect active connection data", 2000, data); } - if (!_brokerType.equals(VM)) - { - assertEquals("Incorrect server total", 30, _jmxUtils.getServerInformation().getTotalMessagesReceived()); - assertEquals("Incorrect server data", 3000, _jmxUtils.getServerInformation().getTotalDataReceived()); - } + assertEquals("Incorrect server total", 30, _jmxUtils.getServerInformation().getTotalMessagesReceived()); + assertEquals("Incorrect server data", 3000, _jmxUtils.getServerInformation().getTotalDataReceived()); if (!isBroker010()) { @@ -187,11 +181,8 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase assertApprox("Incorrect dev vhost peak messages", 0.2d, 2.0d, dev.getPeakMessageReceiptRate()); assertApprox("Incorrect dev vhost peak data", 0.2d, 20.0d, dev.getPeakDataReceiptRate()); - if (!_brokerType.equals(VM)) - { - assertApprox("Incorrect server peak messages", 0.2d, 2.0d, _jmxUtils.getServerInformation().getPeakMessageReceiptRate()); - assertApprox("Incorrect server peak data", 0.2d, 20.0d, _jmxUtils.getServerInformation().getPeakDataReceiptRate()); - } + assertApprox("Incorrect server peak messages", 0.2d, 2.0d, _jmxUtils.getServerInformation().getPeakMessageReceiptRate()); + assertApprox("Incorrect server peak data", 0.2d, 20.0d, _jmxUtils.getServerInformation().getPeakDataReceiptRate()); } /** @@ -211,11 +202,8 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase assertEquals("Incorrect dev vhost total messages", 10, dev.getTotalMessagesReceived()); assertEquals("Incorrect dev vhost total data", 100, dev.getTotalDataReceived()); - if (!_brokerType.equals(VM)) - { - assertEquals("Incorrect server total messages", 20, _jmxUtils.getServerInformation().getTotalMessagesReceived()); - assertEquals("Incorrect server total data", 200, _jmxUtils.getServerInformation().getTotalDataReceived()); - } + assertEquals("Incorrect server total messages", 20, _jmxUtils.getServerInformation().getTotalMessagesReceived()); + assertEquals("Incorrect server total data", 200, _jmxUtils.getServerInformation().getTotalDataReceived()); test.resetStatistics(); @@ -224,10 +212,7 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase assertEquals("Incorrect dev vhost total messages", 10, dev.getTotalMessagesReceived()); assertEquals("Incorrect dev vhost total data", 100, dev.getTotalDataReceived()); - if (!_brokerType.equals(VM)) - { - assertEquals("Incorrect server total messages", 20, _jmxUtils.getServerInformation().getTotalMessagesReceived()); - assertEquals("Incorrect server total data", 200, _jmxUtils.getServerInformation().getTotalDataReceived()); - } + assertEquals("Incorrect server total messages", 20, _jmxUtils.getServerInformation().getTotalMessagesReceived()); + assertEquals("Incorrect server total data", 200, _jmxUtils.getServerInformation().getTotalDataReceived()); } } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java index 2d89d319d7..4a92f04b30 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java @@ -83,15 +83,9 @@ public class MessagingTestConfigProperties /** Holds the name of the default connection factory configuration property. */ public static final String CONNECTION_PROPNAME = "connectionfactory.broker"; - /** Defeins the default connection configuration. */ - public static final String CONNECTION_DEFAULT = "amqp://guest:guest@clientid/?brokerlist='vm://:1'"; - /** Holds the name of the property to get the test broker url from. */ public static final String BROKER_PROPNAME = "qpid.test.broker"; - /** Holds the default broker url for the test. */ - public static final String BROKER_DEFAULT = "vm://:1"; - /** Holds the name of the property to get the test broker virtual path. */ public static final String VIRTUAL_HOST_PROPNAME = "virtualHost"; @@ -274,7 +268,6 @@ public class MessagingTestConfigProperties static { defaults.setPropertyIfNull(INITIAL_CONTEXT_FACTORY_PROPNAME, INITIAL_CONTEXT_FACTORY_DEFAULT); - defaults.setPropertyIfNull(CONNECTION_PROPNAME, CONNECTION_DEFAULT); defaults.setPropertyIfNull(MESSAGE_SIZE_PROPNAME, MESSAGE_SIZE_DEAFULT); defaults.setPropertyIfNull(PUBLISHER_PRODUCER_BIND_PROPNAME, PUBLISHER_PRODUCER_BIND_DEFAULT); defaults.setPropertyIfNull(PUBLISHER_CONSUMER_BIND_PROPNAME, PUBLISHER_CONSUMER_BIND_DEFAULT); @@ -284,7 +277,6 @@ public class MessagingTestConfigProperties defaults.setPropertyIfNull(RECEIVE_DESTINATION_NAME_ROOT_PROPNAME, RECEIVE_DESTINATION_NAME_ROOT_DEFAULT); defaults.setPropertyIfNull(PERSISTENT_MODE_PROPNAME, PERSISTENT_MODE_DEFAULT); defaults.setPropertyIfNull(TRANSACTED_PROPNAME, TRANSACTED_DEFAULT); - defaults.setPropertyIfNull(BROKER_PROPNAME, BROKER_DEFAULT); defaults.setPropertyIfNull(VIRTUAL_HOST_PROPNAME, VIRTUAL_HOST_DEFAULT); defaults.setPropertyIfNull(RATE_PROPNAME, RATE_DEFAULT); defaults.setPropertyIfNull(VERBOSE_PROPNAME, VERBOSE_DEFAULT); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java index 011700d634..35650e314a 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java @@ -20,55 +20,39 @@ */ package org.apache.qpid.server.failover; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.jms.ExceptionListener; +import javax.jms.JMSException; + import org.apache.qpid.AMQDisconnectedException; import org.apache.qpid.AMQException; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQConnectionURL; -import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException; -import org.apache.qpid.server.util.InternalBrokerBaseCase; -import org.apache.qpid.url.URLSyntaxException; +import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import java.util.concurrent.CountDownLatch; - -public class FailoverMethodTest extends InternalBrokerBaseCase implements ExceptionListener +public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionListener { private CountDownLatch _failoverComplete = new CountDownLatch(1); protected static final Logger _logger = LoggerFactory.getLogger(FailoverMethodTest.class); - @Override - public void createBroker() throws Exception - { - super.createBroker(); - TransportConnection.createVMBroker(TransportConnection.DEFAULT_VM_PORT); - } - @Override - public void stopBroker() - { - TransportConnection.killVMBroker(TransportConnection.DEFAULT_VM_PORT); - super.stopBroker(); - } /** * Test that the round robin method has the correct delays. - * The first connection to vm://:1 will work but the localhost connection should fail but the duration it takes + * The first connection will work but the localhost connection should fail but the duration it takes * to report the failure is what is being tested. * - * @throws URLSyntaxException - * @throws InterruptedException - * @throws JMSException */ - public void testFailoverRoundRobinDelay() throws URLSyntaxException, InterruptedException, JMSException + public void testFailoverRoundRobinDelay() throws Exception { - //note: The VM broker has no connect delay and the default 1 retry + //note: The first broker has no connect delay and the default 1 retry // while the tcp:localhost broker has 3 retries with a 2s connect delay String connectionString = "amqp://guest:guest@/test?brokerlist=" + - "'vm://:" + TransportConnection.DEFAULT_VM_PORT + + "'tcp://:" + getPort() + ";tcp://localhost:5670?connectdelay='2000',retries='3''"; AMQConnectionURL url = new AMQConnectionURL(connectionString); @@ -82,7 +66,9 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except stopBroker(); - _failoverComplete.await(); + _failoverComplete.await(30, TimeUnit.SECONDS); + assertEquals("failoverLatch was not decremented in given timeframe", + 0, _failoverComplete.getCount()); long end = System.currentTimeMillis(); @@ -109,10 +95,9 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except } } - public void testFailoverSingleDelay() throws URLSyntaxException, AMQVMBrokerCreationException, - InterruptedException, JMSException + public void testFailoverSingleDelay() throws Exception { - String connectionString = "amqp://guest:guest@/test?brokerlist='vm://:1?connectdelay='2000',retries='3''"; + String connectionString = "amqp://guest:guest@/test?brokerlist='tcp://localhost:" + getPort() + "?connectdelay='2000',retries='3''"; AMQConnectionURL url = new AMQConnectionURL(connectionString); @@ -125,7 +110,9 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except stopBroker(); - _failoverComplete.await(); + _failoverComplete.await(30, TimeUnit.SECONDS); + assertEquals("failoverLatch was not decremented in given timeframe", + 0, _failoverComplete.getCount()); long end = System.currentTimeMillis(); @@ -157,6 +144,10 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except _logger.debug("Received AMQDisconnectedException"); _failoverComplete.countDown(); } + else + { + _logger.error("Unexpected underlying exception", e.getLinkedException()); + } } /** @@ -165,17 +156,11 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except * * Test validates that there is a connection delay as required on initial * connection. - * - * @throws URLSyntaxException - * @throws AMQVMBrokerCreationException - * @throws InterruptedException - * @throws JMSException */ - public void testNoFailover() throws URLSyntaxException, AMQVMBrokerCreationException, - InterruptedException, JMSException + public void testNoFailover() throws Exception { int CONNECT_DELAY = 2000; - String connectionString = "amqp://guest:guest@/test?brokerlist='vm://:1?connectdelay='" + CONNECT_DELAY + "'," + + String connectionString = "amqp://guest:guest@/test?brokerlist='tcp://localhost:" + getPort() + "?connectdelay='" + CONNECT_DELAY + "'," + "retries='3'',failover='nofailover'"; AMQConnectionURL url = new AMQConnectionURL(connectionString); @@ -195,7 +180,7 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except //Wait before starting broker // The wait should allow atleast 1 retries to fail before broker is ready Thread.sleep(750); - createBroker(); + startBroker(); } catch (Exception e) { @@ -231,7 +216,9 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except //Kill connection stopBroker(); - _failoverComplete.await(); + _failoverComplete.await(30, TimeUnit.SECONDS); + assertEquals("failoverLatch was not decremented in given timeframe", + 0, _failoverComplete.getCount()); end = System.currentTimeMillis(); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java index 05aaf16af1..58b2edfee2 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java @@ -176,7 +176,7 @@ public class AlertingTest extends AbstractTestLogging startBroker(); - if (!isExternalBroker()) + if (isInternalBroker()) { assertEquals("Alert Max Msg Count is not correct", 5, ApplicationRegistry.getInstance().getVirtualHostRegistry(). getVirtualHost(VIRTUALHOST).getQueueRegistry().getQueue(new AMQShortString(_destination.getQueueName())). diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java index 02d0d6f334..1b2ec9c092 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java @@ -77,7 +77,7 @@ public class ChannelLoggingTest extends AbstractTestLogging validateMessageID("CHN-1001", log); assertEquals("Incorrect Channel in actor:"+fromActor(log), isBroker010()? 0 : 1, getChannelID(fromActor(log))); - if (isBroker08()) + if (!isBroker010()) { // Wait to ensure that the CHN-1004 message is logged waitForMessage("CHN-1004"); @@ -89,7 +89,7 @@ public class ChannelLoggingTest extends AbstractTestLogging log = getLogMessage(results, 0); // MESSAGE [con:0(guest@anonymous(3273383)/test)/ch:1] CHN-1004 : Prefetch Size (bytes) {0,number} : Count {1,number} validateMessageID("CHN-1004", log); - assertEquals("Incorrect Channel in actor:"+fromActor(log), isBroker010()? 0 : 1, getChannelID(fromActor(log))); + assertEquals("Incorrect Channel in actor:"+fromActor(log), 1, getChannelID(fromActor(log))); assertTrue("Prefetch Count not correct",getMessageString(fromMessage(log)).endsWith("Count "+PREFETCH)); } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java index 595c0d5f35..9feca7279e 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java @@ -76,9 +76,8 @@ public class ManagementLoggingTest extends AbstractTestLogging */ public void testManagementStartupEnabled() throws Exception { - // This test only works on external java brokers due to the fact that - // Management is disabled on InVM brokers. - if (isJavaBroker() && isExternalBroker()) + // This test only works on java brokers + if (isJavaBroker()) { startBrokerAndCreateMonitor(true, false); @@ -130,9 +129,7 @@ public class ManagementLoggingTest extends AbstractTestLogging */ public void testManagementStartupDisabled() throws Exception { - // This test only works on external java brokers due to the fact that - // Management is disabled on InVM brokers. - if (isJavaBroker() && isExternalBroker()) + if (isJavaBroker()) { startBrokerAndCreateMonitor(false, false); @@ -191,9 +188,7 @@ public class ManagementLoggingTest extends AbstractTestLogging */ public void testManagementStartupRMIEntries() throws Exception { - // This test only works on external java brokers due to the fact that - // Management is disabled on InVM brokers. - if (isJavaBroker() && isExternalBroker()) + if (isJavaBroker()) { startBrokerAndCreateMonitor(true, false); @@ -250,9 +245,7 @@ public class ManagementLoggingTest extends AbstractTestLogging */ public void testManagementStartupSSLKeystore() throws Exception { - // This test only works on external java brokers due to the fact that - // Management is disabled on InVM brokers. - if (isJavaBroker() && isExternalBroker()) + if (isJavaBroker()) { startBrokerAndCreateMonitor(true, true); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java index ce6cc60ffd..398c83a8d8 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java @@ -78,21 +78,10 @@ public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase implements Conn BrokerDetails details = _connectionURL.getBrokerDetails(0); - // Due to the problem with SingleServer delaying on all connection - // attempts. So using a high retry value. - if (_brokerType.equals(VM)) - { - // Local testing suggests InVM restart takes under a second - details.setProperty(BrokerDetails.OPTIONS_RETRY, "5"); - details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "200"); - } - else - { - // This will attempt to failover for 3 seconds. - // Local testing suggests failover takes 2 seconds - details.setProperty(BrokerDetails.OPTIONS_RETRY, "10"); - details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "500"); - } + // This will attempt to failover for 3 seconds. + // Local testing suggests failover takes 2 seconds + details.setProperty(BrokerDetails.OPTIONS_RETRY, "10"); + details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "500"); super.setUp(); } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java index 6203e8a194..2ce1251eab 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java @@ -23,7 +23,6 @@ package org.apache.qpid.server.queue; import junit.framework.TestCase; import junit.framework.Assert; import org.apache.log4j.Logger; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQQueue; diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java index be4a865ff6..2d99a44532 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java @@ -85,12 +85,6 @@ public class FirewallConfigTest extends QpidBrokerTestCase public void testVhostAllowBrokerDeny() throws Exception { - if (_brokerType.equals(VM)) - { - //No point running this test with an InVM broker as the - //firewall plugin only functions for TCP connections. - return; - } _configFile = new File(System.getProperty("QPID_HOME"), "etc/config-systests-firewall-2.xml"); @@ -125,13 +119,6 @@ public class FirewallConfigTest extends QpidBrokerTestCase public void testVhostDenyBrokerAllow() throws Exception { - if (_brokerType.equals(VM)) - { - //No point running this test with an InVM broker as the - //firewall plugin only functions for TCP connections. - return; - } - _configFile = new File(System.getProperty("QPID_HOME"), "etc/config-systests-firewall-3.xml"); super.setUp(); @@ -277,11 +264,6 @@ public class FirewallConfigTest extends QpidBrokerTestCase private void testFirewall(boolean initial, boolean inVhost, Runnable restartOrReload) throws Exception { - if (_brokerType.equals(VM)) - { - // No point running this test in a vm broker - return; - } writeFirewallFile(initial, inVhost); setConfigurationProperty("management.enabled", String.valueOf(true)); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java index 212374e8be..b1c8b5682f 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java @@ -52,7 +52,6 @@ public class SelectorTest extends QpidBrokerTestCase implements MessageListener private AMQConnection _connection; private AMQDestination _destination; private int count; - public String _connectionString = "vm://:1"; private static final String INVALID_SELECTOR = "Cost LIKE 5"; CountDownLatch _responseLatch = new CountDownLatch(1); @@ -314,31 +313,4 @@ public class SelectorTest extends QpidBrokerTestCase implements MessageListener assertNull("Consumer2 should not receiver another message",consumer2.receive(1000)); } - public static void main(String[] argv) throws Exception - { - SelectorTest test = new SelectorTest(); - test._connectionString = (argv.length == 0) ? "localhost:3000" : argv[0]; - - try - { - while (true) - { - if (test._connectionString.contains("vm://:1")) - { - test.setUp(); - } - test.testUsingOnMessage(); - - if (test._connectionString.contains("vm://:1")) - { - test.tearDown(); - } - } - } - catch (Exception e) - { - System.err.println(e.getMessage()); - e.printStackTrace(); - } - } } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java deleted file mode 100644 index c11f75e742..0000000000 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.framework.qpid; - -import junit.framework.Test; -import junit.framework.TestResult; - -import org.apache.qpid.test.framework.FrameworkBaseCase; -import org.apache.qpid.test.framework.LocalAMQPCircuitFactory; - -import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator; - -/** - * AMQPFeatureDecorator applies decorations to {@link FrameworkBaseCase} tests, so that they may use Qpid/AMQP specific - * features, not available through JMS. For example, the immediate and mandatory flags. This decorator replaces the - * standard test circuit factory on the base class with one that allows these features to be used. - * - * <p/><table id="crc"><caption>CRC Card</caption> - * <tr><th> Responsibilities <th> Collaborations - * <tr><td> Substitute the circuit factory with an AMQP/Qpid specific one. - * </table> - * - * @todo This wrapper substitutes in a LocalAMQPCircuitFactory, which is fine for local tests. For distributed tests - * the Fanout or Interop factories are substituted in by their decorators instead. These actually use - * distributed circuit static create methods to build the circuits, which should actually be changed to a factory, - * so that static methods do not need to be used. The distributed circuit creater delegates the circuit - * construction to remote test nodes. This decorator should not be used with distributed tests, or should be made - * aware of them, in which case it might ensure that an AMQP feature (implied already by other properties) flag - * is passed out to the remote test nodes, and provide a mechansim for them to decorate their circuit creation - * with AMQP features too. Add factory substituion/decoration mechansim for test clients, here or in a seperate - * class. - */ -public class AMQPFeatureDecorator extends WrappedSuiteTestDecorator -{ - /** The test suite to run. */ - private Test test; - - /** - * Creates a wrapped test test decorator from another one. - * - * @param test The test test. - */ - public AMQPFeatureDecorator(WrappedSuiteTestDecorator test) - { - super(test); - this.test = test; - } - - /** - * Runs the tests with a LocalAMQPCircuitFactory. Only tests that extend FrameworkBaseCase are decorated. - * - * @param testResult The the results object to monitor the test results with. - */ - public void run(TestResult testResult) - { - for (Test test : getAllUnderlyingTests()) - { - if (test instanceof FrameworkBaseCase) - { - FrameworkBaseCase frameworkTest = (FrameworkBaseCase) test; - frameworkTest.setCircuitFactory(new LocalAMQPCircuitFactory()); - } - } - - // Run the test. - test.run(testResult); - } - - /** - * Prints the name of the test for debugging purposes. - * - * @return The name of the test. - */ - public String toString() - { - return "AMQPFeatureDecorator: [test = \"" + test + "\"]"; - } -} diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureDecorator.java deleted file mode 100644 index 2708253d86..0000000000 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureDecorator.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.framework.qpid; - -import junit.framework.Test; -import junit.framework.TestResult; - -import org.apache.qpid.test.framework.BrokerLifecycleAware; -import org.apache.qpid.test.framework.CauseFailureUserPrompt; - -import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator; - -/** - * CauseFailureDecorator applies decorations to {@link BrokerLifecycleAware} tests, so that they may use different failure - * mechanisms. It is capable of detecting when a test case uses in-vm brokers, and setting up an automatic failure - * for those tests, so that the current live broker can be shut-down by test cases. For external brokers, automatic - * failure could be implemented, for example by having a kill script. At the moment this sets up the failure to prompt - * a user interactively to cause a failure, using {@link CauseFailureUserPrompt}. - * - * <p/><table id="crc"><caption>CRC Card</caption> - * <tr><th> Responsibilities <th> Collaborations - * <tr><td> Setup automatic failures for in-vm brokers. <td> {@link CauseFailureInVM} - * <tr><td> Setup user generated failures for external brokers. <td> {@link CauseFailureUserPrompt}. - * <tr><td> - * </table> - * - * @todo Slight problem in that CauseFailureInVM is Qpid specific, whereas CauseFailureUserPrompt is not. Would like the - * failure decorator to be non-qpid specific so that it can test failure of any JMS implementation too. Either pass - * in class name of failure mechanism, set it up in the in-vm decorator instead of here but with prompt user as the - * default for when the in-vm decorator is not used? - */ -public class CauseFailureDecorator extends WrappedSuiteTestDecorator -{ - /** The test suite to run. */ - private Test test; - - /** - * Creates a wrapped test test decorator from another one. - * - * @param test The test test. - */ - public CauseFailureDecorator(WrappedSuiteTestDecorator test) - { - super(test); - this.test = test; - } - - /** - * Runs the tests with a LocalAMQPCircuitFactory. Only tests that extend FrameworkBaseCase are decorated. - * - * @param testResult The the results object to monitor the test results with. - */ - public void run(TestResult testResult) - { - for (Test test : getAllUnderlyingTests()) - { - if (test instanceof BrokerLifecycleAware) - { - BrokerLifecycleAware failureTest = (BrokerLifecycleAware) test; - failureTest.setFailureMechanism(new CauseFailureUserPrompt()); - } - } - - // Run the test. - test.run(testResult); - } - - /** - * Prints the name of the test for debugging purposes. - * - * @return The name of the test. - */ - public String toString() - { - return "CauseFailureDecorator: [test = \"" + test + "\"]"; - } -} diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java deleted file mode 100644 index fd86fc8e21..0000000000 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.framework.qpid; - -import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.test.framework.CauseFailure; -import org.apache.qpid.test.framework.BrokerLifecycleAware; - -/** - * <p/><table id="crc"><caption>CRC Card</caption> - * <tr><th> Responsibilities <th> Collaborations - * <tr><td> Cause messaging broker failure on the active in-vm broker. - * <td> {@link TransportConnection}, {@link ApplicationRegistry} - * </table> - */ -public class CauseFailureInVM implements CauseFailure -{ - /** Holds the in-vm broker instrumented test case to create failures for. */ - private BrokerLifecycleAware inVMTest; - - /** - * Creates an automated failure mechanism for testing against in-vm brokers. The test to create the mechanism - * for is specified, and as this failure is for in-vm brokers, the test must be {@link org.apache.qpid.test.framework.BrokerLifecycleAware}. The test - * must also report that it is currently being run against an in-vm broker, and it is a runtime error if it is not, - * as the creator of this failure mechanism should already have checked that it is. - * - * @param inVMTest The test case to create an automated failure mechanism for. - */ - public CauseFailureInVM(BrokerLifecycleAware inVMTest) - { - // Check that the test is really using in-vm brokers. - if (!inVMTest.usingInVmBroker()) - { - throw new RuntimeException( - "Cannot create in-vm broker failure mechanism for a test that is not using in-vm brokers."); - } - - this.inVMTest = inVMTest; - } - - /** - * Causes the active message broker to fail. - */ - public void causeFailure() - { - int liveBroker = inVMTest.getLiveBroker(); - - TransportConnection.killVMBroker(liveBroker); - ApplicationRegistry.remove(); - } -} diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java deleted file mode 100644 index c43318165d..0000000000 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.framework.qpid; - -import junit.framework.Test; -import junit.framework.TestResult; - -import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.test.framework.BrokerLifecycleAware; -import org.apache.qpid.test.framework.FrameworkBaseCase; - -import org.apache.qpid.junit.extensions.SetupTaskAware; -import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator; - -/** - * InVMBrokerDecorator is a test decorator, that is activated when running tests against an in-vm broker only. Its - * purpose is to automatically create, and close and delete an in-vm broker, during the set-up and tear-down of - * each test case. This decorator may only be used in conjunction with tests that extend {@link FrameworkBaseCase}. - * - * <p/><table id="crc"><caption>CRC Card</caption> - * <tr><th> Responsibilities <th> Collaborations - * <tr><td> Create/Destroy an in-vm broker on every test run. - * </table> - * - * @todo May need to add a more fine grained injection point for the in-vm broker management, as this acts at the - * suite level, rather than the individual test level. - * - * @todo Management of in-vm brokers for failure testing. Failure test setups may need to set their connection url to - * use multiple broker (vm://:1;vm://:2), with fail-over between them. There is round-robin fail-over, but also - * retry? A test case using an in-vm broker needs to record which one it is using, so that it can be - * killed/restarted. - */ -public class InVMBrokerDecorator extends WrappedSuiteTestDecorator -{ - /** The test suite to run. */ - private Test test; - - /** - * Creates a wrapped test suite decorator from another one. - * - * @param test The test suite. - */ - public InVMBrokerDecorator(WrappedSuiteTestDecorator test) - { - super(test); - this.test = test; - } - - /** - * Runs the tests with in-vm broker creation and clean-up added to the tests task stack. - * - * @param testResult The the results object to monitor the test results with. - */ - public void run(TestResult testResult) - { - for (Test test : getAllUnderlyingTests()) - { - // Check that the test to have an in-vm broker setup/teardown task added to it, is actually a framework - // test that can handle setup tasks. - if ((test instanceof SetupTaskAware)) - { - SetupTaskAware frameworkTest = (SetupTaskAware) test; - - frameworkTest.chainSetupTask(new Runnable() - { - public void run() - { - // Ensure that the in-vm broker is created. - try - { - ApplicationRegistry.getInstance(); - TransportConnection.createVMBroker(1); - } - catch (AMQVMBrokerCreationException e) - { - throw new RuntimeException("In-VM broker creation failed: " + e.getMessage(), e); - } - } - }); - - frameworkTest.chainTearDownTask(new Runnable() - { - public void run() - { - // Ensure that the in-vm broker is cleaned up so that the next test starts afresh. - TransportConnection.killVMBroker(1); - ApplicationRegistry.remove(); - } - }); - - // Check if the test is aware whether or not it can control the broker life cycle, and if so provide - // additional instrumentation for it to control the in-vm broker through. - if (test instanceof BrokerLifecycleAware) - { - BrokerLifecycleAware inVMTest = (BrokerLifecycleAware) test; - inVMTest.setInVmBrokers(); - inVMTest.setLiveBroker(1); - inVMTest.setFailureMechanism(new CauseFailureInVM(inVMTest)); - } - } - } - - // Run the test. - test.run(testResult); - } - - /** - * Prints the name of the test for debugging purposes. - * - * @return The name of the test. - */ - public String toString() - { - return "InVMBrokerDecorator: [test = " + test + "]"; - } -} diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java index 3a5f676ca6..87eae32cf8 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java @@ -23,7 +23,6 @@ import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQDestination; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQTopic; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.test.utils.QpidBrokerTestCase; diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java index 292bcd6039..481b144caf 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java @@ -20,7 +20,6 @@ */ package org.apache.qpid.test.unit.client; -import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.LineNumberReader; @@ -37,11 +36,9 @@ import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.QueueSession; import javax.jms.Session; -import javax.jms.TextMessage; import javax.jms.TopicSession; import org.apache.qpid.client.AMQConnection; -import org.apache.qpid.client.AMQConnectionDelegate_0_10; import org.apache.qpid.client.AMQQueue; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQTopic; @@ -231,7 +228,8 @@ public class AMQConnectionTest extends QpidBrokerTestCase } MessageConsumer consumerB = null; - if (isBroker08()) + // 0-8, 0-9, 0-9-1 prefetch is per session, not consumer. + if (!isBroker010()) { Session consSessB = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE); consumerB = consSessB.createConsumer(_queue); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java index 79e2ff8148..aae8b1feb9 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java @@ -24,7 +24,6 @@ import junit.textui.TestRunner; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQQueue; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.slf4j.Logger; diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java index b6232b1734..2e8a2d049d 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java @@ -25,7 +25,6 @@ import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.client.protocol.AMQProtocolHandler; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.framing.*; import org.apache.qpid.jms.ConnectionListener; import org.apache.qpid.protocol.AMQConstant; diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java index 04fc611cd1..d17ead13aa 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java @@ -20,32 +20,30 @@ */ package org.apache.qpid.test.unit.client.connection; +import javax.jms.Connection; +import javax.jms.QueueSession; +import javax.jms.TopicSession; + import org.apache.qpid.AMQConnectionFailureException; import org.apache.qpid.AMQException; import org.apache.qpid.AMQUnresolvedAddressException; -import org.apache.qpid.server.exchange.Exchange; -import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.client.AMQAuthenticationException; import org.apache.qpid.client.AMQConnection; +import org.apache.qpid.client.AMQConnectionURL; import org.apache.qpid.client.AMQQueue; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQTopic; -import org.apache.qpid.client.AMQConnectionURL; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.jms.Session; -import org.apache.qpid.jms.ConnectionURL; import org.apache.qpid.jms.BrokerDetails; - -import javax.jms.Connection; -import javax.jms.QueueSession; -import javax.jms.TopicSession; -import javax.naming.NamingException; +import org.apache.qpid.jms.ConnectionURL; +import org.apache.qpid.jms.Session; +import org.apache.qpid.test.utils.QpidBrokerTestCase; public class ConnectionTest extends QpidBrokerTestCase { - String _broker_NotRunning = "vm://:2"; + String _broker_NotRunning = "tcp://localhost:" + findFreePort(); + String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs"; public void testSimpleConnection() throws Exception diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java index 9c1807199c..5701b5a1fd 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java @@ -93,11 +93,6 @@ public class AMQProtocolSessionTest extends QpidBrokerTestCase checkTempQueueName(new InetSocketAddress(InetAddress.getByName("1080:0:0:0:8:800:200C:417A"), 1234), "tmp_1080_0_0_0_8_800_200c_417a_1234_1"); } - public void testTemporaryQueuePipe() throws UnknownHostException - { - checkTempQueueName(new VmPipeAddress(1), "tmp_vm_1_1"); - } - private void checkTempQueueName(SocketAddress address, String queueName) { _testSession.getNetworkConnection().setLocalAddress(address); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java index de092fc893..f5e0ed75d2 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java @@ -50,7 +50,6 @@ public class MessageRequeueTest extends QpidBrokerTestCase protected final String queue = "direct://amq.direct//message-requeue-test-queue"; protected String payload = "Message:"; - //protected final String BROKER = "vm://:1"; protected final String BROKER = "tcp://127.0.0.1:5672"; private boolean testReception = true; @@ -155,8 +154,8 @@ public class MessageRequeueTest extends QpidBrokerTestCase _logger.info("consumed: " + messagesReceived); assertEquals("number of consumed messages does not match initial data", (int) numTestMessages, messagesReceived); - // wit 0_10 we can have a delivery tag of 0 - if (conn.isBroker08()) + // with 0_10 we can have a delivery tag of 0 + if (!conn.isBroker010()) { for (long b : messageLog) { @@ -224,7 +223,7 @@ public class MessageRequeueTest extends QpidBrokerTestCase StringBuilder list = new StringBuilder(); list.append("Failed to receive:"); int failed = 0; - if (conn.isBroker08()) + if (!conn.isBroker010()) { for (long b : receieved) { diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java index 989ac98747..80422cf3e9 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java @@ -52,7 +52,7 @@ public class DurableSubscriberTest extends QpidBrokerTestCase */ public void testDurSubRestoredAfterNonPersistentMessageSent() throws Exception { - if (isBrokerStorePersistent() || !isBroker08()) + if (isBrokerStorePersistent()) { TopicConnectionFactory factory = getConnectionFactory(); Topic topic = (Topic) getInitialContext().lookup(_topicName); @@ -116,7 +116,7 @@ public class DurableSubscriberTest extends QpidBrokerTestCase */ public void testDurSubRestoresMessageSelector() throws Exception { - if (isBrokerStorePersistent() || !isBroker08()) + if (isBrokerStorePersistent()) { TopicConnectionFactory factory = getConnectionFactory(); Topic topic = (Topic) getInitialContext().lookup(_topicName); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java index 5fb06dfbb4..786fc2adb0 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java @@ -102,7 +102,7 @@ public class TransactionTimeoutTestCase extends QpidBrokerTestCase implements Ex super.setUp(); // Connect to broker - String broker = _brokerType.equals(VM) ? ("vm://:" + DEFAULT_VM_PORT) : ("tcp://localhost:" + DEFAULT_PORT); + String broker = ("tcp://localhost:" + DEFAULT_PORT); ConnectionURL url = new AMQConnectionURL("amqp://guest:guest@clientid/test?brokerlist='" + broker + "'&maxprefetch='1'"); _con = (AMQConnection) getConnection(url); _con.setExceptionListener(this); diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java index 1832a7641e..10217585c1 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java @@ -68,6 +68,14 @@ public class FailoverBaseCase extends QpidBrokerTestCase return _connectionFactory; } + @Override + public void stopBroker(int port) throws Exception + { + if (isBrokerPresent(port)) + { + super.stopBroker(port); + } + } public void tearDown() throws Exception { diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java index 66c8a60c36..b39b31df58 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java @@ -55,10 +55,8 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.qpid.AMQException; -import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQConnectionFactory; import org.apache.qpid.client.AMQQueue; -import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.ConnectionURL; @@ -67,8 +65,7 @@ import org.apache.qpid.server.Broker; import org.apache.qpid.server.BrokerOptions; import org.apache.qpid.server.ProtocolExclusion; import org.apache.qpid.server.configuration.ServerConfiguration; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; +import org.apache.qpid.server.protocol.AmqpProtocolVersion; import org.apache.qpid.server.store.DerbyMessageStore; import org.apache.qpid.url.URLSyntaxException; import org.apache.qpid.util.FileUtils; @@ -79,6 +76,13 @@ import org.apache.qpid.util.LogMonitor; */ public class QpidBrokerTestCase extends QpidTestCase { + + public enum BrokerType + { + EXTERNAL /** Test case relies on a Broker started independently of the test-suite */, + INTERNAL /** Test case starts an embedded broker within this JVM */, + SPAWNED /** Test case spawns a new broker as a separate process */ + } protected final String QpidHome = System.getProperty("QPID_HOME"); protected File _configFile = new File(System.getProperty("broker.config")); @@ -123,17 +127,12 @@ public class QpidBrokerTestCase extends QpidTestCase private static final String BROKER_LOG_INTERLEAVE = "broker.log.interleave"; private static final String BROKER_LOG_PREFIX = "broker.log.prefix"; private static final String BROKER_PERSITENT = "broker.persistent"; - private static final String BROKER_PROTOCOL_EXCLUDES = "broker.protocols.excludes"; + private static final String BROKER_PROTOCOL_EXCLUDES = "broker.protocol.excludes"; // values protected static final String JAVA = "java"; protected static final String CPP = "cpp"; - protected static final String VM = "vm"; - protected static final String EXTERNAL = "external"; - protected static final String INTERNAL = "internal"; - private static final String VERSION_08 = "0-8"; - private static final String VERSION_010 = "0-10"; protected static final String QPID_HOME = "QPID_HOME"; @@ -144,11 +143,11 @@ public class QpidBrokerTestCase extends QpidTestCase public static final int DEFAULT_SSL_PORT = Integer.getInteger("test.sslport", ServerConfiguration.DEFAULT_SSL_PORT); protected String _brokerLanguage = System.getProperty(BROKER_LANGUAGE, JAVA); - protected String _brokerType = System.getProperty(BROKER_TYPE, INTERNAL); + protected BrokerType _brokerType = BrokerType.valueOf(System.getProperty(BROKER_TYPE, "").toUpperCase()); protected String _brokerCommand = System.getProperty(BROKER_COMMAND); private String _brokerClean = System.getProperty(BROKER_CLEAN, null); private Boolean _brokerCleanBetweenTests = Boolean.getBoolean(BROKER_CLEAN_BETWEEN_TESTS); - private String _brokerVersion = System.getProperty(BROKER_VERSION, VERSION_08); + private final AmqpProtocolVersion _brokerVersion = AmqpProtocolVersion.valueOf(System.getProperty(BROKER_VERSION, "")); protected String _output = System.getProperty(TEST_OUTPUT); protected Boolean _brokerPersistent = Boolean.getBoolean(BROKER_PERSITENT); private String _brokerProtocolExcludes = System.getProperty(BROKER_PROTOCOL_EXCLUDES); @@ -407,7 +406,7 @@ public class QpidBrokerTestCase extends QpidTestCase } /** - * Return the management portin use by the broker on this main port + * Return the management port in use by the broker on this main port * * @param mainPort the broker's main port. * @@ -415,7 +414,7 @@ public class QpidBrokerTestCase extends QpidTestCase */ protected int getManagementPort(int mainPort) { - return mainPort + (DEFAULT_MANAGEMENT_PORT - (_brokerType.equals(VM) ? DEFAULT_VM_PORT : DEFAULT_PORT)); + return mainPort + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT); } /** @@ -430,11 +429,7 @@ public class QpidBrokerTestCase extends QpidTestCase protected int getPort(int port) { - if (_brokerType.equals(VM)) - { - return port == 0 ? DEFAULT_VM_PORT : port; - } - else if (!_brokerType.equals(EXTERNAL)) + if (!_brokerType.equals(BrokerType.EXTERNAL)) { return port == 0 ? DEFAULT_PORT : port; } @@ -473,34 +468,7 @@ public class QpidBrokerTestCase extends QpidTestCase throw new IllegalStateException("There is already an existing broker running on port " + port); } - if (_brokerType.equals(VM)) - { - setConfigurationProperty("management.jmxport", String.valueOf(getManagementPort(port))); - setConfigurationProperty(ServerConfiguration.MGMT_CUSTOM_REGISTRY_SOCKET, String.valueOf(false)); - saveTestConfiguration(); - - // create an in_VM broker - final ConfigurationFileApplicationRegistry registry = new ConfigurationFileApplicationRegistry(_configFile); - try - { - ApplicationRegistry.initialise(registry); - } - catch (Exception e) - { - _logger.error("Broker initialise failed due to:",e); - try - { - registry.close(); - } - catch (Throwable closeE) - { - closeE.printStackTrace(); - } - throw e; - } - TransportConnection.createVMBroker(port); - } - else if (_brokerType.equals(INTERNAL) && !existingInternalBroker()) + if (_brokerType.equals(BrokerType.INTERNAL) && !existingInternalBroker()) { setConfigurationProperty(ServerConfiguration.MGMT_CUSTOM_REGISTRY_SOCKET, String.valueOf(false)); saveTestConfiguration(); @@ -523,7 +491,7 @@ public class QpidBrokerTestCase extends QpidTestCase _brokers.put(port, new InternalBrokerHolder(broker)); } - else if (!_brokerType.equals(EXTERNAL)) + else if (!_brokerType.equals(BrokerType.EXTERNAL)) { String cmd = getBrokerCommand(port); _logger.info("starting external broker: " + cmd); @@ -633,11 +601,16 @@ public class QpidBrokerTestCase extends QpidTestCase private void addExcludedPorts(int port, BrokerOptions options) { final String protocolExcludesList = _brokerProtocolExcludes.replace("@PORT", "" + port); + + if (protocolExcludesList.equals("")) + { + return; + } final String[] toks = protocolExcludesList.split("\\s"); if(toks.length % 2 != 0) { - throw new IllegalArgumentException("Must be an even number of tokens in " + protocolExcludesList); + throw new IllegalArgumentException("Must be an even number of tokens in '" + protocolExcludesList + "'"); } for (int i = 0; i < toks.length; i=i+2) { @@ -662,13 +635,9 @@ public class QpidBrokerTestCase extends QpidTestCase return false; } - private String getQpidWork(String broker, int port) + private String getQpidWork(BrokerType broker, int port) { - if (broker.equals(VM)) - { - return System.getProperty("QPID_WORK"); - } - else if (!broker.equals(EXTERNAL)) + if (!broker.equals(BrokerType.EXTERNAL)) { return System.getProperty("QPID_WORK")+ "/" + port; } @@ -755,17 +724,16 @@ public class QpidBrokerTestCase extends QpidTestCase _logger.info("stopping broker: " + getBrokerCommand(port)); BrokerHolder broker = _brokers.remove(port); - if (broker != null) - { - broker.shutdown(); - } - else if (_brokerType.equals(VM)) - { - TransportConnection.killVMBroker(port); - ApplicationRegistry.remove(); - } + broker.shutdown(); } + public boolean isBrokerPresent(int port) throws Exception + { + port = getPort(port); + + return _brokers.containsKey(port); + } + /** * Attempt to set the Java Broker to use the BDBMessageStore for persistence * Falling back to the DerbyMessageStore if @@ -1000,12 +968,12 @@ public class QpidBrokerTestCase extends QpidTestCase */ public boolean isBroker08() { - return _brokerVersion.equals(VERSION_08); + return _brokerVersion.equals(AmqpProtocolVersion.v0_8); } public boolean isBroker010() { - return _brokerVersion.equals(VERSION_010); + return _brokerVersion.equals(AmqpProtocolVersion.v0_10); } protected boolean isJavaBroker() @@ -1020,12 +988,12 @@ public class QpidBrokerTestCase extends QpidTestCase protected boolean isExternalBroker() { - return !_brokerType.equals("vm"); + return !_brokerType.equals("vm"); //TODO } protected boolean isInternalBroker() { - return _brokerType.equals(INTERNAL); + return _brokerType.equals(BrokerType.INTERNAL); } protected boolean isBrokerStorePersistent() @@ -1099,11 +1067,6 @@ public class QpidBrokerTestCase extends QpidTestCase */ public AMQConnectionFactory getConnectionFactory(String factoryName) throws NamingException { - if (_brokerType.equals(VM)) - { - factoryName += ".vm"; - } - return (AMQConnectionFactory) getInitialContext().lookup(factoryName); } @@ -1144,15 +1107,7 @@ public class QpidBrokerTestCase extends QpidTestCase public Connection getClientConnection(String username, String password, String id) throws JMSException, URLSyntaxException, AMQException, NamingException { _logger.info("get Connection"); - Connection con; - if (_brokerType.equals(VM)) - { - con = new AMQConnection("vm://:1", username, password, id, "test"); - } - else - { - con = getConnectionFactory().createConnection(username, password, id); - } + Connection con = getConnectionFactory().createConnection(username, password, id); //add the connection in the lis of connections _connections.add(con); return con; @@ -1410,41 +1365,26 @@ public class QpidBrokerTestCase extends QpidTestCase */ public void reloadBrokerSecurityConfig() throws Exception { - if (_brokerType.equals(VM)) + JMXTestUtils jmxu = new JMXTestUtils(this, "admin" , "admin"); + jmxu.open(); + + try { - ApplicationRegistry.getInstance().getConfiguration().reparseConfigFileSecuritySections(); + ConfigurationManagement configMBean = jmxu.getConfigurationManagement(); + configMBean.reloadSecurityConfiguration(); } - else + finally { - JMXTestUtils jmxu = new JMXTestUtils(this, "admin" , "admin"); - jmxu.open(); - - try - { - ConfigurationManagement configMBean = jmxu.getConfigurationManagement(); - configMBean.reloadSecurityConfiguration(); - } - finally - { - jmxu.close(); - } - - LogMonitor _monitor = new LogMonitor(_outputFile); - assertTrue("The expected server security configuration reload did not occur", - _monitor.waitForMessage(ServerConfiguration.SECURITY_CONFIG_RELOADED, LOGMONITOR_TIMEOUT)); - + jmxu.close(); } + + LogMonitor _monitor = new LogMonitor(_outputFile); + assertTrue("The expected server security configuration reload did not occur", + _monitor.waitForMessage(ServerConfiguration.SECURITY_CONFIG_RELOADED, LOGMONITOR_TIMEOUT)); } protected int getFailingPort() { - if (_brokerType.equals(VM)) - { - throw new RuntimeException("VM is not supported for Failover testing"); - } - else - { - return FAILING_PORT; - } + return FAILING_PORT; } } diff --git a/qpid/java/test-profiles/CPPExcludes b/qpid/java/test-profiles/CPPExcludes index 4127682208..6f6fb01421 100755 --- a/qpid/java/test-profiles/CPPExcludes +++ b/qpid/java/test-profiles/CPPExcludes @@ -173,3 +173,7 @@ org.apache.qpid.test.unit.transacted.TransactionTimeoutTest#* // Java broker only org.apache.qpid.server.logging.management.LoggingManagementMBeanTest#* org.apache.qpid.server.management.AMQUserManagementMBeanTest#* + +// QPID-3133: On 0-10, the exception listener is currently not invoked when reconnection fails to occurs. +org.apache.qpid.server.failover.FailoverMethodTest#* + diff --git a/qpid/java/test-profiles/Excludes b/qpid/java/test-profiles/Excludes index 8359ad8743..7e096d3ac8 100644 --- a/qpid/java/test-profiles/Excludes +++ b/qpid/java/test-profiles/Excludes @@ -17,7 +17,6 @@ // under the License. // -org.apache.qpid.client.MultipleJCAProviderRegistrationTest#test // QPID-1715, QPID-1715 : Client Error Handling on close is still broken org.apache.qpid.server.queue.QueueCreateTest#testCreatePriorityString org.apache.qpid.server.queue.QueueCreateTest#testCreateFlowToDiskValidNoSize diff --git a/qpid/java/test-profiles/Java010Excludes b/qpid/java/test-profiles/Java010Excludes index 0361d83d73..36f156157a 100755 --- a/qpid/java/test-profiles/Java010Excludes +++ b/qpid/java/test-profiles/Java010Excludes @@ -79,3 +79,6 @@ org.apache.qpid.test.unit.client.channelclose.ChannelCloseTest#* //Should probably raise JIRAs for them. org.apache.qpid.test.client.destination.AddressBasedDestinationTest#testCreateExchange org.apache.qpid.test.client.destination.AddressBasedDestinationTest#testBrowseMode + +// QPID-3133: On 0-10, the exception listener is currently not invoked when reconnection fails to occurs. +org.apache.qpid.server.failover.FailoverMethodTest#* diff --git a/qpid/java/test-profiles/JavaExcludes b/qpid/java/test-profiles/JavaExcludes index c38a250abc..409ba9d832 100644 --- a/qpid/java/test-profiles/JavaExcludes +++ b/qpid/java/test-profiles/JavaExcludes @@ -19,13 +19,6 @@ // Those tests are not finished org.apache.qpid.test.testcases.TTLTest#* -org.apache.qpid.test.testcases.FailoverTest#* - -// This is a long running test so should exclude from normal runs -org.apache.qpid.test.client.failover.FailoverTest#test4MinuteFailover - -//QPID-1818 : Client code path does not correctly restore a transacted session after failover. -org.apache.qpid.server.persistent.NoLocalAfterRecoveryTest#* // QPID-1823: this takes ages to run org.apache.qpid.client.SessionCreateTest#* @@ -52,3 +45,45 @@ org.apache.qpid.transport.ConnectionTest#testResumeNonemptyReplayBuffer //QPID-2845: The queue policy types used by the C++ broker are not currently supported by the Java broker org.apache.qpid.test.client.queue.QueuePolicyTest#testRingPolicy org.apache.qpid.test.client.queue.QueuePolicyTest#testRejectPolicy + +/////////////////////////////////////////////////////// +//Moved from JavaStandaloneExcludes when it was removed +/////////////////////////////////////////////////////// + +// This is a long running test so should exclude from normal runs +org.apache.qpid.test.client.failover.FailoverTest#test4MinuteFailover + +// Those tests require failover support +org.apache.qpid.test.client.QueueBrowserAutoAckTest#testFailoverAsQueueBrowserCreated +org.apache.qpid.test.client.QueueBrowserAutoAckTest#testFailoverWithQueueBrowser +org.apache.qpid.test.client.QueueBrowserClientAckTest#testFailoverAsQueueBrowserCreated +org.apache.qpid.test.client.QueueBrowserClientAckTest#testFailoverWithQueueBrowser +org.apache.qpid.test.client.QueueBrowserDupsOkTest#testFailoverAsQueueBrowserCreated +org.apache.qpid.test.client.QueueBrowserDupsOkTest#testFailoverWithQueueBrowser +org.apache.qpid.test.client.QueueBrowserNoAckTest#testFailoverAsQueueBrowserCreated +org.apache.qpid.test.client.QueueBrowserNoAckTest#testFailoverWithQueueBrowser +org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverAsQueueBrowserCreated +org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverWithQueueBrowser +org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverAsQueueBrowserCreated +org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverWithQueueBrowser +org.apache.qpid.test.testcases.FailoverTest#* +org.apache.qpid.test.client.failover.FailoverTest#* + +// InVM Broker tests awaiting resolution of QPID-1103 +org.apache.qpid.test.client.timeouts.SyncWaitDelayTest#* +org.apache.qpid.test.client.timeouts.SyncWaitTimeoutDelayTest#* + +// This test currently does not pick up the runtime location of the nonVm queueBacking store. +org.apache.qpid.test.unit.close.FlowToDiskBackingQueueDeleteTest#* + +// This test may use QpidTestCase but it is not using the getConnection and is hardwired to InVM +org.apache.qpid.test.unit.client.connection.CloseAfterConnectionFailureTest#* + +//QPID-1818 : Client code path does not correctly restore a transacted session after failover. +org.apache.qpid.server.persistent.NoLocalAfterRecoveryTest#* + +// This test requires the standard configuration file for validation. +// Excluding here does not reduce test coverage. +org.apache.qpid.server.configuration.ServerConfigurationFileTest#* + + diff --git a/qpid/java/test-profiles/JavaInVMExcludes b/qpid/java/test-profiles/JavaInVMExcludes deleted file mode 100644 index e8f0cf37e9..0000000000 --- a/qpid/java/test-profiles/JavaInVMExcludes +++ /dev/null @@ -1,64 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -//====================================================================== -//Exclude the following tests when running the InVM default test profile -//====================================================================== - -// The FirewallPlugin only operates for TCP connections, the tests NO-OP when run InVM -org.apache.qpid.server.security.firewall.FirewallConfigTest#* - -// This test requires a broker capable of 0-8/9 and 0-10 -org.apache.qpid.test.client.message.JMSDestinationTest#testReceiveResend - -//Only a single InVM broker is now supported per JVM, so Failover tests do not work on InVm profiles -org.apache.qpid.test.client.QueueBrowserAutoAckTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserAutoAckTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserClientAckTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserClientAckTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserDupsOkTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserDupsOkTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserNoAckTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserNoAckTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverWithQueueBrowser -org.apache.qpid.server.failover.MessageDisappearWithIOExceptionTest#* -org.apache.qpid.test.client.failover.FailoverTest#* -org.apache.qpid.test.unit.ack.AcknowledgeAfterFailoverTest#* -org.apache.qpid.test.unit.ack.AcknowledgeAfterFailoverOnMessageTest#* -org.apache.qpid.test.unit.publish.DirtyTransactedPublishTest#* - -// QPID-2478 test fails when run against broker using 0-8/9 -org.apache.qpid.test.client.message.JMSDestinationTest#testGetDestinationWithCustomExchange - -// related to QPID-2471. Temporarily disabling these tests until I figure out why they are failing with the Java broker. -org.apache.qpid.test.unit.ack.RecoverTest#testRecoverResendsMsgs -org.apache.qpid.test.unit.ack.RecoverTest#testRecoverResendsMsgsAckOnEarlier -org.apache.qpid.test.unit.ack.RecoverTest#testAcknowledgePerConsumer - -// related to QPID-2471. These are new test cases and fail with the Java broker. -org.apache.qpid.test.unit.ack.RecoverTest#testOderingWithAsyncConsumer -org.apache.qpid.test.unit.ack.RecoverTest#testOderingWithSyncConsumer - -//The VM broker does not export the logging management JMX MBean -org.apache.qpid.server.security.acl.ExternalAdminACLTest#* - -org.apache.qpid.test.unit.message.JMSPropertiesTest#testGetPropertyNames diff --git a/qpid/java/test-profiles/08StandaloneExcludes b/qpid/java/test-profiles/JavaPre010Excludes index cc9f58b344..c0a53bcef1 100644 --- a/qpid/java/test-profiles/08StandaloneExcludes +++ b/qpid/java/test-profiles/JavaPre010Excludes @@ -18,10 +18,10 @@ // //====================================================================== -//Exclude the following from brokers defaulting to the 0-8 protocol +//Exclude the following from brokers using the 0-8/0-9/0-9-1 protocols //====================================================================== -// This test requires a broker capable of 0-8/9 and 0-10 +// This test requires a broker capable of 0-8/0-9/0-9-1 and 0-10 concurrently org.apache.qpid.test.client.message.JMSDestinationTest#testReceiveResend // QPID-2478 test fails when run against broker using 0-8/9 diff --git a/qpid/java/test-profiles/JavaStandaloneExcludes b/qpid/java/test-profiles/JavaStandaloneExcludes deleted file mode 100644 index d208a20d15..0000000000 --- a/qpid/java/test-profiles/JavaStandaloneExcludes +++ /dev/null @@ -1,55 +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 is a long running test so should exclude from normal runs -org.apache.qpid.test.client.failover.FailoverTest#test4MinuteFailover - -// Those tests require failover support -org.apache.qpid.test.client.QueueBrowserAutoAckTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserAutoAckTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserClientAckTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserClientAckTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserDupsOkTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserDupsOkTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserNoAckTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserNoAckTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserPreAckTest#testFailoverWithQueueBrowser -org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverAsQueueBrowserCreated -org.apache.qpid.test.client.QueueBrowserTransactedTest#testFailoverWithQueueBrowser -org.apache.qpid.test.testcases.FailoverTest#* -org.apache.qpid.test.client.failover.FailoverTest#* - -// InVM Broker tests awaiting resolution of QPID-1103 -org.apache.qpid.test.client.timeouts.SyncWaitDelayTest#* -org.apache.qpid.test.client.timeouts.SyncWaitTimeoutDelayTest#* - -// This test currently does not pick up the runtime location of the nonVm queueBacking store. -org.apache.qpid.test.unit.close.FlowToDiskBackingQueueDeleteTest#* - -// This test may use QpidTestCase but it is not using the getConnection and is hardwired to InVM -org.apache.qpid.test.unit.client.connection.CloseAfterConnectionFailureTest#* - -//QPID-1818 : Client code path does not correctly restore a transacted session after failover. -org.apache.qpid.server.persistent.NoLocalAfterRecoveryTest#* - -// This test requires the standard configuration file for validation. -// Excluding here does not reduce test coverage. -org.apache.qpid.server.configuration.ServerConfigurationFileTest#* - diff --git a/qpid/java/test-profiles/cpp.async.testprofile b/qpid/java/test-profiles/cpp.async.testprofile index c3d47f0ce6..5357e87687 100644 --- a/qpid/java/test-profiles/cpp.async.testprofile +++ b/qpid/java/test-profiles/cpp.async.testprofile @@ -19,3 +19,5 @@ include=cpp profile.excludes=CPPPrefetchExcludes broker.modules=--load-module ${broker.module.store} +broker.persistent=true + diff --git a/qpid/java/test-profiles/cpp.testprofile b/qpid/java/test-profiles/cpp.testprofile index 694e22f48c..a2114f82ba 100644 --- a/qpid/java/test-profiles/cpp.testprofile +++ b/qpid/java/test-profiles/cpp.testprofile @@ -16,7 +16,7 @@ # specific language governing permissions and limitations # under the License. # -broker.version=0-10 +broker.version=v0_10 broker.language=cpp broker.dir=${project.root}/../cpp/src @@ -32,7 +32,8 @@ broker.stopped=Exception constructed broker.modules= broker.args= -broker=${broker.executable} -p @PORT --data-dir ${build.data}/@PORT -t --auth no --no-module-dir ${broker.modules} ${broker.args} +broker.type=spawned +broker.command=${broker.executable} -p @PORT --data-dir ${build.data}/@PORT -t --auth no --no-module-dir ${broker.modules} ${broker.args} profile.excludes=CPPPrefetchExcludes CPPTransientExcludes test.excludes=Excludes CPPExcludes ${profile}.excludes ${profile.excludes} cpp.excludes diff --git a/qpid/java/test-profiles/java-derby.0.10.testprofile b/qpid/java/test-profiles/java-dby-spawn.0-10.testprofile index ca9115d30d..f51f5a26ac 100644 --- a/qpid/java/test-profiles/java-derby.0.10.testprofile +++ b/qpid/java/test-profiles/java-dby-spawn.0-10.testprofile @@ -17,13 +17,14 @@ # under the License. # broker.language=java -broker.version=0-10 -broker=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml +broker.version=v0_10 +broker.type=spawned +broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=BRK-1004 broker.stopped=Exception broker.config=${project.root}/build/etc/config-systests-derby.xml messagestore.class.name=org.apache.qpid.server.store.DerbyMessageStore -profile.excludes=JavaStandaloneExcludes JavaPersistentExcludes Java010Excludes +profile.excludes=JavaPersistentExcludes Java010Excludes broker.clean.between.tests=true broker.persistent=true diff --git a/qpid/java/test-profiles/java-derby.testprofile b/qpid/java/test-profiles/java-dby-spawn.0-9-1.testprofile index d22e35f07e..f79e1f3aad 100644 --- a/qpid/java/test-profiles/java-derby.testprofile +++ b/qpid/java/test-profiles/java-dby-spawn.0-9-1.testprofile @@ -16,14 +16,17 @@ # specific language governing permissions and limitations # under the License. # +broker.version=v0_9_1 broker.language=java -broker=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT --exclude-0-10 @PORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml +broker.type=spawned +broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT @EXCLUDES -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=BRK-1004 broker.stopped=Exception broker.config=${project.root}/build/etc/config-systests-derby.xml +broker.protocol.excludes=--exclude-0-10 @PORT messagestore.class.name=org.apache.qpid.server.store.DerbyMessageStore -profile.excludes=JavaStandaloneExcludes JavaPersistentExcludes 08StandaloneExcludes +profile.excludes=JavaPersistentExcludes JavaPre010Excludes broker.clean.between.tests=true broker.persistent=true # diff --git a/qpid/java/test-profiles/java-dby.0-10.testprofile b/qpid/java/test-profiles/java-dby.0-10.testprofile new file mode 100644 index 0000000000..5a7b9b5cdc --- /dev/null +++ b/qpid/java/test-profiles/java-dby.0-10.testprofile @@ -0,0 +1,30 @@ +# +# 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. +# +broker.language=java +broker.version=v0_10 +broker.type=internal +broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml +broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work +broker.ready=BRK-1004 +broker.stopped=Exception +broker.config=${project.root}/build/etc/config-systests-derby.xml +messagestore.class.name=org.apache.qpid.server.store.DerbyMessageStore +profile.excludes=JavaPersistentExcludes Java010Excludes +broker.clean.between.tests=true +broker.persistent=true diff --git a/qpid/java/test-profiles/java-dby.0-9-1.testprofile b/qpid/java/test-profiles/java-dby.0-9-1.testprofile new file mode 100644 index 0000000000..f9700da82d --- /dev/null +++ b/qpid/java/test-profiles/java-dby.0-9-1.testprofile @@ -0,0 +1,36 @@ +# +# 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. +# +broker.version=v0_9_1 +broker.language=java +broker.type=internal +broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT @EXCLUDES -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml +broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work +broker.ready=BRK-1004 +broker.stopped=Exception +broker.config=${project.root}/build/etc/config-systests-derby.xml +broker.protocol.excludes=--exclude-0-10 @PORT +messagestore.class.name=org.apache.qpid.server.store.DerbyMessageStore +profile.excludes=JavaPersistentExcludes JavaPre010Excludes +broker.clean.between.tests=true +broker.persistent=true +# +# Do not enable. Allow client to attempt 0-10 and negotiate downwards +# +#qpid.amqp.version=0-91 + diff --git a/qpid/java/test-profiles/java.testprofile b/qpid/java/test-profiles/java-mms-spawn.0-10.testprofile index 00d486309f..4fdac783cc 100644 --- a/qpid/java/test-profiles/java.testprofile +++ b/qpid/java/test-profiles/java-mms-spawn.0-10.testprofile @@ -16,14 +16,15 @@ # specific language governing permissions and limitations # under the License. # +broker.version=v0_10 broker.language=java broker.type=spawned -broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT --exclude-0-10 @PORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml +broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=BRK-1004 broker.stopped=Exception # # Do not enable. Allow client to attempt 0-10 and negotiate downwards # -#qpid.amqp.version=0-91 -profile.excludes=JavaTransientExcludes JavaStandaloneExcludes 08StandaloneExcludes +#qpid.amqp.version=0-10 +profile.excludes=JavaTransientExcludes Java010Excludes diff --git a/qpid/java/test-profiles/java-mms-spawn.0-9-1.testprofile b/qpid/java/test-profiles/java-mms-spawn.0-9-1.testprofile new file mode 100644 index 0000000000..f94b93c793 --- /dev/null +++ b/qpid/java/test-profiles/java-mms-spawn.0-9-1.testprofile @@ -0,0 +1,31 @@ +# +# 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. +# +broker.version=v0_9_1 +broker.language=java +broker.type=spawned +broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT @EXCLUDES -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml +broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work +broker.ready=BRK-1004 +broker.stopped=Exception +broker.protocol.excludes=--exclude-0-10 @PORT +# +# Do not enable. Allow client to attempt 0-10 and negotiate downwards +# +#qpid.amqp.version=0-91 +profile.excludes=JavaTransientExcludes JavaPre010Excludes diff --git a/qpid/java/test-profiles/java.0.10.testprofile b/qpid/java/test-profiles/java-mms.0-10.testprofile index fa87b22e92..3ccc6dfd3b 100644 --- a/qpid/java/test-profiles/java.0.10.testprofile +++ b/qpid/java/test-profiles/java-mms.0-10.testprofile @@ -17,10 +17,11 @@ # under the License. # broker.language=java -broker.version=0-10 -broker=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml +broker.version=v0_10 +broker.type=internal +broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=BRK-1004 broker.stopped=Exception -profile.excludes=JavaTransientExcludes JavaStandaloneExcludes Java010Excludes +profile.excludes=JavaTransientExcludes Java010Excludes diff --git a/qpid/java/test-profiles/internal.testprofile b/qpid/java/test-profiles/java-mms.0-9-1.testprofile index df544b1a20..45e2fc7162 100644 --- a/qpid/java/test-profiles/internal.testprofile +++ b/qpid/java/test-profiles/java-mms.0-9-1.testprofile @@ -17,16 +17,16 @@ # under the License. # broker.language=java +broker.version=v0_9_1 broker.type=internal #broker.command only used for the second broker during failover tests in this profile broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT @EXCLUDES -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml -#broker.command=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT --exclude-0-10 @PORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=BRK-1004 broker.stopped=Exception -broker.protocols.excludes=--exclude-0-10 @PORT +broker.protocol.excludes=--exclude-0-10 @PORT # # Do not enable. Allow client to attempt 0-10 and negotiate downwards # #qpid.amqp.version=0-91 -profile.excludes=JavaTransientExcludes JavaStandaloneExcludes 08StandaloneExcludes +profile.excludes=JavaTransientExcludes JavaPre010Excludes diff --git a/qpid/java/test-profiles/test-provider.properties b/qpid/java/test-profiles/test-provider.properties index 8cea012c1d..fe27cfcfaf 100644 --- a/qpid/java/test-profiles/test-provider.properties +++ b/qpid/java/test-profiles/test-provider.properties @@ -30,16 +30,12 @@ test.port.alt.ssl=25671 connectionfactory.default = amqp://username:password@clientid/test?brokerlist='tcp://localhost:${test.port}' connectionfactory.default.ssl = amqp://username:password@clientid/test?brokerlist='tcp://localhost:${test.port.ssl}?ssl='true'' -connectionfactory.default.vm = amqp://username:password@clientid/test?brokerlist='vm://:1' connectionfactory.failover = amqp://username:password@clientid/test?brokerlist='tcp://localhost:${test.port.alt};tcp://localhost:${test.port}'&sync_ack='true'&sync_publish='all'&failover='roundrobin?cyclecount='20'' connectionfactory.failover.ssl = amqp://username:password@clientid/test?brokerlist='tcp://localhost:${test.port.alt.ssl}?ssl='true';tcp://localhost:${test.port.ssl}?ssl='true''&sync_ack='true'&sync_publish='all'&failover='roundrobin?cyclecount='20'' -connectionfactory.failover.vm = amqp://username:password@clientid/test?brokerlist='vm://:2;vm://:1'&failover='roundrobin?cyclecount='20'' connectionfactory.connection1 = amqp://username:password@clientid/test?brokerlist='tcp://localhost:${test.port}' connectionfactory.connection2 = amqp://username:password@clientid/test?brokerlist='tcp://localhost:${test.port.alt}' -connectionfactory.connection1.vm = amqp://username:password@clientid/test?brokerlist='vm://:1' -connectionfactory.connection2.vm = amqp://username:password@clientid/test?brokerlist='vm://:2' queue.MyQueue = example.MyQueue diff --git a/qpid/java/test-profiles/default.testprofile b/qpid/java/test-profiles/testprofile.defaults index 85ab263f82..35429d3fed 100644 --- a/qpid/java/test-profiles/default.testprofile +++ b/qpid/java/test-profiles/testprofile.defaults @@ -19,12 +19,12 @@ java.naming.factory.initial=org.apache.qpid.jndi.PropertiesFileInitialContextFactory java.naming.provider.url=${test.profiles}/test-provider.properties -broker.version=0-8 -broker.type=vm broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=Listening on TCP port broker.config=${project.root}/build/etc/config-systests.xml messagestore.class.name=org.apache.qpid.server.store.MemoryMessageStore +broker.protocol.excludes= +broker.persistent=false max_prefetch=1000 qpid.dest_syntax=BURL @@ -47,9 +47,8 @@ test.port.alt=25672 test.port.alt.ssl=25671 test.exclude=true -profile.excludes=JavaTransientExcludes JavaInVMExcludes 08StandaloneExcludes +profile.excludes= test.excludes=Excludes XAExcludes JavaExcludes ${profile}.excludes ${profile.excludes} -test.fork=no test.mem=512M test=*Test haltonfailure=no @@ -57,3 +56,5 @@ haltonerror=no exclude.modules=none profile.clustered=false + + |