summaryrefslogtreecommitdiff
path: root/java/client/src/test
diff options
context:
space:
mode:
authorStephen Vinoski <vinoski@apache.org>2006-12-12 04:13:22 +0000
committerStephen Vinoski <vinoski@apache.org>2006-12-12 04:13:22 +0000
commita82cf43345ef2654d61cbb0323e284368541cc78 (patch)
treedefd8ebfb757901aec6fbba6affca31045bf5e5a /java/client/src/test
parent98e503f948059de7b0c2b1ea5242ac7b88e01662 (diff)
downloadqpid-python-a82cf43345ef2654d61cbb0323e284368541cc78.tar.gz
client test reorganization
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@486008 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src/test')
-rw-r--r--java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java185
-rw-r--r--java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java212
-rw-r--r--java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindTopic.java213
-rw-r--r--java/client/src/test/java/org/apache/qpid/IBMPerfTest/README.txt11
-rw-r--r--java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java46
-rw-r--r--java/client/src/test/java/org/apache/qpid/cluster/Client.java127
-rw-r--r--java/client/src/test/java/org/apache/qpid/codec/BasicDeliverTest.java265
-rw-r--r--java/client/src/test/java/org/apache/qpid/codec/Client.java133
-rw-r--r--java/client/src/test/java/org/apache/qpid/codec/Server.java103
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/AMQConnectionFactoryInitialiser.java35
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/AbstractConfig.java69
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/ConnectionFactoryInitialiser.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/Connector.java40
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/ConnectorConfig.java28
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java111
-rwxr-xr-xjava/client/src/test/java/org/apache/qpid/cts/bin/jmscts.sh162
-rwxr-xr-xjava/client/src/test/java/org/apache/qpid/cts/bin/setenv.sh41
-rw-r--r--java/client/src/test/java/org/apache/qpid/cts/config/jmscts.policy22
-rw-r--r--java/client/src/test/java/org/apache/qpid/cts/config/jmscts.properties71
-rw-r--r--java/client/src/test/java/org/apache/qpid/cts/config/providers.xml41
-rw-r--r--java/client/src/test/java/org/apache/qpid/cts/readme.txt5
-rwxr-xr-xjava/client/src/test/java/org/apache/qpid/cts/src/compile.sh34
-rw-r--r--java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java242
-rw-r--r--java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java95
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/log4j.xml45
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java159
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageFactory.java134
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactoryException.java72
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java134
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/MonitorPublisher.java71
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/Publisher.java181
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java74
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/shared/ConnectionException.java71
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/shared/ContextException.java73
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/shared/FileUtils.java168
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/shared/InitialContextHelper.java78
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/shared/Statics.java57
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/shared/example.properties21
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java139
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java51
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/subscriber/Subscriber.java194
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java51
-rw-r--r--java/client/src/test/java/org/apache/qpid/flow/ChannelFlowTest.java110
-rw-r--r--java/client/src/test/java/org/apache/qpid/fragmentation/TestLargePublisher.java193
-rw-r--r--java/client/src/test/java/org/apache/qpid/fragmentation/TestLargeSubscriber.java163
-rw-r--r--java/client/src/test/java/org/apache/qpid/headers/Listener.java117
-rw-r--r--java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java175
-rw-r--r--java/client/src/test/java/org/apache/qpid/headers/Publisher.java133
-rw-r--r--java/client/src/test/java/org/apache/qpid/jndi/referenceable/Bind.java273
-rw-r--r--java/client/src/test/java/org/apache/qpid/jndi/referenceable/Lookup.java196
-rw-r--r--java/client/src/test/java/org/apache/qpid/jndi/referenceable/Unbind.java166
-rw-r--r--java/client/src/test/java/org/apache/qpid/latency/LatencyTest.java151
-rw-r--r--java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java102
-rw-r--r--java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java93
-rw-r--r--java/client/src/test/java/org/apache/qpid/mina/WriterTest.java271
-rw-r--r--java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java267
-rw-r--r--java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java131
-rw-r--r--java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java213
-rw-r--r--java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java180
-rw-r--r--java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java132
-rw-r--r--java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java174
-rw-r--r--java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java120
-rw-r--r--java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java201
-rw-r--r--java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java303
-rw-r--r--java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java72
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java9
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java95
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java153
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/example.properties21
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java250
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java104
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Lookup.java167
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java173
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/testutil/VMBrokerSetup.java (renamed from java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java)2
-rw-r--r--java/client/src/test/java/org/apache/qpid/topic/Config.java243
-rw-r--r--java/client/src/test/java/org/apache/qpid/topic/Listener.java141
-rw-r--r--java/client/src/test/java/org/apache/qpid/topic/MessageFactory.java153
-rw-r--r--java/client/src/test/java/org/apache/qpid/topic/Publisher.java175
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Config.java110
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Ping.java43
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Pong.java43
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Relay.java127
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Start.java42
-rw-r--r--java/client/src/test/java/org/apache/qpid/weblogic/ServiceProvider.java151
-rw-r--r--java/client/src/test/java/org/apache/qpid/weblogic/ServiceRequestingClient.java192
100 files changed, 22 insertions, 10431 deletions
diff --git a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java b/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java
deleted file mode 100644
index 842b2d7696..0000000000
--- a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java
+++ /dev/null
@@ -1,185 +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.IBMPerfTest;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.url.URLSyntaxException;
-
-import javax.jms.ConnectionFactory;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.io.File;
-import java.util.Hashtable;
-
-public class JNDIBindConnectionFactory
-{
-
- public static final String CONNECTION_FACTORY_BINDING = "amq.ConnectionFactory";
- public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/IBMPerfTestsJNDI";
- public static final String PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
- public static final String FSCONTEXT_FACTORY = "com.sun.jndi.fscontext.RefFSContextFactory";
- public static final String DEFAULT_CONNECTION_URL = "amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:5672'";
-
- private static void printUsage()
- {
- System.out.println("Using default values: Usage:java JNDIBindConnectionFactory <connection url> [<Connection Factory Binding>] [<Provider URL>] [<JNDI Context Factory>]");
-
- }
-
- public static void main(String[] args)
- {
- Logger.getRootLogger().setLevel(Level.OFF);
-
- String connectionFactoryBinding = CONNECTION_FACTORY_BINDING;
- String provider = PROVIDER_URL;
- String contextFactory = FSCONTEXT_FACTORY;
- if (args.length == 0)
- {
- printUsage();
- System.exit(1);
- }
-
- String connectionURL = args[0];
-
- System.out.println("Using Connection:" + connectionURL + "\n");
-
-
- if (args.length > 1)
- {
- connectionFactoryBinding = args[1];
-
- if (args.length > 2)
- {
- provider = args[2];
-
- if (args.length > 3)
- {
- contextFactory = args[3];
- }
- }
- else
- {
- System.out.println("Using default File System Context Factory");
- System.out.println("Using default Connection Factory Binding:" + connectionFactoryBinding);
- }
- }
- else
- {
- printUsage();
- }
-
-
- System.out.println("File System Context Factory\n" +
- "Connection:" + connectionURL + "\n" +
- "Connection Factory Binding:" + connectionFactoryBinding + "\n" +
- "JNDI Provider URL:" + provider);
-
- if (provider.startsWith("file"))
- {
- File file = new File(provider.substring(provider.indexOf("://") + 3));
-
- if (file.exists() && !file.isDirectory())
- {
- System.out.println("Couldn't make directory file already exists");
- System.exit(1);
- }
- else
- {
- if (!file.exists())
- {
- if (!file.mkdirs())
- {
- System.out.println("Couldn't make directory");
- System.exit(1);
- }
- }
- }
- }
-
- new JNDIBindConnectionFactory(provider, connectionFactoryBinding, contextFactory, connectionURL);
-
- }
-
- public JNDIBindConnectionFactory(String provider, String binding, String contextFactory, String CONNECTION_URL)
- {
- // Set up the environment for creating the initial context
- Hashtable env = new Hashtable(11);
- env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
-
- env.put(Context.PROVIDER_URL, provider);
-
- try
- {
- // Create the initial context
- Context ctx = new InitialContext(env);
-
- // Create the object to be bound
- ConnectionFactory factory = null;
-
- try
- {
- factory = new AMQConnectionFactory(CONNECTION_URL);
-
-
- try
- {
- Object obj = ctx.lookup(binding);
-
- if (obj != null)
- {
- System.out.println("Un-binding previous Connection Factory");
- ctx.unbind(binding);
- }
- }
- catch (NamingException e)
- {
-
- }
-
- // Perform the bind
- ctx.bind(binding, factory);
- System.out.println("Bound Connection Factory:" + binding);
-
- // Check that it is bound
- Object obj = ctx.lookup(binding);
- System.out.println("Connection URL:" + ((AMQConnectionFactory) obj).getConnectionURL());
-
- System.out.println("JNDI FS Context:" + provider);
- }
- catch (NamingException amqe)
- {
-
- }
- catch (URLSyntaxException e)
- {
-
- }
-
- }
- catch (NamingException e)
- {
- System.out.println("Operation failed: " + e);
- }
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java b/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java
deleted file mode 100644
index 5f328a4107..0000000000
--- a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java
+++ /dev/null
@@ -1,212 +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.IBMPerfTest;
-
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.log4j.Logger;
-import org.apache.log4j.Level;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.jms.*;
-import java.util.Hashtable;
-import java.io.File;
-import java.net.MalformedURLException;
-
-public class JNDIBindQueue
-{
- public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/IBMPerfTestsJNDI";
- public static final String PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
- public static final String FSCONTEXT_FACTORY = "com.sun.jndi.fscontext.RefFSContextFactory";
-
- Connection _connection = null;
- Context _ctx = null;
-
-
- public JNDIBindQueue(String queueBinding, String queueName, String provider, String contextFactory)
- {
- // Set up the environment for creating the initial context
- Hashtable env = new Hashtable(11);
- env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
-
- env.put(Context.PROVIDER_URL, provider);
-
- try
- {
- // Create the initial context
- _ctx = new InitialContext(env);
-
- // Create the object to be bound
-
- try
- {
- _connection = new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:5672'");
- System.out.println("Connected");
- }
- catch (Exception amqe)
- {
- System.out.println("Unable to create AMQConnectionFactory:" + amqe);
- }
-
- if (_connection != null)
- {
- bindQueue(queueName, queueBinding);
- }
-
- // Check that it is bound
- Object obj = _ctx.lookup(queueBinding);
-
- System.out.println("Bound Queue:" + ((AMQQueue) obj).toURL());
-
- System.out.println("JNDI FS Context:" + provider);
-
- }
- catch (NamingException e)
- {
- System.out.println("Operation failed: " + e);
- }
- finally
- {
- try
- {
- if (_connection != null)
- {
- _connection.close();
- }
- }
- catch (JMSException closeE)
- {
-
- }
- }
-
-
- }
-
-
- private void bindQueue(String queueName, String queueBinding) throws NamingException
- {
-
- try
- {
- Object obj = _ctx.lookup(queueBinding);
-
- if (obj != null)
- {
- System.out.println("Un-binding exisiting object");
- _ctx.unbind(queueBinding);
- }
- }
- catch (NamingException e)
- {
-
- }
-
- Queue queue = null;
- try
- {
-
- Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- if (session != null)
- {
- queue = ((AMQSession) session).createQueue(queueName);
- }
- }
- catch (JMSException jmse)
- {
- System.out.println("Unable to create Queue:" + jmse);
- }
-
- // Perform the bind
- _ctx.bind(queueBinding, queue);
- }
-
-
- public static void main(String[] args)
- {
- Logger.getRootLogger().setLevel(Level.OFF);
-
- String provider = JNDIBindQueue.PROVIDER_URL;
- String contextFactory = JNDIBindQueue.FSCONTEXT_FACTORY;
-
- if (args.length > 1)
- {
- String binding = args[0];
- String queueName = args[1];
-
- if (args.length > 2)
- {
- provider = args[2];
-
- if (args.length > 3)
- {
- contextFactory = args[3];
- }
- }
- else
- {
- System.out.println("Using default File System Context Factory");
- }
-
- System.out.println("File System Context Factory\n" +
- "Binding Queue:'" + queueName + "' to '" + binding + "'\n" +
- "JNDI Provider URL:" + provider);
-
- if (provider.startsWith("file"))
- {
- File file = new File(provider.substring(provider.indexOf("://") + 3));
-
- if (file.exists() && !file.isDirectory())
- {
- System.out.println("Couldn't make directory file already exists");
- System.exit(1);
- }
- else
- {
- if (!file.exists())
- {
- if (!file.mkdirs())
- {
- System.out.println("Couldn't make directory");
- System.exit(1);
- }
- }
- }
- }
-
-
- new JNDIBindQueue(binding, queueName, provider, contextFactory);
-
- }
- else
- {
- System.out.println("Using Defaults: Usage:java JNDIBindQueue <Binding> <queue name> [<Provider URL> [<JNDI Context Factory>]]");
- }
-
- }
-
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindTopic.java b/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindTopic.java
deleted file mode 100644
index c31dce22cf..0000000000
--- a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindTopic.java
+++ /dev/null
@@ -1,213 +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.IBMPerfTest;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.log4j.Logger;
-import org.apache.log4j.Level;
-
-import javax.jms.*;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Hashtable;
-import java.io.File;
-import java.net.MalformedURLException;
-
-public class JNDIBindTopic
-{
- public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/IBMPerfTestsJNDI";
- public static final String PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
-
- public static final String FSCONTEXT_FACTORY = "com.sun.jndi.fscontext.RefFSContextFactory";
-
- Connection _connection = null;
- Context _ctx = null;
-
-
- public JNDIBindTopic(String topicBinding, String topicName, String provider, String contextFactory)
- {
- // Set up the environment for creating the initial context
- Hashtable env = new Hashtable(11);
- env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
-
- env.put(Context.PROVIDER_URL, provider);
-
- try
- {
- // Create the initial context
- _ctx = new InitialContext(env);
-
- // Create the object to be bound
-
- try
- {
- _connection = new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:5672'");
- System.out.println("Connected");
- }
- catch (Exception amqe)
- {
- System.out.println("Unable to create AMQConnectionFactory:" + amqe);
- }
-
- if (_connection != null)
- {
- bindTopic(topicName, topicBinding);
- }
-
- // Check that it is bound
- Object obj = _ctx.lookup(topicBinding);
-
- System.out.println("Bound Queue:" + ((AMQTopic) obj).toURL());
-
- System.out.println("JNDI FS Context:" + provider);
-
- }
- catch (NamingException e)
- {
- System.out.println("Operation failed: " + e);
- }
- finally
- {
- try
- {
- if (_connection != null)
- {
- _connection.close();
- }
- }
- catch (JMSException closeE)
- {
-
- }
- }
-
-
- }
-
-
- private void bindTopic(String topicName, String topicBinding) throws NamingException
- {
-
- try
- {
- Object obj = _ctx.lookup(topicBinding);
-
- if (obj != null)
- {
- System.out.println("Un-binding exisiting object");
- _ctx.unbind(topicBinding);
- }
- }
- catch (NamingException e)
- {
-
- }
-
- Topic topic = null;
- try
- {
-
- Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- if (session != null)
- {
- topic = ((AMQSession) session).createTopic(topicName);
- }
- }
- catch (JMSException jmse)
- {
- System.out.println("Unable to create Topic:" + jmse);
- }
-
- // Perform the bind
- _ctx.bind(topicBinding, topic);
- }
-
-
- public static void main(String[] args)
- {
- Logger.getRootLogger().setLevel(Level.OFF);
-
- String provider = JNDIBindTopic.PROVIDER_URL;
- String contextFactory = JNDIBindTopic.FSCONTEXT_FACTORY;
-
- if (args.length > 1)
- {
- String binding = args[0];
- String queueName = args[1];
-
- if (args.length > 2)
- {
- provider = args[2];
-
- if (args.length > 3)
- {
- contextFactory = args[3];
- }
- }
- else
- {
- System.out.println("Using default File System Context Factory");
- }
-
- System.out.println("File System Context Factory\n" +
- "Binding Topic:'" + queueName + "' to '" + binding + "'\n" +
- "JNDI Provider URL:" + provider);
-
-
- if (provider.startsWith("file"))
- {
- File file = new File(provider.substring(provider.indexOf("://") + 3));
-
- if (file.exists() && !file.isDirectory())
- {
- System.out.println("Couldn't make directory file already exists");
- System.exit(1);
- }
- else
- {
- if (!file.exists())
- {
- if (!file.mkdirs())
- {
- System.out.println("Couldn't make directory");
- System.exit(1);
- }
- }
- }
- }
-
- new JNDIBindTopic(binding, queueName, provider, contextFactory);
-
- }
- else
- {
- System.out.println("Usage:java JNDIBindTopic <Binding> <topic name> [<Provider URL> [<JNDI Context Factory>]]");
- }
-
- }
-
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/README.txt b/java/client/src/test/java/org/apache/qpid/IBMPerfTest/README.txt
deleted file mode 100644
index 95ee9f9c77..0000000000
--- a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/README.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-These JNDI setup tools are mainly for use in conjunction with the IBM JMS Performance Harness available here:
-The jar should be placed in the client/test/lib/ directory.
-
-http://www.alphaworks.ibm.com/tech/perfharness
-
-
-These JNDI classes use the the SUN FileSystem context.
-There are two jar files that should be placed in your client/test/lib directory.
-
-http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=22&PartDetailId=7110-jndi-1.2.1-oth-JPR&SiteId=JSC&TransactionId=noreg
-
diff --git a/java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java b/java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java
deleted file mode 100644
index 9b477c19e2..0000000000
--- a/java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java
+++ /dev/null
@@ -1,46 +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.message;
-
-import javax.jms.JMSException;
-
-public class TestMessageHelper
-{
- public static JMSTextMessage newJMSTextMessage() throws JMSException
- {
- return new JMSTextMessage();
- }
-
- public static JMSBytesMessage newJMSBytesMessage() throws JMSException
- {
- return new JMSBytesMessage();
- }
-
- public static JMSMapMessage newJMSMapMessage() throws JMSException
- {
- return new JMSMapMessage();
- }
-
- public static JMSStreamMessage newJMSStreamMessage()
- {
- return new JMSStreamMessage();
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/cluster/Client.java b/java/client/src/test/java/org/apache/qpid/cluster/Client.java
deleted file mode 100644
index 7a413eee3d..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cluster/Client.java
+++ /dev/null
@@ -1,127 +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.cluster;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-
-import javax.jms.MessageListener;
-import javax.jms.Message;
-import javax.jms.Session;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.TextMessage;
-import java.util.Random;
-
-public class Client
-{
- private final Random random = new Random();
- private final String name;
- private final Session session;
- private final MessageProducer topicProducer;
- private final MessageProducer queueProducer;
-
- Client(AMQConnection connection, String name) throws JMSException, InterruptedException
- {
- this.name = name;
- session = connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
-
- AMQTopic topic = new AMQTopic("cluster_test_topic");
- AMQQueue queue = new AMQQueue("cluster_test_queue");
-
- topicProducer = session.createProducer(topic);
- queueProducer = session.createProducer(queue);
-
- //subscribe to a known topic
- session.createConsumer(topic).setMessageListener(new TopicHandler());
- //subscribe to a known queue
- session.createConsumer(queue).setMessageListener(new QueueHandler());
-
- connection.start();
-
- while(true)
- {
- Thread.sleep(random.nextInt(60000));
- sendToQueue(name + ":" + randomString(5));
- }
- }
-
- private synchronized void sendToTopic(String message) throws JMSException
- {
- topicProducer.send(session.createTextMessage(message));
- }
-
- private synchronized void sendToQueue(String message) throws JMSException
- {
- queueProducer.send(session.createTextMessage(message));
- }
-
- private String randomString(int length){
- char[] c = new char[length];
- for(int i = 0; i < length; i++)
- {
- c[i] = (char) ('A' + random.nextInt(26));
- }
- return new String(c);
- }
-
- private class QueueHandler implements MessageListener
- {
- public void onMessage(Message message)
- {
- try
- {
- sendToTopic(((TextMessage) message).getText());
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- private class TopicHandler implements MessageListener
- {
- public void onMessage(Message message)
- {
- try
- {
- System.out.println(((TextMessage) message).getText());
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- public static void main(String[] argv) throws AMQException, JMSException, InterruptedException, URLSyntaxException
- {
- //assume args describe the set of brokers to try
-
- String clientName = argv.length > 1 ? argv[1] : "testClient";
- new Client(new AMQConnection(argv.length > 0 ? argv[0] : "vm://:1", "guest", "guest", clientName, "/test"), clientName);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/codec/BasicDeliverTest.java b/java/client/src/test/java/org/apache/qpid/codec/BasicDeliverTest.java
deleted file mode 100644
index 892b349cea..0000000000
--- a/java/client/src/test/java/org/apache/qpid/codec/BasicDeliverTest.java
+++ /dev/null
@@ -1,265 +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.codec;
-
-import org.apache.qpid.framing.*;
-import org.apache.mina.common.*;
-import org.apache.mina.common.support.BaseIoSession;
-import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-import org.apache.mina.filter.codec.ProtocolEncoderOutput;
-
-import java.net.SocketAddress;
-
-/**
- */
-public class BasicDeliverTest
-{
- public static void main(String[] argv) throws Exception
- {
- BasicDeliverTest test = new BasicDeliverTest();
-
- //warm up:
- test.encode(512, 100000);
-
- //real tests:
- test.encode(16, 10000, 15);
- test.encode(32, 10000, 15);
- test.encode(64, 10000, 15);
- test.encode(128, 10000, 15);
- test.encode(256, 10000, 15);
- test.encode(512, 10000, 15);
- test.encode(1024, 10000, 15);
- test.encode(2048, 10000, 15);
-
- test.decode(16, 10000, 15);
- test.decode(32, 10000, 15);
- test.decode(64, 10000, 15);
- test.decode(128, 10000, 15);
- test.decode(256, 10000, 15);
- test.decode(512, 10000, 15);
- test.decode(1024, 10000, 15);
- test.decode(2048, 10000, 15);
- }
-
- void decode(int size, int count, int iterations) throws Exception
- {
- long min = Long.MAX_VALUE;
- long max = 0;
- long total = 0;
- for(int i = 0; i < iterations; i++)
- {
- long time = decode(size, count);
- total += time;
- if(time < min) min = time;
- if(time > max) max = time;
- }
- System.out.println("Decoded " + count + " messages of " + size +
- " bytes: avg=" + (total / iterations) + ", min=" + min + ", max=" + max) ;
- }
-
-
- long decode(int size, int count) throws Exception
- {
- AMQDataBlock block = getDataBlock(size);
- ByteBuffer data = ByteBuffer.allocate((int) block.getSize()); // XXX: Is cast a problem?
- block.writePayload(data);
- data.flip();
- AMQDecoder decoder = new AMQDecoder(false);
- long start = System.currentTimeMillis();
- for(int i = 0; i < count; i++)
- {
- decoder.decode(session, data, decoderOutput);
- data.rewind();
- }
- return System.currentTimeMillis() - start;
- }
-
- void encode(int size, int count, int iterations) throws Exception
- {
- long min = Long.MAX_VALUE;
- long max = 0;
- long total = 0;
- for(int i = 0; i < iterations; i++)
- {
- long time = encode(size, count);
- total += time;
- if(time < min) min = time;
- if(time > max) max = time;
- }
- System.out.println("Encoded " + count + " messages of " + size +
- " bytes: avg=" + (total / iterations) + ", min=" + min + ", max=" + max) ;
- }
-
- long encode(int size, int count) throws Exception
- {
- IoSession session = null;
- AMQDataBlock block = getDataBlock(size);
- AMQEncoder encoder = new AMQEncoder();
- long start = System.currentTimeMillis();
- for(int i = 0; i < count; i++)
- {
- encoder.encode(session, block, encoderOutput);
- }
- return System.currentTimeMillis() - start;
- }
-
- private final ProtocolEncoderOutput encoderOutput = new ProtocolEncoderOutput(){
-
- public void write(ByteBuffer byteBuffer)
- {
- }
-
- public void mergeAll()
- {
- }
-
- public WriteFuture flush()
- {
- return null;
- }
- };
-
- private final ProtocolDecoderOutput decoderOutput = new ProtocolDecoderOutput(){
- public void write(Object object)
- {
- }
-
- public void flush()
- {
- }
- };
-
- private final IoSession session = new BaseIoSession(){
-
- protected void updateTrafficMask()
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public IoService getService()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public IoServiceConfig getServiceConfig()
- {
- return null;
- }
-
- public IoHandler getHandler()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public IoSessionConfig getConfig()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public IoFilterChain getFilterChain()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public TransportType getTransportType()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public SocketAddress getRemoteAddress()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public SocketAddress getLocalAddress()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public SocketAddress getServiceAddress()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public int getScheduledWriteRequests()
- {
- return 0; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public int getScheduledWriteBytes()
- {
- return 0; //To change body of implemented methods use File | Settings | File Templates.
- }
- };
-
- private static final char[] DATA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
-
- static CompositeAMQDataBlock getDataBlock(int size)
- {
- //create a frame representing message delivery
- AMQFrame[] frames = new AMQFrame[3];
- frames[0] = wrapBody( createBasicDeliverBody() );
- frames[1] = wrapBody( createContentHeaderBody() );
- frames[2] = wrapBody( createContentBody(size) );
-
- return new CompositeAMQDataBlock(frames);
- }
-
- static AMQFrame wrapBody(AMQBody body)
- {
- AMQFrame frame = new AMQFrame();
- frame.bodyFrame = body;
- frame.channel = 1;
-
- return frame;
- }
-
- static ContentBody createContentBody(int size)
- {
- ContentBody body = new ContentBody();
- body.payload = ByteBuffer.allocate(size);
- for(int i = 0; i < size; i++)
- {
- body.payload.put((byte) DATA[i % DATA.length]);
- }
- return body;
- }
-
- static ContentHeaderBody createContentHeaderBody()
- {
- ContentHeaderBody body = new ContentHeaderBody();
- body.properties = new BasicContentHeaderProperties();
- body.weight = 1;
- body.classId = 6;
- return body;
- }
-
- static BasicDeliverBody createBasicDeliverBody()
- {
- BasicDeliverBody body = new BasicDeliverBody();
- body.consumerTag = "myConsumerTag";
- body.deliveryTag = 1;
- body.exchange = "myExchange";
- body.redelivered = false;
- body.routingKey = "myRoutingKey";
- return body;
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/codec/Client.java b/java/client/src/test/java/org/apache/qpid/codec/Client.java
deleted file mode 100644
index c0de5ab133..0000000000
--- a/java/client/src/test/java/org/apache/qpid/codec/Client.java
+++ /dev/null
@@ -1,133 +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.codec;
-
-import org.apache.mina.transport.socket.nio.SocketConnector;
-import org.apache.mina.common.ConnectFuture;
-import org.apache.mina.common.IoHandlerAdapter;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.apache.qpid.framing.AMQDataBlock;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.BasicDeliverBody;
-import org.apache.qpid.framing.ContentBody;
-
-import java.net.InetSocketAddress;
-
-public class Client extends IoHandlerAdapter
-{
- //private static final int[] DEFAULT_SIZES = new int[]{1024, 512, 256, 128, 56};
- //private static final int[] DEFAULT_SIZES = new int[]{256, 256, 256, 256, 256, 512, 512, 512, 512, 512};
- private static final int[] DEFAULT_SIZES = new int[]{256, 512, 256, 512, 256, 512, 256, 512, 256, 512};
- //private static final int[] DEFAULT_SIZES = new int[]{1024, 1024, 1024, 1024, 1024};
-
- private final IoSession _session;
- private final long _start;
- private final int _size;
- private final int _count;
- private int _received;
- private boolean _closed;
-
- Client(String host, int port, int size, int count) throws Exception
- {
- _count = count;
- _size = size;
- AMQDataBlock block = BasicDeliverTest.getDataBlock(size);
-
- InetSocketAddress address = new InetSocketAddress(host, port);
- ConnectFuture future = new SocketConnector().connect(address, this);
- future.join();
- _session = future.getSession();
-
- _start = System.currentTimeMillis();
- for(int i = 0; i < count; i++)
- {
- _session.write(block);
- }
- }
-
- void close()
- {
- long time = System.currentTimeMillis() - _start;
- System.out.println("Received " + _received + " messages of " + _size
- + " bytes in " + time + "ms.");
- _session.close();
- synchronized(this)
- {
- _closed = true;
- notify();
- }
- }
-
- void waitForClose() throws InterruptedException
- {
- synchronized(this)
- {
- while(!_closed)
- {
- wait();
- }
- }
- }
-
- public void sessionCreated(IoSession session) throws Exception
- {
- session.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(new AMQCodecFactory(false)));
- }
-
- public void messageReceived(IoSession session, Object object) throws Exception
- {
- if(isContent(object) && ++_received == _count) close();
- }
-
- public void exceptionCaught(IoSession session, Throwable throwable) throws Exception
- {
- throwable.printStackTrace();
- close();
- }
-
- private static boolean isDeliver(Object o)
- {
- return o instanceof AMQFrame && ((AMQFrame) o).bodyFrame instanceof BasicDeliverBody;
- }
-
- private static boolean isContent(Object o)
- {
- return o instanceof AMQFrame && ((AMQFrame) o).bodyFrame instanceof ContentBody;
- }
-
- public static void main(String[] argv) throws Exception
- {
- String host = argv.length > 0 ? argv[0] : "localhost";
- int port = argv.length > 1 ? Integer.parseInt(argv[1]) : 8888;
- int count = argv.length > 2 ? Integer.parseInt(argv[2]) : 10000;
- int[] sizes = argv.length > 3 ? new int[]{Integer.parseInt(argv[3])} : DEFAULT_SIZES;
-
- System.out.println("Connecting to " + host + ":" + port);
-
- for(int i = 0; i < sizes.length; i++)
- {
- new Client(host, port, sizes[i], count).waitForClose();
- Thread.sleep(1000);
- }
- }
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/codec/Server.java b/java/client/src/test/java/org/apache/qpid/codec/Server.java
deleted file mode 100644
index fa4295e0b2..0000000000
--- a/java/client/src/test/java/org/apache/qpid/codec/Server.java
+++ /dev/null
@@ -1,103 +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.codec;
-
-import org.apache.mina.common.IoHandlerAdapter;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.util.SessionUtil;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.CompositeAMQDataBlock;
-
-import java.net.InetSocketAddress;
-
-public class Server extends IoHandlerAdapter
-{
- Server(int port) throws Exception
- {
- new SocketAcceptor().bind(new InetSocketAddress(port), this);
- System.out.println("Listening on " + port);
- }
-
- public void sessionCreated(IoSession session) throws Exception
- {
- SessionUtil.initialize(session);
- session.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(new AMQCodecFactory(false)));
- }
-
- public void messageReceived(IoSession session, Object object) throws Exception
- {
- getAccumulator(session).received(session, (AMQFrame) object);
- }
-
- public void sessionOpened(IoSession session) throws Exception
- {
- System.out.println("sessionOpened()");
- }
-
- public void sessionClosed(IoSession session) throws Exception
- {
- System.out.println("sessionClosed()");
- }
-
- public void exceptionCaught(IoSession session, Throwable t) throws Exception
- {
- System.out.println("exceptionCaught()");
- t.printStackTrace();
- session.close();
- }
-
- private Accumulator getAccumulator(IoSession session)
- {
- Accumulator a = (Accumulator) session.getAttribute(ACCUMULATOR);
- if(a == null)
- {
- a = new Accumulator();
- session.setAttribute(ACCUMULATOR, a);
- }
- return a;
- }
-
- private static final String ACCUMULATOR = Accumulator.class.getName();
-
- private static class Accumulator
- {
- private final AMQFrame[] frames = new AMQFrame[3];
- private int i;
-
- void received(IoSession session, AMQFrame frame)
- {
- frames[i++] = frame;
- if(i >= frames.length)
- {
- i = 0;
- session.write(new CompositeAMQDataBlock(frames));
- }
- }
- }
-
- public static void main(String[] argv) throws Exception
- {
- int port = argv.length > 0 ? Integer.parseInt(argv[0]) : 8888;
- new Server(port);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/config/AMQConnectionFactoryInitialiser.java b/java/client/src/test/java/org/apache/qpid/config/AMQConnectionFactoryInitialiser.java
deleted file mode 100644
index cac0064785..0000000000
--- a/java/client/src/test/java/org/apache/qpid/config/AMQConnectionFactoryInitialiser.java
+++ /dev/null
@@ -1,35 +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.config;
-
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.config.ConnectionFactoryInitialiser;
-import org.apache.qpid.config.ConnectorConfig;
-
-import javax.jms.ConnectionFactory;
-
-class AMQConnectionFactoryInitialiser implements ConnectionFactoryInitialiser
-{
- public ConnectionFactory getFactory(ConnectorConfig config)
- {
- return new AMQConnectionFactory(config.getHost(), config.getPort(), "/test_path");
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/config/AbstractConfig.java b/java/client/src/test/java/org/apache/qpid/config/AbstractConfig.java
deleted file mode 100644
index 04381d66a0..0000000000
--- a/java/client/src/test/java/org/apache/qpid/config/AbstractConfig.java
+++ /dev/null
@@ -1,69 +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.config;
-
-public abstract class AbstractConfig
-{
- public boolean setOptions(String[] argv)
- {
- try
- {
- for(int i = 0; i < argv.length - 1; i += 2)
- {
- String key = argv[i];
- String value = argv[i+1];
- setOption(key, value);
- }
- return true;
- }
- catch(Exception e)
- {
- System.out.println(e.getMessage());
- }
- return false;
- }
-
- protected int parseInt(String msg, String i)
- {
- try
- {
- return Integer.parseInt(i);
- }
- catch(NumberFormatException e)
- {
- throw new RuntimeException(msg + ": " + i);
- }
- }
-
- protected long parseLong(String msg, String i)
- {
- try
- {
- return Long.parseLong(i);
- }
- catch(NumberFormatException e)
- {
- throw new RuntimeException(msg + ": " + i);
- }
- }
-
- public abstract void setOption(String key, String value);
-}
diff --git a/java/client/src/test/java/org/apache/qpid/config/ConnectionFactoryInitialiser.java b/java/client/src/test/java/org/apache/qpid/config/ConnectionFactoryInitialiser.java
deleted file mode 100644
index a9984eb09a..0000000000
--- a/java/client/src/test/java/org/apache/qpid/config/ConnectionFactoryInitialiser.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.config;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-
-public interface ConnectionFactoryInitialiser
-{
- public ConnectionFactory getFactory(ConnectorConfig config) throws JMSException;
-}
diff --git a/java/client/src/test/java/org/apache/qpid/config/Connector.java b/java/client/src/test/java/org/apache/qpid/config/Connector.java
deleted file mode 100644
index ff2377f087..0000000000
--- a/java/client/src/test/java/org/apache/qpid/config/Connector.java
+++ /dev/null
@@ -1,40 +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.config;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-
-public class Connector
-{
- public Connection createConnection(ConnectorConfig config) throws Exception
- {
- return getConnectionFactory(config).createConnection();
- }
-
- ConnectionFactory getConnectionFactory(ConnectorConfig config) throws Exception
- {
- String factory = config.getFactory();
- if(factory == null) factory = AMQConnectionFactoryInitialiser.class.getName();
- System.out.println("Using " + factory);
- return ((ConnectionFactoryInitialiser) Class.forName(factory).newInstance()).getFactory(config);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/config/ConnectorConfig.java b/java/client/src/test/java/org/apache/qpid/config/ConnectorConfig.java
deleted file mode 100644
index b120ed3f12..0000000000
--- a/java/client/src/test/java/org/apache/qpid/config/ConnectorConfig.java
+++ /dev/null
@@ -1,28 +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.config;
-
-public interface ConnectorConfig
-{
- public String getHost();
- public int getPort();
- public String getFactory();
-}
diff --git a/java/client/src/test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java b/java/client/src/test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java
deleted file mode 100644
index 44285efd96..0000000000
--- a/java/client/src/test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java
+++ /dev/null
@@ -1,111 +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.config;
-
-import org.apache.qpid.config.ConnectionFactoryInitialiser;
-import org.apache.qpid.config.ConnectorConfig;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.MBeanException;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.naming.NameNotFoundException;
-import java.util.Hashtable;
-
-public class JBossConnectionFactoryInitialiser implements ConnectionFactoryInitialiser
-{
- public ConnectionFactory getFactory(ConnectorConfig config) throws JMSException
- {
- ConnectionFactory cf = null;
- InitialContext ic = null;
- Hashtable ht = new Hashtable();
- ht.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- String jbossHost = System.getProperty("jboss.host", "eqd-lxamq01");
- String jbossPort = System.getProperty("jboss.port", "1099");
- ht.put(InitialContext.PROVIDER_URL, "jnp://" + jbossHost + ":" + jbossPort);
- ht.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
-
- try
- {
- ic = new InitialContext(ht);
- if (!doesDestinationExist("topictest.messages", ic))
- {
- deployTopic("topictest.messages", ic);
- }
- if (!doesDestinationExist("topictest.control", ic))
- {
- deployTopic("topictest.control", ic);
- }
-
- cf = (ConnectionFactory) ic.lookup("/ConnectionFactory");
- return cf;
- }
- catch (NamingException e)
- {
- throw new JMSException("Unable to lookup object: " + e);
- }
- catch (Exception e)
- {
- throw new JMSException("Error creating topic: " + e);
- }
- }
-
- private boolean doesDestinationExist(String name, InitialContext ic) throws Exception
- {
- try
- {
- ic.lookup("/" + name);
- }
- catch (NameNotFoundException e)
- {
- return false;
- }
- return true;
- }
-
- private void deployTopic(String name, InitialContext ic) throws Exception
- {
- MBeanServerConnection mBeanServer = lookupMBeanServerProxy(ic);
-
- ObjectName serverObjectName = new ObjectName("jboss.messaging:service=ServerPeer");
-
- String jndiName = "/" + name;
- try
- {
- mBeanServer.invoke(serverObjectName, "createTopic",
- new Object[]{name, jndiName},
- new String[]{"java.lang.String", "java.lang.String"});
- }
- catch (MBeanException e)
- {
- System.err.println("Error: " + e);
- System.err.println("Cause: " + e.getCause());
- }
- }
-
- private MBeanServerConnection lookupMBeanServerProxy(InitialContext ic) throws NamingException
- {
- return (MBeanServerConnection) ic.lookup("jmx/invoker/RMIAdaptor");
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/cts/bin/jmscts.sh b/java/client/src/test/java/org/apache/qpid/cts/bin/jmscts.sh
deleted file mode 100755
index 37b8018aaf..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cts/bin/jmscts.sh
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-
-# -----------------------------------------------------------------------------
-# Start/Stop Script for the JMS compliance test suite
-#
-# Required Environment Variables
-#
-# JAVA_HOME Points to the Java Development Kit installation.
-#
-# Optional Environment Variables
-#
-# JMSCTS_HOME Points to the JMS CTS installation directory.
-#
-# JAVA_OPTS Java runtime options used when the command is executed.
-#
-#
-# $Id: jmscts.sh,v 1.6 2003/09/27 09:50:49 tanderson Exp $
-# ---------------------------------------------------------------------------
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false
-case "`uname`" in
-CYGWIN*) cygwin=true;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- echo "The JAVA_HOME environment variable is not set."
- echo "This is required to run jmscts"
- exit 1
-fi
-if [ ! -r "$JAVA_HOME"/bin/java ]; then
- echo "The JAVA_HOME environment variable is not set correctly."
- echo "This is required to run jmscts"
- exit 1
-fi
-_RUNJAVA="$JAVA_HOME"/bin/java
-
-
-# Guess JMSCTS_HOME if it is not set
-if [ -z "$JMSCTS_HOME" ]; then
-# resolve links - $0 may be a softlink
- PRG="$0"
- while [ -h "$PRG" ]; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '.*/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`/"$link"
- fi
- done
-
- PRGDIR=`dirname "$PRG"`
- JMSCTS_HOME=`cd "$PRGDIR/.." ; pwd`
-elif [ ! -r "$JMSCTS_HOME"/bin/jmscts.sh ]; then
- echo "The JMSCTS_HOME environment variable is not set correctly."
- echo "This is required to run jmscts"
- exit 1
-fi
-
-# Set CLASSPATH to empty by default. User jars can be added via the setenv.sh
-# script
-CLASSPATH=
-
-if [ -r "$JMSCTS_HOME"/bin/setenv.sh ]; then
- . "$JMSCTS_HOME"/bin/setenv.sh
-fi
-
-CLASSPATH="$CLASSPATH":"$JMSCTS_HOME"/lib/jmscts-0.5-b2.jar
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- JMSCTS_HOME=`cygpath --path --windows "$JMSCTS_HOME"`
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
-POLICY_FILE="$JMSCTS_HOME"/config/jmscts.policy
-
-# Configure TrAX
-JAVAX_OPTS=-Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl
-
-
-# Execute the requested command
-
-echo "Using JMSCTS_HOME: $JMSCTS_HOME"
-echo "Using JAVA_HOME: $JAVA_HOME"
-echo "Using CLASSPATH: $CLASSPATH"
-
-if [ "$1" = "run" ]; then
-
- shift
- exec "$_RUNJAVA" $JAVA_OPTS $JAVAX_OPTS -Djmscts.home="$JMSCTS_HOME" \
- -classpath "$CLASSPATH" \
- -Djava.security.manager -Djava.security.policy="$POLICY_FILE" \
- org.exolab.jmscts.test.ComplianceTestSuite "$@"
-
-elif [ "$1" = "stress" ]; then
-
- shift
- exec "$_RUNJAVA" $JAVA_OPTS $JAVAX_OPTS -Djmscts.home="$JMSCTS_HOME" \
- -classpath "$CLASSPATH" \
- -Djava.security.manager -Djava.security.policy="$POLICY_FILE" \
- org.exolab.jmscts.stress.StressTestSuite "$@"
-
-elif [ "$1" = "stop" ] ; then
-
- shift
- "$_RUNJAVA" $JAVA_OPTS $JAVAX_OPTS -Djmscts.home="$JMSCTS_HOME" \
- -classpath "$CLASSPATH" \
- -Djava.security.manager -Djava.security.policy="$POLICY_FILE" \
- org.exolab.jmscts.core.Admin -stop
-
-elif [ "$1" = "abort" ] ; then
-
- shift
- exec "$_RUNJAVA" $JAVA_OPTS $JAVAX_OPTS -Djmscts.home="$JMSCTS_HOME" \
- -classpath "$CLASSPATH" \
- -Djava.security.manager -Djava.security.policy="$POLICY_FILE" \
- org.exolab.jmscts.core.Admin -abort
-
-elif [ "$1" = "snapshot" ] ; then
-
- shift
- exec "$_RUNJAVA" $JAVA_OPTS $JAVAX_OPTS -Djmscts.home="$JMSCTS_HOME" \
- -classpath "$CLASSPATH" \
- -Djava.security.manager -Djava.security.policy="$POLICY_FILE" \
- org.exolab.jmscts.core.Admin -snapshot "$@"
-
-else
- echo "usage: jmscts.sh (commands)"
- echo "commands:"
- echo " run Run compliance tests"
- echo " stress Run stress tests"
- echo " stop Stop the JMS CTS"
- echo " abort Abort the JMS CTS"
- echo " snapshot Take a snapshot"
- exit 1
-fi
diff --git a/java/client/src/test/java/org/apache/qpid/cts/bin/setenv.sh b/java/client/src/test/java/org/apache/qpid/cts/bin/setenv.sh
deleted file mode 100755
index 9b9189d646..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cts/bin/setenv.sh
+++ /dev/null
@@ -1,41 +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.
-#
-
-# ---------------------------------------------------------------------------
-# Sample environment script for JMS CTS
-#
-# This is invoked by jmscts.sh to configure:
-# . the CLASSPATH, for JMS provider jars
-# . JVM options
-#
-# The following configures the JMS CTS for OpenJMS 0.7.6
-# ---------------------------------------------------------------------------
-
-# Configure the CLASSPATH
-#
-DISTDIR="$IBASE/amqp/dist"
-LIBDIR="$IBASE/amqp/lib"
-
-CLASSPATH="$LIBDIR/jakarta-commons/commons-collections-3.1.jar:$LIBDIR/util-concurrent/backport-util-concurrent.jar:$LIBDIR/mina/mina-0.7.3.jar:$LIBDIR/jms/jms.jar:$LIBDIR/logging-log4j/log4j-1.2.9.jar:$DISTDIR/amqp-common.jar:$DISTDIR/amqp-jms.jar"
-
-# Configure JVM options
-#
-JAVA_OPTS=-Xmx512m -Xms512m
-JAVA_OPTS="$JAVA_OPTS \
- -Damqj.logging.level=WARN"
diff --git a/java/client/src/test/java/org/apache/qpid/cts/config/jmscts.policy b/java/client/src/test/java/org/apache/qpid/cts/config/jmscts.policy
deleted file mode 100644
index ff8b5db5ec..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cts/config/jmscts.policy
+++ /dev/null
@@ -1,22 +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.
-//
-// grant all users all permissions. This is only for test cases
-// and should be modified for deployment
-grant {
- permission java.security.AllPermission;
-};
diff --git a/java/client/src/test/java/org/apache/qpid/cts/config/jmscts.properties b/java/client/src/test/java/org/apache/qpid/cts/config/jmscts.properties
deleted file mode 100644
index 7177fed49d..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cts/config/jmscts.properties
+++ /dev/null
@@ -1,71 +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.
-#
-
-# =============================================================================
-# General properties
-# -----------------------------------------------------------------------------
-
-#
-# Username & password
-# A user name and password for creating Connection instances via
-# TopicConnectionFactory.createTopicConnection(...) etc
-#
-valid.username=guest
-valid.password=guest
-
-#
-# Invalid user name and password
-# As above, but guaranteed to fail.
-#
-invalid.username=guest
-invalid.password=guest
-
-#
-# Message receipt timeout
-# The default time to wait for messages, in milliseconds
-#
-org.exolab.jmscts.core.MessagingBehaviour.timeout=2000
-
-
-# =============================================================================
-# Compliance test properties
-# -----------------------------------------------------------------------------
-
-#
-# Expiration interval
-# Time in milliseconds to wait for the JMS provider to collect expired
-# messages.
-# This can be set for providers which collect expired messages periodically,
-# rather than at the moment they expire.
-# NOTE: for OpenJMS 0.7.6, this should be set to 5000
-org.exolab.jmscts.test.producer.ttl.ExpirationTest.expirationInterval=0
-
-
-# =============================================================================
-# Stress test properties
-# -----------------------------------------------------------------------------
-
-#
-# Each of the following properties determines the no. of messages that
-# will be sent by stress tests
-#
-org.exolab.jmscts.stress.Send0KTest.count=1000
-org.exolab.jmscts.stress.ReceiveSize0KTest.count=1000
-org.exolab.jmscts.stress.SendReceive0KTest.count=1000
-org.exolab.jmscts.stress.SendReceive2Size0KTest.count=1000
diff --git a/java/client/src/test/java/org/apache/qpid/cts/config/providers.xml b/java/client/src/test/java/org/apache/qpid/cts/config/providers.xml
deleted file mode 100644
index 30c4a39c5b..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cts/config/providers.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0"?>
-<!--
- -
- - Licensed to the Apache Software Foundation (ASF) under one
- - or more contributor license agreements. See the NOTICE file
- - distributed with this work for additional information
- - regarding copyright ownership. The ASF licenses this file
- - to you under the Apache License, Version 2.0 (the
- - "License"); you may not use this file except in compliance
- - with the License. You may obtain a copy of the License at
- -
- - http://www.apache.org/licenses/LICENSE-2.0
- -
- - Unless required by applicable law or agreed to in writing,
- - software distributed under the License is distributed on an
- - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- - KIND, either express or implied. See the License for the
- - specific language governing permissions and limitations
- - under the License.
- -
- -->
-
-<!-- ====================================================================== -->
-<!-- Sample provider configuration file -->
-<!-- -->
-<!-- This configures JMS CTS to test OpenJMS -->
-<!-- ====================================================================== -->
-
-<configuration>
-
- <provider>
- <name>AMQP</name>
- <class>org.exolab.jmscts.amqp.AMQPProvider</class>
- <paths>
- <path>/home/guso/harness/jmscts-0.5-b2/lib/amqp-provider-0.0a1.jar</path>
- </paths>
- <config>
- </config>
- </provider>
-
-</configuration>
diff --git a/java/client/src/test/java/org/apache/qpid/cts/readme.txt b/java/client/src/test/java/org/apache/qpid/cts/readme.txt
deleted file mode 100644
index 117e7d4954..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cts/readme.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-The files present in the bin, config and src directories should be copied over a complete copy of jms-cts-0.5-b2.
-
-The path entries on the config/providers.xml and src/compile.sh files should be changed before attempting to run.
-
-The scripts expect a properly configured IBASE environment. Before attempting to run, the amqp provider classes must be packaged and installed. The src/compile.sh script will help to achieve that. \ No newline at end of file
diff --git a/java/client/src/test/java/org/apache/qpid/cts/src/compile.sh b/java/client/src/test/java/org/apache/qpid/cts/src/compile.sh
deleted file mode 100755
index 7b8a9f03ec..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cts/src/compile.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-
-
-JMSCTS_PATH=/home/guso/harness/jmscts-0.5-b2
-
-distjms="$IBASE/amqp/dist"
-lib="$IBASE/amqp/lib"
-lib2="$JMSCTS_PATH/lib/"
-libs="$lib/jakarta-commons/commons-collections-3.1.jar:$lib/util-concurrent/backport-util-concurrent.jar:$lib/mina/mina-0.7.3.jar:$lib/jms/jms.jar:$lib/logging-log4j/log4j-1.2.9.jar:$distjms/amqp-common.jar:$distjms/amqp-jms.jar"
-libs2="$lib2/ant-1.5.3-1.jar:$lib2/junit-3.8.1.jar:$lib2/ant-optional-1.5.3-1.jar:$lib2/log4j-1.2.7.jar:$lib2/castor-0.9.5.jar:$lib2/openjms-provider-0.5-b2.jar:$lib2/commons-cli-1.0.jar:$lib2/oro-2.0.7.jar:$lib2/commons-collections-2.1.jar:$lib2/xalan-2.5.1.jar:$lib2/commons-logging-1.0.2.jar:$lib2/xdoclet-1.2b2.jar:$lib2/concurrent-1.3.2.jar:$lib2/xdoclet-xdoclet-module-1.2b2.jar:$lib2/exolabcore-0.3.7.jar:$lib2/xdoclet-xjavadoc-uc-1.2b2.jar:$lib2/jms-1.0.2a.jar:$lib2/xerces-2.3.0.jar:$lib2/jmscts-0.5-b2.jar:$lib2/xml-apis-1.0.b2.jar"
-
-javac -classpath $libs:$libs2 $JMSCTS_PATH/src/providers/amqp/org/exolab/jmscts/amqp/*.java
-cd $JMSCTS_PATH/src/providers/amqp
-jar cvf amqp-provider-0.0a1.jar org/exolab/jmscts/amqp/*.class
-mv amqp-provider-0.0a1.jar $lib2
-
diff --git a/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java b/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java
deleted file mode 100644
index 006bda7e2e..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/**
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "Exolab" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Exoffice Technologies. For written permission,
- * please contact jima@intalio.com.
- *
- * 4. Products derived from this Software may not be called "Exolab"
- * nor may "Exolab" appear in their names without prior written
- * permission of Exoffice Technologies. Exolab is a registered
- * trademark of Exoffice Technologies.
- *
- * 5. Due credit should be given to the Exolab Project
- * (http://www.exolab.org/).
- *
- * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001, 2003 (C) Exoffice Technologies Inc. All Rights Reserved.
- *
- */
-package org.apache.qpid.cts.src.providers.amqp.org.exolab.jmscts.amqp;
-
-import org.apache.qpid.client.*;
-import org.exolab.jmscts.provider.Administrator;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import java.net.InetAddress;
-import java.util.HashMap;
-
-/**
- * This class provides methods for obtaining and manipulating administered
- * objects managed by the Sonicmq implementation of JMS
- *
- */
-class AMQPAdministrator implements Administrator {
- // AMQ Connection configuration
- private int port = 5672;
- private String host = "localhost";
- private String user = "guest";
- private String pass = "guest";
- private String vhost = "/test";
-
- // The cached broker connection & session
- private AMQConnection _connection = null;
- private Session _session = null;
-
- // Factory request names
- private static final String QUEUE_CONNECTION_FACTORY = "QueueConnectionFactory";
- private static final String TOPIC_CONNECTION_FACTORY = "TopicConnectionFactory";
-
- /**
- * The cache of known administered objects
- */
- private HashMap<String, Object> _directory = new HashMap<String, Object>();
-
- /**
- * Returns the name of the QueueConnectionFactory bound in JNDI
- *
- * @return the default QueueConnectionFactory name
- */
- public String getQueueConnectionFactory() {
- return QUEUE_CONNECTION_FACTORY;
- }
-
- /**
- * Returns the name of the TopicConnectionFactory bound in JNDI
- *
- * @return the default TopicConnectionFactory name
- */
- public String getTopicConnectionFactory() {
- return TOPIC_CONNECTION_FACTORY;
- }
-
- /**
- * Returns the name of the XAQueueConnectionFactory bound in JNDI
- *
- * @return the default XAQueueConnectionFactory name
- */
- public String getXAQueueConnectionFactory() {
- return null;
- }
-
- /**
- * Returns the name of the XATopicConnectionFactory bound in JNDI
- *
- * @return the default XATopicConnectionFactory name
- */
- public String getXATopicConnectionFactory() {
- return null;
- }
-
- /**
- * Look up the named administered object
- *
- * @param name the name that the administered object is bound to
- * @return the administered object bound to name
- * @throws NamingException if the object is not bound, or the lookup fails
- */
- public Object lookup(String name) throws NamingException {
- Object result = _directory.get(name);
- if (result == null) {
- if (name.equals(QUEUE_CONNECTION_FACTORY)) {
- _directory.put(QUEUE_CONNECTION_FACTORY, new AMQConnectionFactory(host, port, user, pass, vhost));
- } else if (name.equals(TOPIC_CONNECTION_FACTORY)) {
- _directory.put(TOPIC_CONNECTION_FACTORY, new AMQConnectionFactory(host, port, user, pass, vhost));
- } else {
- throw new NameNotFoundException("Name not found: " + name);
- }
- }
- return result;
- }
-
- /**
- * Create an administered destination
- *
- * @param name the destination name
- * @param queue if true, create a queue, else create a topic
- * @throws JMSException if the destination cannot be created
- */
- public void createDestination(String name, boolean queue)
- throws JMSException {
- AMQDestination destination = null;
-
- try {
- if (queue) {
- destination = new AMQQueue(name);
- createConsumer(destination);
- } else {
- destination = new AMQTopic(name);
- createConsumer(destination);
- }
-
- _directory.put(name, destination);
- } catch (Exception exception) {
- JMSException error = new JMSException(exception.getMessage());
- error.setLinkedException(exception);
- throw error;
- }
- }
-
- /**
- * Destroy an administered destination
- *
- * @param name the destination name
- * @throws JMSException if the destination cannot be destroyed
- */
- public void destroyDestination(String name)
- throws JMSException {
-
- try {
- Destination destination = (Destination) lookup(name);
- _directory.remove(name);
- } catch (NamingException exception) {
- JMSException error = new JMSException(exception.getMessage());
- error.setLinkedException(exception);
- throw error;
- } catch (Exception exception) {
- JMSException error = new JMSException(exception.getMessage());
- error.setLinkedException(exception);
- throw error;
- }
- }
-
- /**
- * Returns true if an administered destination exists
- *
- * @param name the destination name
- * @throws JMSException for any internal JMS provider error
- */
- public boolean destinationExists(String name)
- throws JMSException {
-
- boolean exists = false;
- try {
- lookup(name);
- exists = true;
- } catch (NameNotFoundException ignore) {
- } catch (Exception exception) {
- JMSException error = new JMSException(exception.getMessage());
- error.setLinkedException(exception);
- throw error;
- }
- return exists;
- }
-
- public void initialise() throws JMSException {
- try {
- InetAddress address = InetAddress.getLocalHost();
- _connection = new AMQConnection(host, port, user, pass,
- address.getHostName(), vhost);
- _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- } catch (Exception exception) {
- JMSException error = new JMSException(exception.getMessage());
- error.setLinkedException(exception);
- throw error;
- }
- }
-
- public synchronized void cleanup() {
- try {
- _connection.close();
- } catch (JMSException e) {
- e.printStackTrace();
- }
- _connection = null;
- _session = null;
- _directory.clear();
- }
-
- MessageConsumer createConsumer(AMQDestination destination) throws JMSException
- {
- return ((AMQSession)_session).createConsumer(destination, /*pre-fetch*/0, false, /*exclusive*/false, null);
- }
-} //-- AMQPAdministrator
diff --git a/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java b/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java
deleted file mode 100644
index aafa415d1e..0000000000
--- a/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "Exolab" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Exoffice Technologies. For written permission,
- * please contact jima@intalio.com.
- *
- * 4. Products derived from this Software may not be called "Exolab"
- * nor may "Exolab" appear in their names without prior written
- * permission of Exoffice Technologies. Exolab is a registered
- * trademark of Exoffice Technologies.
- *
- * 5. Due credit should be given to the Exolab Project
- * (http://www.exolab.org/).
- *
- * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001, 2003 (C) Exoffice Technologies Inc. All Rights Reserved.
- *
- */
-package org.apache.qpid.cts.src.providers.amqp.org.exolab.jmscts.amqp;
-
-import javax.jms.JMSException;
-
-import org.exolab.jmscts.provider.Administrator;
-import org.exolab.jmscts.provider.Provider;
-
-
-/**
- * This class enables test cases to be run against the SonicMQ provider
- *
- * @see AMQPAdministrator
- */
-public class AMQPProvider implements Provider {
-
- /**
- * The administration interface
- */
- private AMQPAdministrator _admin = new AMQPAdministrator();
-
- /**
- * Construct an instance of the interface to the AMQP provider
- */
- public AMQPProvider() {
- }
-
- /**
- * Initialises the administation interface
- *
- * @throws JMSException if the administration interface can't be
- * initialised
- */
- public void initialise(boolean start) throws JMSException {
- _admin.initialise();
- }
-
- /**
- * Returns the administration interface
- */
- public Administrator getAdministrator() {
- return _admin;
- }
-
- /**
- * This method cleans up the administrator
- */
- public void cleanup(boolean stop) {
- _admin.cleanup();
- _admin = null;
- }
-
-} //-- AMQPProvider
diff --git a/java/client/src/test/java/org/apache/qpid/example/log4j.xml b/java/client/src/test/java/org/apache/qpid/example/log4j.xml
deleted file mode 100644
index de64423a51..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/log4j.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0"?>
-<!--
- -
- - Licensed to the Apache Software Foundation (ASF) under one
- - or more contributor license agreements. See the NOTICE file
- - distributed with this work for additional information
- - regarding copyright ownership. The ASF licenses this file
- - to you under the Apache License, Version 2.0 (the
- - "License"); you may not use this file except in compliance
- - with the License. You may obtain a copy of the License at
- -
- - http://www.apache.org/licenses/LICENSE-2.0
- -
- - Unless required by applicable law or agreed to in writing,
- - software distributed under the License is distributed on an
- - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- - KIND, either express or implied. See the License for the
- - specific language governing permissions and limitations
- - under the License.
- -
- -->
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
- <appender name="FileAppender" class="org.apache.log4j.FileAppender">
- <param name="File" value="ams_messaging.log"/>
- <param name="Append" value="false"/>
-
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
- </layout>
- </appender>
-
- <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
-
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
- </layout>
- </appender>
-
- <root>
- <priority value="debug"/>
- <appender-ref ref="STDOUT"/>
- <appender-ref ref="FileAppender"/>
- </root>
-</log4j:configuration> \ No newline at end of file
diff --git a/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java b/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java
deleted file mode 100644
index b199d41432..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.example.publisher;
-
-import org.apache.log4j.Logger;
-
-import java.io.File;
-
-import org.apache.qpid.example.shared.FileUtils;
-import org.apache.qpid.example.shared.Statics;
-
-import javax.jms.JMSException;
-
-/**
- * Class that sends message files to the Publisher to distribute
- * using files as input
- * Must set properties for host in properties file or uses in vm broker
- */
-public class FileMessageDispatcher {
-
- protected static final Logger _logger = Logger.getLogger(FileMessageDispatcher.class);
-
- protected static Publisher _publisher = null;
-
- /**
- * To use this main method you need to specify a path or file to use for input
- * This class then uses file contents from the dir/file specified to generate
- * messages to publish
- * Intended to be a very simple way to get going with publishing using the broker
- * @param args - must specify one value, the path to file(s) for publisher
- */
- public static void main(String[] args)
- {
-
- //Check command line args ok - must provide a path or file for us to dispatch
- if (args.length == 0)
- {
- System.err.println("Usage: FileMessageDispatcher <filesToDispatch>" + "");
- }
- else
- {
- try
- {
- //publish message(s) from file(s) to configured queue
- publish(args[0]);
-
- //Move payload file(s) to archive location as no error
- FileUtils.moveFileToNewDir(args[0], System.getProperties().getProperty(Statics.ARCHIVE_PATH));
- }
- catch(Exception e)
- {
- //log error and exit
- _logger.error("Error trying to dispatch message: " + e);
- System.exit(1);
- }
- finally
- {
- //clean up before exiting
- if (getPublisher() != null)
- {
- getPublisher().cleanup();
- }
- }
- }
-
- if (_logger.isDebugEnabled())
- {
- _logger.debug("Finished dispatching message");
- }
-
- System.exit(0);
- }
-
- /**
- * Publish the content of a file or files from a directory as messages
- * @param path - from main args
- * @throws JMSException
- * @throws MessageFactoryException - if cannot create message from file content
- */
- public static void publish(String path) throws JMSException, MessageFactoryException
- {
- File tempFile = new File(path);
- if (tempFile.isDirectory())
- {
- //while more files in dir publish them
- File[] files = tempFile.listFiles();
-
- if (files == null || files.length == 0)
- {
- _logger.info("FileMessageDispatcher - No files to publish in input directory: " + tempFile);
- }
- else
- {
- for (File file : files)
- {
- //Create message factory passing in payload path
- FileMessageFactory factory = new FileMessageFactory(getPublisher().getSession(), file.toString());
-
- //Send the message generated from the payload using the _publisher
- getPublisher().sendMessage(factory.createEventMessage());
-
- }
- }
- }
- else
- {
- //handle a single file
- //Create message factory passing in payload path
- FileMessageFactory factory = new FileMessageFactory(getPublisher().getSession(),tempFile.toString());
-
- //Send the message generated from the payload using the _publisher
- getPublisher().sendMessage(factory.createEventMessage());
- }
- }
-
- /**
- * Cleanup before exit
- */
- public static void cleanup()
- {
- if (getPublisher() != null)
- {
- getPublisher().cleanup();
- }
- }
-
- /**
- * @return A Publisher instance
- */
- private static Publisher getPublisher()
- {
- if (_publisher != null)
- {
- return _publisher;
- }
-
- //Create a _publisher
- _publisher = new Publisher();
-
- return _publisher;
- }
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageFactory.java b/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageFactory.java
deleted file mode 100644
index 88bcbbbccb..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageFactory.java
+++ /dev/null
@@ -1,134 +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.example.publisher;
-
-import org.apache.qpid.example.shared.FileUtils;
-import org.apache.qpid.example.shared.Statics;
-
-import java.io.*;
-import javax.jms.*;
-
-public class FileMessageFactory
-{
- protected final Session _session;
- protected final String _payload;
- protected final String _filename;
-
- /**
- * Contructs and instance using a filename from which content will be used to create message
- * @param session
- * @param filename
- * @throws MessageFactoryException
- */
- public FileMessageFactory(Session session, String filename) throws MessageFactoryException
- {
- try
- {
- _filename = filename;
- _payload = FileUtils.getFileContent(filename);
- _session = session;
- }
- catch (IOException e)
- {
- throw new MessageFactoryException(e.toString());
- }
- }
-
- /**
- * Creates a text message and sets filename property on it
- * The filename property is purely intended to provide visibility
- * of file content passing trhough the broker using example classes
- * @return Message - a TextMessage with content from file
- * @throws JMSException
- */
- public Message createEventMessage() throws JMSException
- {
- TextMessage msg = _session.createTextMessage();
- msg.setText(_payload);
- msg.setStringProperty(Statics.FILENAME_PROPERTY,new File(_filename).getName());
- return msg;
- }
-
- /**
- * Creates message from a string for use by the monitor
- * @param session
- * @param textMsg - message content
- * @return Message - TextMessage with content from String
- * @throws JMSException
- */
- public static Message createSimpleEventMessage(Session session, String textMsg) throws JMSException
- {
- TextMessage msg = session.createTextMessage();
- msg.setText(textMsg);
- return msg;
- }
-
- public Message createShutdownMessage() throws JMSException
- {
- return _session.createTextMessage("SHUTDOWN");
- }
-
- public Message createReportRequestMessage() throws JMSException
- {
- return _session.createTextMessage("REPORT");
- }
-
- public Message createReportResponseMessage(String msg) throws JMSException
- {
- return _session.createTextMessage(msg);
- }
-
- public boolean isShutdown(Message m)
- {
- return checkText(m, "SHUTDOWN");
- }
-
- public boolean isReport(Message m)
- {
- return checkText(m, "REPORT");
- }
-
- public Object getReport(Message m)
- {
- try
- {
- return ((TextMessage) m).getText();
- }
- catch (JMSException e)
- {
- e.printStackTrace(System.out);
- return e.toString();
- }
- }
-
- private static boolean checkText(Message m, String s)
- {
- try
- {
- return m instanceof TextMessage && ((TextMessage) m).getText().equals(s);
- }
- catch (JMSException e)
- {
- e.printStackTrace(System.out);
- return false;
- }
- }
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactoryException.java b/java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactoryException.java
deleted file mode 100644
index 34360d6708..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactoryException.java
+++ /dev/null
@@ -1,72 +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.example.publisher;
-
-import org.apache.log4j.Logger;
-
-public class MessageFactoryException extends Exception {
-
- private int _errorCode;
-
- public MessageFactoryException(String message)
- {
- super(message);
- }
-
- public MessageFactoryException(String msg, Throwable t)
- {
- super(msg, t);
- }
-
- public MessageFactoryException(int errorCode, String msg, Throwable t)
- {
- super(msg + " [error code " + errorCode + ']', t);
- _errorCode = errorCode;
- }
-
- public MessageFactoryException(int errorCode, String msg)
- {
- super(msg + " [error code " + errorCode + ']');
- _errorCode = errorCode;
- }
-
- public MessageFactoryException(Logger logger, String msg, Throwable t)
- {
- this(msg, t);
- logger.error(getMessage(), this);
- }
-
- public MessageFactoryException(Logger logger, String msg)
- {
- this(msg);
- logger.error(getMessage(), this);
- }
-
- public MessageFactoryException(Logger logger, int errorCode, String msg)
- {
- this(errorCode, msg);
- logger.error(getMessage(), this);
- }
-
- public int getErrorCode()
- {
- return _errorCode;
- }
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java b/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java
deleted file mode 100644
index 8784d340da..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java
+++ /dev/null
@@ -1,134 +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.example.publisher;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.BasicConfigurator;
-
-import javax.jms.*;
-
-import java.util.Properties;
-
-/**
- * Class that sends heartbeat messages to allow monitoring of message consumption
- * Sends regular (currently 20 seconds apart) heartbeat message
- */
-public class MonitorMessageDispatcher {
-
- private static final Logger _logger = Logger.getLogger(MonitorMessageDispatcher.class);
-
- protected static MonitorPublisher _monitorPublisher = null;
-
- protected static final String DEFAULT_MONITOR_PUB_NAME = "MonitorPublisher";
-
- /**
- * Easy entry point for running a message dispatcher for monitoring consumption
- * @param args
- */
- public static void main(String[] args)
- {
-
- //Switch on logging appropriately for your app
- BasicConfigurator.configure();
-
- try
- {
- while(true)
- {
- try
- {
- //endlessly publish messages to monitor queue
- publish();
-
- if (_logger.isDebugEnabled())
- {
- _logger.debug("Dispatched monitor message");
- }
-
- //sleep for twenty seconds and then publish again - change if appropriate
- Thread.sleep(20000);
- }
- catch(UndeliveredMessageException a)
- {
- //trigger application specific failure handling here
- _logger.error("Problem delivering monitor message");
- break;
- }
- }
- }
- catch(Exception e)
- {
- _logger.error("Error trying to dispatch AMS monitor message: " + e);
- System.exit(1);
- }
- finally
- {
- if (getMonitorPublisher() != null)
- {
- getMonitorPublisher().cleanup();
- }
- }
-
- System.exit(1);
- }
-
- /**
- * Publish heartbeat message
- * @throws JMSException
- * @throws UndeliveredMessageException
- */
- public static void publish() throws JMSException, UndeliveredMessageException
- {
- //Send the message generated from the payload using the _publisher
- getMonitorPublisher().sendImmediateMessage
- (FileMessageFactory.createSimpleEventMessage(getMonitorPublisher().getSession(),"monitor:" +System.currentTimeMillis()));
- }
-
- /**
- * Cleanup publishers
- */
- public static void cleanup()
- {
- if (getMonitorPublisher() != null)
- {
- getMonitorPublisher().cleanup();
- }
-
- if (getMonitorPublisher() != null)
- {
- getMonitorPublisher().cleanup();
- }
- }
-
- //Returns a _publisher for the monitor queue
- private static MonitorPublisher getMonitorPublisher()
- {
- if (_monitorPublisher != null)
- {
- return _monitorPublisher;
- }
-
- //Create a _publisher using failover details and constant for monitor queue
- _monitorPublisher = new MonitorPublisher();
-
- _monitorPublisher.setName(MonitorMessageDispatcher.DEFAULT_MONITOR_PUB_NAME);
- return _monitorPublisher;
- }
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorPublisher.java b/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorPublisher.java
deleted file mode 100644
index 233c3fea0a..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorPublisher.java
+++ /dev/null
@@ -1,71 +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.example.publisher;
-
-import javax.jms.Message;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import org.apache.qpid.client.BasicMessageProducer;
-import org.apache.log4j.Logger;
-
-/**
- * Subclass of Publisher which uses QPID functionality to send a heartbeat message
- * Note immediate flag not available via JMS MessageProducer
- */
-public class MonitorPublisher extends Publisher
-{
-
- private static final Logger _log = Logger.getLogger(Publisher.class);
-
- BasicMessageProducer _producer;
-
- public MonitorPublisher()
- {
- super();
- }
-
- /*
- * Publishes a non-persistent message using transacted session
- */
- public boolean sendImmediateMessage(Message message) throws UndeliveredMessageException
- {
- try
- {
- _producer = (BasicMessageProducer)_session.createProducer(_destination);
-
- //Send message via our producer which is not persistent and is immediate
- //NB: not available via jms interface MessageProducer
- _producer.send(message, DeliveryMode.NON_PERSISTENT, true);
-
- //commit the message send and close the transaction
- _session.commit();
-
- }
- catch (JMSException e)
- {
- //Have to assume our commit failed but do not rollback here as channel closed
- _log.error(e);
- e.printStackTrace();
- throw new UndeliveredMessageException("Cannot deliver immediate message",e);
- }
-
- _log.info(_name + " finished sending message: " + message);
- return true;
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/publisher/Publisher.java b/java/client/src/test/java/org/apache/qpid/example/publisher/Publisher.java
deleted file mode 100644
index be42e0e413..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/publisher/Publisher.java
+++ /dev/null
@@ -1,181 +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.example.publisher;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.client.AMQConnectionFactory;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.DeliveryMode;
-import javax.jms.Queue;
-import javax.jms.MessageProducer;
-import javax.jms.Connection;
-import javax.jms.Session;
-
-import javax.naming.InitialContext;
-
-import org.apache.qpid.example.shared.InitialContextHelper;
-
-public class Publisher
-{
- private static final Logger _log = Logger.getLogger(Publisher.class);
-
- protected InitialContextHelper _contextHelper;
-
- protected Connection _connection;
-
- protected Session _session;
-
- protected MessageProducer _producer;
-
- protected String _destinationDir;
-
- protected String _name = "Publisher";
-
- protected Queue _destination;
-
- protected static final String _defaultDestinationDir = "/tmp";
-
- /**
- * Creates a Publisher instance using properties from example.properties
- * See InitialContextHelper for details of how context etc created
- */
- public Publisher()
- {
- try
- {
- //get an initial context from default properties
- _contextHelper = new InitialContextHelper(null);
- InitialContext ctx = _contextHelper.getInitialContext();
-
- //then create a connection using the AMQConnectionFactory
- AMQConnectionFactory cf = (AMQConnectionFactory) ctx.lookup("local");
- _connection = cf.createConnection();
-
- //create a transactional session
- _session = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- //lookup the example queue and use it
- //Queue is non-exclusive and not deleted when last consumer detaches
- _destination = _session.createQueue((String)ctx.lookup("MyQueue"));
-
- //create a message producer
- _producer = _session.createProducer(_destination);
-
- //set destination dir for files that have been processed
- _destinationDir = _defaultDestinationDir;
-
- _connection.start();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- _log.error(e);
- }
- }
-
- /**
- * Publishes a non-persistent message using transacted session
- * Note that persistent is the default mode for send - so need to specify for transient
- */
- public boolean sendMessage(Message message)
- {
- try
- {
- //Send message via our producer which is not persistent
- _producer.send(message, DeliveryMode.NON_PERSISTENT, _producer.getPriority(), _producer.getTimeToLive());
-
- //commit the message send and close the transaction
- _session.commit();
-
- }
- catch (JMSException e)
- {
- //Have to assume our commit failed and rollback here
- try
- {
- _session.rollback();
- _log.error(e);
- e.printStackTrace();
- return false;
- }
- catch (JMSException j)
- {
- _log.error("Unable to rollback publish transaction ",e);
- return false;
- }
- }
-
- _log.info(_name + " finished sending message: " + message);
- return true;
- }
-
- /**
- * Cleanup resources before exit
- */
- public void cleanup()
- {
- try
- {
- if (_connection != null)
- {
- _connection.stop();
- _connection.close();
- }
- _connection = null;
- _producer = null;
- }
- catch(Exception e)
- {
- _log.error("Error trying to cleanup publisher " + e);
- System.exit(1);
- }
- }
-
- /**
- * Exposes session
- * @return Session
- */
- public Session getSession()
- {
- return _session;
- }
-
- public String getDestinationDir()
- {
- return _destinationDir;
- }
-
- public void setDestinationDir(String destinationDir)
- {
- _destinationDir = destinationDir;
- }
-
- public String getName()
- {
- return _name;
- }
-
- public void setName(String _name) {
- this._name = _name;
- }
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java b/java/client/src/test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java
deleted file mode 100644
index 3335833c2d..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java
+++ /dev/null
@@ -1,74 +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.example.publisher;
-
-import org.apache.log4j.Logger;
-
-/**
- * Exception thrown by monitor when cannot send a message marked for immediate delivery
- */
-public class UndeliveredMessageException extends Exception {
-
- private int _errorCode;
-
- public UndeliveredMessageException(String message)
- {
- super(message);
- }
-
- public UndeliveredMessageException(String msg, Throwable t)
- {
- super(msg, t);
- }
-
- public UndeliveredMessageException(int errorCode, String msg, Throwable t)
- {
- super(msg + " [error code " + errorCode + ']', t);
- _errorCode = errorCode;
- }
-
- public UndeliveredMessageException(int errorCode, String msg)
- {
- super(msg + " [error code " + errorCode + ']');
- _errorCode = errorCode;
- }
-
- public UndeliveredMessageException(Logger logger, String msg, Throwable t)
- {
- this(msg, t);
- logger.error(getMessage(), this);
- }
-
- public UndeliveredMessageException(Logger logger, String msg)
- {
- this(msg);
- logger.error(getMessage(), this);
- }
-
- public UndeliveredMessageException(Logger logger, int errorCode, String msg)
- {
- this(errorCode, msg);
- logger.error(getMessage(), this);
- }
-
- public int getErrorCode()
- {
- return _errorCode;
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/shared/ConnectionException.java b/java/client/src/test/java/org/apache/qpid/example/shared/ConnectionException.java
deleted file mode 100644
index 8723983862..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/shared/ConnectionException.java
+++ /dev/null
@@ -1,71 +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.example.shared;
-
-import org.apache.log4j.Logger;
-
-public class ConnectionException extends Exception {
-
- private int _errorCode;
-
- public ConnectionException(String message)
- {
- super(message);
- }
-
- public ConnectionException(String msg, Throwable t)
- {
- super(msg, t);
- }
-
- public ConnectionException(int errorCode, String msg, Throwable t)
- {
- super(msg + " [error code " + errorCode + ']', t);
- _errorCode = errorCode;
- }
-
- public ConnectionException(int errorCode, String msg)
- {
- super(msg + " [error code " + errorCode + ']');
- _errorCode = errorCode;
- }
-
- public ConnectionException(Logger logger, String msg, Throwable t)
- {
- this(msg, t);
- logger.error(getMessage(), this);
- }
-
- public ConnectionException(Logger logger, String msg)
- {
- this(msg);
- logger.error(getMessage(), this);
- }
-
- public ConnectionException(Logger logger, int errorCode, String msg)
- {
- this(errorCode, msg);
- logger.error(getMessage(), this);
- }
-
- public int getErrorCode()
- {
- return _errorCode;
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/shared/ContextException.java b/java/client/src/test/java/org/apache/qpid/example/shared/ContextException.java
deleted file mode 100644
index 787cecd541..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/shared/ContextException.java
+++ /dev/null
@@ -1,73 +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.example.shared;
-
-import org.apache.log4j.Logger;
-
-public class ContextException extends Exception {
-
- private int _errorCode;
-
- public ContextException(String message)
- {
- super(message);
- }
-
- public ContextException(String msg, Throwable t)
- {
- super(msg, t);
- }
-
- public ContextException(int errorCode, String msg, Throwable t)
- {
- super(msg + " [error code " + errorCode + ']', t);
- _errorCode = errorCode;
- }
-
- public ContextException(int errorCode, String msg)
- {
- super(msg + " [error code " + errorCode + ']');
- _errorCode = errorCode;
- }
-
- public ContextException(Logger logger, String msg, Throwable t)
- {
- this(msg, t);
- logger.error(getMessage(), this);
- }
-
- public ContextException(Logger logger, String msg)
- {
- this(msg);
- logger.error(getMessage(), this);
- }
-
- public ContextException(Logger logger, int errorCode, String msg)
- {
- this(errorCode, msg);
- logger.error(getMessage(), this);
- }
-
- public int getErrorCode()
- {
- return _errorCode;
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/shared/FileUtils.java b/java/client/src/test/java/org/apache/qpid/example/shared/FileUtils.java
deleted file mode 100644
index 54446cb6a7..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/shared/FileUtils.java
+++ /dev/null
@@ -1,168 +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.example.shared;
-
-import java.io.*;
-
-/**
- * Class that provides file related utility methods for utility use
- */
-public class FileUtils {
-
-
- //Reads file content into String
- public static String getFileContent(String filePath) throws IOException
- {
-
- BufferedReader reader = null;
- String tempData = "";
- String eol = "\n\r";
-
- try
- {
- String line;
- reader = new BufferedReader(new FileReader(filePath));
- while ((line = reader.readLine()) != null)
- {
- if (!tempData.equals(""))
- {
- tempData = tempData + eol + line;
- }
- else
- {
- tempData = line;
- }
- }
- }
- finally
- {
- if (reader != null)
- {
- reader.close();
- }
- }
- return tempData;
- }
-
- /*
- * Reads xml from a file and returns it as an array of chars
- */
- public static char[] getFileAsCharArray(String filePath) throws IOException
- {
- BufferedReader reader = null;
- char[] tempChars = null;
- String tempData = "";
-
- try
- {
- String line;
- reader = new BufferedReader(new FileReader(filePath));
- while ((line = reader.readLine()) != null)
- {
- tempData = tempData + line;
- }
- tempChars = tempData.toCharArray();
- }
- finally
- {
- if (reader != null)
- {
- reader.close();
- }
- }
- return tempChars;
- }
-
- /*
- * Write String content to filename provided
- */
- public static void writeStringToFile(String content, String path) throws IOException
- {
-
- BufferedWriter writer = new BufferedWriter(new FileWriter(new File(path)));
- writer.write(content);
- writer.flush();
- writer.close();
- }
-
- /*
- * Allows moving of files to a new dir and preserves the last bit of the name only
- */
- public static void moveFileToNewDir(String path, String newDir) throws IOException
- {
- //get file name from current path
- //while more files in dir publish them
- File pathFile = new File(path);
- if (pathFile.isDirectory())
- {
- File[] files = pathFile.listFiles();
- for (File file : files)
- {
- moveFileToNewDir(file,newDir);
- }
- }
- }
-
- /*
- * Allows moving of a file to a new dir and preserves the last bit of the name only
- */
- public static void moveFileToNewDir(File fileToMove, String newDir) throws IOException
- {
- moveFile(fileToMove,getArchiveFileName(fileToMove,newDir));
- }
-
- /*
- * Moves file from a given path to a new path with String params
- */
- public static void moveFile(String fromPath, String dest) throws IOException
- {
- moveFile(new File(fromPath),new File(dest));
- }
-
- /*
- * Moves file from a given path to a new path with mixed params
- */
- public static void moveFile(File fileToMove, String dest) throws IOException
- {
- moveFile(fileToMove,new File(dest));
- }
-
- /*
- * Moves file from a given path to a new path with File params
- */
- public static void moveFile(File fileToMove, File dest) throws IOException
- {
- fileToMove.renameTo(dest);
- }
-
- /*
- * Deletes a given file
- */
- public static void deleteFile(String filePath) throws IOException
- {
- new File(filePath).delete();
- }
-
- private static String getArchiveFileName(File fileToMove, String archiveDir)
- {
- //get file name from current path
- String fileName = fileToMove.getName();
- return archiveDir + File.separator + fileName;
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/shared/InitialContextHelper.java b/java/client/src/test/java/org/apache/qpid/example/shared/InitialContextHelper.java
deleted file mode 100644
index b39892b688..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/shared/InitialContextHelper.java
+++ /dev/null
@@ -1,78 +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.example.shared;
-
-import org.apache.log4j.Logger;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Properties;
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * Class that provides helper methods for JNDI
- */
-public class InitialContextHelper {
-
- public static final String _defaultPropertiesName = "example.properties";
- protected static Properties _fileProperties;
- protected static InitialContext _initialContext;
- protected static final Logger _log = Logger.getLogger(InitialContextHelper.class);
-
- public InitialContextHelper(String propertiesName) throws ContextException
- {
- try
- {
- if (propertiesName == null || propertiesName.length() == 0)
- {
- propertiesName = _defaultPropertiesName;
- }
-
- _fileProperties = new Properties();
- ClassLoader cl = this.getClass().getClassLoader();
-
- //NB: Need to change path to reflect package if moving classes around !
- InputStream is = cl.getResourceAsStream("org/apache/qpid/example/shared/" + propertiesName);
- _fileProperties.load(is);
- _initialContext = new InitialContext(_fileProperties);
- }
- catch (IOException e)
- {
- throw new ContextException(_log, e.toString());
- }
- catch (NamingException n)
- {
- throw new ContextException(_log, n.toString());
- }
- }
-
- public Properties getFileProperties()
- {
- return _fileProperties;
- }
-
- public InitialContext getInitialContext()
- {
- return _initialContext;
- }
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/shared/Statics.java b/java/client/src/test/java/org/apache/qpid/example/shared/Statics.java
deleted file mode 100644
index c056f8a7da..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/shared/Statics.java
+++ /dev/null
@@ -1,57 +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.example.shared;
-
-/**
- * Constants used by AMS Publisher/Subscriber classes
- */
-public class Statics {
-
- public static final String TOPIC_NAME = "EXAMPLE_TOPIC";
-
- public static final String QUEUE_NAME = "EXAMPLE_QUEUE";
-
- public static final String MONITOR_QUEUE_SUFFIX = "_MONITOR";
-
- public static final String HOST_PROPERTY = "host";
-
- public static final String PORT_PROPERTY = "port";
-
- public static final String USER_PROPERTY = "user";
-
- public static final String PWD_PROPERTY = "pwd";
-
- public static final String TOPIC_PROPERTY = "topic";
-
- public static final String QUEUE_PROPERTY = "queue";
-
- public static final String VIRTUAL_PATH_PROPERTY = "virtualpath";
-
- public static final String ARCHIVE_PATH = "archivepath";
-
- public static final String CLIENT_PROPERTY = "client";
-
- public static final String FILENAME_PROPERTY = "filename";
-
- public static final String DEFAULT_USER = "guest";
-
- public static final String DEFAULT_PWD = "guest";
-
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/shared/example.properties b/java/client/src/test/java/org/apache/qpid/example/shared/example.properties
deleted file mode 100644
index 82de41908f..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/shared/example.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory
-
-# use the following property to configure the default connector
-#java.naming.provider.url - ignored.
-
-# register some connection factories
-# connectionfactory.[jndiname] = [ConnectionURL]
-connectionfactory.local = amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'
-
-# register some queues in JNDI using the form
-# queue.[jndiName] = [physicalName]
-queue.MyQueue = example.MyQueue
-
-# register some topics in JNDI using the form
-# topic.[jndiName] = [physicalName]
-topic.ibmStocks = stocks.nyse.ibm
-
-# Register an AMQP destination in JNDI
-# NOTE: Qpid currently only supports direct,topics and headers
-# destination.[jniName] = [BindingURL]
-destination.direct = direct://amq.direct//directQueue
diff --git a/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java b/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java
deleted file mode 100644
index 9c195aef40..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java
+++ /dev/null
@@ -1,139 +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.example.subscriber;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.example.shared.Statics;
-
-import javax.jms.*;
-
-/**
- * Subclass of Subscriber which consumes a heartbeat message
- */
-
-public class MonitoredSubscriber extends Subscriber
-{
- protected String _monitorDestinationName;
-
- private static final Logger _logger = Logger.getLogger(MonitoredSubscriber.class);
-
- private static MessageConsumer _monitorConsumer;
-
- public MonitoredSubscriber()
- {
- super();
- //lookup queue name and append suffix
- _monitorDestinationName = _destinationName + Statics.MONITOR_QUEUE_SUFFIX;
- }
-
- /**
- * MessageListener implementation for this subscriber
- */
- public static class MonitorMessageListener implements MessageListener
- {
- private String _name;
-
- public MonitorMessageListener(String name)
- {
- _name = name;
-
- }
-
- /**
- * Listens for heartbeat messages and acknowledges them
- * @param message
- */
- public void onMessage(javax.jms.Message message)
- {
- _logger.info(_name + " monitor got message '" + message + "'");
-
- try
- {
- _logger.debug("Monitor acknowledging recieved message");
-
- //Now acknowledge the message to clear it from our queue
- message.acknowledge();
- }
- catch(JMSException j)
- {
- _logger.error("Monitor caught JMSException trying to acknowledge message receipt");
- j.printStackTrace();
- }
- catch(Exception e)
- {
- _logger.error("Monitor caught unexpected exception trying to handle message");
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Subscribes to Queue and attaches additional monitor listener
- */
- public void subscribeAndMonitor()
- {
- try
- {
- _connection = _connectionFactory.createConnection();
-
- //create a transactional session
- Session session = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- //Queue is non-exclusive and not deleted when last consumer detaches
- Destination destination = session.createQueue(_monitorDestinationName);
-
- //Create a consumer with a destination of our queue which will use defaults for prefetch etc
- _monitorConsumer = session.createConsumer(destination);
-
- //give the monitor message listener a name of it's own
- _monitorConsumer.setMessageListener(new MonitoredSubscriber.MonitorMessageListener
- ("MonitorListener " + System.currentTimeMillis()));
-
- MonitoredSubscriber._logger.info("Starting monitored subscription ...");
-
- MonitoredSubscriber._connection.start();
-
- //and now start ordinary consumption too
- subscribe();
- }
- catch (Throwable t)
- {
- _logger.error("Fatal error: " + t);
- t.printStackTrace();
- }
- }
-
- /**
- * Stop consuming
- */
- public void stopMonitor()
- {
- try
- {
- _monitorConsumer.close();
- _monitorConsumer = null;
- stop();
- }
- catch(JMSException j)
- {
- _logger.error("JMSException trying to Subscriber.stop: " + j.getStackTrace());
- }
- }
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java b/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java
deleted file mode 100644
index d2f27da052..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java
+++ /dev/null
@@ -1,51 +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.example.subscriber;
-
-import org.apache.log4j.BasicConfigurator;
-
-/**
- * Allows you to simply start a monitored subscriber
- */
-public class MonitoredSubscriptionWrapper {
-
- private static MonitoredSubscriber _subscriber;
-
- /**
- * Create a monitored subscriber and start it
- * @param args - no params required
- */
- public static void main(String args[])
- {
- //switch on logging
- BasicConfigurator.configure();
-
- _subscriber = new MonitoredSubscriber();
-
- _subscriber.subscribe();
- }
-
- /**
- * Stop subscribing now ...
- */
- public static void stop()
- {
- _subscriber.stop();
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/example/subscriber/Subscriber.java b/java/client/src/test/java/org/apache/qpid/example/subscriber/Subscriber.java
deleted file mode 100644
index 34c7d6c7bb..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/subscriber/Subscriber.java
+++ /dev/null
@@ -1,194 +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.example.subscriber;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnectionFactory;
-
-import javax.jms.*;
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-
-import org.apache.qpid.example.shared.InitialContextHelper;
-
-/**
- * Subscriber which consumes messages from a queue
- */
-
-public class Subscriber
-{
- private static final Logger _log = Logger.getLogger(Subscriber.class);
-
- protected static Connection _connection;
-
- protected static MessageConsumer _consumer;
-
- protected static InitialContextHelper _contextHelper;
-
- protected static AMQConnectionFactory _connectionFactory;
-
- protected String _destinationName;
-
- public Subscriber()
- {
- try
- {
- //get an initial context from default properties
- _contextHelper = new InitialContextHelper(null);
- InitialContext ctx = _contextHelper.getInitialContext();
-
- //then create a connection using the AMQConnectionFactory
- _connectionFactory = (AMQConnectionFactory) ctx.lookup("local");
-
- //lookup queue name
- _destinationName = (String) ctx.lookup("MyQueue");
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- _log.error(e);
- }
- }
-
- /**
- * Listener class that handles messages
- */
- public static class ExampleMessageListener implements MessageListener
- {
- private String _name;
-
- public ExampleMessageListener(String name)
- {
- _name = name;
-
- }
-
- /**
- * Listens for message callbacks, handles and then acknowledges them
- * @param message - the message received
- */
- public void onMessage(javax.jms.Message message)
- {
- _log.info(_name + " got message '" + message + "'");
-
- try
- {
- //NB: Handle your message appropriately for your application here
- //do some stuff
-
- _log.debug("Acknowledging recieved message");
-
- //Now acknowledge the message to clear it from our queue
- message.acknowledge();
- }
- catch(JMSException j)
- {
- _log.error("JMSException trying to acknowledge message receipt");
- j.printStackTrace();
- }
- catch(Exception e)
- {
- _log.error("Unexpected exception trying to handle message");
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Subscribes to example Queue and attaches listener
- */
- public void subscribe()
- {
- _log.info("Starting subscription ...");
-
- try
- {
- _connection = _connectionFactory.createConnection();
-
- //create a transactional session
- Session session = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- //Queue is non-exclusive and not deleted when last consumer detaches
- Destination destination = session.createQueue(_destinationName);
-
- //Create a consumer with a destination of our queue which will use defaults for prefetch etc
- _consumer = session.createConsumer(destination);
-
- //give the message listener a name of it's own
- _consumer.setMessageListener(new ExampleMessageListener("MessageListener " + System.currentTimeMillis()));
-
- _connection.start();
- }
- catch (Throwable t)
- {
- _log.error("Fatal error: " + t);
- t.printStackTrace();
- }
-
- _log.info("Waiting for messages ...");
-
- //wait for messages and sleep to survive failover
- try
- {
- while(true)
- {
- Thread.sleep(Long.MAX_VALUE);
- }
- }
- catch (Exception e)
- {
- _log.warn("Exception while Subscriber sleeping",e);
- }
- }
-
- /**
- * Set destination (queue or topic) name
- * @param name
- */
- public void setDestinationName(String name)
- {
- _destinationName = name;
- }
-
- /**
- * Stop consuming and close connection
- */
- public void stop()
- {
- try
- {
- _consumer.close();
- _consumer = null;
- _connection.stop();
- _connection.close();
- }
- catch(JMSException j)
- {
- _log.error("JMSException trying to Subscriber.stop: " + j.getStackTrace());
- }
- }
-
-}
-
-
-
-
diff --git a/java/client/src/test/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java b/java/client/src/test/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java
deleted file mode 100644
index 32a0ef685c..0000000000
--- a/java/client/src/test/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java
+++ /dev/null
@@ -1,51 +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.example.subscriber;
-
-import org.apache.log4j.BasicConfigurator;
-
-/**
- * Allows you to simply start a subscriber
- */
-public class SubscriptionWrapper {
-
- private static Subscriber _subscriber;
-
- /**
- * Create a subscriber and start it
- * @param args
- */
- public static void main(String args[])
- {
- //switch on logging
- BasicConfigurator.configure();
-
- _subscriber = new Subscriber();
-
- _subscriber.subscribe();
- }
-
- /**
- * Stop subscribing now ...
- */
- public static void stop()
- {
- _subscriber.stop();
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/flow/ChannelFlowTest.java b/java/client/src/test/java/org/apache/qpid/flow/ChannelFlowTest.java
deleted file mode 100644
index 0c57a73d5d..0000000000
--- a/java/client/src/test/java/org/apache/qpid/flow/ChannelFlowTest.java
+++ /dev/null
@@ -1,110 +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.flow;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-
-public class ChannelFlowTest implements MessageListener
-{
- private int sent;
- private int received;
-
- ChannelFlowTest(String broker) throws Exception
- {
- this(new AMQConnection(broker, "guest", "guest", randomize("Client"), "/test_path"));
- }
-
- ChannelFlowTest(AMQConnection connection) throws Exception
- {
- this(connection, new AMQQueue(randomize("ChannelFlowTest"), true));
- }
-
- ChannelFlowTest(AMQConnection connection, AMQDestination destination) throws Exception
- {
- AMQSession session = (AMQSession) connection.createSession(false, AMQSession.NO_ACKNOWLEDGE, 50,25);
-
- //set up a slow consumer
- session.createConsumer(destination).setMessageListener(this);
- connection.start();
-
- //create a publisher
- MessageProducer producer = session.createProducer(destination);
- Message msg = session.createTextMessage("Message");
-
- //publish in bursts that are fast enough to cause channel flow control
- for(int i = 0; i < 10; i++)
- {
- for(int j = 0; j < 100; j++)
- {
- producer.send(msg);
- sent++;
- }
- waitUntilReceived(sent - 40);
- }
-
- waitUntilReceived(sent);
-
- session.close();
- connection.close();
- }
-
-
- private synchronized void waitUntilReceived(int count) throws InterruptedException
- {
- while(received <count)
- {
- wait();
- }
- }
-
- public synchronized void onMessage(Message message)
- {
- try
- {
- Thread.sleep(50);
-
- received++;
- notify();
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
-
- private static String randomize(String in)
- {
- return in + System.currentTimeMillis();
- }
-
- public static void main(String[] argv) throws Exception
- {
- new ChannelFlowTest(argv.length == 0 ? "localhost:5672" : argv[0]);
- }
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargePublisher.java b/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargePublisher.java
deleted file mode 100644
index 983186a545..0000000000
--- a/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargePublisher.java
+++ /dev/null
@@ -1,193 +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.fragmentation;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.jms.MessageProducer;
-import org.apache.qpid.jms.Session;
-import org.apache.log4j.Logger;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * A client that behaves as follows:
- * <ul><li>Connects to a queue, whose name is specified as a cmd-line argument</li>
- * <li>Creates a temporary queue</li>
- * <li>Creates messages containing a property that is the name of the temporary queue</li>
- * <li>Fires off a message on the original queue and waits for a response on the temporary queue</li>
- * </ul>
- */
-public class TestLargePublisher
-{
- private static final Logger _log = Logger.getLogger(TestLargePublisher.class);
-
- private AMQConnection _connection;
-
- private Session _session;
-
- private class CallbackHandler implements MessageListener
- {
- private int _expectedMessageCount;
-
- private int _actualMessageCount;
-
- private long _startTime;
-
- public CallbackHandler(int expectedMessageCount, long startTime)
- {
- _expectedMessageCount = expectedMessageCount;
- _startTime = startTime;
- }
-
- public void onMessage(Message m)
- {
- if (_log.isDebugEnabled())
- {
- _log.debug("Message received: " + m);
- }
- _actualMessageCount++;
- if (_actualMessageCount%1000 == 0)
- {
- _log.info("Received message count: " + _actualMessageCount);
- }
- /*if (!"henson".equals(m.toString()))
- {
- _log.error("AbstractJMSMessage response not correct: expected 'henson' but got " + m.toString());
- }
- else
- {
- if (_log.isDebugEnabled())
- {
- _log.debug("AbstractJMSMessage " + m + " received");
- }
- else
- {
- _log.info("AbstractJMSMessage received");
- }
- } */
-
- if (_actualMessageCount == _expectedMessageCount)
- {
- long timeTaken = System.currentTimeMillis() - _startTime;
- System.out.println("Total time taken to receive " + _expectedMessageCount+ " messages was " +
- timeTaken + "ms, equivalent to " +
- (_expectedMessageCount/(timeTaken/1000.0)) + " messages per second");
- }
- }
- }
-
- public TestLargePublisher(String host, int port, String clientID,
- final int messageCount) throws AMQException,URLSyntaxException
- {
- try
- {
- createConnection(host, port, clientID);
-
- _session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- AMQTopic destination = new AMQTopic("large");
- MessageProducer producer = (MessageProducer) _session.createProducer(destination);
-
- _connection.start();
- //TextMessage msg = _session.createTextMessage(tempDestination.getQueueName() + "/Presented to in conjunction with Mahnah Mahnah and the Snowths");
- final long startTime = System.currentTimeMillis();
-
- for (int i = 0; i < messageCount; i++)
- {
- BytesMessage msg = _session.createBytesMessage();
- populateMessage(msg);
- producer.send(msg);
- }
- _log.info("Finished sending " + messageCount + " messages");
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- }
- }
-
- private void createConnection(String host, int port, String clientID) throws AMQException , URLSyntaxException
- {
- _connection = new AMQConnection(host, port, "guest", "guest",
- clientID, "/test");
- }
-
- private void populateMessage(BytesMessage msg) throws JMSException
- {
- int size = 1024 * 187; // 187k
- byte[] data = new byte[size];
- for (int i = 0; i < data.length; i++)
- {
- data[i] = (byte)(i%25);
- }
- msg.writeBytes(data);
- }
-
- /**
- *
- * @param args argument 1 if present specifies the name of the temporary queue to create. Leaving it blank
- * means the server will allocate a name.
- */
- public static void main(String[] args) throws URLSyntaxException
- {
- final String host;
- final int port;
- final int numMessages;
- if (args.length == 0)
- {
- host = "localhost";
- port = 5672;
- numMessages = 100;
-// System.err.println("Usage: TestLargePublisher <host> <port> <number of messages>");
- }
- else
- {
- host = args[0];
- port = Integer.parseInt(args[1]);
- numMessages = Integer.parseInt(args[2]);
- }
-
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- String clientID = address.getHostName() + System.currentTimeMillis();
- TestLargePublisher client = new TestLargePublisher(host, port, clientID, numMessages);
- }
- catch (UnknownHostException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- catch (AMQException e)
- {
- System.err.println("Error in client: " + e);
- e.printStackTrace();
- }
-
- //System.exit(0);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargeSubscriber.java b/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargeSubscriber.java
deleted file mode 100644
index 03ace4a8d9..0000000000
--- a/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargeSubscriber.java
+++ /dev/null
@@ -1,163 +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.fragmentation;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.jms.Session;
-import org.apache.log4j.Logger;
-
-import javax.jms.*;
-import java.net.InetAddress;
-
-public class TestLargeSubscriber
-{
- private static final Logger _logger = Logger.getLogger(TestLargeSubscriber.class);
-
- private static MessageProducer _destinationProducer;
-
- private static String _destinationName;
-
- public static void main(String[] args)
- {
- _logger.info("Starting...");
-
- final String host;
- final int port;
- final String username;
- final String password;
- final String virtualPath;
- final int numExpectedMessages;
- if (args.length == 0)
- {
- host = "localhost";
- port = 5672;
- username = "guest";
- password = "guest";
- virtualPath = "/test";
- numExpectedMessages = 100;
- }
- else if (args.length == 6)
- {
- host = args[0];
- port = Integer.parseInt(args[1]);
- username = args[2];
- password = args[3];
- virtualPath = args[4];
- numExpectedMessages = Integer.parseInt(args[5]);
- }
- else
- {
- System.out.println("Usage: host port username password virtual-path expectedMessageCount");
- System.exit(1);
- throw new RuntimeException("cannot be reached");
- }
-
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- AMQConnection con = new AMQConnection(host, port, username, password,
- address.getHostName(), virtualPath);
- final Session session = (Session) con.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- final int expectedMessageCount = numExpectedMessages;
-
- MessageConsumer consumer = session.createConsumer(new AMQTopic("large"),
- 100, true, false, null);
-
- consumer.setMessageListener(new MessageListener()
- {
- private int _messageCount;
-
- private long _startTime = 0;
-
- public void onMessage(Message message)
- {
- validateMessage(message);
- if (_messageCount++ == 0)
- {
- _startTime = System.currentTimeMillis();
- }
- if (_logger.isInfoEnabled())
- {
- _logger.info("Got message '" + message + "'");
- }
- if (_messageCount == expectedMessageCount)
- {
- long totalTime = System.currentTimeMillis() - _startTime;
- _logger.error("Total time to receive " + _messageCount + " messages was " +
- totalTime + "ms. Rate is " + (_messageCount/(totalTime/1000.0)));
- }
- }
-
- private void validateMessage(Message message)
- {
- if (!(message instanceof BytesMessage))
- {
- _logger.error("Message is not of correct type - should be BytesMessage and is " +
- message.getClass());
- }
- BytesMessage bm = (BytesMessage) message;
- final int expectedSize = 1024 * 187; // 187k
- try
- {
- if (bm.getBodyLength() != expectedSize)
- {
- _logger.error("Message is not correct length - should be " + expectedSize + " and is " +
- bm.getBodyLength());
- }
- }
- catch (JMSException e)
- {
- _logger.error("Failed to validate message: " + e, e);
- }
- try
- {
- byte[] data = new byte[(int)bm.getBodyLength()];
- bm.readBytes(data);
- for (int i = 0; i < data.length; i++)
- {
- if (data[i] != (byte)(i%25))
- {
- _logger.error("byte " + i + " of message is wrong - should be " + i%25 + " but is " +
- data[i]);
- }
- }
- _logger.info("***** Validated message successfully");
- }
- catch (JMSException e)
- {
- _logger.error("Failed to validate message: " + e, e);
- }
- }
- });
- con.start();
- }
- catch (Throwable t)
- {
- System.err.println("Fatal error: " + t);
- t.printStackTrace();
- }
-
- System.out.println("Waiting...");
- }
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/headers/Listener.java b/java/client/src/test/java/org/apache/qpid/headers/Listener.java
deleted file mode 100644
index d97fc22a35..0000000000
--- a/java/client/src/test/java/org/apache/qpid/headers/Listener.java
+++ /dev/null
@@ -1,117 +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.headers;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.jms.Session;
-import org.apache.qpid.testutil.Config;
-
-import javax.jms.MessageListener;
-import javax.jms.Message;
-import javax.jms.Destination;
-import javax.jms.MessageProducer;
-import javax.jms.JMSException;
-
-public class Listener implements MessageListener
-{
- private final AMQConnection _connection;
- private final MessageProducer _controller;
- private final AMQSession _session;
- private final MessageFactory _factory;
- private int count;
- private long start;
-
- Listener(AMQConnection connection, Destination exchange) throws Exception
- {
- _connection = connection;
- _session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- _factory = new MessageFactory(_session, 0, 19);
-
- //register for events
- _factory.createConsumer(exchange).setMessageListener(this);
- _connection.start();
-
- _controller = _session.createProducer(exchange);
- }
-
- private void shutdown()
- {
- try
- {
- _session.close();
- _connection.stop();
- _connection.close();
- }
- catch(Exception e)
- {
- e.printStackTrace(System.out);
- }
- }
-
- private void report()
- {
- try
- {
- String msg = getReport();
- _controller.send(_factory.createReportResponseMessage(msg));
- System.out.println("Sent report: " + msg);
- }
- catch(Exception e)
- {
- e.printStackTrace(System.out);
- }
- }
-
- private String getReport() throws JMSException
- {
- long time = (System.currentTimeMillis() - start);
- return "Received " + count + " in " + time + "ms";
- }
-
- public void onMessage(Message message)
- {
- if(count == 0) start = System.currentTimeMillis();
-
- if(_factory.isShutdown(message))
- {
- shutdown();
- }
- else if(_factory.isReport(message))
- {
- //send a report:
- report();
- }
- else if (++count % 100 == 0)
- {
- System.out.println("Received " + count + " messages.");
- }
- }
-
- public static void main(String[] argv) throws Exception
- {
- Config config = new Config();
- config.setType(Config.HEADERS);
- config.setName("test_headers_exchange");
- config.setOptions(argv);
- new Listener((AMQConnection) config.getConnection(), config.getDestination());
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java b/java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java
deleted file mode 100644
index 6f538d068c..0000000000
--- a/java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java
+++ /dev/null
@@ -1,175 +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.headers;
-
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.FieldTableFactory;
-
-import javax.jms.BytesMessage;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.TextMessage;
-
-/**
- */
-class MessageFactory
-{
- private static final char[] DATA = "abcdefghijklmnopqrstuvwxyz".toCharArray();
-
- private final AMQSession _session;
- private final byte[] _payload;
-
- private String[] _headerNames;
-
- MessageFactory(AMQSession session)
- {
- this(session, Integer.getInteger("amqj.test.message_size", 256).intValue(), 5);
- }
-
- MessageFactory(AMQSession session, int payloadSize, int headerCount)
- {
- if (headerCount < 1)
- {
- throw new IllegalArgumentException("Header count must be positive");
- }
- _session = session;
- _payload = new byte[payloadSize];
- for (int i = 0; i < _payload.length; i++)
- {
- _payload[i] = (byte) DATA[i % DATA.length];
- }
- _headerNames = new String[headerCount];
- // note that with the standard encoding the headers get prefixed with an S to indicate their type
- for (int i = 0; i < _headerNames.length; i++)
- {
- if (i < 10)
- {
- _headerNames[i] = "F000" + i;
- }
- else if (i >= 10 && i < 100)
- {
- _headerNames[i] = "F00" + i;
- }
- else
- {
- _headerNames[i] = "F0" + i;
- }
- }
- }
-
- Message createEventMessage() throws JMSException
- {
- BytesMessage msg = _session.createBytesMessage();
- if (_payload.length != 0)
- {
- msg.writeBytes(_payload);
- }
- return setHeaders(msg, _headerNames);
- }
-
- Message createShutdownMessage() throws JMSException
- {
- return setHeaders(_session.createMessage(), new String[]{"F0000", "SHUTDOWN"});
- }
-
- Message createReportRequestMessage() throws JMSException
- {
- return setHeaders(_session.createMessage(), new String[]{"F0000", "REPORT"});
- }
-
- Message createReportResponseMessage(String msg) throws JMSException
- {
- return setHeaders(_session.createTextMessage(msg), new String[]{"CONTROL", "REPORT"});
- }
-
- boolean isShutdown(Message m)
- {
- return checkPresent(m, "SHUTDOWN");
- }
-
- boolean isReport(Message m)
- {
- return checkPresent(m, "REPORT");
- }
-
- Object getReport(Message m)
- {
- try
- {
- return ((TextMessage) m).getText();
- }
- catch (JMSException e)
- {
- e.printStackTrace(System.out);
- return e.toString();
- }
- }
-
- FieldTable getConsumerBinding()
- {
- FieldTable binding = FieldTableFactory.newFieldTable();
- binding.put("SF0000", "value");
- return binding;
- }
-
- FieldTable getControllerBinding()
- {
- FieldTable binding = FieldTableFactory.newFieldTable();
- binding.put("SCONTROL", "value");
- return binding;
- }
-
- MessageConsumer createConsumer(Destination source) throws Exception
- {
- return _session.createConsumer(source, 0, false, true, null, getConsumerBinding());
- }
-
- MessageConsumer createController(Destination source) throws Exception
- {
- return _session.createConsumer(source, 0, false, true, null, getControllerBinding());
- }
-
- private static boolean checkPresent(Message m, String s)
- {
- try
- {
- return m.getStringProperty(s) != null;
- }
- catch (JMSException e)
- {
- e.printStackTrace(System.out);
- return false;
- }
- }
-
- private static Message setHeaders(Message m, String[] headers) throws JMSException
- {
- for (int i = 0; i < headers.length; i++)
- {
- // the value in GRM is 5 bytes
- m.setStringProperty(headers[i], "value");
- }
- return m;
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/headers/Publisher.java b/java/client/src/test/java/org/apache/qpid/headers/Publisher.java
deleted file mode 100644
index a4ac5f670d..0000000000
--- a/java/client/src/test/java/org/apache/qpid/headers/Publisher.java
+++ /dev/null
@@ -1,133 +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.headers;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.testutil.Config;
-
-import javax.jms.*;
-
-public class Publisher implements MessageListener
-{
- private final Object _lock = new Object();
- private final AMQConnection _connection;
- private final AMQSession _session;
- private final Destination _exchange;
- private final MessageFactory _factory;
- private final MessageProducer _publisher;
- private int _count;
-
- Publisher(AMQConnection connection, Destination exchange) throws Exception
- {
- _connection = connection;
- _exchange = exchange;
- _session = (AMQSession) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- _factory = new MessageFactory(_session, 0, 19);
- _publisher = _session.createProducer(_exchange);
- }
-
- Publisher(Config config) throws Exception
- {
- this((AMQConnection) config.getConnection(), config.getDestination());
- }
-
- private void test(int msgCount, int consumerCount) throws Exception
- {
- _count = consumerCount;
- _factory.createController(_exchange).setMessageListener(this);
- _connection.start();
- long start = System.currentTimeMillis();
- publish(msgCount);
- waitForCompletion(consumerCount);
- long end = System.currentTimeMillis();
-
- System.out.println("Completed in " + (end - start) + " ms.");
-
- //request shutdown
- _publisher.send(_factory.createShutdownMessage());
-
- _connection.stop();
- _connection.close();
- }
-
- private void publish(int count) throws Exception
- {
-
- //send events
- for (int i = 0; i < count; i++)
- {
- _publisher.send(_factory.createEventMessage());
- if ((i + 1) % 100 == 0)
- {
- System.out.println("Sent " + (i + 1) + " messages");
- }
- }
-
- //request report
- _publisher.send(_factory.createReportRequestMessage());
- }
-
- private void waitForCompletion(int consumers) throws Exception
- {
- System.out.println("Waiting for completion...");
- synchronized (_lock)
- {
- while (_count > 0)
- {
- _lock.wait();
- }
- }
- }
-
-
- public void onMessage(Message message)
- {
- System.out.println("Received report " + _factory.getReport(message) + " " + --_count + " remaining");
- if (_count == 0)
- {
- synchronized (_lock)
- {
- _lock.notify();
- }
- }
- }
-
-
- public static void main(String[] argv) throws Exception
- {
- if (argv.length >= 2)
- {
- int msgCount = Integer.parseInt(argv[argv.length - 2]);
- int consumerCount = Integer.parseInt(argv[argv.length - 1]);
-
- Config config = new Config();
- config.setType(Config.HEADERS);
- config.setName("test_headers_exchange");
- String[] options = new String[argv.length - 2];
- System.arraycopy(argv, 0, options, 0, options.length);
- config.setOptions(options);
-
- new Publisher(config).test(msgCount, consumerCount);
- }
-
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/jndi/referenceable/Bind.java b/java/client/src/test/java/org/apache/qpid/jndi/referenceable/Bind.java
deleted file mode 100644
index ee6a12c233..0000000000
--- a/java/client/src/test/java/org/apache/qpid/jndi/referenceable/Bind.java
+++ /dev/null
@@ -1,273 +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.jndi.referenceable;
-
-import org.apache.qpid.client.*;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-
-import javax.jms.*;
-import javax.naming.*;
-
-import java.util.Properties;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-/**
- * Binds a reference from a JNDI source.
- * Given a properties file with the JNDI information and a binding string.
- */
-public class Bind
-{
- private static final String USAGE="USAGE: java bind <JNDI Properties file> -cf <url> <binding> | -c <url> <binding> [-t <topic Name> <binding>] [-q <queue Name> <binding>]";
- public Bind(String propertiesFile, String bindingURL, Referenceable reference) throws NameAlreadyBoundException, NoInitialContextException
- {
- // Set up the environment for creating the initial context
- String qpid_home = System.getProperty("QPID_HOME");
-
- if (qpid_home == null || qpid_home.equals(""))
- {
- System.out.println("QPID_HOME is not set");
- System.exit(1);
- }
-
- if (qpid_home.charAt(qpid_home.length() - 1) != '/')
- {
- qpid_home += "/";
- }
-
- try
- {
- InputStream inputStream = new FileInputStream(qpid_home + propertiesFile);
- Properties properties = new Properties();
- properties.load(inputStream);
-
- // Create the initial context
- Context ctx = new InitialContext(properties);
-
- // Perform the binds
- ctx.bind(bindingURL, reference);
-
- // Close the context when we're done
- ctx.close();
- }
- catch (IOException ioe)
- {
- System.out.println("Unable to access properties file:" + propertiesFile + " Due to:" + ioe);
- }
- catch (NamingException e)
- {
- System.out.println("Operation failed: " + e);
- if (e instanceof NameAlreadyBoundException)
- {
- throw (NameAlreadyBoundException) e;
- }
-
- if (e instanceof NoInitialContextException)
- {
- throw (NoInitialContextException) e;
- }
- }
-
- }
-
- private static String parse(String[] args, int index, String what, String type)
- {
- try
- {
- return args[index];
- }
- catch (IndexOutOfBoundsException ioobe)
- {
- System.out.println("ERROR: No " + what + " specified for " + type + ".");
- System.out.println(USAGE);
- System.exit(1);
- }
-
- // The path is either return normally or exception.. which calls system exit so keep the compiler happy
- return "Never going to happen";
- }
-
-
- public static void main(String[] args) throws NameAlreadyBoundException, NoInitialContextException, URLSyntaxException, AMQException, JMSException
- {
-
-
- org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
-
-// org.apache.log4j.Logger _logger = org.apache.log4j.Logger.getLogger(AMQConnection.class);
-// _logger.setLevel(org.apache.log4j.Level.OFF);
-
- boolean exit = false;
-
- String qpid_home = System.getProperty("QPID_HOME");
-
- if (qpid_home == null || qpid_home.equals(""))
- {
- System.out.println("QPID_HOME is not set");
- exit = true;
- }
-
- if (args.length <= 2)
- {
- System.out.println("At least a connection or connection factory must be requested to be bound.");
- exit = true;
- }
- else
- {
- if ((args.length - 1) % 3 != 0)
- {
- System.out.println("Not all values have full details");
- exit = true;
- }
- }
- if (exit)
- {
- System.out.println(USAGE);
- System.exit(1);
- }
-
- if (qpid_home.charAt(qpid_home.length() - 1) != '/')
-
- {
- qpid_home += "/";
- }
-
- AMQConnectionFactory cf = null;
- AMQConnection c = null;
- AMQSession session = null;
- Referenceable reference = null;
-
- for (int index = 1; index < args.length; index ++)
- {
- String obj = args[index];
-
- String what = "Invalid";
- String binding;
-
- if (obj.startsWith("-c"))
- {
- boolean isFactory = obj.contains("f");
-
-
- if (isFactory)
- {
- what = "ConnectionFactory";
- }
- else
- {
- what = "Factory";
- }
-
- String url = parse(args, ++index, "url", what);
-
- if (isFactory)
- {
-
- cf = new AMQConnectionFactory(url);
- reference = cf;
- }
- else
- {
- c = new AMQConnection(url);
- reference = c;
- }
-
- }
-
- if (obj.equals("-t") || obj.equals("-q"))
- {
- if (c == null)
- {
- c = (AMQConnection) cf.createConnection();
- }
-
- if (session == null)
- {
- session = (AMQSession) c.createSession(false, Session.AUTO_ACKNOWLEDGE);
- }
-
- }
-
- if (obj.equals("-t"))
- {
-
- String topicName = parse(args, ++index, "Topic Name", "Topic");
- reference = (AMQTopic) session.createTopic(topicName);
- what = "Topic";
- }
- else
- {
- if (obj.equals("-q"))
- {
- String topicName = parse(args, ++index, "Queue Name", "Queue");
- reference = (AMQQueue) session.createQueue(topicName);
- what = "Queue";
- }
- }
-
- binding = parse(args, ++index, "binding", what);
- if (binding == null)
- {
- System.out.println(obj + " is not a known Object to bind.");
- System.exit(1);
- }
- else
- {
- System.out.print("Binding:" + reference + " to " + binding);
- try
- {
- new Bind(args[0], binding, reference);
- System.out.println(" ..Successful");
-
- }
- catch (NameAlreadyBoundException nabe)
- {
- System.out.println("");
- if (!obj.startsWith("-c") || index == args.length - 1)
- {
- throw nabe;
- }
- else
- {
- System.out.println("Continuing with other bindings using the same connection details");
- }
- }
- finally
- {
- if (!obj.startsWith("-c") || index == args.length - 1)
- {
- if (c != null)
- {
- c.close();
- }
- }
- }
- }
- }
-
- if (c != null)
- {
- c.close();
- }
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/jndi/referenceable/Lookup.java b/java/client/src/test/java/org/apache/qpid/jndi/referenceable/Lookup.java
deleted file mode 100644
index 1c9d8b0fd5..0000000000
--- a/java/client/src/test/java/org/apache/qpid/jndi/referenceable/Lookup.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.jndi.referenceable;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * Looksup a reference from a JNDI source.
- * Given a properties file with the JNDI information and a binding string.
- */
-public class Lookup
-{
- private static final String USAGE = "USAGE: java lookup <JNDI Properties file> -b <binding>";
- private Properties _properties;
- private Object _object;
-
- public Lookup(String propertiesFile, String bindingValue) throws NamingException
- {
- // Set up the environment for creating the initial context
- String qpid_home = System.getProperty("QPID_HOME");
-
- if (qpid_home == null || qpid_home.equals(""))
- {
- System.out.println("QPID_HOME is not set");
- System.exit(1);
- }
-
- if (qpid_home.charAt(qpid_home.length() - 1) != '/')
- {
- qpid_home += "/";
- }
-
- try
- {
- InputStream inputStream = new FileInputStream(qpid_home + propertiesFile);
- Properties properties = new Properties();
- properties.load(inputStream);
-
- _properties = properties;
- lookup(bindingValue);
- }
- catch (IOException ioe)
- {
- System.out.println("Unable to access properties file:" + propertiesFile + " Due to:" + ioe);
- }
- }
-
- public Object lookup(String bindingValue) throws NamingException
- {
-
- // Create the initial context
- Context ctx = new InitialContext(_properties);
-
- // Perform the binds
- _object = ctx.lookup(bindingValue);
-
- // Close the context when we're done
- ctx.close();
-
- return getObject();
- }
-
- public Object getObject()
- {
- return _object;
- }
-
- private static String parse(String[] args, int index, String what)
- {
- try
- {
- return args[index];
- }
- catch (IndexOutOfBoundsException ioobe)
- {
- System.out.println("ERROR: No " + what + " specified.");
- System.out.println(USAGE);
- System.exit(1);
- }
-
- // The path is either return normally or exception.. which calls system exit so keep the compiler happy
- return "Never going to happen";
- }
-
-
- public static void main(String[] args) throws NamingException
- {
- boolean exit = false;
-
- String qpid_home = System.getProperty("QPID_HOME");
-
- if (qpid_home == null || qpid_home.equals(""))
- {
- System.out.println("QPID_HOME is not set");
- exit = true;
- }
-
- if (args.length <= 2)
- {
- System.out.println("At least a connection or connection factory must be requested to be bound.");
- exit = true;
- }
- else
- {
- if ((args.length - 1) % 2 != 0)
- {
- System.out.println("Not all values have full details");
- exit = true;
- }
- }
- if (exit)
- {
- System.out.println(USAGE);
- System.exit(1);
- }
-
- if (qpid_home.charAt(qpid_home.length() - 1) != '/')
-
- {
- qpid_home += "/";
- }
-
- for (int index = 1; index < args.length; index ++)
- {
- String obj = args[index];
-
-
- if (obj.equals("-b"))
- {
- String binding = parse(args, ++index, "binding");
-
- if (binding == null)
- {
- System.out.println("Binding not specified.");
- System.exit(1);
- }
- else
- {
- System.out.print("Looking up:" + binding);
- try
- {
- Lookup l = new Lookup(args[0], binding);
-
- Object object = l.getObject();
-
- if (object instanceof Connection)
- {
- try
- {
- ((Connection) object).close();
- }
- catch (JMSException jmse)
- {
- ;
- }
- }
- }
- catch (NamingException nabe)
- {
- System.out.println("Problem unbinding " + binding + " continuing with other values.");
- }
- }
- }// if -b
- else
- {
- System.out.println("Continuing with other bindings option not known:" + obj);
- }
- }//for
- }//main
-}//class
diff --git a/java/client/src/test/java/org/apache/qpid/jndi/referenceable/Unbind.java b/java/client/src/test/java/org/apache/qpid/jndi/referenceable/Unbind.java
deleted file mode 100644
index 1acead674c..0000000000
--- a/java/client/src/test/java/org/apache/qpid/jndi/referenceable/Unbind.java
+++ /dev/null
@@ -1,166 +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.jndi.referenceable;
-
-import javax.naming.*;
-
-import java.util.Properties;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-/**
- * Unbinds a reference from a JNDI source.
- * Given a properties file with the JNDI information and a binding string.
- */
-public class Unbind
-{
- private static final String USAGE = "USAGE: java unbind <JNDI Properties file> -b <binding>";
-
- public Unbind(String propertiesFile, String bindingValue) throws NamingException
- {
- // Set up the environment for creating the initial context
- String qpid_home = System.getProperty("QPID_HOME");
-
- if (qpid_home == null || qpid_home.equals(""))
- {
- System.out.println("QPID_HOME is not set");
- System.exit(1);
- }
-
- if (qpid_home.charAt(qpid_home.length() - 1) != '/')
- {
- qpid_home += "/";
- }
-
- try
- {
- InputStream inputStream = new FileInputStream(qpid_home + propertiesFile);
- Properties properties = new Properties();
- properties.load(inputStream);
-
- // Create the initial context
- Context ctx = new InitialContext(properties);
-
- // Perform the binds
- ctx.unbind(bindingValue);
-
- // Close the context when we're done
- ctx.close();
- }
- catch (IOException ioe)
- {
- System.out.println("Unable to access properties file:" + propertiesFile + " Due to:" + ioe);
- }
- }
-
- private static String parse(String[] args, int index, String what)
- {
- try
- {
- return args[index];
- }
- catch (IndexOutOfBoundsException ioobe)
- {
- System.out.println("ERROR: No " + what + " specified.");
- System.out.println(USAGE);
- System.exit(1);
- }
-
- // The path is either return normally or exception.. which calls system exit so keep the compiler happy
- return "Never going to happen";
- }
-
-
- public static void main(String[] args) throws NamingException
- {
- boolean exit = false;
-
- String qpid_home = System.getProperty("QPID_HOME");
-
- if (qpid_home == null || qpid_home.equals(""))
- {
- System.out.println("QPID_HOME is not set");
- exit = true;
- }
-
- if (args.length <= 2)
- {
- System.out.println("At least a connection or connection factory must be requested to be bound.");
- exit = true;
- }
- else
- {
- if ((args.length - 1) % 2 != 0)
- {
- System.out.println("Not all values have full details");
- exit = true;
- }
- }
- if (exit)
- {
- System.out.println(USAGE);
- System.exit(1);
- }
-
- if (qpid_home.charAt(qpid_home.length() - 1) != '/')
-
- {
- qpid_home += "/";
- }
-
- for (int index = 1; index < args.length; index ++)
- {
- String obj = args[index];
-
-
- if (obj.equals("-b"))
- {
- String binding = parse(args, ++index, "binding");
-
- if (binding == null)
- {
- System.out.println("Binding not specified.");
- System.exit(1);
- }
- else
- {
- System.out.print("UnBinding:" + binding);
- try
- {
- new Unbind(args[0], binding);
- System.out.println(" ..Successful");
- }
- catch (NamingException nabe)
- {
- System.out.println("");
-
- System.out.println("Problem unbinding " + binding + " continuing with other values.");
- }
- }
- }// if -b
- else
- {
- System.out.println("Continuing with other bindings option not known:" + obj);
- }
- }//for
- }//main
-}//class
diff --git a/java/client/src/test/java/org/apache/qpid/latency/LatencyTest.java b/java/client/src/test/java/org/apache/qpid/latency/LatencyTest.java
deleted file mode 100644
index ebc9488f68..0000000000
--- a/java/client/src/test/java/org/apache/qpid/latency/LatencyTest.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.qpid.latency;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQSession;
-
-import javax.jms.MessageProducer;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.JMSException;
-import javax.jms.TextMessage;
-import javax.jms.BytesMessage;
-
-public class LatencyTest implements MessageListener
-{
- private volatile boolean waiting;
- private int sent;
- private int received;
-
- private final byte[] data;
-
- private long min = Long.MAX_VALUE;
- private long max = 0;
- private long total = 0;
-
- LatencyTest(String broker, int count, int delay, int length) throws Exception
- {
- this(new AMQConnection(broker, "guest", "guest", randomize("Client"), "/test_path"), count, delay, length);
- }
-
- LatencyTest(AMQConnection connection, int count, int delay, int length) throws Exception
- {
- this(connection, new AMQQueue(randomize("LatencyTest"), true), count, delay, length);
- }
-
- LatencyTest(AMQConnection connection, AMQDestination destination, int count, int delay, int length) throws Exception
- {
- AMQSession session = (AMQSession) connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
-
- data = new byte[length];
- for(int i = 0; i < data.length; i++)
- {
- data[i] = (byte) (i % 100);
- }
-
- //set up a consumer
- session.createConsumer(destination).setMessageListener(this);
- connection.start();
-
- //create a publisher
- MessageProducer producer = session.createProducer(destination, false, false, true);
-
- //publish at a low volume
- for(int i = 0; i < count; i++)
- {
- BytesMessage msg = session.createBytesMessage();
- msg.writeBytes(data);
- msg.setStringProperty("sent-at", Long.toString(System.nanoTime()));
- producer.send(msg);
- Thread.sleep(delay);
- if(++sent % 100 == 0)
- {
- System.out.println("Sent " + sent + " of " + count);
- }
- }
-
- waitUntilReceived(sent);
-
- session.close();
- connection.close();
-
- System.out.println("Latency (in nanoseconds): avg=" + (total/sent) + ", min=" + min + ", max=" + max
- + ", avg(discarding min and max)=" + ((total - min - max) / (sent - 2)));
- }
-
-
- private synchronized void waitUntilReceived(int count) throws InterruptedException
- {
- waiting = true;
- while(received < count)
- {
- wait();
- }
- waiting = false;
- }
-
- public void onMessage(Message message)
- {
- received++;
- try
- {
- long sent = Long.parseLong(message.getStringProperty("sent-at"));
- long time = System.nanoTime() - sent;
- total += time;
- min = Math.min(min, time);
- max = Math.max(max, time);
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- }
-
- if(waiting){
- synchronized(this)
- {
- notify();
- }
- }
- }
-
- private static String randomize(String in)
- {
- return in + System.currentTimeMillis();
- }
-
- public static void main(String[] argv) throws Exception
- {
- String host = argv.length > 0 ? argv[0] : "localhost:5672";
- if("-help".equals(host))
- {
- System.out.println("Usage: <broker> <message count> <delay between messages> <message size>");
- }
- int count = argv.length > 1 ? Integer.parseInt(argv[1]) : 1000;
- int delay = argv.length > 2 ? Integer.parseInt(argv[2]) : 1000;
- int size = argv.length > 3 ? Integer.parseInt(argv[3]) : 512;
- new LatencyTest(host, count, delay, size);
- }
-
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java b/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java
deleted file mode 100644
index de3d558f7c..0000000000
--- a/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java
+++ /dev/null
@@ -1,102 +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.mina;
-
-import org.apache.log4j.Logger;
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoHandlerAdapter;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
-import org.apache.mina.transport.socket.nio.SocketSessionConfig;
-import org.apache.qpid.pool.ReadWriteThreadModel;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-
-import junit.framework.TestCase;
-
-/**
- * Tests MINA socket performance. This acceptor simply reads data from the network and writes it back again.
- *
- */
-public class AcceptorTest extends TestCase
-{
- private static final Logger _logger = Logger.getLogger(AcceptorTest.class);
-
- public static int PORT = 9999;
-
- private static class TestHandler extends IoHandlerAdapter
- {
- private int _sentCount;
-
- private int _bytesSent;
-
- public void messageReceived(IoSession session, Object message) throws Exception
- {
- ((ByteBuffer) message).acquire();
- session.write(message);
- _logger.debug("Sent response " + ++_sentCount);
- _bytesSent += ((ByteBuffer)message).remaining();
- _logger.debug("Bytes sent: " + _bytesSent);
- }
-
- public void messageSent(IoSession session, Object message) throws Exception
- {
- //((ByteBuffer) message).release();
- }
-
- public void exceptionCaught(IoSession session, Throwable cause) throws Exception
- {
- _logger.error("Error: " + cause, cause);
- }
- }
-
- public void testStartAcceptor() throws IOException
- {
- IoAcceptor acceptor = null;
- acceptor = new SocketAcceptor();
-
- SocketAcceptorConfig config = (SocketAcceptorConfig) acceptor.getDefaultConfig();
- SocketSessionConfig sc = (SocketSessionConfig) config.getSessionConfig();
- sc.setTcpNoDelay(true);
- sc.setSendBufferSize(32768);
- sc.setReceiveBufferSize(32768);
-
- config.setThreadModel(new ReadWriteThreadModel());
-
- acceptor.bind(new InetSocketAddress(PORT),
- new TestHandler());
- _logger.info("Bound on port " + PORT);
- }
-
- public static void main(String[] args) throws IOException
- {
- AcceptorTest a = new AcceptorTest();
- a.testStartAcceptor();
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(AcceptorTest.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java b/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java
deleted file mode 100644
index bfe29c47e6..0000000000
--- a/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java
+++ /dev/null
@@ -1,93 +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.mina;
-
-import org.apache.log4j.Logger;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.ServerSocket;
-import java.net.Socket;
-
-import junit.framework.TestCase;
-
-public class BlockingAcceptorTest extends TestCase
-{
- private static final Logger _logger = Logger.getLogger(BlockingAcceptorTest.class);
-
- public static int PORT = 9999;
-
- public void testStartAcceptor() throws IOException
- {
-
- ServerSocket sock = new ServerSocket(PORT);
-
- sock.setReuseAddress(true);
- sock.setReceiveBufferSize(32768);
- _logger.info("Bound on port " + PORT);
-
- while (true)
- {
- final Socket s = sock.accept();
- _logger.info("Received connection from " + s.getRemoteSocketAddress());
- s.setReceiveBufferSize(32768);
- s.setSendBufferSize(32768);
- s.setTcpNoDelay(true);
- new Thread(new Runnable()
- {
- public void run()
- {
- byte[] chunk = new byte[32768];
- try
- {
- InputStream is = s.getInputStream();
- OutputStream os = s.getOutputStream();
-
- while (true)
- {
- int count = is.read(chunk, 0, chunk.length);
- if (count > 0)
- {
- os.write(chunk, 0, count);
- }
- }
- }
- catch (IOException e)
- {
- _logger.error("Error - closing connection: " + e, e);
- }
- }
- }, "SocketReaderWriter").start();
- }
- }
-
- public static void main(String[] args) throws IOException
- {
- BlockingAcceptorTest a = new BlockingAcceptorTest();
- a.testStartAcceptor();
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(AcceptorTest.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java b/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
deleted file mode 100644
index 910345624f..0000000000
--- a/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
+++ /dev/null
@@ -1,271 +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.mina;
-
-import org.apache.log4j.Logger;
-import org.apache.mina.common.*;
-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 java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.concurrent.CountDownLatch;
-
-import junit.framework.TestCase;
-
-public class WriterTest extends TestCase
-{
- private static final Logger _logger = Logger.getLogger(WriterTest.class);
-
- private static class RunnableWriterTest implements Runnable
- {
- private Logger _logger;
-
- private IoSession _session;
-
- private long _startTime;
-
- private long[] _chunkTimes;
-
- private int _chunkCount = 500000;
-
- private int _chunkSize = 1024;
-
- private CountDownLatch _notifier;
-
- public RunnableWriterTest(Logger logger)
- {
- _logger = logger;
- }
-
- public void run()
- {
- _startTime = System.currentTimeMillis();
- _notifier = new CountDownLatch(1);
- for (int i = 0; i < _chunkCount; i++)
- {
- ByteBuffer buf = ByteBuffer.allocate(_chunkSize, false);
- byte check = (byte) (i % 128);
- buf.put(check);
- buf.fill((byte)88, buf.remaining());
- buf.flip();
- _session.write(buf);
- }
-
- try
- {
- _logger.info("All buffers sent; waiting for receipt from server");
- _notifier.await();
- }
- catch (InterruptedException e)
- {
- }
- _logger.info("Completed");
- long totalTime = System.currentTimeMillis() - _startTime;
- _logger.info("Total time: " + totalTime);
- _logger.info("MB per second: " + (_chunkSize * _chunkCount)/totalTime);
- long lastChunkTime = _startTime;
- double average = 0;
- for (int i = 0; i < _chunkTimes.length; i++)
- {
- if (i == 0)
- {
- average = _chunkTimes[i] - _startTime;
- }
- else
- {
- long delta = _chunkTimes[i] - lastChunkTime;
- if (delta != 0)
- {
- average = (average + delta)/2;
- }
- }
- lastChunkTime = _chunkTimes[i];
- }
- _logger.info("Average chunk time: " + average + "ms");
- CloseFuture cf = _session.close();
- cf.join();
- }
-
- private class WriterHandler extends IoHandlerAdapter
- {
- private int _chunksReceived = 0;
-
- private int _partialBytesRead = 0;
-
- private byte _partialCheckNumber;
-
- private int _totalBytesReceived = 0;
-
- public void messageReceived(IoSession session, Object message) throws Exception
- {
- ByteBuffer result = (ByteBuffer) message;
- _totalBytesReceived += result.remaining();
- int size = result.remaining();
- long now = System.currentTimeMillis();
- if (_partialBytesRead > 0)
- {
- int offset = _chunkSize - _partialBytesRead;
- if (size >= offset)
- {
- _chunkTimes[_chunksReceived++] = now;
- result.position(offset);
- }
- else
- {
- // have not read even one chunk, including the previous partial bytes
- _partialBytesRead += size;
- return;
- }
- }
-
- int chunkCount = result.remaining()/_chunkSize;
-
- for (int i = 0; i < chunkCount; i++)
- {
- _chunkTimes[_chunksReceived++] = now;
- byte check = result.get();
- _logger.debug("Check number " + check + " read");
- if (check != (byte)((_chunksReceived - 1)%128))
- {
- _logger.error("Check number " + check + " read when expected " + (_chunksReceived%128));
- }
- _logger.debug("Chunk times recorded");
-
- try
- {
- result.skip(_chunkSize - 1);
- }
- catch (IllegalArgumentException e)
- {
- _logger.error("Position was: " + result.position());
- _logger.error("Tried to skip to: " + (_chunkSize * i));
- _logger.error("limit was; " + result.limit());
- }
- }
- _logger.debug("Chunks received now " + _chunksReceived);
- _logger.debug("Bytes received: " + _totalBytesReceived);
- _partialBytesRead = result.remaining();
-
- if (_partialBytesRead > 0)
- {
- _partialCheckNumber = result.get();
- }
-
- if (_chunksReceived >= _chunkCount)
- {
- _notifier.countDown();
- }
-
- }
-
- public void exceptionCaught(IoSession session, Throwable cause) throws Exception
- {
- _logger.error("Error: " + cause, cause);
- }
- }
-
- public void startWriter(int chunkSize) throws IOException, InterruptedException
- {
- _chunkSize = chunkSize;
-
- IoConnector ioConnector = null;
-
- ioConnector = new SocketConnector();
-
- SocketConnectorConfig cfg = (SocketConnectorConfig) ioConnector.getDefaultConfig();
- cfg.setThreadModel(ThreadModel.MANUAL);
- SocketSessionConfig scfg = (SocketSessionConfig) cfg.getSessionConfig();
- scfg.setTcpNoDelay(true);
- scfg.setSendBufferSize(32768);
- scfg.setReceiveBufferSize(32768);
-
- final InetSocketAddress address = new InetSocketAddress("localhost", AcceptorTest.PORT);
- _logger.info("Attempting connection to " + address);
- ConnectFuture future = ioConnector.connect(address, new WriterHandler());
- // wait for connection to complete
- future.join();
- _logger.info("Connection completed");
- // we call getSession which throws an IOException if there has been an error connecting
- _session = future.getSession();
- _chunkTimes = new long[_chunkCount];
- Thread t = new Thread(this);
- t.start();
- t.join();
- _logger.info("Test completed");
- }
- }
-
- private RunnableWriterTest _runnableWriterTest = new RunnableWriterTest(_logger);
-
- public void test1k() throws IOException, InterruptedException
- {
- _logger.info("Starting 1k test");
- _runnableWriterTest.startWriter(1024);
- }
-
- public void test2k() throws IOException, InterruptedException
- {
- _logger.info("Starting 2k test");
- _runnableWriterTest.startWriter(2048);
- }
-
- public void test4k() throws IOException, InterruptedException
- {
- _logger.info("Starting 4k test");
- _runnableWriterTest.startWriter(4096);
- }
-
- public void test8k() throws IOException, InterruptedException
- {
- _logger.info("Starting 8k test");
- _runnableWriterTest.startWriter(8192);
- }
-
- public void test16k() throws IOException, InterruptedException
- {
- _logger.info("Starting 16k test");
- _runnableWriterTest.startWriter(16384);
- }
-
- public void test32k() throws IOException, InterruptedException
- {
- _logger.info("Starting 32k test");
- _runnableWriterTest.startWriter(32768);
- }
-
- public static void main(String[] args) throws IOException, InterruptedException
- {
- WriterTest w = new WriterTest();
- //w.test1k();
- //w.test2k();
- //w.test4k();
- w.test8k();
- //w.test16k();
- //w.test32k();
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(WriterTest.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java b/java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java
deleted file mode 100644
index 10e03d3522..0000000000
--- a/java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java
+++ /dev/null
@@ -1,267 +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.multiconsumer;
-
-import java.io.ByteArrayOutputStream;
-import java.util.zip.Deflater;
-import java.util.zip.Inflater;
-
-import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQTopic;
-
-/**
- * Test AMQ.
- */
-public class AMQTest extends TestCase implements ExceptionListener
-{
-
- private final static String COMPRESSION_PROPNAME = "_MSGAPI_COMP";
- private final static String UTF8 = "UTF-8";
- private static final String SUBJECT = "test.amq";
- private static final String DUMMYCONTENT = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- private static final String HUGECONTENT;
-
- private Connection connect = null;
- private Session pubSession = null;
- private Session subSession = null;
- private Topic topic = null;
-
- static
- {
- StringBuilder sb = new StringBuilder(DUMMYCONTENT.length() * 115);
- for (int i = 0; i < 100; i++)
- {
- sb.append(DUMMYCONTENT);
- }
- HUGECONTENT = sb.toString();
- }
-
- private void setup() throws Exception
- {
- connect = new AMQConnection("localhost", 5672, "guest", "guest", "client1", "/");
- connect.setExceptionListener(this);
- pubSession = connect.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
- subSession = connect.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
- topic = new AMQTopic(SUBJECT);
-
- connect.start();
- }
-
- public void testMultipleListeners() throws Exception
- {
- setup();
- try
- {
- // Create 5 listeners
- MsgHandler[] listeners = new MsgHandler[5];
- for (int i = 0; i < listeners.length; i++)
- {
- listeners[i] = new MsgHandler();
- MessageConsumer subscriber = subSession.createConsumer(topic);
- subscriber.setMessageListener(listeners[i]);
- }
- MessageProducer publisher = pubSession.createProducer(topic);
- // Send a single message
- TextMessage msg = pubSession.createTextMessage();
- msg.setText(DUMMYCONTENT);
- publisher.send(msg);
- Thread.sleep(5000);
- // Check listeners to ensure they all got it
- for (int i = 0; i < listeners.length; i++)
- {
- if (listeners[i].isGotIt())
- {
- System.out.println("Got callback for listener " + i);
- }
- else
- {
- TestCase.fail("Listener " + i + " did not get callback");
- }
- }
- }
- catch (Throwable e)
- {
- System.err.println("Error: " + e);
- e.printStackTrace(System.err);
- }
- finally
- {
- close();
- }
- }
-
- public void testCompression() throws Exception
- {
- setup();
- String comp = this.compressString(HUGECONTENT);
- try
- {
- MsgHandler listener = new MsgHandler();
- MessageConsumer subscriber = subSession.createConsumer(topic);
- subscriber.setMessageListener(listener);
- MessageProducer publisher = pubSession.createProducer(topic);
-
- // Send a single message
- TextMessage msg = pubSession.createTextMessage();
- // Set the compressed text
- msg.setText(comp);
- msg.setBooleanProperty(COMPRESSION_PROPNAME, true);
- publisher.send(msg);
- Thread.sleep(1000);
- // Check listeners to ensure we got it
- if (listener.isGotIt())
- {
- System.out.println("Got callback for listener");
- }
- else
- {
- TestCase.fail("Listener did not get callback");
- }
- }
- finally
- {
- close();
- }
- }
-
- private void close() throws Exception
- {
- if (connect != null)
- {
- connect.close();
- }
- }
-
- private class MsgHandler implements MessageListener
- {
- private boolean gotIt = false;
-
- public void onMessage(Message msg)
- {
- try
- {
- TextMessage textMessage = (TextMessage) msg;
- String string = textMessage.getText();
- if (string != null && string.length() > 0)
- {
- gotIt = true;
- }
- if (textMessage.getBooleanProperty(COMPRESSION_PROPNAME))
- {
- string = inflateString(string);
- }
- System.out.println("Got callback of size " + (string==null?0:string.length()));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public boolean isGotIt()
- {
- return this.gotIt;
- }
- }
-
- private String compressString(String string) throws Exception
- {
- long start = System.currentTimeMillis();
- byte[] input = string.getBytes();
- Deflater compressor = new Deflater(Deflater.BEST_COMPRESSION);
- compressor.setInput(input);
- compressor.finish();
-
- // Get byte array from output of compressor
- ByteArrayOutputStream baos = new ByteArrayOutputStream(input.length);
- byte[] buf = new byte[1024];
- while (!compressor.finished())
- {
- int cnt = compressor.deflate(buf);
- baos.write(buf, 0, cnt);
- }
- baos.close();
- byte[] output = baos.toByteArray();
-
- // Convert byte array into String
- byte[] base64 = Base64.encodeBase64(output);
- String sComp = new String(base64, UTF8);
-
- long diff = System.currentTimeMillis() - start;
- System.out.println("Compressed text from " + input.length + " to "
- + sComp.getBytes().length + " in " + diff + " ms");
- System.out.println("Compressed text = '" + sComp + "'");
-
- return sComp;
- }
-
- private String inflateString(String string) throws Exception
- {
- byte[] input = string.getBytes();
-
- // First convert Base64 string back to binary array
- byte[] bytes = Base64.decodeBase64(input);
-
- // Set string as input data for decompressor
- Inflater decompressor = new Inflater();
- decompressor.setInput(bytes);
-
- // Decompress the data
- ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length);
- byte[] buf = new byte[1024];
- while (!decompressor.finished())
- {
- int count = decompressor.inflate(buf);
- bos.write(buf, 0, count);
- }
- bos.close();
- byte[] output = bos.toByteArray();
-
- // Get the decompressed data
- return new String(output, UTF8);
- }
-
- /**
- * @see javax.jms.ExceptionListener#onException(javax.jms.JMSException)
- */
- public void onException(JMSException e)
- {
- System.err.println(e.getMessage());
- e.printStackTrace(System.err);
- }
-
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java b/java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java
deleted file mode 100644
index b060498d9b..0000000000
--- a/java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java
+++ /dev/null
@@ -1,131 +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.ping;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Level;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.jms.Session;
-
-import javax.jms.*;
-import java.net.InetAddress;
-
-public class TestPingClient
-{
- private static final Logger _logger = Logger.getLogger(TestPingClient.class);
-
- private static class TestPingMessageListener implements MessageListener
- {
- public TestPingMessageListener()
- {
- }
-
- long _lastTimestamp = 0L;
- long _lastTimestampString = 0L;
-
- public void onMessage(javax.jms.Message message)
- {
- if (_logger.isInfoEnabled())
- {
- long timestamp = 0L;
- long timestampString = 0L;
-
- try
- {
- timestamp = message.getLongProperty("timestamp");
- timestampString = Long.parseLong(message.getStringProperty("timestampString"));
-
- if (timestampString != timestamp)
- {
- _logger.info("Timetamps differ!:\n" +
- "timestamp:" + timestamp + "\n" +
- "timestampString:" + timestampString);
- }
-
- }
- catch (JMSException jmse)
- {
- }
-
- long diff = timestamp - _lastTimestamp;
- _lastTimestamp = timestamp;
-
- long stringDiff = timestampString - _lastTimestampString;
-
- _lastTimestampString = timestampString;
-
- _logger.info("Ping: T:" + diff + "ms, TS:" + stringDiff);
-
- // _logger.info(_name + " got message '" + message + "\n");
- }
- }
- }
-
- public static void main(String[] args)
- {
- _logger.setLevel(Level.INFO);
-
- _logger.info("Starting...");
-
- if (args.length < 4)
- {
- System.out.println("Usage: brokerdetails username password virtual-path [selector] ");
- System.exit(1);
- }
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- AMQConnection con1 = new AMQConnection(args[0], args[1], args[2],
- address.getHostName(), args[3]);
-
- final org.apache.qpid.jms.Session session1 = (org.apache.qpid.jms.Session)
- con1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-
- String selector = null;
-
- if (args.length == 5)
- {
- selector = args[4];
- }
-
- _logger.info("Message selector is <" + selector + ">...");
-
- Queue q = new AMQQueue("ping");
-
- MessageConsumer consumer1 = session1.createConsumer(q,
- 1, false, false, selector);
-
- consumer1.setMessageListener(new TestPingMessageListener());
- con1.start();
- }
- catch (Throwable t)
- {
- System.err.println("Fatal error: " + t);
- t.printStackTrace();
- }
-
- System.out.println("Waiting...");
- }
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java b/java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java
deleted file mode 100644
index 458dca0d56..0000000000
--- a/java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java
+++ /dev/null
@@ -1,213 +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.ping;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.client.AMQNoConsumersException;
-import org.apache.qpid.client.BasicMessageProducer;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.jms.MessageProducer;
-import org.apache.qpid.jms.Session;
-
-import javax.jms.*;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * A client that behaves as follows:
- * <ul><li>Connects to a queue, whose name is specified as a cmd-line argument</li>
- * <li>Creates a temporary queue</li>
- * <li>Creates messages containing a property that is the name of the temporary queue</li>
- * <li>Fires off a message on the original queue and waits for a response on the temporary queue</li>
- * </ul>
- */
-public class TestPingProducer implements ExceptionListener
-{
- private static final Logger _log = Logger.getLogger(TestPingProducer.class);
-
- private AMQConnection _connection;
-
- private Session _session;
-
- private boolean _publish;
-
- private long SLEEP_TIME = 250L;
-
- private class CallbackHandler implements MessageListener
- {
-
- private int _actualMessageCount;
-
-
- public void onMessage(Message m)
- {
- if (_log.isDebugEnabled())
- {
- _log.debug("Message received: " + m);
- }
- _actualMessageCount++;
- if (_actualMessageCount % 1000 == 0)
- {
- _log.info("Received message count: " + _actualMessageCount);
- }
- }
- }
-
- public TestPingProducer(boolean TRANSACTED, String brokerDetails, String clientID,
- String virtualpath) throws AMQException, URLSyntaxException
- {
- try
- {
- createConnection(brokerDetails, clientID, virtualpath);
-
- if (TRANSACTED)
- {
- _session = (Session) _connection.createSession(true, Session.SESSION_TRANSACTED);
- }
- else
- {
- _session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- }
-
- AMQQueue destination = new AMQQueue("ping");
- MessageProducer producer = (MessageProducer) _session.createProducer(destination);
-
- _connection.setExceptionListener(this);
-
- _connection.start();
-
- int messageNumber = 0;
-
- while (_publish)
- {
-/*
- TextMessage msg = _session.createTextMessage(
- "Presented to in conjunction with Mahnah Mahnah and the Snowths: " + ++messageNumber);
-*/
- ObjectMessage msg = _session.createObjectMessage();
-
- msg.setStringProperty("timestampString", Long.toString(System.currentTimeMillis()));
- msg.setLongProperty("timestamp", System.currentTimeMillis());
-
- ((BasicMessageProducer) producer).send(msg, DeliveryMode.NON_PERSISTENT, true);
-
-
- if (TRANSACTED)
- {
- try{
- _session.commit();
- _log.info("Message Sent.");// +"\n"+ msg);
- }catch (JMSException e)
- {
- try
- {
- _session.rollback();
- }
- catch (JMSException jsme)
- {
- _log.info(jsme);
- }
-
-
- if (e.getLinkedException() instanceof AMQNoConsumersException)
- {
- _log.info("No Consumers never mind.");
-
- continue;
- }
- }
- }
-
-
- if (SLEEP_TIME > 0)
- {
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException ie)
- {
- //do nothing
- }
- }
-
-
- }
-
- }
- catch (JMSException e)
- {
- _publish = false;
- e.printStackTrace();
- }
- }
-
- private void createConnection(String brokerDetails, String clientID, String virtualpath) throws AMQException, URLSyntaxException
- {
- _publish = true;
- _connection = new AMQConnection(brokerDetails, "guest", "guest",
- clientID, virtualpath);
- }
-
- /**
- * @param args argument 1 if present specifies the name of the temporary queue to create. Leaving it blank
- * means the server will allocate a name.
- */
- public static void main(String[] args) throws URLSyntaxException
- {
- if (args.length == 0)
- {
- System.err.println("Usage: TestPingPublisher <brokerDetails> <virtual path> [transacted]");
- System.exit(0);
- }
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- String clientID = address.getHostName() + System.currentTimeMillis();
- new TestPingProducer(args.length == 3, args[0], clientID, args[1]);
- }
- catch (UnknownHostException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- catch (AMQException e)
- {
- System.err.println("Error in client: " + e);
- e.printStackTrace();
- }
-
- //System.exit(0);
- }
-
- /**
- * @see javax.jms.ExceptionListener#onException(javax.jms.JMSException)
- */
- public void onException(JMSException e)
- {
- System.err.println(e.getMessage());
-
- _publish = false;
- e.printStackTrace(System.err);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java b/java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java
deleted file mode 100644
index c7742be042..0000000000
--- a/java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java
+++ /dev/null
@@ -1,180 +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.ping;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.client.BasicMessageProducer;
-import org.apache.qpid.jms.MessageProducer;
-import org.apache.qpid.jms.Session;
-
-import javax.jms.*;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * A client that behaves as follows:
- * <ul><li>Connects to a queue, whose name is specified as a cmd-line argument</li>
- * <li>Creates a temporary queue</li>
- * <li>Creates messages containing a property that is the name of the temporary queue</li>
- * <li>Fires off a message on the original queue and waits for a response on the temporary queue</li>
- * </ul>
- */
-public class TestPingPublisher implements ExceptionListener
-{
- private static final Logger _log = Logger.getLogger(TestPingPublisher.class);
-
- private AMQConnection _connection;
-
- private Session _session;
-
- private boolean _publish;
-
- private long SLEEP_TIME = 0L;
-
- private class CallbackHandler implements MessageListener
- {
-
- private int _actualMessageCount;
-
-
- public void onMessage(Message m)
- {
- if (_log.isDebugEnabled())
- {
- _log.debug("Message received: " + m);
- }
- _actualMessageCount++;
- if (_actualMessageCount % 1000 == 0)
- {
- _log.info("Received message count: " + _actualMessageCount);
- }
- }
- }
-
- public TestPingPublisher(String brokerDetails, String clientID, String virtualpath) throws AMQException, URLSyntaxException
- {
- try
- {
- createConnection(brokerDetails, clientID, virtualpath);
-
- _session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- //AMQQueue destination = new AMQQueue("ping");
- AMQTopic destination = new AMQTopic("ping");
- MessageProducer producer = (MessageProducer) _session.createProducer(destination);
-
- _connection.setExceptionListener(this);
-
- _connection.start();
-
- int messageNumber = 0;
-
- while (_publish)
- {
-/*
- TextMessage msg = _session.createTextMessage(
- "Presented to in conjunction with Mahnah Mahnah and the Snowths: " + ++messageNumber);
-*/
- ObjectMessage msg = _session.createObjectMessage();
-
- Long time = System.nanoTime();
- msg.setStringProperty("timestampString", Long.toString(time));
- msg.setLongProperty("timestamp", time);
-
- ((BasicMessageProducer) producer).send(msg, DeliveryMode.PERSISTENT, true);
-
- _log.info("Message Sent:\n" + msg);
-
- if (SLEEP_TIME > 0)
- {
- try
- {
- Thread.sleep(SLEEP_TIME);
- }
- catch (InterruptedException ie)
- {
- //do nothing
- }
- }
-
-
- }
-
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- }
- }
-
- private void createConnection(String brokerDetails, String clientID, String virtualpath) throws AMQException, URLSyntaxException
- {
- _publish = true;
- _connection = new AMQConnection(brokerDetails, "guest", "guest",
- clientID, virtualpath);
-
- }
-
- /**
- * @param args argument 1 if present specifies the name of the temporary queue to create. Leaving it blank
- * means the server will allocate a name.
- */
- public static void main(String[] args) throws URLSyntaxException
- {
- if (args.length == 0)
- {
- System.err.println("Usage: TestPingPublisher <brokerDetails> <virtual path>");
- System.exit(0);
- }
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- String clientID = address.getHostName() + System.currentTimeMillis();
- new TestPingPublisher(args[0], clientID, args[1]);
- }
- catch (UnknownHostException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- catch (AMQException e)
- {
- System.err.println("Error in client: " + e);
- e.printStackTrace();
- }
-
- //System.exit(0);
- }
-
- /**
- * @see javax.jms.ExceptionListener#onException(javax.jms.JMSException)
- */
- public void onException(JMSException e)
- {
- System.err.println(e.getMessage());
-
- _publish = false;
- e.printStackTrace(System.err);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java b/java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java
deleted file mode 100644
index 8e8c3f2e6e..0000000000
--- a/java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java
+++ /dev/null
@@ -1,132 +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.ping;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Level;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.jms.Session;
-
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Topic;
-import javax.jms.JMSException;
-import java.net.InetAddress;
-
-public class TestPingSubscriber
-{
- private static final Logger _logger = Logger.getLogger(TestPingClient.class);
-
- private static class TestPingMessageListener implements MessageListener
- {
- public TestPingMessageListener()
- {
- }
-
- long _lastTimestamp = 0L;
- long _lastTimestampString = 0L;
-
- public void onMessage(javax.jms.Message message)
- {
- Long time = System.nanoTime();
-
- if (_logger.isInfoEnabled())
- {
- long timestamp = 0L;
- long timestampString = 0L;
-
- try
- {
- timestamp = message.getLongProperty("timestamp");
- timestampString = Long.parseLong(message.getStringProperty("timestampString"));
-
- if (timestampString != timestamp)
- {
- _logger.info("Timetamps differ!:\n" +
- "timestamp:" + timestamp + "\n" +
- "timestampString:" + timestampString);
- }
-
- }
- catch (JMSException jmse)
- {
- }
-
- long diff = time - timestamp;
-
- long stringDiff = time - timestampString;
-
- _logger.info("Ping: TS:" + stringDiff/1000+"us");
-
- // _logger.info(_name + " got message '" + message + "\n");
- }
- }
- }
-
- public static void main(String[] args)
- {
- _logger.setLevel(Level.INFO);
-
- _logger.info("Starting...");
-
- if (args.length < 4)
- {
- System.out.println("Usage: brokerdetails username password virtual-path [selector] ");
- System.exit(1);
- }
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- AMQConnection con1 = new AMQConnection(args[0], args[1], args[2],
- address.getHostName(), args[3]);
-
- final org.apache.qpid.jms.Session session1 = (org.apache.qpid.jms.Session)
- con1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-
- String selector = null;
-
- if (args.length == 5)
- {
- selector = args[4];
- }
-
- _logger.info("Message selector is <" + selector + ">...");
-
- Topic t = new AMQTopic("ping");
-
- MessageConsumer consumer1 = session1.createConsumer(t,
- 1, false, false, selector);
-
- consumer1.setMessageListener(new TestPingMessageListener());
- con1.start();
- }
- catch (Throwable t)
- {
- System.err.println("Fatal error: " + t);
- t.printStackTrace();
- }
-
- System.out.println("Waiting...");
- }
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java b/java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java
deleted file mode 100644
index 45b241975d..0000000000
--- a/java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java
+++ /dev/null
@@ -1,174 +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.pubsub1;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.jms.MessageProducer;
-import org.apache.qpid.jms.Session;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.TextMessage;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * A client that behaves as follows:
- * <ul><li>Connects to a queue, whose name is specified as a cmd-line argument</li>
- * <li>Creates a temporary queue</li>
- * <li>Creates messages containing a property that is the name of the temporary queue</li>
- * <li>Fires off a message on the original queue and waits for a response on the temporary queue</li>
- * </ul>
- *
- */
-public class TestPublisher
-{
- private static final Logger _log = Logger.getLogger(TestPublisher.class);
-
- private AMQConnection _connection;
-
- private Session _session;
-
- private class CallbackHandler implements MessageListener
- {
- private int _expectedMessageCount;
-
- private int _actualMessageCount;
-
- private long _startTime;
-
- public CallbackHandler(int expectedMessageCount, long startTime)
- {
- _expectedMessageCount = expectedMessageCount;
- _startTime = startTime;
- }
-
- public void onMessage(Message m)
- {
- if (_log.isDebugEnabled())
- {
- _log.debug("Message received: " + m);
- }
- _actualMessageCount++;
- if (_actualMessageCount%1000 == 0)
- {
- _log.info("Received message count: " + _actualMessageCount);
- }
- /*if (!"henson".equals(m.toString()))
- {
- _log.error("AbstractJMSMessage response not correct: expected 'henson' but got " + m.toString());
- }
- else
- {
- if (_log.isDebugEnabled())
- {
- _log.debug("AbstractJMSMessage " + m + " received");
- }
- else
- {
- _log.info("AbstractJMSMessage received");
- }
- } */
-
- if (_actualMessageCount == _expectedMessageCount)
- {
- long timeTaken = System.currentTimeMillis() - _startTime;
- System.out.println("Total time taken to receive " + _expectedMessageCount+ " messages was " +
- timeTaken + "ms, equivalent to " +
- (_expectedMessageCount/(timeTaken/1000.0)) + " messages per second");
- }
- }
- }
-
- public TestPublisher(String host, int port, String clientID, String commandQueueName,
- final int messageCount) throws AMQException, URLSyntaxException
- {
- try
- {
- createConnection(host, port, clientID);
-
- _session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- AMQTopic destination = new AMQTopic(commandQueueName);
- MessageProducer producer = (MessageProducer) _session.createProducer(destination);
-
- _connection.start();
- //TextMessage msg = _session.createTextMessage(tempDestination.getQueueName() + "/Presented to in conjunction with Mahnah Mahnah and the Snowths");
- final long startTime = System.currentTimeMillis();
-
- for (int i = 0; i < messageCount; i++)
- {
- TextMessage msg = _session.createTextMessage(destination.getTopicName() + "/Presented to in conjunction with Mahnah Mahnah and the Snowths: " + i);
-
- //msg.setIntProperty("a",i % 2);
- //msg.setIntProperty("b",i % 4);
-
- producer.send(msg);
- }
- _log.info("Finished sending " + messageCount + " messages");
- }
- catch (JMSException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
-
- private void createConnection(String host, int port, String clientID) throws AMQException, URLSyntaxException
- {
- _connection = new AMQConnection(host, port, "guest", "guest",
- clientID, "/test");
- }
-
- /**
- *
- * @param args argument 1 if present specifies the name of the temporary queue to create. Leaving it blank
- * means the server will allocate a name.
- */
- public static void main(String[] args) throws URLSyntaxException
- {
- if (args.length == 0)
- {
- System.err.println("Usage: TestPublisher <host> <port> <command queue name> <number of messages>");
- }
- try
- {
- int port = Integer.parseInt(args[1]);
- InetAddress address = InetAddress.getLocalHost();
- String clientID = address.getHostName() + System.currentTimeMillis();
- TestPublisher client = new TestPublisher(args[0], port, clientID, args[2], Integer.parseInt(args[3]));
- }
- catch (UnknownHostException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- catch (AMQException e)
- {
- System.err.println("Error in client: " + e);
- e.printStackTrace();
- }
-
- //System.exit(0);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java b/java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java
deleted file mode 100644
index 14cf206f50..0000000000
--- a/java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java
+++ /dev/null
@@ -1,120 +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.pubsub1;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.jms.Session;
-
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Topic;
-import java.net.InetAddress;
-
-public class TestSubscriber
-{
- private static final Logger _logger = Logger.getLogger(TestSubscriber.class);
-
- private static class TestMessageListener implements MessageListener
- {
- private String _name;
-
- private int _expectedMessageCount;
-
- private int _messageCount;
-
- private long _startTime = 0;
-
- public TestMessageListener(String name, int expectedMessageCount)
- {
- _name = name;
- _expectedMessageCount = expectedMessageCount;
- }
-
- public void onMessage(javax.jms.Message message)
- {
- if (_messageCount++ == 0)
- {
- _startTime = System.currentTimeMillis();
- }
- if (_logger.isInfoEnabled())
- {
- _logger.info(_name + " got message '" + message + "'");
- }
- if (_messageCount == _expectedMessageCount)
- {
- long totalTime = System.currentTimeMillis() - _startTime;
- _logger.error(_name + ": Total time to receive " + _messageCount + " messages was " +
- totalTime + "ms. Rate is " + (_messageCount/(totalTime/1000.0)));
- }
- if (_messageCount > _expectedMessageCount)
- {
- _logger.error("Oops! More messages received than expected (" + _messageCount + ")");
- }
- }
- }
-
- public static void main(String[] args)
- {
- _logger.info("Starting...");
-
- if (args.length != 7)
- {
- System.out.println("Usage: host port username password virtual-path expectedMessageCount selector");
- System.exit(1);
- }
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- AMQConnection con1 = new AMQConnection(args[0], Integer.parseInt(args[1]), args[2], args[3],
- address.getHostName(), args[4]);
- final org.apache.qpid.jms.Session session1 = (org.apache.qpid.jms.Session) con1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- AMQConnection con2 = new AMQConnection(args[0], Integer.parseInt(args[1]), args[2], args[3],
- address.getHostName(), args[4]);
- final org.apache.qpid.jms.Session session2 = (org.apache.qpid.jms.Session) con2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- String selector = args[6];
-
- final int expectedMessageCount = Integer.parseInt(args[5]);
- _logger.info("Message selector is <" + selector + ">...");
-
- Topic t = new AMQTopic("cbr");
- MessageConsumer consumer1 = session1.createConsumer(t,
- 100, false, false, selector);
- MessageConsumer consumer2 = session2.createConsumer(t,
- 100, false, false, selector);
-
- consumer1.setMessageListener(new TestMessageListener("ML 1", expectedMessageCount));
- consumer2.setMessageListener(new TestMessageListener("ML 2", expectedMessageCount));
- con1.start();
- con2.start();
- }
- catch (Throwable t)
- {
- System.err.println("Fatal error: " + t);
- t.printStackTrace();
- }
-
- System.out.println("Waiting...");
- }
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java b/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java
deleted file mode 100644
index 7cbec7c85c..0000000000
--- a/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java
+++ /dev/null
@@ -1,201 +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.requestreply1;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.jms.Session;
-import org.apache.qpid.jms.ConnectionListener;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-
-import javax.jms.*;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class ServiceProvidingClient
-{
- private static final Logger _logger = Logger.getLogger(ServiceProvidingClient.class);
-
- private MessageProducer _destinationProducer;
-
- private Destination _responseDest;
-
- private AMQConnection _connection;
-
- public ServiceProvidingClient(String brokerDetails, String username, String password,
- String clientName, String virtualPath, String serviceName)
- throws AMQException, JMSException, URLSyntaxException
- {
- _connection = new AMQConnection(brokerDetails, username, password,
- clientName, virtualPath);
- _connection.setConnectionListener(new ConnectionListener()
- {
-
- public void bytesSent(long count)
- {
- }
-
- public void bytesReceived(long count)
- {
- }
-
- public boolean preFailover(boolean redirect)
- {
- return true;
- }
-
- public boolean preResubscribe()
- {
- return true;
- }
-
- public void failoverComplete()
- {
- _logger.info("App got failover complete callback");
- }
- });
- final Session session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- _logger.info("Service (queue) name is '" + serviceName + "'...");
-
- AMQQueue destination = new AMQQueue(serviceName);
-
- MessageConsumer consumer = session.createConsumer(destination,
- 100, true, false, null);
-
- consumer.setMessageListener(new MessageListener()
- {
- private int _messageCount;
-
- public void onMessage(Message message)
- {
- //_logger.info("Got message '" + message + "'");
-
- TextMessage tm = (TextMessage) message;
-
- try
- {
- Destination responseDest = tm.getJMSReplyTo();
- if (responseDest == null)
- {
- _logger.info("Producer not created because the response destination is null.");
- return;
- }
-
- if (!responseDest.equals(_responseDest))
- {
- _responseDest = responseDest;
-
- _logger.info("About to create a producer");
- _destinationProducer = session.createProducer(responseDest);
- _destinationProducer.setDisableMessageTimestamp(true);
- _destinationProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- _logger.info("After create a producer");
- }
- }
- catch (JMSException e)
- {
- _logger.error("Error creating destination");
- }
- _messageCount++;
- if (_messageCount % 1000 == 0)
- {
- _logger.info("Received message total: " + _messageCount);
- _logger.info("Sending response to '" + _responseDest + "'");
- }
-
- try
- {
- String payload = "This is a response: sing together: 'Mahnah mahnah...'" + tm.getText();
- TextMessage msg = session.createTextMessage(payload);
- if (tm.propertyExists("timeSent"))
- {
- _logger.info("timeSent property set on message");
- _logger.info("timeSent value is: " + tm.getLongProperty("timeSent"));
- msg.setStringProperty("timeSent", tm.getStringProperty("timeSent"));
- }
- _destinationProducer.send(msg);
- if (_messageCount % 1000 == 0)
- {
- _logger.info("Sent response to '" + _responseDest + "'");
- }
- }
- catch (JMSException e)
- {
- _logger.error("Error sending message: " + e, e);
- }
- }
- });
- }
-
- public void run() throws JMSException
- {
- _connection.start();
- _logger.info("Waiting...");
- }
-
- public static void main(String[] args)
- {
- _logger.info("Starting...");
-
- if (args.length < 5)
- {
- System.out.println("Usage: brokerDetails username password virtual-path serviceQueue [selector]");
- System.exit(1);
- }
- String clientId = null;
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- clientId = address.getHostName() + System.currentTimeMillis();
- }
- catch (UnknownHostException e)
- {
- _logger.error("Error: " + e, e);
- }
-
- try
- {
- ServiceProvidingClient client = new ServiceProvidingClient(args[0], args[1], args[2],
- clientId, args[3], args[4]);
- client.run();
- }
- catch (JMSException e)
- {
- _logger.error("Error: " + e, e);
- }
- catch (AMQException e)
- {
- _logger.error("Error: " + e, e);
- }
- catch (URLSyntaxException e)
- {
- _logger.error("Error: " + e, e);
- }
-
-
-
- }
-
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java b/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java
deleted file mode 100644
index 74becfd9bb..0000000000
--- a/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java
+++ /dev/null
@@ -1,303 +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.requestreply1;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.jms.MessageConsumer;
-import org.apache.qpid.jms.MessageProducer;
-import org.apache.qpid.jms.Session;
-
-import javax.jms.*;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * A client that behaves as follows:
- * <ul><li>Connects to a queue, whose name is specified as a cmd-line argument</li>
- * <li>Creates a temporary queue</li>
- * <li>Creates messages containing a property that is the name of the temporary queue</li>
- * <li>Fires off a message on the original queue and waits for a response on the temporary queue</li>
- * </ul>
- *
- */
-public class ServiceRequestingClient implements ExceptionListener
-{
- private static final Logger _log = Logger.getLogger(ServiceRequestingClient.class);
-
- private static final String MESSAGE_DATA_BYTES = "jfd ghljgl hjvhlj cvhvjf ldhfsj lhfdsjf hldsjfk hdslkfj hsdflk ";
-
- private String MESSAGE_DATA;
-
- private AMQConnection _connection;
-
- private Session _session;
-
- private long _averageLatency;
-
- private int _messageCount;
-
- private volatile boolean _completed;
-
- private AMQDestination _tempDestination;
-
- private MessageProducer _producer;
-
- private Object _waiter;
-
- private static String createMessagePayload(int size)
- {
- _log.info("Message size set to " + size + " bytes");
- StringBuffer buf = new StringBuffer(size);
- int count = 0;
- while (count < size + MESSAGE_DATA_BYTES.length())
- {
- buf.append(MESSAGE_DATA_BYTES);
- count += MESSAGE_DATA_BYTES.length();
- }
- if (count < size)
- {
- buf.append(MESSAGE_DATA_BYTES, 0, size - count);
- }
-
- return buf.toString();
- }
-
- private class CallbackHandler implements MessageListener
- {
- private int _expectedMessageCount;
-
- private int _actualMessageCount;
-
- private long _startTime;
-
- public CallbackHandler(int expectedMessageCount, long startTime)
- {
- _expectedMessageCount = expectedMessageCount;
- _startTime = startTime;
- }
-
- public void onMessage(Message m)
- {
- if (_log.isDebugEnabled())
- {
- _log.debug("Message received: " + m);
- }
- try
- {
- m.getPropertyNames();
- if (m.propertyExists("timeSent"))
- {
- long timeSent = Long.parseLong(m.getStringProperty("timeSent"));
- long now = System.currentTimeMillis();
- if (_averageLatency == 0)
- {
- _averageLatency = now - timeSent;
- _log.info("Latency " + _averageLatency);
- }
- else
- {
- _log.info("Individual latency: " + (now - timeSent));
- _averageLatency = (_averageLatency + (now - timeSent)) / 2;
- _log.info("Average latency now: " + _averageLatency);
- }
- }
- }
- catch (JMSException e)
- {
- _log.error("Error getting latency data: " + e, e);
- }
- _actualMessageCount++;
- if (_actualMessageCount % 1000 == 0)
- {
- _log.info("Received message count: " + _actualMessageCount);
- }
-
- if (_actualMessageCount == _expectedMessageCount)
- {
- _completed = true;
- notifyWaiter();
- long timeTaken = System.currentTimeMillis() - _startTime;
- _log.info("Total time taken to receive " + _expectedMessageCount + " messages was " +
- timeTaken + "ms, equivalent to " +
- (_expectedMessageCount / (timeTaken / 1000.0)) + " messages per second");
-
- try
- {
- _connection.close();
- _log.info("Connection closed");
- }
- catch (JMSException e)
- {
- _log.error("Error closing connection");
- }
- }
- }
- }
-
- private void notifyWaiter()
- {
- if (_waiter != null)
- {
- synchronized (_waiter)
- {
- _waiter.notify();
- }
- }
- }
- public ServiceRequestingClient(String brokerHosts, String clientID, String username, String password,
- String vpath, String commandQueueName,
- final int messageCount, final int messageDataLength) throws AMQException, URLSyntaxException
- {
- _messageCount = messageCount;
- MESSAGE_DATA = createMessagePayload(messageDataLength);
- try
- {
- createConnection(brokerHosts, clientID, username, password, vpath);
- _session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-
- _connection.setExceptionListener(this);
-
-
- AMQQueue destination = new AMQQueue(commandQueueName);
- _producer = (MessageProducer) _session.createProducer(destination);
- _producer.setDisableMessageTimestamp(true);
- _producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- _tempDestination = new AMQQueue("TempResponse" +
- Long.toString(System.currentTimeMillis()), true);
- MessageConsumer messageConsumer = (MessageConsumer) _session.createConsumer(_tempDestination, 100, true,
- true, null);
-
- //Send first message, then wait a bit to allow the provider to get initialised
- TextMessage first = _session.createTextMessage(MESSAGE_DATA);
- first.setJMSReplyTo(_tempDestination);
- _producer.send(first);
- try
- {
- Thread.sleep(1000);
- }
- catch (InterruptedException ignore)
- {
- }
-
- //now start the clock and the test...
- final long startTime = System.currentTimeMillis();
-
- messageConsumer.setMessageListener(new CallbackHandler(messageCount, startTime));
- }
- catch (JMSException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
-
- /**
- * Run the test and notify an object upon receipt of all responses.
- * @param waiter the object that will be notified
- * @throws JMSException
- */
- public void run(Object waiter) throws JMSException
- {
- _waiter = waiter;
- _connection.start();
- for (int i = 1; i < _messageCount; i++)
- {
- TextMessage msg = _session.createTextMessage(MESSAGE_DATA + i);
- msg.setJMSReplyTo(_tempDestination);
- if (i % 1000 == 0)
- {
- long timeNow = System.currentTimeMillis();
- msg.setStringProperty("timeSent", String.valueOf(timeNow));
- }
- _producer.send(msg);
- }
- _log.info("Finished sending " + _messageCount + " messages");
- }
-
- public boolean isCompleted()
- {
- return _completed;
- }
-
- private void createConnection(String brokerHosts, String clientID, String username, String password,
- String vpath) throws AMQException, URLSyntaxException
- {
- _connection = new AMQConnection(brokerHosts, username, password,
- clientID, vpath);
- }
-
- /**
- * @param args argument 1 if present specifies the name of the temporary queue to create. Leaving it blank
- * means the server will allocate a name.
- */
- public static void main(String[] args)
- {
- if (args.length < 6)
- {
- System.err.println(
- "Usage: ServiceRequestingClient <brokerDetails - semicolon separated host:port list> <username> <password> <vpath> <command queue name> <number of messages> <message size>");
- }
- try
- {
- int messageDataLength = args.length > 6 ? Integer.parseInt(args[6]) : 4096;
-
- InetAddress address = InetAddress.getLocalHost();
- String clientID = address.getHostName() + System.currentTimeMillis();
- ServiceRequestingClient client = new ServiceRequestingClient(args[0], clientID, args[1], args[2], args[3],
- args[4], Integer.parseInt(args[5]),
- messageDataLength);
- Object waiter = new Object();
- client.run(waiter);
- synchronized (waiter)
- {
- while (!client.isCompleted())
- {
- waiter.wait();
- }
- }
-
- }
- catch (UnknownHostException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- catch (Exception e)
- {
- System.err.println("Error in client: " + e);
- e.printStackTrace();
- }
- }
-
- /**
- * @see javax.jms.ExceptionListener#onException(javax.jms.JMSException)
- */
- public void onException(JMSException e)
- {
- System.err.println(e.getMessage());
- e.printStackTrace(System.err);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java b/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
deleted file mode 100644
index 56d1ce9b6d..0000000000
--- a/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
+++ /dev/null
@@ -1,72 +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.requestreply1;
-
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.test.VMBrokerSetup;
-import org.apache.log4j.Logger;
-
-import junit.framework.TestCase;
-
-public class VmRequestReply extends TestCase
-{
- private static final Logger _logger = Logger.getLogger(VmRequestReply.class);
-
- public void testSimpleClient() throws Exception
- {
- ServiceProvidingClient serviceProvider = new ServiceProvidingClient("vm://:1", "guest", "guest",
- "serviceProvidingClient", "/test",
- "serviceQ");
-
- ServiceRequestingClient serviceRequester = new ServiceRequestingClient("vm://:1", "myClient", "guest", "guest",
- "/test", "serviceQ", 5000, 512);
-
- serviceProvider.run();
- Object waiter = new Object();
- serviceRequester.run(waiter);
- synchronized (waiter)
- {
- while (!serviceRequester.isCompleted())
- {
- waiter.wait();
- }
- }
- }
-
- public static void main(String[] args)
- {
- VmRequestReply rr = new VmRequestReply();
- try
- {
- rr.testSimpleClient();
- }
- catch (Exception e)
- {
- _logger.error("Error: " + e, e);
- }
- }
-
- public static junit.framework.Test suite()
- {
- return new VMBrokerSetup(new junit.framework.TestSuite(VmRequestReply.class));
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
index 5161705ef2..27a2b6a5e9 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
@@ -26,7 +26,7 @@ import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import javax.jms.*;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
index 2983a16e6d..e6f7032aa7 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
@@ -26,7 +26,7 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSBytesMessage;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import org.apache.mina.common.ByteBuffer;
import java.util.ArrayList;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
index c1ecef6b57..f4efd64dbb 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
@@ -26,10 +26,9 @@ import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.message.JMSBytesMessage;
import org.apache.qpid.framing.AMQFrameDecodingException;
-import org.apache.qpid.framing.FieldTableTest;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.framing.FieldTableFactory;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import org.apache.mina.common.ByteBuffer;
import org.apache.log4j.Logger;
@@ -134,7 +133,11 @@ public class FieldTableMessageTest extends TestCase implements MessageListener
{
ByteBuffer buffer = ((JMSBytesMessage) m).getData();
FieldTable actual = FieldTableFactory.newFieldTable(buffer, buffer.remaining());
- new FieldTableTest().assertEquivalent(_expected, actual);
+ for (Object o : _expected.keySet())
+ {
+ String key = (String) o;
+ assertEquals("Values for " + key + " did not match", _expected.get(key), actual.get(key));
+ }
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
index 5353a19d13..6fbc4809eb 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
@@ -28,7 +28,7 @@ import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSTextMessage;
import org.apache.qpid.client.message.JMSMapMessage;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import java.util.ArrayList;
import java.util.Iterator;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
index 16ac8596c3..80af81652e 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
@@ -25,7 +25,7 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import javax.jms.*;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
index e7d7159bd8..9b1637058d 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
@@ -26,7 +26,7 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSObjectMessage;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import javax.jms.JMSException;
import javax.jms.Message;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
index 02f371e81b..fdf50a7609 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
@@ -27,7 +27,7 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.message.JMSTextMessage;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import javax.jms.Destination;
import javax.jms.JMSException;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
index 6fa8ab95bf..9ddb290e73 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
@@ -26,7 +26,7 @@ import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import javax.jms.JMSException;
import javax.jms.Message;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
index cd3954fbcb..04ad15da7a 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
@@ -27,7 +27,7 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSTextMessage;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import org.apache.log4j.Logger;
import java.util.ArrayList;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
index 9b46c5b18a..63b5bf48b7 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
@@ -28,7 +28,7 @@ import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.AMQException;
import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import java.lang.reflect.Method;
import javax.jms.*;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
index af4673856e..1c8f925d72 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
@@ -27,7 +27,7 @@ import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import org.apache.qpid.url.URLSyntaxException;
import javax.jms.JMSException;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
index d3a05c3d75..d323f042e9 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
@@ -24,7 +24,7 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import org.apache.log4j.Logger;
import javax.jms.*;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java
deleted file mode 100644
index d89bc4a771..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.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.unit.client.connection;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.log4j.Logger;
-
-import junit.framework.TestCase;
-
-public class TestManyConnections extends TestCase
-{
- private static final Logger _log = Logger.getLogger(TestManyConnections.class);
-
- private AMQConnection[] _connections;
-
- private void createConnection(int index, String brokerHosts, String clientID, String username, String password,
- String vpath) throws AMQException, URLSyntaxException
- {
- _connections[index] = new AMQConnection(brokerHosts, username, password,
- clientID, vpath);
- }
-
- private void createConnections(int count) throws AMQException, URLSyntaxException
- {
- _connections = new AMQConnection[count];
- long startTime = System.currentTimeMillis();
- for (int i = 0; i < count; i++)
- {
- createConnection(i, "vm://:1", "myClient" + i, "guest", "guest", "/test");
- }
- long endTime = System.currentTimeMillis();
- _log.info("Time to create " + count + " connections: " + (endTime - startTime) +
- "ms");
- }
-
- public void testCreate10Connections() throws AMQException, URLSyntaxException
- {
- createConnections(10);
- }
-
- public void testCreate50Connections() throws AMQException, URLSyntaxException
- {
- createConnections(50);
- }
-
- public void testCreate100Connections() throws AMQException, URLSyntaxException
- {
- createConnections(100);
- }
-
- public void testCreate250Connections() throws AMQException, URLSyntaxException
- {
- createConnections(250);
- }
-
- public void testCreate500Connections() throws AMQException, URLSyntaxException
- {
- createConnections(500);
- }
-
- public void testCreate1000Connections() throws AMQException, URLSyntaxException
- {
- createConnections(1000);
- }
-
- public void testCreate5000Connections() throws AMQException, URLSyntaxException
- {
- createConnections(5000);
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(TestManyConnections.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
index 9218424a5e..dde3d53299 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
@@ -22,7 +22,7 @@ package org.apache.qpid.test.unit.client.forwardall;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import junit.framework.TestCase;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
index 9bb2fcc59b..07eedc8bb9 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
@@ -24,7 +24,7 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java
deleted file mode 100644
index cdb00240b6..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java
+++ /dev/null
@@ -1,153 +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.unit.jndi;
-
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQTopic;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.naming.spi.InitialContextFactory;
-import java.util.Properties;
-import java.io.InputStream;
-
-
-import junit.framework.TestCase;
-
-public class PropertiesFileInitialContextFactoryTest extends TestCase
-{
- InitialContextFactory contextFactory;
- Properties _properties;
- Properties _fileProperties;
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- //create simple set of hardcoded props
- _properties = new Properties();
- _properties.put("java.naming.factory.initial", "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
- _properties.put("connectionfactory.local", "amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'");
- _properties.put("queue.MyQueue", "example.MyQueue");
- _properties.put("topic.ibmStocks", "stocks.nyse.ibm");
- _properties.put("destination.direct", "direct://amq.direct//directQueue");
-
- //create properties from file as a more realistic test
- _fileProperties = new Properties();
- ClassLoader cl = this.getClass().getClassLoader();
- InputStream is = cl.getResourceAsStream("org/apache/qpid/test/unit/jndi/example.properties");
- _fileProperties.load(is);
- }
-
- /**
- * Test using hardcoded properties
- */
- public void testWithoutFile()
- {
- Context ctx = null;
-
- try
- {
- ctx = new InitialContext(_properties);
- }
- catch (NamingException ne)
- {
- fail("Error loading context:" + ne);
- }
-
- checkPropertiesMatch(ctx, "Using hardcoded properties: ");
- }
-
- /**
- * Test using properties from example file
- */
- public void testWithFile()
- {
- Context ctx = null;
-
- try
- {
- ctx = new InitialContext(_fileProperties);
- }
- catch (Exception e)
- {
- fail("Error loading context:" + e);
- }
-
- checkPropertiesMatch(ctx, "Using properties from file: ");
- }
-
- public void tearDown()
- {
- _properties = null;
- _fileProperties = null;
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(PropertiesFileInitialContextFactoryTest.class);
- }
-
- private void checkPropertiesMatch(Context ctx, String errorInfo)
- {
- try
- {
- AMQConnectionFactory cf = (AMQConnectionFactory) ctx.lookup("local");
- assertEquals("amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'", cf.getConnectionURL().toString());
- }
- catch (NamingException ne)
- {
- fail(errorInfo + "Unable to create Connection Factory:" + ne);
- }
-
- try
- {
- AMQQueue queue = (AMQQueue) ctx.lookup("MyQueue");
- assertEquals("example.MyQueue", queue.getRoutingKey());
- }
- catch (NamingException ne)
- {
- fail(errorInfo + "Unable to create queue:" + ne);
- }
-
- try
- {
- AMQTopic topic = (AMQTopic) ctx.lookup("ibmStocks");
- assertEquals("stocks.nyse.ibm", topic.getTopicName());
- }
- catch (Exception ne)
- {
- fail(errorInfo + "Unable to create topic:" + ne);
- }
-
- try
- {
- AMQQueue direct = (AMQQueue) ctx.lookup("direct");
- assertEquals("directQueue", direct.getRoutingKey());
- }
- catch (NamingException ne)
- {
- fail(errorInfo + "Unable to create direct destination:" + ne);
- }
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/example.properties b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/example.properties
deleted file mode 100644
index 82de41908f..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/example.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory
-
-# use the following property to configure the default connector
-#java.naming.provider.url - ignored.
-
-# register some connection factories
-# connectionfactory.[jndiname] = [ConnectionURL]
-connectionfactory.local = amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'
-
-# register some queues in JNDI using the form
-# queue.[jndiName] = [physicalName]
-queue.MyQueue = example.MyQueue
-
-# register some topics in JNDI using the form
-# topic.[jndiName] = [physicalName]
-topic.ibmStocks = stocks.nyse.ibm
-
-# Register an AMQP destination in JNDI
-# NOTE: Qpid currently only supports direct,topics and headers
-# destination.[jniName] = [BindingURL]
-destination.direct = direct://amq.direct//directQueue
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java
deleted file mode 100644
index db871281bf..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java
+++ /dev/null
@@ -1,250 +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.unit.jndi.referenceabletest;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.url.URLSyntaxException;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameAlreadyBoundException;
-import javax.naming.NamingException;
-import javax.naming.NoInitialContextException;
-import java.io.File;
-import java.util.Hashtable;
-
-import junit.framework.TestCase;
-
-/**
- * Usage: To run these you need to have the sun JNDI SPI for the FileSystem.
- * This can be downloaded from sun here:
- * http://java.sun.com/products/jndi/downloads/index.html
- * Click : Download JNDI 1.2.1 & More button
- * Download: File System Service Provider, 1.2 Beta 3
- * and add the two jars in the lib dir to your class path.
- * <p/>
- * Also you need to create the directory /temp/qpid-jndi-test
- */
-class Bind extends TestCase
-{
- public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest" + System.currentTimeMillis();
- public static final String DEFAULT_PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
- public String PROVIDER_URL = DEFAULT_PROVIDER_URL;
-
- String _connectionFactoryString = "";
-
- String _connectionString = "amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'";
- Topic _topic = null;
-
- boolean _bound = false;
-
- public Bind() throws NameAlreadyBoundException, NoInitialContextException
- {
- this(false, DEFAULT_PROVIDER_URL);
- }
-
- public Bind(boolean output) throws NameAlreadyBoundException, NoInitialContextException
- {
- this(output, DEFAULT_PROVIDER_URL);
- }
-
- public Bind(boolean output, String providerURL) throws NameAlreadyBoundException, NoInitialContextException
- {
- PROVIDER_URL = providerURL;
-
- // Set up the environment for creating the initial context
- Hashtable env = new Hashtable(11);
- env.put(Context.INITIAL_CONTEXT_FACTORY,
- "com.sun.jndi.fscontext.RefFSContextFactory");
-
-
- env.put(Context.PROVIDER_URL, PROVIDER_URL);
-
-
- File file = new File(PROVIDER_URL.substring(PROVIDER_URL.indexOf("://") + 3));
-
- if (file.exists() && !file.isDirectory())
- {
- System.out.println("Couldn't make directory file already exists");
- return;
- }
- else
- {
- if (!file.exists())
- {
- if (!file.mkdirs())
- {
- System.out.println("Couldn't make directory");
- return;
- }
- }
- }
-
- Connection connection = null;
- try
- {
- // Create the initial context
- Context ctx = new InitialContext(env);
-
- // Create the connection factory to be bound
- ConnectionFactory connectionFactory = null;
- // Create the Connection to be bound
-
-
- try
- {
- connectionFactory = new AMQConnectionFactory(_connectionString);
- connection = connectionFactory.createConnection();
-
- _connectionFactoryString = ((AMQConnectionFactory) connectionFactory).getConnectionURL().getURL();
- }
- catch (JMSException jmsqe)
- {
- fail("Unable to create Connection:" + jmsqe);
- }
- catch (URLSyntaxException urlse)
- {
- fail("Unable to create Connection:" + urlse);
- }
-
- try
- {
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- _topic = session.createTopic("Fruity");
- }
- catch (JMSException jmse)
- {
-
- }
- // Perform the binds
- ctx.bind("ConnectionFactory", connectionFactory);
- if (output)
- {
- System.out.println("Bound factory\n" + ((AMQConnectionFactory) connectionFactory).getConnectionURL());
- }
- ctx.bind("Connection", connection);
- if (output)
- {
- System.out.println("Bound Connection\n" + ((AMQConnection) connection).toURL());
- }
- ctx.bind("Topic", _topic);
- if (output)
- {
- System.out.println("Bound Topic:\n" + ((AMQTopic) _topic).toURL());
- }
- _bound = true;
-
- // Check that it is bound
- //Object obj = ctx.lookup("Connection");
- //System.out.println(((AMQConnection)obj).toURL());
-
- // Close the context when we're done
- ctx.close();
- }
- catch (NamingException e)
- {
- System.out.println("Operation failed: " + e);
- if (e instanceof NameAlreadyBoundException)
- {
- throw(NameAlreadyBoundException) e;
- }
-
- if (e instanceof NoInitialContextException)
- {
- throw(NoInitialContextException) e;
- }
- }
- finally
- {
- try
- {
- if (connection != null)
- {
- connection.close();
- }
- }
- catch (JMSException e)
- {
- //ignore just want it closed
- }
- }
- }
-
- public String connectionFactoryValue()
- {
- if (_connectionFactoryString != null)
- {
- return _connectionFactoryString;
- }
- else
- {
- return "";
- }
- }
-
- public String connectionValue()
- {
- if (_connectionString != null)
- {
- return _connectionString;
- }
- else
- {
- return "";
- }
- }
-
- public String topicValue()
- {
- if (_topic != null)
- {
- return ((AMQTopic) _topic).toURL();
- }
- else
- {
- return "";
- }
-
- }
-
- public boolean bound()
- {
- return _bound;
- }
-
- public String getProviderURL()
- {
- return PROVIDER_URL;
- }
-
- public static void main(String[] args) throws NameAlreadyBoundException, NoInitialContextException
- {
- new Bind(true);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java
deleted file mode 100644
index 4731caca98..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java
+++ /dev/null
@@ -1,104 +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.unit.jndi.referenceabletest;
-
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.test.VMBrokerSetup;
-
-import javax.naming.NameAlreadyBoundException;
-import javax.naming.NoInitialContextException;
-
-import junit.framework.TestCase;
-
-/**
- * Usage: To run these you need to have the sun JNDI SPI for the FileSystem.
- * This can be downloaded from sun here:
- * http://java.sun.com/products/jndi/downloads/index.html
- * Click : Download JNDI 1.2.1 & More button
- * Download: File System Service Provider, 1.2 Beta 3
- * and add the two jars in the lib dir to your class path.
- * <p/>
- * Also you need to create the directory /temp/qpid-jndi-test
- */
-public class JNDIReferenceableTest extends TestCase
-{
- // FIXME FSContext has been removed from repository. This needs redone with the PropertiesFileInitialContextFactory. QPID-84
- public void testReferenceable()
- {
- Bind b = null;
- try
- {
- try
- {
- b = new Bind();
- }
- catch (NameAlreadyBoundException e)
- {
- if (new Unbind().unbound())
- {
- try
- {
- b = new Bind();
- }
- catch (NameAlreadyBoundException ee)
- {
- fail("Unable to clear bound objects for test.");
- }
- }
- else
- {
- fail("Unable to clear bound objects for test.");
- }
- }
- }
- catch (NoInitialContextException e)
- {
- fail("You don't have the File System SPI on you class path.\n" +
- "This can be downloaded from sun here:\n" +
- "http://java.sun.com/products/jndi/downloads/index.html\n" +
- "Click : Download JNDI 1.2.1 & More button\n" +
- "Download: File System Service Provider, 1.2 Beta 3\n" +
- "and add the two jars in the lib dir to your class path.");
- }
-
- assertTrue(b.bound());
-
- Lookup l = new Lookup(b.getProviderURL());
-
- assertTrue(l.connectionFactoryValue().equals(b.connectionFactoryValue()));
-
- assertTrue(l.connectionValue().equals(b.connectionValue()));
-
- assertTrue(l.topicValue().equals(b.topicValue()));
-
-
- Unbind u = new Unbind();
-
- assertTrue(u.unbound());
-
- }
-
- public static junit.framework.Test suite()
- {
- return new VMBrokerSetup(new junit.framework.TestSuite(JNDIReferenceableTest.class));
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Lookup.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Lookup.java
deleted file mode 100644
index b804ccb30c..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Lookup.java
+++ /dev/null
@@ -1,167 +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.unit.jndi.referenceabletest;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.client.AMQTopic;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.jms.JMSException;
-import java.io.File;
-import java.util.Hashtable;
-
-
-/**
- * Usage: To run these you need to have the sun JNDI SPI for the FileSystem.
- * This can be downloaded from sun here:
- * http://java.sun.com/products/jndi/downloads/index.html
- * Click : Download JNDI 1.2.1 & More button
- * Download: File System Service Provider, 1.2 Beta 3
- * and add the two jars in the lib dir to your class path.
- * <p/>
- * Also you need to create the directory /temp/qpid-jndi-test
- */
-class Lookup
-{
- public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest";
- public static final String DEFAULT_PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
- public String PROVIDER_URL = DEFAULT_PROVIDER_URL;
-
- AMQTopic _topic = null;
- AMQConnection _connection = null;
- AMQConnectionFactory _connectionFactory = null;
- private String _connectionURL;
-
-
- public Lookup()
- {
- this(DEFAULT_PROVIDER_URL);
- }
-
- public Lookup(String providerURL)
- {
-
- PROVIDER_URL = providerURL;
-
- // Set up the environment for creating the initial context
- Hashtable env = new Hashtable(11);
- env.put(Context.INITIAL_CONTEXT_FACTORY,
- "com.sun.jndi.fscontext.RefFSContextFactory");
-
- env.put(Context.PROVIDER_URL, PROVIDER_URL);
-
- File file = new File(PROVIDER_URL.substring(PROVIDER_URL.indexOf("://") + 3));
-
- if (file.exists() && !file.isDirectory())
- {
- System.out.println("Couldn't make directory file already exists");
- return;
- }
- else
- {
- if (!file.exists())
- {
- if (!file.mkdirs())
- {
- System.out.println("Couldn't make directory");
- return;
- }
- }
- }
-
- try
- {
- // Create the initial context
- Context ctx = new InitialContext(env);
-
- _topic = (AMQTopic) ctx.lookup("Topic");
-
- _connection = (AMQConnection) ctx.lookup("Connection");
-
- _connectionURL = _connection.toURL();
-
- _connectionFactory = (AMQConnectionFactory) ctx.lookup("ConnectionFactory");
- //System.out.println(topic);
-
- // Close the context when we're done
- ctx.close();
- }
- catch (NamingException e)
- {
- System.out.println("Operation failed: " + e);
- }
- finally
- {
- try
- {
- if (_connection != null)
- {
- _connection.close();
- }
- }
- catch (JMSException e)
- {
- //ignore just need to close
- }
- }
- }
-
- public String connectionFactoryValue()
- {
- if (_connectionFactory != null)
- {
- return _connectionFactory.getConnectionURL().toString();
- }
- return "";
- }
-
- public String connectionValue()
- {
- if (_connectionURL != null)
- {
- return _connectionURL;
- }
- return "";
- }
-
- public String topicValue()
- {
- if (_topic != null)
- {
- return _topic.toURL();
- }
- return "";
- }
-
- public String getProviderURL()
- {
- return PROVIDER_URL;
- }
-
- public static void main(String[] args)
- {
- new Lookup();
- }
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java
deleted file mode 100644
index 869bc55d8f..0000000000
--- a/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java
+++ /dev/null
@@ -1,173 +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.unit.jndi.referenceabletest;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import java.io.File;
-import java.util.Hashtable;
-
-/**
- * Usage: To run these you need to have the sun JNDI SPI for the FileSystem.
- * This can be downloaded from sun here:
- * http://java.sun.com/products/jndi/downloads/index.html
- * Click : Download JNDI 1.2.1 & More button
- * Download: File System Service Provider, 1.2 Beta 3
- * and add the two jars in the lib dir to your class path.
- * <p/>
- * Also you need to create the directory /temp/qpid-jndi-test
- */
-class Unbind
-{
- public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest" + System.currentTimeMillis();
- public static final String DEFAULT_PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
- public String PROVIDER_URL = DEFAULT_PROVIDER_URL;
-
- boolean _unbound = false;
-
- public Unbind()
- {
- this(false, DEFAULT_PROVIDER_URL);
- }
-
- public Unbind(Boolean output)
- {
- this(output, DEFAULT_PROVIDER_URL);
- }
-
- public Unbind(String provider)
- {
- this(false, provider);
- }
-
- public Unbind(boolean output, String providerURL)
- {
- PROVIDER_URL = providerURL;
- // Set up the environment for creating the initial context
- Hashtable env = new Hashtable(11);
- env.put(Context.INITIAL_CONTEXT_FACTORY,
- "com.sun.jndi.fscontext.RefFSContextFactory");
- env.put(Context.PROVIDER_URL, PROVIDER_URL);
-
- File file = new File(PROVIDER_URL.substring(PROVIDER_URL.indexOf("://") + 3));
-
- if (file.exists() && !file.isDirectory())
- {
- System.out.println("Couldn't make directory file already exists");
- return;
- }
- else
- {
- if (!file.exists())
- {
- if (!file.mkdirs())
- {
- System.out.println("Couldn't make directory");
- return;
- }
- }
- }
-
- try
- {
- // Create the initial context
- Context ctx = new InitialContext(env);
-
- // Remove the binding
- ctx.unbind("ConnectionFactory");
- ctx.unbind("Connection");
- ctx.unbind("Topic");
-
- // Check that it is gone
- Object obj = null;
- try
- {
- obj = ctx.lookup("ConnectionFactory");
- }
- catch (NameNotFoundException ne)
- {
- if (output)
- {
- System.out.println("unbind ConnectionFactory successful");
- }
- try
- {
- obj = ctx.lookup("Connection");
- try
- {
- ((Connection) obj).close();
- }
- catch (JMSException e)
- {
- //ignore just need to close
- }
- }
- catch (NameNotFoundException ne2)
- {
- if (output)
- {
- System.out.println("unbind Connection successful");
- }
-
- try
- {
- obj = ctx.lookup("Topic");
- }
- catch (NameNotFoundException ne3)
- {
- if (output)
- {
- System.out.println("unbind Topic successful");
- }
- _unbound = true;
- }
- }
- }
-
- //System.out.println("unbind failed; object still there: " + obj);
-
- // Close the context when we're done
-
- ctx.close();
-
- }
- catch (NamingException e)
- {
- System.out.println("Operation failed: " + e);
- }
- }
-
- public boolean unbound()
- {
- return _unbound;
- }
-
- public static void main(String[] args)
- {
-
- new Unbind(true);
- }
-}
-
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
index b20cfa046a..f00d7185af 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
@@ -27,7 +27,7 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import javax.jms.JMSException;
import javax.jms.Message;
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
index 92f3234bba..e858e1ad36 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
@@ -25,7 +25,7 @@ import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.qpid.testutil.VMBrokerSetup;
import javax.jms.*;
diff --git a/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java b/java/client/src/test/java/org/apache/qpid/testutil/VMBrokerSetup.java
index e859fac4af..cedf1ac824 100644
--- a/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
+++ b/java/client/src/test/java/org/apache/qpid/testutil/VMBrokerSetup.java
@@ -17,7 +17,7 @@
* under the License.
*
*/
-package org.apache.qpid.test;
+package org.apache.qpid.testutil;
import junit.extensions.TestSetup;
import junit.framework.Test;
diff --git a/java/client/src/test/java/org/apache/qpid/topic/Config.java b/java/client/src/test/java/org/apache/qpid/topic/Config.java
deleted file mode 100644
index bb740f9094..0000000000
--- a/java/client/src/test/java/org/apache/qpid/topic/Config.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.topic;
-
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.config.ConnectorConfig;
-import org.apache.qpid.config.ConnectionFactoryInitialiser;
-import org.apache.qpid.config.Connector;
-import org.apache.qpid.config.AbstractConfig;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-
-class Config extends AbstractConfig implements ConnectorConfig
-{
-
- private String host = "localhost";
- private int port = 5672;
- private String factory = null;
-
- private int payload = 256;
- private int messages = 1000;
- private int clients = 1;
- private int batch = 1;
- private long delay = 1;
- private int warmup;
- private int ackMode= AMQSession.NO_ACKNOWLEDGE;
- private String clientId;
- private String subscriptionId;
- private boolean persistent;
-
- public Config()
- {
- }
-
- int getAckMode()
- {
- return ackMode;
- }
-
- void setPayload(int payload)
- {
- this.payload = payload;
- }
-
- int getPayload()
- {
- return payload;
- }
-
- void setClients(int clients)
- {
- this.clients = clients;
- }
-
- int getClients()
- {
- return clients;
- }
-
- void setMessages(int messages)
- {
- this.messages = messages;
- }
-
- int getMessages()
- {
- return messages;
- }
-
- public String getHost()
- {
- return host;
- }
-
- public void setHost(String host)
- {
- this.host = host;
- }
-
- public int getPort()
- {
- return port;
- }
-
- public String getFactory()
- {
- return factory;
- }
-
- public void setPort(int port)
- {
- this.port = port;
- }
-
- int getBatch()
- {
- return batch;
- }
-
- void setBatch(int batch)
- {
- this.batch = batch;
- }
-
- int getWarmup()
- {
- return warmup;
- }
-
- void setWarmup(int warmup)
- {
- this.warmup = warmup;
- }
-
- public long getDelay()
- {
- return delay;
- }
-
- public void setDelay(long delay)
- {
- this.delay = delay;
- }
-
- String getClientId()
- {
- return clientId;
- }
-
- String getSubscriptionId()
- {
- return subscriptionId;
- }
-
- boolean usePersistentMessages()
- {
- return persistent;
- }
-
- public void setOption(String key, String value)
- {
- if("-host".equalsIgnoreCase(key))
- {
- setHost(value);
- }
- else if("-port".equalsIgnoreCase(key))
- {
- try
- {
- setPort(Integer.parseInt(value));
- }
- catch(NumberFormatException e)
- {
- throw new RuntimeException("Bad port number: " + value);
- }
- }
- else if("-payload".equalsIgnoreCase(key))
- {
- setPayload(parseInt("Bad payload size", value));
- }
- else if("-messages".equalsIgnoreCase(key))
- {
- setMessages(parseInt("Bad message count", value));
- }
- else if("-clients".equalsIgnoreCase(key))
- {
- setClients(parseInt("Bad client count", value));
- }
- else if("-batch".equalsIgnoreCase(key))
- {
- setBatch(parseInt("Bad batch count", value));
- }
- else if("-delay".equalsIgnoreCase(key))
- {
- setDelay(parseLong("Bad batch delay", value));
- }
- else if("-warmup".equalsIgnoreCase(key))
- {
- setWarmup(parseInt("Bad warmup count", value));
- }
- else if("-ack".equalsIgnoreCase(key))
- {
- ackMode = parseInt("Bad ack mode", value);
- }
- else if("-factory".equalsIgnoreCase(key))
- {
- factory = value;
- }
- else if("-clientId".equalsIgnoreCase(key))
- {
- clientId = value;
- }
- else if("-subscriptionId".equalsIgnoreCase(key))
- {
- subscriptionId = value;
- }
- else if("-persistent".equalsIgnoreCase(key))
- {
- persistent = "true".equalsIgnoreCase(value);
- }
- else
- {
- System.out.println("Ignoring unrecognised option: " + key);
- }
- }
-
- static String getAckModeDescription(int ackMode)
- {
- switch(ackMode)
- {
- case AMQSession.NO_ACKNOWLEDGE: return "NO_ACKNOWLEDGE";
- case AMQSession.AUTO_ACKNOWLEDGE: return "AUTO_ACKNOWLEDGE";
- case AMQSession.CLIENT_ACKNOWLEDGE: return "CLIENT_ACKNOWLEDGE";
- case AMQSession.DUPS_OK_ACKNOWLEDGE: return "DUPS_OK_ACKNOWELDGE";
- case AMQSession.PRE_ACKNOWLEDGE: return "PRE_ACKNOWLEDGE";
- }
- return "AckMode=" + ackMode;
- }
-
- public Connection createConnection() throws Exception
- {
- return new Connector().createConnection(this);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/topic/Listener.java b/java/client/src/test/java/org/apache/qpid/topic/Listener.java
deleted file mode 100644
index 47c608cfe4..0000000000
--- a/java/client/src/test/java/org/apache/qpid/topic/Listener.java
+++ /dev/null
@@ -1,141 +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.topic;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-public class Listener implements MessageListener
-{
- private final Connection _connection;
- private final MessageProducer _controller;
- private final javax.jms.Session _session;
- private final MessageFactory _factory;
- private boolean init;
- private int count;
- private long start;
-
- Listener(Connection connection, int ackMode) throws Exception
- {
- this(connection, ackMode, null);
- }
-
- Listener(Connection connection, int ackMode, String name) throws Exception
- {
- _connection = connection;
- _session = connection.createSession(false, ackMode);
- _factory = new MessageFactory(_session);
-
- //register for events
- if(name == null)
- {
- _factory.createTopicConsumer().setMessageListener(this);
- }
- else
- {
- _factory.createDurableTopicConsumer(name).setMessageListener(this);
- }
-
- _connection.start();
-
- _controller = _factory.createControlPublisher();
- System.out.println("Waiting for messages " +
- Config.getAckModeDescription(ackMode)
- + (name == null ? "" : " (subscribed with name " + name + " and client id " + connection.getClientID() + ")")
- + "...");
-
- }
-
- private void shutdown()
- {
- try
- {
- _session.close();
- _connection.stop();
- _connection.close();
- }
- catch(Exception e)
- {
- e.printStackTrace(System.out);
- }
- }
-
- private void report()
- {
- try
- {
- String msg = getReport();
- _controller.send(_factory.createReportResponseMessage(msg));
- System.out.println("Sent report: " + msg);
- }
- catch(Exception e)
- {
- e.printStackTrace(System.out);
- }
- }
-
- private String getReport()
- {
- long time = (System.currentTimeMillis() - start);
- return "Received " + count + " in " + time + "ms";
- }
-
- public void onMessage(Message message)
- {
- if(!init)
- {
- start = System.currentTimeMillis();
- count = 0;
- init = true;
- }
-
- if(_factory.isShutdown(message))
- {
- shutdown();
- }
- else if(_factory.isReport(message))
- {
- //send a report:
- report();
- init = false;
- }
- else if (++count % 100 == 0)
- {
- System.out.println("Received " + count + " messages.");
- }
- }
-
- public static void main(String[] argv) throws Exception
- {
- Config config = new Config();
- config.setOptions(argv);
-
- Connection con = config.createConnection();
- if(config.getClientId() != null)
- {
- con.setClientID(config.getClientId());
- }
- new Listener(con, config.getAckMode(), config.getSubscriptionId());
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/topic/MessageFactory.java b/java/client/src/test/java/org/apache/qpid/topic/MessageFactory.java
deleted file mode 100644
index 1520f18408..0000000000
--- a/java/client/src/test/java/org/apache/qpid/topic/MessageFactory.java
+++ /dev/null
@@ -1,153 +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.topic;
-
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.AMQTopic;
-
-import javax.jms.*;
-
-/**
- */
-class MessageFactory
-{
- private static final char[] DATA = "abcdefghijklmnopqrstuvwxyz".toCharArray();
-
- private final Session _session;
- private final Topic _topic;
- private final Topic _control;
- private final byte[] _payload;
-
-
- MessageFactory(Session session) throws JMSException
- {
- this(session, 256);
- }
-
- MessageFactory(Session session, int size) throws JMSException
- {
- _session = session;
- if(session instanceof AMQSession)
- {
- _topic = new AMQTopic("topictest.messages");
- _control = new AMQTopic("topictest.control");
- }
- else
- {
- _topic = session.createTopic("topictest.messages");
- _control = session.createTopic("topictest.control");
- }
- _payload = new byte[size];
-
- for(int i = 0; i < size; i++)
- {
- _payload[i] = (byte) DATA[i % DATA.length];
- }
- }
-
- Topic getTopic()
- {
- return _topic;
- }
-
- Message createEventMessage() throws JMSException
- {
- BytesMessage msg = _session.createBytesMessage();
- msg.writeBytes(_payload);
- return msg;
- }
-
- Message createShutdownMessage() throws JMSException
- {
- return _session.createTextMessage("SHUTDOWN");
- }
-
- Message createReportRequestMessage() throws JMSException
- {
- return _session.createTextMessage("REPORT");
- }
-
- Message createReportResponseMessage(String msg) throws JMSException
- {
- return _session.createTextMessage(msg);
- }
-
- boolean isShutdown(Message m)
- {
- return checkText(m, "SHUTDOWN");
- }
-
- boolean isReport(Message m)
- {
- return checkText(m, "REPORT");
- }
-
- Object getReport(Message m)
- {
- try
- {
- return ((TextMessage) m).getText();
- }
- catch (JMSException e)
- {
- e.printStackTrace(System.out);
- return e.toString();
- }
- }
-
- MessageConsumer createTopicConsumer() throws Exception
- {
- return _session.createConsumer(_topic);
- }
-
- MessageConsumer createDurableTopicConsumer(String name) throws Exception
- {
- return _session.createDurableSubscriber(_topic, name);
- }
-
- MessageConsumer createControlConsumer() throws Exception
- {
- return _session.createConsumer(_control);
- }
-
- MessageProducer createTopicPublisher() throws Exception
- {
- return _session.createProducer(_topic);
- }
-
- MessageProducer createControlPublisher() throws Exception
- {
- return _session.createProducer(_control);
- }
-
- private static boolean checkText(Message m, String s)
- {
- try
- {
- return m instanceof TextMessage && ((TextMessage) m).getText().equals(s);
- }
- catch (JMSException e)
- {
- e.printStackTrace(System.out);
- return false;
- }
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/topic/Publisher.java b/java/client/src/test/java/org/apache/qpid/topic/Publisher.java
deleted file mode 100644
index d788029ee9..0000000000
--- a/java/client/src/test/java/org/apache/qpid/topic/Publisher.java
+++ /dev/null
@@ -1,175 +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.topic;
-
-import javax.jms.*;
-
-public class Publisher implements MessageListener
-{
- private final Object _lock = new Object();
- private final Connection _connection;
- private final Session _session;
- private final MessageFactory _factory;
- private final MessageProducer _publisher;
- private int _count;
-
- Publisher(Connection connection, int size, int ackMode, boolean persistent) throws Exception
- {
- _connection = connection;
- _session = _connection.createSession(false, ackMode);
- _factory = new MessageFactory(_session, size);
- _publisher = _factory.createTopicPublisher();
- _publisher.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
- System.out.println("Publishing " + (persistent ? "persistent" : "non-persistent") + " messages of " + size + " bytes, " + Config.getAckModeDescription(ackMode) + ".");
- }
-
- private void test(Config config) throws Exception
- {
- test(config.getBatch(), config.getDelay(), config.getMessages(), config.getClients(), config.getWarmup());
- }
-
- private void test(int batches, long delay, int msgCount, int consumerCount, int warmup) throws Exception
- {
- _factory.createControlConsumer().setMessageListener(this);
- _connection.start();
-
- if(warmup > 0)
- {
- System.out.println("Runing warmup (" + warmup + " msgs)");
- long time = batch(warmup, consumerCount);
- System.out.println("Warmup completed in " + time + "ms");
- }
-
- long[] times = new long[batches];
- for(int i = 0; i < batches; i++)
- {
- if(i > 0) Thread.sleep(delay*1000);
- times[i] = batch(msgCount, consumerCount);
- System.out.println("Batch " + (i+1) + " of " + batches + " completed in " + times[i] + " ms.");
- }
-
- long min = min(times);
- long max = max(times);
- System.out.println("min: " + min + ", max: " + max + " avg: " + avg(times, min, max));
-
- //request shutdown
- _publisher.send(_factory.createShutdownMessage());
-
- _connection.stop();
- _connection.close();
- }
-
- private long batch(int msgCount, int consumerCount) throws Exception
- {
- _count = consumerCount;
- long start = System.currentTimeMillis();
- publish(msgCount);
- waitForCompletion(consumerCount);
- return System.currentTimeMillis() - start;
- }
-
- private void publish(int count) throws Exception
- {
-
- //send events
- for (int i = 0; i < count; i++)
- {
- _publisher.send(_factory.createEventMessage());
- if ((i + 1) % 100 == 0)
- {
- System.out.println("Sent " + (i + 1) + " messages");
- }
- }
-
- //request report
- _publisher.send(_factory.createReportRequestMessage());
- }
-
- private void waitForCompletion(int consumers) throws Exception
- {
- System.out.println("Waiting for completion...");
- synchronized (_lock)
- {
- while (_count > 0)
- {
- _lock.wait();
- }
- }
- }
-
-
- public void onMessage(Message message)
- {
- System.out.println("Received report " + _factory.getReport(message) + " " + --_count + " remaining");
- if (_count == 0)
- {
- synchronized (_lock)
- {
- _lock.notify();
- }
- }
- }
-
- static long min(long[] times)
- {
- long min = times.length > 0 ? times[0] : 0;
- for(int i = 0; i < times.length; i++)
- {
- min = Math.min(min, times[i]);
- }
- return min;
- }
-
- static long max(long[] times)
- {
- long max = times.length > 0 ? times[0] : 0;
- for(int i = 0; i < times.length; i++)
- {
- max = Math.max(max, times[i]);
- }
- return max;
- }
-
- static long avg(long[] times, long min, long max)
- {
- long sum = 0;
- for(int i = 0; i < times.length; i++)
- {
- sum += times[i];
- }
- sum -= min;
- sum -= max;
-
- return (sum / (times.length - 2));
- }
-
- public static void main(String[] argv) throws Exception
- {
- Config config = new Config();
- config.setOptions(argv);
-
- Connection con = config.createConnection();
- int size = config.getPayload();
- int ackMode = config.getAckMode();
- boolean persistent = config.usePersistentMessages();
- new Publisher(con, size, ackMode, persistent).test(config);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/transacted/Config.java b/java/client/src/test/java/org/apache/qpid/transacted/Config.java
deleted file mode 100644
index bd104e5407..0000000000
--- a/java/client/src/test/java/org/apache/qpid/transacted/Config.java
+++ /dev/null
@@ -1,110 +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.transacted;
-
-import org.apache.qpid.config.ConnectorConfig;
-import org.apache.qpid.config.AbstractConfig;
-import org.apache.qpid.config.Connector;
-
-import javax.jms.Connection;
-
-class Config extends AbstractConfig implements ConnectorConfig
-{
- private String host = "localhost";
- private int port = 5672;
- private String factory;
- private boolean echo;
- private int batch = 100;
- private boolean persistent = true;
-
- Config(String[] argv)
- {
- setOptions(argv);
- }
-
- Connection createConnection() throws Exception
- {
- return new Connector().createConnection(this);
- }
-
- public boolean isEchoOn()
- {
- return echo;
- }
-
- public boolean usePersistentMessages()
- {
- return persistent;
- }
-
- public int getBatchSize()
- {
- return batch;
- }
-
- public String getHost()
- {
- return host;
- }
-
- public int getPort()
- {
- return port;
- }
-
- public String getFactory()
- {
- return factory;
- }
-
- public void setOption(String key, String value)
- {
- if("-host".equalsIgnoreCase(key))
- {
- host = value;
- }
- else if("-port".equalsIgnoreCase(key))
- {
- port = parseInt("Bad port number", value);
- }
- else if("-factory".equalsIgnoreCase(key))
- {
- factory = value;
- }
- else if("-echo".equalsIgnoreCase(key))
- {
- echo = "true".equalsIgnoreCase(value);
- }
- else if("-persistent".equalsIgnoreCase(key))
- {
- persistent = "true".equalsIgnoreCase(value);
- }
- else if("-batch".equalsIgnoreCase(key))
- {
- batch = parseInt("Bad batch size", value);
- }
- else
- {
- System.out.println("Ignoring nrecognised option " + key);
- }
- }
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/transacted/Ping.java b/java/client/src/test/java/org/apache/qpid/transacted/Ping.java
deleted file mode 100644
index e0af4422a6..0000000000
--- a/java/client/src/test/java/org/apache/qpid/transacted/Ping.java
+++ /dev/null
@@ -1,43 +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.transacted;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQQueue;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import java.util.Arrays;
-
-public class Ping
-{
- public static void main(String[] argv) throws Exception
- {
- Config config = new Config(argv);
- Connection con = config.createConnection();
- con.setClientID("ping");
- new Relay(new AMQQueue("ping"), new AMQQueue("pong"), con,
- config.isEchoOn(),
- config.getBatchSize(),
- config.usePersistentMessages()).start();
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/transacted/Pong.java b/java/client/src/test/java/org/apache/qpid/transacted/Pong.java
deleted file mode 100644
index 13295c137a..0000000000
--- a/java/client/src/test/java/org/apache/qpid/transacted/Pong.java
+++ /dev/null
@@ -1,43 +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.transacted;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQQueue;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-
-public class Pong
-{
- public static void main(String[] argv) throws Exception
- {
- Config config = new Config(argv);
- Connection con = config.createConnection();
- con.setClientID("pong");
- new Relay(new AMQQueue("pong"), new AMQQueue("ping"), con,
- config.isEchoOn(),
- config.getBatchSize(),
- config.usePersistentMessages()).start();
-
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/transacted/Relay.java b/java/client/src/test/java/org/apache/qpid/transacted/Relay.java
deleted file mode 100644
index cede95e5f0..0000000000
--- a/java/client/src/test/java/org/apache/qpid/transacted/Relay.java
+++ /dev/null
@@ -1,127 +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.transacted;
-
-import org.apache.qpid.client.AMQSession;
-
-import javax.jms.MessageProducer;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.jms.Destination;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.TextMessage;
-import javax.jms.DeliveryMode;
-
-class Relay implements Runnable
-{
- private final Connection _con;
- private final Session _session;
- private final MessageConsumer _src;
- private final MessageProducer _dest;
- private final int _batch;
- private final boolean _echo;
- private int _counter;
- private long start;
- private boolean _running;
-
- Relay(Destination src, Destination dest, Connection con) throws JMSException
- {
- this(src, dest, con, false, 100, true);
- }
-
- Relay(Destination src, Destination dest, Connection con, boolean echo, int batch, boolean persistent) throws JMSException
- {
- _echo = echo;
- _batch = batch;
- _con = con;
- _session = con.createSession(true, AMQSession.NO_ACKNOWLEDGE);
- _src = _session.createConsumer(src);
- _dest = _session.createProducer(dest);
- _dest.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- }
-
- public void run()
- {
- start = System.currentTimeMillis();
- try{
- while(true) relay();
- }
- catch(JMSException e)
- {
- e.printStackTrace();
- }
- try
- {
- _session.close();
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- }
- }
-
- void relay() throws JMSException
- {
- _dest.send(relay(_src.receive()));
- _session.commit();
- }
-
- Message relay(Message in) throws JMSException
- {
- if(!_running)
- {
- System.out.println(_con.getClientID() + " started.");
- _running = true;
- }
- if(++_counter % _batch == 0)
- {
- long time = System.currentTimeMillis() - start;
- System.out.println(_batch + " iterations performed in " + time + " ms");
- try
- {
- Thread.sleep(100);
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- start = System.currentTimeMillis();
- }
- if(_echo)
- {
- System.out.println("Received: " + ((TextMessage) in).getText());
- }
- return _session.createTextMessage(_con.getClientID() + _counter);
- }
-
- void start() throws InterruptedException, JMSException
- {
- Thread runner = new Thread(this);
- runner.start();
- _con.start();
- System.out.println(_con.getClientID() + " waiting...");
- runner.join();
- _con.close();
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/transacted/Start.java b/java/client/src/test/java/org/apache/qpid/transacted/Start.java
deleted file mode 100644
index 5564ed93ab..0000000000
--- a/java/client/src/test/java/org/apache/qpid/transacted/Start.java
+++ /dev/null
@@ -1,42 +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.transacted;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQQueue;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Session;
-
-public class Start
-{
- public static void main(String[] argv) throws Exception
- {
- Connection con = new Config(argv).createConnection();
- AMQQueue ping = new AMQQueue("ping");
- Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
- session.createProducer(ping).send(session.createTextMessage("start"));
- session.close();
- con.close();
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/weblogic/ServiceProvider.java b/java/client/src/test/java/org/apache/qpid/weblogic/ServiceProvider.java
deleted file mode 100644
index 71d806b338..0000000000
--- a/java/client/src/test/java/org/apache/qpid/weblogic/ServiceProvider.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.qpid.weblogic;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
-
-import javax.jms.*;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.naming.Context;
-import java.net.InetAddress;
-import java.util.Hashtable;
-
-public class ServiceProvider
-{
- private static final String JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";
- private static final String JMS_FACTORY = "transientJMSConnectionFactory";
-
- private static final Logger _logger = Logger.getLogger(ServiceProvider.class);
-
- private static MessageProducer _destinationProducer;
-
- private static Queue _destinationQ;
-
- public static void main(String[] args)
- {
- _logger.info("Starting...");
-
- if (args.length != 2)
- {
- System.out.println("Usage: <WLS URI> <service queue>");
- System.exit(1);
- }
- try
- {
- String url = args[0];
- String receiveQueue = args[1];
-
- final InitialContext ctx = getInitialContext(url);
-
- QueueConnectionFactory qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
- QueueConnection qcon = qconFactory.createQueueConnection();
- final QueueSession qsession = qcon.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
- Queue receiveQ = (Queue) ctx.lookup(receiveQueue);
-
- _logger.info("Service (queue) name is '" + receiveQ + "'...");
-
- String selector = (args.length > 2 && args[2] != null && args[2].length() > 1) ? args[2] : null;
-
- _logger.info("Message selector is <" + selector + ">...");
-
- MessageConsumer consumer = qsession.createConsumer(receiveQ, selector);
-
- consumer.setMessageListener(new MessageListener()
- {
- private int _messageCount;
-
- public void onMessage(javax.jms.Message message)
- {
- //_logger.info("Got message '" + message + "'");
-
- TextMessage tm = (TextMessage) message;
-
- try
- {
- Queue responseQueue = (Queue)tm.getJMSReplyTo();
- if (!responseQueue.equals(_destinationQ))
- {
- _destinationQ = responseQueue;
- _logger.info("Creating destination for " + responseQueue);
-
- try
- {
- _destinationProducer = qsession.createProducer(_destinationQ);
- _destinationProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- }
- catch (JMSException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- _messageCount++;
- if (_messageCount % 1000 == 0)
- {
- _logger.info("Received message total: " + _messageCount);
- _logger.info("Sending response to '" + responseQueue + "'");
- }
-
- String payload = "This is a response: sing together: 'Mahnah mahnah...'" + tm.getText();
- TextMessage msg = qsession.createTextMessage(payload);
- if (tm.propertyExists("timeSent"))
- {
- _logger.info("timeSent property set on message");
- final long timeSent = tm.getLongProperty("timeSent");
- msg.setLongProperty("timeSent", timeSent);
- _logger.info("time taken to go from service request to provider is: " + (System.currentTimeMillis() - timeSent));
- }
- _destinationProducer.send(msg);
- if (_messageCount % 1000 == 0)
- {
- tm.acknowledge();
- _logger.info("Sent response to '" + responseQueue + "'");
- }
- }
- catch (JMSException e)
- {
- _logger.error("Error sending message: " + e, e);
- }
- }
- });
- qcon.start();
- }
- catch (Throwable t)
- {
- System.err.println("Fatal error: " + t);
- t.printStackTrace();
- }
-
-
- System.out.println("Waiting...");
- }
-
- private static InitialContext getInitialContext(String url) throws NamingException
- {
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
- env.put(Context.PROVIDER_URL, url);
- return new InitialContext(env);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/weblogic/ServiceRequestingClient.java b/java/client/src/test/java/org/apache/qpid/weblogic/ServiceRequestingClient.java
deleted file mode 100644
index a1e15258c3..0000000000
--- a/java/client/src/test/java/org/apache/qpid/weblogic/ServiceRequestingClient.java
+++ /dev/null
@@ -1,192 +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.weblogic;
-
-import org.apache.qpid.jms.*;
-import org.apache.log4j.Logger;
-
-import javax.naming.NamingException;
-import javax.naming.InitialContext;
-import javax.naming.Context;
-import javax.jms.*;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import java.util.Hashtable;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.Reader;
-import java.io.FileReader;
-
-/**
- * Created by IntelliJ IDEA.
- * User: U806869
- * Date: 28-May-2005
- * Time: 21:54:51
- * To change this template use File | Settings | File Templates.
- */
-public class ServiceRequestingClient
-{
- private static final Logger _log = Logger.getLogger(ServiceRequestingClient.class);
- private static final String JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";
- private static final String JMS_FACTORY = "transientJMSConnectionFactory";
-
- private static class CallbackHandler implements MessageListener
- {
- private int _expectedMessageCount;
-
- private int _actualMessageCount;
-
- private long _startTime;
-
- private long _averageLatency;
-
- public CallbackHandler(int expectedMessageCount, long startTime)
- {
- _expectedMessageCount = expectedMessageCount;
- _startTime = startTime;
- }
-
- public void onMessage(Message m)
- {
- if (_log.isDebugEnabled())
- {
- _log.debug("Message received: " + m);
- }
- try
- {
- if (m.propertyExists("timeSent"))
- {
- long timeSent = m.getLongProperty("timeSent");
- long now = System.currentTimeMillis();
- if (_averageLatency == 0)
- {
- _averageLatency = now - timeSent;
- _log.info("Latency " + _averageLatency);
- }
- else
- {
- _log.info("Individual latency: " + (now-timeSent));
- _averageLatency = (_averageLatency + (now - timeSent))/2;
- _log.info("Average latency now: " + _averageLatency);
- }
- }
- }
- catch (JMSException e)
- {
- _log.error("Could not calculate latency");
- }
-
- _actualMessageCount++;
- if (_actualMessageCount%1000 == 0)
- {
- try
- {
- m.acknowledge();
- }
- catch (JMSException e)
- {
- _log.error("Error acknowledging message");
- }
- _log.info("Received message count: " + _actualMessageCount);
- }
- /*if (!"henson".equals(m.toString()))
- {
- _log.error("Message response not correct: expected 'henson' but got " + m.toString());
- }
- else
- {
- if (_log.isDebugEnabled())
- {
- _log.debug("Message " + m + " received");
- }
- else
- {
- _log.info("Message received");
- }
- } */
-
- if (_actualMessageCount == _expectedMessageCount)
- {
- long timeTaken = System.currentTimeMillis() - _startTime;
- System.out.println("Total time taken to receive " + _expectedMessageCount+ " messages was " +
- timeTaken + "ms, equivalent to " +
- (_expectedMessageCount/(timeTaken/1000.0)) + " messages per second");
- System.out.println("Average latency is: " + _averageLatency);
- }
- }
- }
-
- public static void main(String[] args) throws Exception
- {
- if (args.length != 3)
- {
- System.out.println("Usage: IXPublisher <WLS URL> <sendQueue> <count> will publish count messages to ");
- System.out.println("queue sendQueue and waits for a response on a temp queue");
- System.exit(1);
- }
-
- String url = args[0];
- String sendQueue = args[1];
- int messageCount = Integer.parseInt(args[2]);
-
- InitialContext ctx = getInitialContext(url);
-
- QueueConnectionFactory qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
- QueueConnection qcon = qconFactory.createQueueConnection();
- QueueSession qsession = qcon.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
- Queue sendQ = (Queue) ctx.lookup(sendQueue);
- Queue receiveQ = qsession.createTemporaryQueue();
- QueueSender qsender = qsession.createSender(sendQ);
- qsender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- _log.debug("Queue sender created for service queue " + sendQ);
-
- javax.jms.MessageConsumer messageConsumer = (javax.jms.MessageConsumer) qsession.createConsumer(receiveQ);
-
- //TextMessage msg = _session.createTextMessage(tempDestination.getQueueName() + "/Presented to in conjunction with Mahnah Mahnah and the Snowths");
- final long startTime = System.currentTimeMillis();
-
- messageConsumer.setMessageListener(new CallbackHandler(messageCount, startTime));
- qcon.start();
- for (int i = 0; i < messageCount; i++)
- {
- TextMessage msg = qsession.createTextMessage("/Presented to in conjunction with Mahnah Mahnah and the Snowths:" + i);
- msg.setJMSReplyTo(receiveQ);
- if (i%1000 == 0)
- {
- long timeNow = System.currentTimeMillis();
- msg.setLongProperty("timeSent", timeNow);
- }
- qsender.send(msg);
- }
-
- new Thread("foo").start();
- //qsession.close();
- //qcon.close();
- }
-
- private static InitialContext getInitialContext(String url) throws NamingException
- {
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
- env.put(Context.PROVIDER_URL, url);
- return new InitialContext(env);
- }
-}