summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2006-11-24 14:07:34 +0000
committerRobert Greig <rgreig@apache.org>2006-11-24 14:07:34 +0000
commitfe364d0e50b10c8b2ee888a4abb84b47679e2a5f (patch)
tree3764f087e8d20cca06a83c349d6c16aafb1d3684
parent85b240b34441a1ba4a9937a3c06c16f52382754e (diff)
downloadqpid-python-fe364d0e50b10c8b2ee888a4abb84b47679e2a5f.tar.gz
Merge of client tests from trunk revision 478883
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/new_persistence@478886 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java30
-rw-r--r--java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindTopic.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/ack/DisconnectAndRedeliverTest.java209
-rw-r--r--java/client/src/test/java/org/apache/qpid/ack/UnitTests.java32
-rw-r--r--java/client/src/test/java/org/apache/qpid/basic/FieldTableKeyEnumeratorTest.java83
-rw-r--r--java/client/src/test/java/org/apache/qpid/basic/ReceiveTest.java80
-rw-r--r--java/client/src/test/java/org/apache/qpid/basic/UnitTests.java41
-rw-r--r--java/client/src/test/java/org/apache/qpid/client/AllClientUnitTests.java44
-rw-r--r--java/client/src/test/java/org/apache/qpid/client/channelclose/UnitTests.java34
-rw-r--r--java/client/src/test/java/org/apache/qpid/client/message/TestBytesMessage.java296
-rw-r--r--java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java41
-rw-r--r--java/client/src/test/java/org/apache/qpid/client/message/TestTextMessage.java51
-rw-r--r--java/client/src/test/java/org/apache/qpid/client/message/UnitTests.java32
-rw-r--r--java/client/src/test/java/org/apache/qpid/cluster/Client.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/codec/BasicDeliverTest.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/codec/Client.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/codec/Server.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/AMQConnectionFactoryInitialiser.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/AbstractConfig.java29
-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.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/ConnectorConfig.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/connection/ConnectionTest.java101
-rw-r--r--java/client/src/test/java/org/apache/qpid/connection/TestManyConnections.java99
-rw-r--r--java/client/src/test/java/org/apache/qpid/connectionurl/ConnectionURLTest.java449
-rw-r--r--java/client/src/test/java/org/apache/qpid/connectionurl/UnitTests.java33
-rwxr-xr-xjava/client/src/test/java/org/apache/qpid/cts/bin/jmscts.sh29
-rwxr-xr-xjava/client/src/test/java/org/apache/qpid/cts/bin/setenv.sh29
-rw-r--r--java/client/src/test/java/org/apache/qpid/cts/config/jmscts.policy17
-rw-r--r--java/client/src/test/java/org/apache/qpid/cts/config/jmscts.properties19
-rw-r--r--java/client/src/test/java/org/apache/qpid/cts/config/providers.xml29
-rwxr-xr-xjava/client/src/test/java/org/apache/qpid/cts/src/compile.sh29
-rw-r--r--java/client/src/test/java/org/apache/qpid/destinationurl/DestinationURLTest.java150
-rw-r--r--java/client/src/test/java/org/apache/qpid/destinationurl/UnitTests.java33
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/log4j.xml29
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java38
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactory.java23
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactoryException.java24
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java27
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/MonitorPublisher.java33
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/Publisher.java113
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/publisher/UndeliveredMessageException.java22
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/shared/ConnectionException.java24
-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.java22
-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.java23
-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.java69
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java26
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/subscriber/Subscriber.java176
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java26
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/test/TestAMSPubSub.java38
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/test/TestMultSubscribers.java34
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/test/TestPublisher.java27
-rw-r--r--java/client/src/test/java/org/apache/qpid/example/test/TestSubscriber.java24
-rw-r--r--java/client/src/test/java/org/apache/qpid/failover/FailoverBrokerTester.java270
-rw-r--r--java/client/src/test/java/org/apache/qpid/failover/FailoverMultiMethodTest.java258
-rw-r--r--java/client/src/test/java/org/apache/qpid/failover/FailoverRoundRobinTest.java233
-rw-r--r--java/client/src/test/java/org/apache/qpid/failover/FailoverSingleServerTest.java257
-rw-r--r--java/client/src/test/java/org/apache/qpid/failover/FailoverTest.java249
-rw-r--r--java/client/src/test/java/org/apache/qpid/failover/FailoverTxTest.java179
-rw-r--r--java/client/src/test/java/org/apache/qpid/flow/ChannelFlowTest.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/forwardall/Combined.java54
-rw-r--r--java/client/src/test/java/org/apache/qpid/forwardall/ServiceCreator.java74
-rw-r--r--java/client/src/test/java/org/apache/qpid/forwardall/SpecialQueue.java41
-rw-r--r--java/client/src/test/java/org/apache/qpid/forwardall/UnitTests.java34
-rw-r--r--java/client/src/test/java/org/apache/qpid/fragmentation/TestLargePublisher.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/fragmentation/TestLargeSubscriber.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java60
-rw-r--r--java/client/src/test/java/org/apache/qpid/headers/Listener.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/headers/Publisher.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/jndi/referenceable/Bind.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/jndi/referenceable/Lookup.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/jndi/referenceable/Unbind.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/JNDIReferenceableTest.java102
-rw-r--r--java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/UnitTests.java33
-rw-r--r--java/client/src/test/java/org/apache/qpid/latency/LatencyTest.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java48
-rw-r--r--java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java50
-rw-r--r--java/client/src/test/java/org/apache/qpid/mina/WriterTest.java323
-rw-r--r--java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java37
-rw-r--r--java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java40
-rw-r--r--java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java77
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java52
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java (renamed from java/client/src/test/java/org/apache/qpid/ack/RecoverTest.java)73
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java (renamed from java/client/src/test/java/org/apache/qpid/basic/BytesMessageTest.java)82
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java81
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java (renamed from java/client/src/test/java/org/apache/qpid/basic/FieldTableMessageTest.java)61
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java218
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java (renamed from java/client/src/test/java/org/apache/qpid/basic/MultipleConnectionTest.java)84
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java (renamed from java/client/src/test/java/org/apache/qpid/basic/ObjectMessageTest.java)98
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java115
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java (renamed from java/client/src/test/java/org/apache/qpid/basic/SessionStartTest.java)58
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java (renamed from java/client/src/test/java/org/apache/qpid/basic/TextMessageTest.java)100
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java205
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java119
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java (renamed from java/client/src/test/java/org/apache/qpid/client/channelclose/ChannelCloseOkTest.java)104
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java109
-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/connectionurl/ConnectionURLTest.java434
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java145
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/Client.java (renamed from java/client/src/test/java/org/apache/qpid/forwardall/Client.java)31
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java63
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/Service.java (renamed from java/client/src/test/java/org/apache/qpid/forwardall/Service.java)39
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/ServiceCreator.java106
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java44
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java433
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java357
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java (renamed from java/client/src/test/java/org/apache/qpid/client/message/ObjectMessageTest.java)112
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java54
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java122
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/TestIoSession.java99
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java119
-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.java (renamed from java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/Bind.java)108
-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.java (renamed from java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/Lookup.java)85
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java (renamed from java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/Unbind.java)62
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java (renamed from java/client/src/test/java/org/apache/qpid/topic/DurableSubscriptionTest.java)102
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java147
-rw-r--r--java/client/src/test/java/org/apache/qpid/testutil/Config.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/topic/Config.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/topic/Listener.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/topic/MessageFactory.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/topic/Publisher.java32
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Config.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Ping.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Pong.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Relay.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/Start.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/TransactedTest.java159
-rw-r--r--java/client/src/test/java/org/apache/qpid/transacted/UnitTests.java32
-rw-r--r--java/client/src/test/java/org/apache/qpid/weblogic/ServiceProvider.java29
-rw-r--r--java/client/src/test/java/org/apache/qpid/weblogic/ServiceRequestingClient.java29
145 files changed, 5679 insertions, 5524 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
index 038be976ad..842b2d7696 100644
--- a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java
+++ b/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index b90fc8b3cd..5f328a4107 100644
--- a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java
+++ b/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindQueue.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
@@ -23,7 +26,6 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQQueue;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
-import org.junit.Assert;
import javax.naming.Context;
import javax.naming.InitialContext;
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
index 2de58a2b17..c31dce22cf 100644
--- a/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindTopic.java
+++ b/java/client/src/test/java/org/apache/qpid/IBMPerfTest/JNDIBindTopic.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
diff --git a/java/client/src/test/java/org/apache/qpid/ack/DisconnectAndRedeliverTest.java b/java/client/src/test/java/org/apache/qpid/ack/DisconnectAndRedeliverTest.java
deleted file mode 100644
index 9e248cdfb8..0000000000
--- a/java/client/src/test/java/org/apache/qpid/ack/DisconnectAndRedeliverTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.ack;
-
-import junit.framework.JUnit4TestAdapter;
-import org.apache.log4j.Logger;
-import org.apache.log4j.xml.DOMConfigurator;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.store.TestableMemoryMessageStore;
-import org.apache.qpid.server.util.TestApplicationRegistry;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.jms.*;
-
-public class DisconnectAndRedeliverTest
-{
- private static final Logger _logger = Logger.getLogger(DisconnectAndRedeliverTest.class);
-
- static
- {
- //DOMConfigurator.configure("../etc/log4j.xml");
- DOMConfigurator.configure("broker/etc/log4j.xml");
- }
-
- @Before
- public void resetAppliactionRegistry() throws Exception
- {
- ApplicationRegistry.initialise(new TestApplicationRegistry());
- }
-
- @After
- public void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
- }
-
- /**
- * This tests that when there are unacknowledged messages on a channel they are requeued for delivery when
- * the channel is closed.
- *
- * @throws Exception
- */
- @Test
- public void disconnectRedeliversMessages() throws Exception
- {
- Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
-
- TestableMemoryMessageStore store = (TestableMemoryMessageStore) ApplicationRegistry.getInstance().getMessageStore();
-
- Session consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- AMQQueue queue = new AMQQueue("someQ", "someQ", false, false);
- MessageConsumer consumer = consumerSession.createConsumer(queue);
- //force synch to ensure the consumer has resulted in a bound queue
- ((AMQSession) consumerSession).declareExchangeSynch("amq.direct", "direct");
-
- Connection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "/test");
- Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- MessageProducer producer = producerSession.createProducer(queue);
-
- _logger.info("Sending four messages");
- producer.send(producerSession.createTextMessage("msg1"));
- producer.send(producerSession.createTextMessage("msg2"));
- producer.send(producerSession.createTextMessage("msg3"));
- producer.send(producerSession.createTextMessage("msg4"));
-
- con2.close();
-
- _logger.info("Starting connection");
- con.start();
- TextMessage tm = (TextMessage) consumer.receive();
- tm.acknowledge();
- _logger.info("Received and acknowledged first message");
- consumer.receive();
- consumer.receive();
- consumer.receive();
- _logger.info("Received all four messages. About to disconnect and reconnect");
-
- con.close();
- con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
- consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- consumer = consumerSession.createConsumer(queue);
-
- _logger.info("Starting second consumer connection");
- con.start();
-
- tm = (TextMessage) consumer.receive(3000);
- Assert.assertEquals("msg2", tm.getText());
-
-
- tm = (TextMessage) consumer.receive(3000);
- Assert.assertEquals("msg3", tm.getText());
-
-
- tm = (TextMessage) consumer.receive(3000);
- Assert.assertEquals("msg4", tm.getText());
-
- _logger.info("Received redelivery of three messages. Acknowledging last message");
- tm.acknowledge();
-
- con.close();
-
- con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
- consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- consumer = consumerSession.createConsumer(queue);
- _logger.info("Starting third consumer connection");
- con.start();
- tm = (TextMessage) consumer.receiveNoWait();
- Assert.assertNull(tm);
- _logger.info("No messages redelivered as is expected");
- con.close();
-
- con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
- consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- consumer = consumerSession.createConsumer(queue);
- _logger.info("Starting fourth consumer connection");
- con.start();
- tm = (TextMessage) consumer.receive(3000);
- Assert.assertNull(tm);
- _logger.info("No messages redelivered as is expected");
- con.close();
-
- _logger.info("Actually:" + store.getMessageMetaDataMap().size());
- // Assert.assertTrue(store.getMessageMap().size() == 0);
- }
-
- /**
- * Tests that unacknowledged messages are thrown away when the channel is closed and they cannot be
- * requeued (due perhaps to the queue being deleted).
- *
- * @throws Exception
- */
- @Test
- public void disconnectWithTransientQueueThrowsAwayMessages() throws Exception
- {
-
- Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
- TestableMemoryMessageStore store = (TestableMemoryMessageStore) ApplicationRegistry.getInstance().getMessageStore();
- Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- Queue queue = new AMQQueue("someQ", "someQ", false, true);
- MessageConsumer consumer = consumerSession.createConsumer(queue);
- //force synch to ensure the consumer has resulted in a bound queue
- ((AMQSession) consumerSession).declareExchangeSynch("amq.direct", "direct");
-
- Connection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "/test");
- Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- MessageProducer producer = producerSession.createProducer(queue);
-
- _logger.info("Sending four messages");
- producer.send(producerSession.createTextMessage("msg1"));
- producer.send(producerSession.createTextMessage("msg2"));
- producer.send(producerSession.createTextMessage("msg3"));
- producer.send(producerSession.createTextMessage("msg4"));
-
- con2.close();
-
- _logger.info("Starting connection");
- con.start();
- TextMessage tm = (TextMessage) consumer.receive();
- tm.acknowledge();
- _logger.info("Received and acknowledged first message");
- consumer.receive();
- consumer.receive();
- consumer.receive();
- _logger.info("Received all four messages. About to disconnect and reconnect");
-
- con.close();
- con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
- consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- consumer = consumerSession.createConsumer(queue);
-
- _logger.info("Starting second consumer connection");
- con.start();
-
- tm = (TextMessage) consumer.receiveNoWait();
- Assert.assertNull(tm);
- _logger.info("No messages redelivered as is expected");
-
- _logger.info("Actually:" + store.getMessageMetaDataMap().size());
- Assert.assertTrue(store.getMessageMetaDataMap().size() == 0);
- con.close();
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(DisconnectAndRedeliverTest.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/ack/UnitTests.java b/java/client/src/test/java/org/apache/qpid/ack/UnitTests.java
deleted file mode 100644
index 5caaff69cf..0000000000
--- a/java/client/src/test/java/org/apache/qpid/ack/UnitTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.ack;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({DisconnectAndRedeliverTest.class, RecoverTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/basic/FieldTableKeyEnumeratorTest.java b/java/client/src/test/java/org/apache/qpid/basic/FieldTableKeyEnumeratorTest.java
deleted file mode 100644
index 08ff65ea29..0000000000
--- a/java/client/src/test/java/org/apache/qpid/basic/FieldTableKeyEnumeratorTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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 org.junit.Test;
-import org.junit.Assert;
-import org.apache.qpid.framing.FieldTable;
-
-
-import java.util.Enumeration;
-
-import junit.framework.JUnit4TestAdapter;
-
-import javax.jms.JMSException;
-
-public class FieldTableKeyEnumeratorTest
-{
- @Test
- public void testKeyEnumeration()
- {
- FieldTable result = new FieldTable();
- result.put("one", 1L);
- result.put("two", 2L);
- result.put("three", 3L);
- result.put("four", 4L);
- result.put("five", 5L);
-
- Enumeration e = result.keys();
-
- Assert.assertTrue("one".equals(e.nextElement()));
- Assert.assertTrue("two".equals(e.nextElement()));
- Assert.assertTrue("three".equals(e.nextElement()));
- Assert.assertTrue("four".equals(e.nextElement()));
- Assert.assertTrue("five".equals(e.nextElement()));
- }
-
- @Test
- public void testPropertEnu()
- {
- try
- {
- JMSTextMessage text = new JMSTextMessage();
-
- text.setBooleanProperty("Boolean1", true);
- text.setBooleanProperty("Boolean2", true);
- text.setIntProperty("Int", 2);
- text.setLongProperty("Long", 2);
-
- Enumeration e = text.getPropertyNames();
-
- Assert.assertTrue("Boolean1".equals(e.nextElement()));
- Assert.assertTrue("Boolean2".equals(e.nextElement()));
- Assert.assertTrue("Int".equals(e.nextElement()));
- Assert.assertTrue("Long".equals(e.nextElement()));
- }
- catch (JMSException e)
- {
-
- }
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(FieldTableKeyEnumeratorTest.class);
- }
-
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/basic/ReceiveTest.java b/java/client/src/test/java/org/apache/qpid/basic/ReceiveTest.java
deleted file mode 100644
index d72d748935..0000000000
--- a/java/client/src/test/java/org/apache/qpid/basic/ReceiveTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.basic;
-
-import junit.framework.JUnit4TestAdapter;
-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 org.junit.Before;
-import org.junit.Test;
-
-import javax.jms.MessageConsumer;
-
-public class ReceiveTest
-{
- private AMQConnection _connection;
- private AMQDestination _destination;
- private AMQSession _session;
- private MessageConsumer _consumer;
-
- public String _connectionString = "vm://:1";
-
- @Before
- public void init() throws Exception
- {
- String broker = _connectionString;
- init(new AMQConnection(broker, "guest", "guest", "ReceiveTestClient", "/test_path"));
- }
-
- private void init(AMQConnection connection) throws Exception
- {
- init(connection, new AMQQueue("ReceiveTest", true));
- }
-
- private void init(AMQConnection connection, AMQDestination destination) throws Exception
- {
- _connection = connection;
- _destination = destination;
- _session = (AMQSession) connection.createSession(true, AMQSession.NO_ACKNOWLEDGE);
- _consumer = _session.createConsumer(_destination);
- _connection.start();
- }
-
- @Test
- public void test() throws Exception
- {
- _consumer.receive(5000);
- _connection.close();
- }
-
- public static void main(String[] argv) throws Exception
- {
- ReceiveTest test = new ReceiveTest();
- test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
- test.init();
- test.test();
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(ReceiveTest.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/basic/UnitTests.java b/java/client/src/test/java/org/apache/qpid/basic/UnitTests.java
deleted file mode 100644
index b87254f73a..0000000000
--- a/java/client/src/test/java/org/apache/qpid/basic/UnitTests.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.basic;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.apache.qpid.client.message.FieldTableKeyEnumeratorTest;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- BytesMessageTest.class,
- FieldTableMessageTest.class,
- FieldTableKeyEnumeratorTest.class,
- MultipleConnectionTest.class,
- ObjectMessageTest.class,
- SessionStartTest.class,
- TextMessageTest.class
- })
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/client/AllClientUnitTests.java b/java/client/src/test/java/org/apache/qpid/client/AllClientUnitTests.java
deleted file mode 100644
index 0ecd715284..0000000000
--- a/java/client/src/test/java/org/apache/qpid/client/AllClientUnitTests.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.qpid.client;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * All client unit tests - even one in packages like org.apache.qpid.ack.
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- org.apache.qpid.ack.UnitTests.class,
- org.apache.qpid.basic.UnitTests.class,
- org.apache.qpid.client.channelclose.UnitTests.class,
- org.apache.qpid.client.message.UnitTests.class,
- org.apache.qpid.forwardall.UnitTests.class,
- org.apache.qpid.destinationurl.UnitTests.class,
- org.apache.qpid.jndi.referenceabletest.UnitTests.class,
- org.apache.qpid.transacted.UnitTests.class
- })
-public class AllClientUnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(AllClientUnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/client/channelclose/UnitTests.java b/java/client/src/test/java/org/apache/qpid/client/channelclose/UnitTests.java
deleted file mode 100644
index ed98bc0c30..0000000000
--- a/java/client/src/test/java/org/apache/qpid/client/channelclose/UnitTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.channelclose;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- ChannelCloseOkTest.class
- })
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/client/message/TestBytesMessage.java b/java/client/src/test/java/org/apache/qpid/client/message/TestBytesMessage.java
deleted file mode 100644
index 03bb65081f..0000000000
--- a/java/client/src/test/java/org/apache/qpid/client/message/TestBytesMessage.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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 junit.framework.JUnit4TestAdapter;
-import org.junit.Test;
-import org.junit.Assert;
-
-import javax.jms.MessageNotReadableException;
-import javax.jms.MessageNotWriteableException;
-import javax.jms.MessageEOFException;
-
-public class TestBytesMessage
-{
- /**
- * Tests that on creation a call to getBodyLength() throws an exception
- * if null was passed in during creation
- */
- @Test(expected=MessageNotReadableException.class)
- public void testNotReadableOnCreationWithNull() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.getBodyLength();
- }
-
- @Test(expected= MessageNotWriteableException.class)
- public void testResetMakesReadble() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeInt(10);
- bm.reset();
- bm.writeInt(12);
- }
-
- @Test
- public void testClearBodyMakesWritable() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeInt(10);
- bm.reset();
- bm.clearBody();
- bm.writeInt(10);
- }
-
- @Test
- public void testWriteInt() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeInt(10);
- bm.reset();
- long len = bm.getBodyLength();
- Assert.assertTrue(len == 4);
- int val = bm.readInt();
- Assert.assertTrue(val == 10);
- }
-
- @Test
- public void testWriteString() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeUTF("Bananas");
- bm.reset();
- String res = bm.readUTF();
- Assert.assertEquals("Bananas", res);
- }
-
- @Test(expected=NullPointerException.class)
- public void testWriteObjectThrowsNPE() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeObject(null);
- }
-
- @Test
- public void testReadBoolean() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeBoolean(true);
- bm.reset();
- boolean result = bm.readBoolean();
- Assert.assertTrue(result);
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFByte() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeByte((byte)1);
- bm.reset();
- bm.readByte();
- // should throw
- bm.readByte();
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFUnsignedByte() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeByte((byte)1);
- bm.reset();
- bm.readByte();
- // should throw
- bm.readUnsignedByte();
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFBoolean() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeBoolean(true);
- bm.reset();
- bm.readBoolean();
- // should throw
- bm.readBoolean();
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFChar() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeChar('A');
- bm.reset();
- bm.readChar();
- // should throw
- bm.readChar();
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFDouble() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeDouble(1.3d);
- bm.reset();
- bm.readDouble();
- // should throw
- bm.readDouble();
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFFloat() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeFloat(1.3f);
- bm.reset();
- bm.readFloat();
- // should throw
- bm.readFloat();
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFInt() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeInt(99);
- bm.reset();
- bm.readInt();
- // should throw
- bm.readInt();
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFLong() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeLong(4L);
- bm.reset();
- bm.readLong();
- // should throw
- bm.readLong();
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFShort() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeShort((short)4);
- bm.reset();
- bm.readShort();
- // should throw
- bm.readShort();
- }
-
- @Test(expected=MessageEOFException.class)
- public void testEOFUnsignedShort() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeShort((short)4);
- bm.reset();
- bm.readUnsignedShort();
- // should throw
- bm.readUnsignedShort();
- }
-
- /**
- * Tests that the readBytes() method populates the passed in array
- * correctly
- * @throws Exception
- */
- @Test
- public void testReadBytes() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeByte((byte)3);
- bm.writeByte((byte)4);
- bm.reset();
- byte[] result = new byte[2];
- int count = bm.readBytes(result);
- Assert.assertEquals((byte)3, result[0]);
- Assert.assertEquals((byte)4, result[1]);
- Assert.assertEquals(2, count);
- }
-
- @Test
- public void testReadBytesEOF() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeByte((byte)3);
- bm.writeByte((byte)4);
- bm.reset();
- byte[] result = new byte[2];
- bm.readBytes(result);
- int count = bm.readBytes(result);
- Assert.assertEquals(-1, count);
- }
-
- @Test
- public void testReadBytesWithLargerArray() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeByte((byte)3);
- bm.writeByte((byte)4);
- bm.reset();
- byte[] result = new byte[3];
- int count = bm.readBytes(result);
- Assert.assertEquals(2, count);
- Assert.assertEquals((byte)3, result[0]);
- Assert.assertEquals((byte)4, result[1]);
- Assert.assertEquals((byte)0, result[2]);
- }
-
- @Test
- public void testReadBytesWithCount() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.writeByte((byte)3);
- bm.writeByte((byte)4);
- bm.writeByte((byte)5);
- bm.reset();
- byte[] result = new byte[3];
- int count = bm.readBytes(result, 2);
- Assert.assertEquals(2, count);
- Assert.assertEquals((byte)3, result[0]);
- Assert.assertEquals((byte)4, result[1]);
- Assert.assertEquals((byte)0, result[2]);
- }
-
- @Test
- public void testToBodyString() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- final String testText = "This is a test";
- bm.writeUTF(testText);
- bm.reset();
- String result = bm.toBodyString();
- Assert.assertEquals(testText, result);
- }
-
- @Test
- public void testToBodyStringWithNull() throws Exception
- {
- JMSBytesMessage bm = new JMSBytesMessage();
- bm.reset();
- String result = bm.toBodyString();
- Assert.assertNull(result);
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(TestBytesMessage.class);
- }
-}
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
new file mode 100644
index 0000000000..c34dbf14f1
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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();
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/client/message/TestTextMessage.java b/java/client/src/test/java/org/apache/qpid/client/message/TestTextMessage.java
deleted file mode 100644
index 766f47d841..0000000000
--- a/java/client/src/test/java/org/apache/qpid/client/message/TestTextMessage.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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 junit.framework.JUnit4TestAdapter;
-import org.junit.Test;
-import org.junit.Assert;
-
-public class TestTextMessage
-{
- @Test
- public void testTextOnConstruction() throws Exception
- {
- JMSTextMessage tm = new JMSTextMessage();
- tm.setText("pies");
- String val = tm.getText();
- Assert.assertEquals(val, "pies");
- }
-
- @Test
- public void testClearBody() throws Exception
- {
- JMSTextMessage tm = new JMSTextMessage();
- tm.setText("pies");
- tm.clearBody();
- String val = tm.getText();
- Assert.assertNull(val);
- tm.setText("Banana");
- val = tm.getText();
- Assert.assertEquals(val, "Banana");
- }
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(TestTextMessage.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/client/message/UnitTests.java b/java/client/src/test/java/org/apache/qpid/client/message/UnitTests.java
deleted file mode 100644
index 889c437df3..0000000000
--- a/java/client/src/test/java/org/apache/qpid/client/message/UnitTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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 junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({TestBytesMessage.class, TestTextMessage.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
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
index 1d12f157b9..7a413eee3d 100644
--- a/java/client/src/test/java/org/apache/qpid/cluster/Client.java
+++ b/java/client/src/test/java/org/apache/qpid/cluster/Client.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 4dd67c48d9..892b349cea 100644
--- a/java/client/src/test/java/org/apache/qpid/codec/BasicDeliverTest.java
+++ b/java/client/src/test/java/org/apache/qpid/codec/BasicDeliverTest.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 3118aa8539..c0de5ab133 100644
--- a/java/client/src/test/java/org/apache/qpid/codec/Client.java
+++ b/java/client/src/test/java/org/apache/qpid/codec/Client.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 772424e002..fa4295e0b2 100644
--- a/java/client/src/test/java/org/apache/qpid/codec/Server.java
+++ b/java/client/src/test/java/org/apache/qpid/codec/Server.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 7c208e4cc4..cac0064785 100644
--- a/java/client/src/test/java/org/apache/qpid/config/AMQConnectionFactoryInitialiser.java
+++ b/java/client/src/test/java/org/apache/qpid/config/AMQConnectionFactoryInitialiser.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 9b1bf88497..04381d66a0 100644
--- a/java/client/src/test/java/org/apache/qpid/config/AbstractConfig.java
+++ b/java/client/src/test/java/org/apache/qpid/config/AbstractConfig.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index a5599c8e58..a9984eb09a 100644
--- a/java/client/src/test/java/org/apache/qpid/config/ConnectionFactoryInitialiser.java
+++ b/java/client/src/test/java/org/apache/qpid/config/ConnectionFactoryInitialiser.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index a3b93aad22..ff2377f087 100644
--- a/java/client/src/test/java/org/apache/qpid/config/Connector.java
+++ b/java/client/src/test/java/org/apache/qpid/config/Connector.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 8921d579a6..b120ed3f12 100644
--- a/java/client/src/test/java/org/apache/qpid/config/ConnectorConfig.java
+++ b/java/client/src/test/java/org/apache/qpid/config/ConnectorConfig.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 60e358056f..44285efd96 100644
--- a/java/client/src/test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java
+++ b/java/client/src/test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
diff --git a/java/client/src/test/java/org/apache/qpid/connection/ConnectionTest.java b/java/client/src/test/java/org/apache/qpid/connection/ConnectionTest.java
deleted file mode 100644
index e86d238dc4..0000000000
--- a/java/client/src/test/java/org/apache/qpid/connection/ConnectionTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.connection;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQAuthenticationException;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.AMQConnectionException;
-import org.apache.qpid.AMQUnresolvedAddressException;
-import org.junit.Test;
-import org.junit.Assert;
-
-import javax.jms.Connection;
-
-import junit.framework.JUnit4TestAdapter;
-
-public class ConnectionTest
-{
- @Test
- public void simpleConnection() throws Exception
- {
- Connection connection = new AMQConnection("localhost:5672", "guest", "guest",
- "fred", "/test");
- System.out.println("connection = " + connection);
- }
-
- @Test
- public void passwordFailureConnection() throws Exception
- {
- try
- {
- new AMQConnection("amqp://guest:rubbishpassword@clientid/testpath?brokerlist='tcp://localhost:5672?retries='1''");
- Assert.fail("Connection should not be established");
- }
- catch (AMQException amqe)
- {
- if (!(amqe instanceof AMQAuthenticationException))
- {
- Assert.fail("Correct exception not thrown");
- }
- }
- }
-
- @Test
- public void connectionFailure() throws Exception
- {
- try
- {
- new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:5673?retries='0''");
- Assert.fail("Connection should not be established");
- }
- catch (AMQException amqe)
- {
- if (!(amqe instanceof AMQConnectionException))
- {
- Assert.fail("Correct exception not thrown");
- }
- }
- }
-
- @Test
- public void unresolvedHostFailure() throws Exception
- {
- try
- {
- new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='tcp://rubbishhost:5672?retries='0''");
- Assert.fail("Connection should not be established");
- }
- catch (AMQException amqe)
- {
- if (!(amqe instanceof AMQUnresolvedAddressException))
- {
- Assert.fail("Correct exception not thrown");
- }
- }
- }
-
- /**
- * For Junit 3 compatibility.
- */
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(ConnectionTest.class);
- }
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/connection/TestManyConnections.java b/java/client/src/test/java/org/apache/qpid/connection/TestManyConnections.java
deleted file mode 100644
index 4456037c2e..0000000000
--- a/java/client/src/test/java/org/apache/qpid/connection/TestManyConnections.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.connection;
-
-import junit.framework.JUnit4TestAdapter;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.log4j.Logger;
-import org.junit.Test;
-
-public class TestManyConnections
-{
- 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");
- }
-
- @Test
- public void create10Connections() throws AMQException, URLSyntaxException
- {
- createConnections(10);
- }
-
- @Test
- public void create50Connections() throws AMQException, URLSyntaxException
- {
- createConnections(50);
- }
-
- @Test
- public void create100Connections() throws AMQException, URLSyntaxException
- {
- createConnections(100);
- }
-
- @Test
- public void create250Connections() throws AMQException, URLSyntaxException
- {
- createConnections(250);
- }
-
- @Test
- public void create500Connections() throws AMQException, URLSyntaxException
- {
- createConnections(500);
- }
-
- @Test
- public void create1000Connections() throws AMQException, URLSyntaxException
- {
- createConnections(1000);
- }
-
- @Test
- public void create5000Connections() throws AMQException, URLSyntaxException
- {
- createConnections(5000);
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(TestManyConnections.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/connectionurl/ConnectionURLTest.java b/java/client/src/test/java/org/apache/qpid/connectionurl/ConnectionURLTest.java
deleted file mode 100644
index cc8442af90..0000000000
--- a/java/client/src/test/java/org/apache/qpid/connectionurl/ConnectionURLTest.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.connectionurl;
-
-import org.junit.Test;
-import org.junit.Assert;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.client.AMQBrokerDetails;
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.jms.BrokerDetails;
-import org.apache.qpid.url.URLSyntaxException;
-import junit.framework.JUnit4TestAdapter;
-
-public class ConnectionURLTest
-{
- @Test
- public void failoverURL() throws URLSyntaxException
- {
- String url = "amqp://ritchiem:bob@/temp?brokerlist='tcp://localhost:5672;tcp://fancyserver:3000/',failover='roundrobin'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
- Assert.assertTrue(connectionurl.getFailoverMethod().equals("roundrobin"));
- Assert.assertTrue(connectionurl.getUsername().equals("ritchiem"));
- Assert.assertTrue(connectionurl.getPassword().equals("bob"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 2);
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
-
- service = connectionurl.getBrokerDetails(1);
-
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("fancyserver"));
- Assert.assertTrue(service.getPort() == 3000);
-
- }
-
- @Test
- public void singleTransportUsernamePasswordURL() throws URLSyntaxException
- {
- String url = "amqp://ritchiem:bob@/temp?brokerlist='tcp://localhost:5672'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("ritchiem"));
- Assert.assertTrue(connectionurl.getPassword().equals("bob"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
- }
-
- @Test
- public void singleTransportUsernameBlankPasswordURL() throws URLSyntaxException
- {
- String url = "amqp://ritchiem:@/temp?brokerlist='tcp://localhost:5672'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("ritchiem"));
- Assert.assertTrue(connectionurl.getPassword().equals(""));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
- }
-
- @Test
- public void failedURLNullPassword()
- {
- String url = "amqp://ritchiem@/temp?brokerlist='tcp://localhost:5672'";
-
- try
- {
- new AMQConnectionURL(url);
- Assert.fail("URL has null password");
- }
- catch (URLSyntaxException e)
- {
- Assert.assertTrue(e.getReason().equals("Null password in user information not allowed."));
- Assert.assertTrue(e.getIndex() == 7);
- }
- }
-
-
- @Test
- public void singleTransportURL() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
-
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/test"));
-
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
-
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
- }
-
- @Test
- public void singleTransportWithClientURLURL() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@clientname/temp?brokerlist='tcp://localhost:5672'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
-
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
- Assert.assertTrue(connectionurl.getClientName().equals("clientname"));
-
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
-
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("tcp"));
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
- }
-
- @Test
- public void singleTransport1OptionURL() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@/temp?brokerlist='tcp://localhost:5672',routingkey='jim'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
-
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("tcp"));
-
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
- Assert.assertTrue(connectionurl.getOption("routingkey").equals("jim"));
- }
-
- @Test
- public void singleTransportDefaultedBroker() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@/temp?brokerlist='localhost'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
-
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("tcp"));
-
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
- }
-
-
- @Test
- public void singleTransportMultiOptionURL() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@/temp?brokerlist='tcp://localhost:5672',routingkey='jim',timeout='200',immediatedelivery='true'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("tcp"));
-
- Assert.assertTrue(service.getHost().equals("localhost"));
- Assert.assertTrue(service.getPort() == 5672);
-
- Assert.assertTrue(connectionurl.getOption("routingkey").equals("jim"));
- Assert.assertTrue(connectionurl.getOption("timeout").equals("200"));
- Assert.assertTrue(connectionurl.getOption("immediatedelivery").equals("true"));
- }
-
- @Test
- public void singlevmURL() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@/messages?brokerlist='vm://:2'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
- Assert.assertTrue(connectionurl.getFailoverMethod() == null);
- Assert.assertTrue(connectionurl.getUsername().equals("guest"));
- Assert.assertTrue(connectionurl.getPassword().equals("guest"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/messages"));
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("vm"));
- Assert.assertTrue(service.getHost().equals(""));
- Assert.assertTrue(service.getPort() == 2);
-
- }
-
- @Test
- public void failoverVMURL() throws URLSyntaxException
- {
- String url = "amqp://ritchiem:bob@/temp?brokerlist='vm://:2;vm://:3',failover='roundrobin'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
- Assert.assertTrue(connectionurl.getFailoverMethod().equals("roundrobin"));
- Assert.assertTrue(connectionurl.getUsername().equals("ritchiem"));
- Assert.assertTrue(connectionurl.getPassword().equals("bob"));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/temp"));
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 2);
-
- BrokerDetails service = connectionurl.getBrokerDetails(0);
-
- Assert.assertTrue(service.getTransport().equals("vm"));
- Assert.assertTrue(service.getHost().equals(""));
- Assert.assertTrue(service.getPort() == 2);
-
- service = connectionurl.getBrokerDetails(1);
- Assert.assertTrue(service.getTransport().equals("vm"));
- Assert.assertTrue(service.getHost().equals(""));
- Assert.assertTrue(service.getPort() == 3);
- }
-
-
- @Test
- public void noVirtualHostURL()
- {
- String url = "amqp://user@?brokerlist='tcp://localhost:5672'";
-
- try
- {
- new AMQConnectionURL(url);
- Assert.fail("URL has no virtual host should not parse");
- }
- catch (URLSyntaxException e)
- {
- // This should occur.
- }
- }
-
- @Test
- public void noClientID() throws URLSyntaxException
- {
- String url = "amqp://user:@/test?brokerlist='tcp://localhost:5672'";
-
- ConnectionURL connectionurl = new AMQConnectionURL(url);
-
- Assert.assertTrue(connectionurl.getUsername().equals("user"));
- Assert.assertTrue(connectionurl.getPassword().equals(""));
- Assert.assertTrue(connectionurl.getVirtualHost().equals("/test"));
-
- Assert.assertTrue(connectionurl.getBrokerCount() == 1);
- }
-
- @Test
- public void wrongOptionSeperatorInBroker()
- {
- String url = "amqp://user:@/test?brokerlist='tcp://localhost:5672+option='value''";
-
- try
- {
- new AMQConnectionURL(url);
-
- Float version = Float.parseFloat(System.getProperty("java.specification.version"));
- if (version > 1.5)
- {
- Assert.fail("URL Should not parse on Java 1.6 or greater");
- }
- }
- catch (URLSyntaxException urise)
- {
- Assert.assertTrue(urise.getReason().equals("Illegal character in port number"));
- }
-
- }
-
- @Test
- public void wrongOptionSeperatorInOptions()
- {
- String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'+failover='roundrobin'";
- try
- {
- new AMQConnectionURL(url);
- Assert.fail("URL Should not parse");
- }
- catch (URLSyntaxException urise)
- {
- Assert.assertTrue(urise.getReason().equals("Unterminated option. Possible illegal option separator:'+'"));
- }
-
- }
-
- @Test
- public void transportsDefaultToTCP() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@/test?brokerlist='localhost:5672;myhost:5673'&failover='roundrobin'";
-
- AMQConnectionURL connection = new AMQConnectionURL(url);
-
- BrokerDetails broker = connection.getBrokerDetails(0);
- Assert.assertTrue(broker.getTransport().equals("tcp"));
-
- broker = connection.getBrokerDetails(1);
- Assert.assertTrue(broker.getTransport().equals("tcp"));
- }
-
- @Test
- public void noUserDetailsProvidedWithClientID()
-
- {
- String url = "amqp://clientID/test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'";
- try
- {
- new AMQConnectionURL(url);
- Assert.fail("URL Should not parse");
- }
- catch (URLSyntaxException urise)
- {
- Assert.assertTrue(urise.getMessage().startsWith("User information not found on url"));
- }
-
- }
-
- @Test
- public void noUserDetailsProvidedNOClientID()
-
- {
- String url = "amqp:///test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'";
- try
- {
- new AMQConnectionURL(url);
- Assert.fail("URL Should not parse");
- }
- catch (URLSyntaxException urise)
- {
- Assert.assertTrue(urise.getMessage().startsWith("User information not found on url"));
- }
-
- }
-
- @Test
- public void checkVirtualhostFormat() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@/t.-_+!=:?brokerlist='tcp://localhost:5672'";
-
- AMQConnectionURL connection = new AMQConnectionURL(url);
- Assert.assertTrue(connection.getVirtualHost().equals("/t.-_+!=:"));
- }
-
- @Test
- public void checkDefaultPort() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@/test=:?brokerlist='tcp://localhost'";
-
- AMQConnectionURL connection = new AMQConnectionURL(url);
-
- BrokerDetails broker = connection.getBrokerDetails(0);
- Assert.assertTrue(broker.getPort() == AMQBrokerDetails.DEFAULT_PORT);
-
- }
-
- @Test
- public void checkMissingFinalQuote() throws URLSyntaxException
- {
- String url = "amqp://guest:guest@id/test" + "?brokerlist='tcp://localhost:5672";
-
- try{
- new AMQConnectionURL(url);
- }catch(URLSyntaxException e)
- {
- Assert.assertEquals(e.getMessage(),"Unterminated option at index 32: brokerlist='tcp://localhost:5672");
- }
-
-
-
- }
-
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(ConnectionURLTest.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/connectionurl/UnitTests.java b/java/client/src/test/java/org/apache/qpid/connectionurl/UnitTests.java
deleted file mode 100644
index f4f269330e..0000000000
--- a/java/client/src/test/java/org/apache/qpid/connectionurl/UnitTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.connectionurl;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.apache.qpid.ack.*;
-import junit.framework.JUnit4TestAdapter;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ConnectionURLTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(org.apache.qpid.connectionurl.UnitTests.class);
- }
-}
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
index 5786e0d689..37b8018aaf 100755
--- 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
@@ -1,18 +1,21 @@
#!/bin/sh
#
-# Copyright (c) 2006 The Apache Software Foundation
-#
-# Licensed 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.
+# 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.
#
# -----------------------------------------------------------------------------
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
index 17cbfb8d11..9b9189d646 100755
--- 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
@@ -1,17 +1,20 @@
#
-# Copyright (c) 2006 The Apache Software Foundation
-#
-# Licensed 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.
+# 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.
#
# ---------------------------------------------------------------------------
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
index 6acd889dc4..ff8b5db5ec 100644
--- 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
@@ -1,3 +1,20 @@
+// 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 {
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
index eccb1fd411..7177fed49d 100644
--- 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
@@ -1,3 +1,22 @@
+#
+# 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
# -----------------------------------------------------------------------------
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
index eea1f334cc..30c4a39c5b 100644
--- 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
@@ -1,19 +1,22 @@
<?xml version="1.0"?>
<!--
-
- - Copyright (c) 2006 The Apache Software Foundation
- -
- - Licensed 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.
+ - 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.
-
-->
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
index c5877e7927..7b8a9f03ec 100755
--- 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
@@ -1,18 +1,21 @@
#!/bin/sh
#
-# Copyright (c) 2006 The Apache Software Foundation
-#
-# Licensed 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.
+# 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.
#
diff --git a/java/client/src/test/java/org/apache/qpid/destinationurl/DestinationURLTest.java b/java/client/src/test/java/org/apache/qpid/destinationurl/DestinationURLTest.java
deleted file mode 100644
index 8369fa9e75..0000000000
--- a/java/client/src/test/java/org/apache/qpid/destinationurl/DestinationURLTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.destinationurl;
-
-import org.junit.Test;
-import org.junit.Assert;
-import org.apache.qpid.url.AMQBindingURL;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.exchange.ExchangeDefaults;
-import junit.framework.JUnit4TestAdapter;
-
-public class DestinationURLTest
-{
- @Test
- public void fullURL() throws URLSyntaxException
- {
-
- String url = "exchange.Class://exchangeName/Destination/Queue";
-
- AMQBindingURL dest = new AMQBindingURL(url);
-
- Assert.assertTrue(url.equals(dest.toString()));
-
- Assert.assertTrue(dest.getExchangeClass().equals("exchange.Class"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals("Destination"));
- Assert.assertTrue(dest.getQueueName().equals("Queue"));
- }
-
- @Test
- public void queue() throws URLSyntaxException
- {
-
- String url = "exchangeClass://exchangeName//Queue";
-
- AMQBindingURL dest = new AMQBindingURL(url);
-
- Assert.assertTrue(url.equals(dest.toString()));
-
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals(""));
- Assert.assertTrue(dest.getQueueName().equals("Queue"));
- }
-
- @Test
- public void queueWithOption() throws URLSyntaxException
- {
-
- String url = "exchangeClass://exchangeName//Queue?option='value'";
-
- AMQBindingURL dest = new AMQBindingURL(url);
-
- Assert.assertTrue(url.equals(dest.toString()));
-
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals(""));
- Assert.assertTrue(dest.getQueueName().equals("Queue"));
- Assert.assertTrue(dest.getOption("option").equals("value"));
- }
-
-
- @Test
- public void destination() throws URLSyntaxException
- {
-
- String url = "exchangeClass://exchangeName/Destination/";
-
- AMQBindingURL dest = new AMQBindingURL(url);
-
- Assert.assertTrue(url.equals(dest.toString()));
-
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals("Destination"));
- Assert.assertTrue(dest.getQueueName().equals(""));
- }
-
- @Test
- public void destinationWithOption() throws URLSyntaxException
- {
-
- String url = "exchangeClass://exchangeName/Destination/?option='value'";
-
- AMQBindingURL dest = new AMQBindingURL(url);
-
- Assert.assertTrue(url.equals(dest.toString()));
-
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals("Destination"));
- Assert.assertTrue(dest.getQueueName().equals(""));
-
- Assert.assertTrue(dest.getOption("option").equals("value"));
- }
-
- @Test
- public void destinationWithMultiOption() throws URLSyntaxException
- {
-
- String url = "exchangeClass://exchangeName/Destination/?option='value',option2='value2'";
-
- AMQBindingURL dest = new AMQBindingURL(url);
-
- Assert.assertTrue(dest.getExchangeClass().equals("exchangeClass"));
- Assert.assertTrue(dest.getExchangeName().equals("exchangeName"));
- Assert.assertTrue(dest.getDestinationName().equals("Destination"));
- Assert.assertTrue(dest.getQueueName().equals(""));
-
- Assert.assertTrue(dest.getOption("option").equals("value"));
- Assert.assertTrue(dest.getOption("option2").equals("value2"));
- }
-
- @Test
- public void destinationWithNoExchangeDefaultsToDirect() throws URLSyntaxException
- {
-
- String url = "IBMPerfQueue1?durable='true'";
-
- AMQBindingURL dest = new AMQBindingURL(url);
-
- Assert.assertTrue(dest.getExchangeClass().equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS));
- Assert.assertTrue(dest.getExchangeName().equals(ExchangeDefaults.DIRECT_EXCHANGE_NAME));
- Assert.assertTrue(dest.getDestinationName().equals(""));
- Assert.assertTrue(dest.getQueueName().equals("IBMPerfQueue1"));
-
- Assert.assertTrue(dest.getOption("durable").equals("true"));
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(DestinationURLTest.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/destinationurl/UnitTests.java b/java/client/src/test/java/org/apache/qpid/destinationurl/UnitTests.java
deleted file mode 100644
index 12760aef94..0000000000
--- a/java/client/src/test/java/org/apache/qpid/destinationurl/UnitTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.destinationurl;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.apache.qpid.ack.*;
-import junit.framework.JUnit4TestAdapter;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({DestinationURLTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(org.apache.qpid.destinationurl.UnitTests.class);
- }
-}
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
index e537b1796d..de64423a51 100644
--- a/java/client/src/test/java/org/apache/qpid/example/log4j.xml
+++ b/java/client/src/test/java/org/apache/qpid/example/log4j.xml
@@ -1,19 +1,22 @@
<?xml version="1.0"?>
<!--
-
- - Copyright (c) 2006 The Apache Software Foundation
- -
- - Licensed 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.
+ - 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">
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
index 4dd58cf4a1..ca3e5ce3f5 100644
--- 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
@@ -1,3 +1,21 @@
+/*
+ * 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;
@@ -12,11 +30,7 @@ import javax.jms.JMSException;
/**
* Class that sends message files to the Publisher to distribute
* using files as input
- * Must set system properties for host etc or amend and use config props
- * Author: Marnie McCormack
- * Date: 20-Jul-2006
- * Time: 09:56:56
- * Copyright JPMorgan Chase 2006
+ * Must set properties for host in properties file or uses in vm broker
*/
public class FileMessageDispatcher {
@@ -29,7 +43,7 @@ public class FileMessageDispatcher {
public static void main(String[] args)
{
- //Check command line args ok - must provide a path or file for us to run
+ //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>" + "");
@@ -116,8 +130,6 @@ public class FileMessageDispatcher {
/*
* Returns a _publisher for a queue
- * Using system properties to get connection info for now
- * Must set using -D the host, client, queue, user, pwd, virtual path, archive path
*/
private static Publisher getPublisher()
{
@@ -126,14 +138,8 @@ public class FileMessageDispatcher {
return _publisher;
}
- //Create _publisher using system properties
- Properties props = System.getProperties();
-
- //Create a _publisher using failover details
- _publisher = new Publisher(props.getProperty(Statics.HOST_PROPERTY),
- props.getProperty(Statics.CLIENT_PROPERTY), props.getProperty(Statics.QUEUE_PROPERTY),
- props.getProperty(Statics.USER_PROPERTY), props.getProperty(Statics.PWD_PROPERTY),
- props.getProperty(Statics.VIRTUAL_PATH_PROPERTY), props.getProperty(Statics.ARCHIVE_PATH));
+ //Create a _publisher
+ _publisher = new Publisher();
_publisher.setName(DEFAULT_PUB_NAME);
return _publisher;
diff --git a/java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactory.java b/java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactory.java
index ff40eddb03..f9944284c8 100644
--- a/java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactory.java
+++ b/java/client/src/test/java/org/apache/qpid/example/publisher/MessageFactory.java
@@ -1,9 +1,20 @@
-/**
- * Class that creates messages from file payload
- * Author: Marnie McCormack
- * Date: 18-Jul-2006
- * Time: 10:48:38
- * Copyright JPMorgan Chase 2006
+/*
+ * 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;
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
index d0fb821700..34360d6708 100644
--- 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
@@ -1,13 +1,25 @@
+/*
+ * 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;
-/**
- * Author: Marnie McCormack
- * Date: 18-Jul-2006
- * Time: 11:13:23
- * Copyright JPMorgan Chase 2006
- */
public class MessageFactoryException extends Exception {
private int _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
index 9d56403cda..16b32da22a 100644
--- 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
@@ -1,3 +1,21 @@
+/*
+ * 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;
@@ -9,10 +27,6 @@ import java.util.Properties;
/**
* Class that sends heartbeat messages to allow monitoring of message consumption
* Sends regular (currently 20 seconds apart) heartbeat message
- * Author: Marnie McCormack
- * Date: 20-Jul-2006
- * Time: 09:56:56
- * Copyright JPMorgan Chase 2006
*/
public class MonitorMessageDispatcher {
@@ -104,10 +118,7 @@ public class MonitorMessageDispatcher {
Properties props = System.getProperties();
//Create a _publisher using failover details and constant for monitor queue
- _monitorPublisher = new MonitorPublisher(props.getProperty(Statics.HOST_PROPERTY),
- props.getProperty(Statics.CLIENT_PROPERTY), Statics.MONITOR_QUEUE,
- props.getProperty(Statics.USER_PROPERTY), props.getProperty(Statics.PWD_PROPERTY),
- props.getProperty(Statics.VIRTUAL_PATH_PROPERTY), props.getProperty(Statics.ARCHIVE_PATH));
+ _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
index 4c1d884f5d..233c3fea0a 100644
--- 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
@@ -1,3 +1,21 @@
+/*
+ * 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;
@@ -9,10 +27,6 @@ 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
- * Author: Marnie McCormack
- * Date: 12-Sep-2006
- * Time: 09:41:07
- * Copyright JPMorgan Chase 2006
*/
public class MonitorPublisher extends Publisher
{
@@ -21,16 +35,9 @@ public class MonitorPublisher extends Publisher
BasicMessageProducer _producer;
- public MonitorPublisher(String host, int port, String clientID, String queueName,
- String user, String password, String virtualPath, String destinationDir)
- {
- super(host,port,clientID,queueName,user,password,virtualPath,destinationDir);
- }
-
- public MonitorPublisher(String hostdetails, String clientID, String queueName,
- String user, String password, String virtualPath, String destinationDir)
+ public MonitorPublisher()
{
- super(hostdetails,clientID,queueName,user,password,virtualPath,destinationDir);
+ super();
}
/*
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
index a2d9e5bdf6..d64fd9b142 100644
--- 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
@@ -1,13 +1,26 @@
/*
- * Class that publishes to an AMQ message queue
- * Author: Marnie McCormack
- *
+ * 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.AMQConnection;
+import org.apache.qpid.client.AMQConnectionFactory;
import org.apache.qpid.jms.Session;
@@ -17,15 +30,16 @@ import javax.jms.DeliveryMode;
import javax.jms.Queue;
import javax.jms.MessageProducer;
import javax.jms.Connection;
+import javax.naming.InitialContext;
-
-import org.apache.qpid.example.shared.ConnectionException;
-import org.apache.qpid.example.shared.Statics;
+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;
@@ -38,62 +52,33 @@ public class Publisher
protected Queue _destination;
+ protected static final String _defaultDestinationDir = "/tmp";
+
//constructor for use with a single host
- public Publisher(String host, int port, String clientID, String queueName,
- String user, String password, String virtualPath, String destinationDir)
+ public Publisher()
{
try
{
- createConnection(host, port, clientID, user, password, virtualPath);
-
- //create a transactional session
- _session = (Session) _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+ //get an initial context from default properties
+ _contextHelper = new InitialContextHelper(null);
+ InitialContext ctx = _contextHelper.getInitialContext();
- //now using a queue rather than a topic
- //AMQTopic destination = new AMQTopic(topicName);
- //Queue is non-exclusive and not deleted when last consumer detaches
- _destination = _session.createQueue(queueName);
-
- //create a message producer
- _producer = _session.createProducer(_destination);
-
- //set destination dir for files that have been processed
- _destinationDir = destinationDir;
-
- _connection.start();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- _log.error(e);
- }
- }
-
- //constructor that allows for multiple host details to be provided for failover
- public Publisher(String hostdetails, String clientID, String queueName,
- String user, String password, String virtualPath, String destinationDir)
- {
- try
- {
- if (queueName==null||queueName.length()==0)
- {
- queueName = Statics.QUEUE_NAME;
- }
- createConnectionWithFailover(hostdetails, clientID, user, password, virtualPath);
+ //then create a connection using the AMQConnectionFactory
+ AMQConnectionFactory cf = (AMQConnectionFactory) ctx.lookup("local");
+ _connection = cf.createConnection();
//create a transactional session
_session = (Session) _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
- //now using a queue rather than a topic
- //AMQTopic destination = new AMQTopic(topicName);
+ //lookup the example queue and use it
//Queue is non-exclusive and not deleted when last consumer detaches
- _destination = _session.createQueue(queueName);
+ _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 = destinationDir;
+ _destinationDir = _defaultDestinationDir;
_connection.start();
}
@@ -104,9 +89,9 @@ public class Publisher
}
}
- /*
+ /**
* Publishes a non-persistent message using transacted session
- */
+ **/
public boolean sendMessage(Message message)
{
try
@@ -173,34 +158,6 @@ public class Publisher
_destinationDir = destinationDir;
}
- //ONly using one set of host details
- private void createConnection(String host, int port, String clientID, String user, String password, String virtualPath)
- throws ConnectionException
- {
- try
- {
- _connection = new AMQConnection(host, port, user, password, clientID, virtualPath);
- }
- catch (Exception e)
- {
- throw new ConnectionException(e.toString());
- }
- }
-
- //Create connection with more than one set of host details for failover
- private void createConnectionWithFailover(String hostdetails, String clientID, String user, String password, String virtualPath)
- throws ConnectionException
- {
- try
- {
- _connection = new AMQConnection(hostdetails, user, password, clientID, virtualPath);
- }
- catch (Exception e)
- {
- throw new ConnectionException(e.toString());
- }
- }
-
public String getName()
{
return _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
index 921e5f4855..3335833c2d 100644
--- 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
@@ -1,13 +1,27 @@
+/*
+ * 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
- * Author: Marnie McCormack
- * Date: 18-Jul-2006
- * Time: 11:13:23
- * Copyright JPMorgan Chase 2006
*/
public class UndeliveredMessageException extends Exception {
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
index 0ce08fd59d..8723983862 100644
--- 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
@@ -1,13 +1,25 @@
+/*
+ * 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;
-/**
- * Author: Marnie McCormack
- * Date: 18-Jul-2006
- * Time: 11:13:23
- * Copyright JPMorgan Chase 2006
- */
public class ConnectionException extends Exception {
private int _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
new file mode 100644
index 0000000000..787cecd541
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/example/shared/ContextException.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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
index 6f33727194..54446cb6a7 100644
--- 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
@@ -1,13 +1,27 @@
+/*
+ * 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
- * Author: Marnie McCormack
- * Date: 20-Jul-2006
- * Time: 08:17:16
- * Copyright JPMorgan Chase 2006
*/
public class FileUtils {
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
new file mode 100644
index 0000000000..b39892b688
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/example/shared/InitialContextHelper.java
@@ -0,0 +1,78 @@
+/*
+ *
+ * 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
index e945c743be..c056f8a7da 100644
--- 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
@@ -1,10 +1,25 @@
+/*
+ * 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
- * Author: Marnie McCormack
- * Date: 18-Jul-2006
- * Time: 09:19:33
*/
public class Statics {
@@ -12,7 +27,7 @@ public class Statics {
public static final String QUEUE_NAME = "EXAMPLE_QUEUE";
- public static final String MONITOR_QUEUE = "MONITOR_QUEUE";
+ public static final String MONITOR_QUEUE_SUFFIX = "_MONITOR";
public static final String HOST_PROPERTY = "host";
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
new file mode 100644
index 0000000000..82de41908f
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/example/shared/example.properties
@@ -0,0 +1,21 @@
+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
index 37a8dbeca8..d6e020bf43 100644
--- 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
@@ -1,27 +1,47 @@
+/*
+ * 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.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.JMSException;
-import javax.jms.Queue;
+import javax.jms.*;
/**
* Subclass of Subscriber which consumes a heartbeat message
- * Author: Marnie McCormack
- * Date: 12-Sep-2006
- * Time: 09:41:07
- * Copyright JPMorgan Chase 2006
*/
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;
+ }
+
public static class MonitorMessageListener implements MessageListener
{
private String _name;
@@ -61,39 +81,32 @@ public class MonitoredSubscriber extends Subscriber
/*
* Subscribes to Queue and attaches additional monitor listener
- * @param hostdetails - for broker connection in host1:port1;host2:port2 format
- * @param username - for connection to the broker
- * @password - for connection to the broker
- * @virtualpath
*/
- public void subscribeAndMonitor(String hostdetails, String username, String password,
- String virtualPath, String queueName)
+ public void subscribeAndMonitor()
{
- Queue queue;
-
try
{
- //Create monitor comsumer for failover purposes
- if (queueName==null||queueName.length()==0)
- {
- queue = getSession(_connection).createQueue(Statics.QUEUE_NAME);
- }
- else
- {
- queue = getSession(_connection).createQueue(queueName);
- }
+ _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);
- _monitorConsumer = getSession(_connection).createConsumer(queue);
+ //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()));
+ _monitorConsumer.setMessageListener(new MonitoredSubscriber.MonitorMessageListener
+ ("MonitorListener " + System.currentTimeMillis()));
MonitoredSubscriber._logger.info("Starting monitored subscription ...");
MonitoredSubscriber._connection.start();
//and now start ordinary consumption too
- subscribe(hostdetails,username,password,virtualPath,queueName);
+ subscribe();
}
catch (Throwable t)
{
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
index 719e7441cc..d6ec8bd5de 100644
--- 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
@@ -1,3 +1,21 @@
+/*
+ * 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;
@@ -7,10 +25,6 @@ import java.util.Properties;
/**
* Allows you to simply start a monitored subscriber
- * Author: Marnie McCormack
- * Date: 08-Aug-2006
- * Time: 12:05:52
- * Copyright JPMorgan Chase 2006
*/
public class MonitoredSubscriptionWrapper {
@@ -28,9 +42,7 @@ public class MonitoredSubscriptionWrapper {
//note that for failover should set -Dhost=host1:port1;host2:port2
//Client will then failover in order i.e. connect to first host and failover to second and so on
- _subscriber.subscribe(props.getProperty(Statics.HOST_PROPERTY),
- props.getProperty(Statics.USER_PROPERTY), props.getProperty(Statics.PWD_PROPERTY),
- props.getProperty(Statics.VIRTUAL_PATH_PROPERTY), props.getProperty(Statics.QUEUE_NAME));
+ _subscriber.subscribe();
}
//Stop subscribing now ...
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
index 710192f291..6b89567b83 100644
--- 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
@@ -1,43 +1,82 @@
+/*
+ * 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.AMQConnection;
+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.Statics;
-import org.apache.qpid.example.shared.ConnectionException;
-
-import java.net.InetAddress;
+import org.apache.qpid.example.shared.InitialContextHelper;
/**
* Subscriber which consumes messages from a queue
- * Author: Marnie McCormack
- * Date: 12-Sep-2006
- * Time: 09:41:07
- * Copyright JPMorgan Chase 2006
*/
public class Subscriber
{
- private static final Logger _logger = Logger.getLogger(Subscriber.class);
+ private static final Logger _log = Logger.getLogger(Subscriber.class);
protected static Connection _connection;
protected static MessageConsumer _consumer;
- protected static Session _session;
+ 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 AMSMessageListener implements MessageListener
+ public static class ExampleMessageListener implements MessageListener
{
private String _name;
- public AMSMessageListener(String name)
+ public ExampleMessageListener(String name)
{
_name = name;
@@ -49,76 +88,63 @@ public class Subscriber
*/
public void onMessage(javax.jms.Message message)
{
- _logger.info(_name + " got message '" + message + "'");
+ _log.info(_name + " got message '" + message + "'");
try
{
- //@TODO handle your message appropriately for your application here ?
+ //NB: Handle your message appropriately for your application here
+ //do some stuff
- _logger.debug("Acknowledging recieved message");
+ _log.debug("Acknowledging recieved message");
//Now acknowledge the message to clear it from our queue
message.acknowledge();
}
catch(JMSException j)
{
- _logger.error("JMSException trying to acknowledge message receipt");
+ _log.error("JMSException trying to acknowledge message receipt");
j.printStackTrace();
}
catch(Exception e)
{
- _logger.error("Unexpected exception trying to handle message");
+ _log.error("Unexpected exception trying to handle message");
e.printStackTrace();
}
}
}
/*
- * Subscribes to AMS Queue and attaches listener
- * @param hostdetails - for broker connection in host1:port1;host2:port2 format
- * @param username - for connection to the broker
- * @password - for connection to the broker
- * @virtualpath
+ * Subscribes to example Queue and attaches listener
*/
- public void subscribe(String hostdetails, String username, String password,
- String virtualPath, String queue)
+ public void subscribe()
{
- Queue q;
-
- _logger.info("Starting subscription ...");
-
+ _log.info("Starting subscription ...");
try
{
- //To enable failover simply specify more than one host:port combination for hostdetails
- //Format is host1:port1;host2:port2
- _connection = getConnectionWithFailover(hostdetails,username,password,virtualPath);
+ _connection = _connectionFactory.createConnection();
- //Default to a queue with a default name if queue is null - replace with your own name from config etc
- if (queue==null || queue.length()==0)
- {
- q = getSession(_connection).createQueue(Statics.QUEUE_NAME);
- }
- else
- {
- q = getSession(_connection).createQueue(queue);
- }
+ //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 = getSession(_connection).createConsumer(q);
+ _consumer = session.createConsumer(destination);
//give the message listener a name of it's own
- _consumer.setMessageListener(new AMSMessageListener("MessageListener " + System.currentTimeMillis()));
+ _consumer.setMessageListener(new ExampleMessageListener("MessageListener " + System.currentTimeMillis()));
_connection.start();
}
catch (Throwable t)
{
- _logger.error("Fatal error: " + t);
+ _log.error("Fatal error: " + t);
t.printStackTrace();
}
- _logger.info("Waiting for messages ...");
+ _log.info("Waiting for messages ...");
//wait for messages and sleep to survive failover
try
@@ -130,10 +156,15 @@ public class Subscriber
}
catch (Exception e)
{
- _logger.warn("Exception while Subscriber sleeping",e);
+ _log.warn("Exception while Subscriber sleeping",e);
}
}
+ public void setDestinationName(String name)
+ {
+ _destinationName = name;
+ }
+
/*
* stop consuming and close connection
*/
@@ -148,58 +179,7 @@ public class Subscriber
}
catch(JMSException j)
{
- _logger.error("JMSException trying to Subscriber.stop: " + j.getStackTrace());
- }
- }
-
- /*
- * Get a connection for our broker with failover by providing an array of hostdetails
- * @param hostdetails - a delimited string of host1:port1;host2:port2 style connection details
- * @param username - for connection to the broker
- * @password - for connection to the broker
- * @virtualpath
- */
- protected Connection getConnectionWithFailover(String hostdetails, String username, String password,
- String virtualPath) throws ConnectionException
- {
- if (_connection == null)
- {
- try
- {
- _connection = new AMQConnection(hostdetails,username,password,InetAddress.getLocalHost().getHostName(),virtualPath);
-
- //To use a url to get your connection create a string in this format and then get a connection with it
- //String myurl = "amqp://guest:guest@/temp?brokerlist='tcp://localhost:5672',failover='roundrobin'";
- //_connection = new AMQConnectionFactory(url).createConnection();
-
- return _connection;
- }
- catch (Exception e)
- {
- throw new ConnectionException(e.toString());
- }
- }
- else
- {
- return _connection;
- }
- }
-
- /*
- * Creates a non-transacted session for consuming messages
- * Using client acknowledge mode means messages removed from queue only once ack'd
- * @param connection - to the broker
- */
- protected Session getSession(Connection connection) throws JMSException
- {
- if (_session == null)
- {
- _session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- return _session;
- }
- else
- {
- return _session;
+ _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
index bc0363be2a..4e755e858f 100644
--- 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
@@ -1,3 +1,21 @@
+/*
+ * 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.qpid.example.shared.Statics;
@@ -8,10 +26,6 @@ import org.apache.log4j.BasicConfigurator;
/**
* Allows you to simply start a subscriber
- * Author: Marnie McCormack
- * Date: 08-Aug-2006
- * Time: 12:05:52
- * Copyright JPMorgan Chase 2006
*/
public class SubscriptionWrapper {
@@ -29,9 +43,7 @@ public class SubscriptionWrapper {
//note that for failover should set -Dhost=host1:port1;host2:port2
//Client will then failover in order i.e. connect to first host and failover to second and so on
- _subscriber.subscribe(props.getProperty(Statics.HOST_PROPERTY),
- props.getProperty(Statics.USER_PROPERTY), props.getProperty(Statics.PWD_PROPERTY),
- props.getProperty(Statics.VIRTUAL_PATH_PROPERTY), props.getProperty(Statics.QUEUE_PROPERTY));
+ _subscriber.subscribe();
}
//Stop subscribing now ...
diff --git a/java/client/src/test/java/org/apache/qpid/example/test/TestAMSPubSub.java b/java/client/src/test/java/org/apache/qpid/example/test/TestAMSPubSub.java
index 1364c7b849..3a81a0224b 100644
--- a/java/client/src/test/java/org/apache/qpid/example/test/TestAMSPubSub.java
+++ b/java/client/src/test/java/org/apache/qpid/example/test/TestAMSPubSub.java
@@ -1,10 +1,20 @@
-/**
- * Class that uses an input file for message content and doesn't archive it up after passing
- * to the AMS publisher
- * Author: Marnie McCormack
- * Date: 18-Jul-2006
- * Time: 14:54:31
- * Copyright JPMorgan Chase 2006
+/*
+ * 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.test;
@@ -22,11 +32,10 @@ import org.apache.log4j.BasicConfigurator;
public class TestAMSPubSub {
private static final Logger _logger = Logger.getLogger(TestAMSPubSub.class);
- private static final String _defaultPayloadPath = "C:/Requirements/examplexml/test.xml";
+ private static final String _defaultPayloadPath = "/tmp";
private static Subscriber subscriber;
- private static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml";
/**
* Test main for class using default of local file for message payload
@@ -43,8 +52,8 @@ public class TestAMSPubSub {
//create publisher and subscriber
subscriber = new Subscriber();
- //subscribe to the topic
- testPubSub.subscribe(args);
+ //subscribe
+ testPubSub.subscribe();
//publish a message
if (args.length == 1)
@@ -66,12 +75,9 @@ public class TestAMSPubSub {
}
- private void subscribe(String[] args)
+ private void subscribe()
{
- Properties props = System.getProperties();
- subscriber.subscribe(props.getProperty(Statics.HOST_PROPERTY),
- props.getProperty(Statics.USER_PROPERTY), props.getProperty(Statics.PWD_PROPERTY),
- props.getProperty(Statics.VIRTUAL_PATH_PROPERTY),props.getProperty(Statics.QUEUE_PROPERTY));
+ subscriber.subscribe();
}
private void publish(String payloadPath)
diff --git a/java/client/src/test/java/org/apache/qpid/example/test/TestMultSubscribers.java b/java/client/src/test/java/org/apache/qpid/example/test/TestMultSubscribers.java
index a1af923e12..f1a921e106 100644
--- a/java/client/src/test/java/org/apache/qpid/example/test/TestMultSubscribers.java
+++ b/java/client/src/test/java/org/apache/qpid/example/test/TestMultSubscribers.java
@@ -1,10 +1,20 @@
-/**
- * Class that uses an input file for message content and doesn't archive it up after passing
- * to the AMS publisher
- * Author: Marnie McCormack
- * Date: 18-Jul-2006
- * Time: 14:54:31
- * Copyright JPMorgan Chase 2006
+/*
+ * 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.test;
@@ -22,7 +32,7 @@ import org.apache.log4j.BasicConfigurator;
public class TestMultSubscribers {
private static final Logger _logger = Logger.getLogger(TestMultSubscribers.class);
- private static final String _defaultPayloadPath = "C:/Requirements/examplexml/test.xml";
+ private static final String _defaultPayloadPath = "/tmp";
private static Subscriber subscriber1;
private static Subscriber subscriber2;
@@ -74,12 +84,8 @@ public class TestMultSubscribers {
private void subscribe(String[] args)
{
Properties props = System.getProperties();
- subscriber1.subscribe(props.getProperty(Statics.HOST_PROPERTY),
- props.getProperty(Statics.USER_PROPERTY), props.getProperty(Statics.PWD_PROPERTY),
- props.getProperty(Statics.VIRTUAL_PATH_PROPERTY),props.getProperty(Statics.QUEUE_PROPERTY));
- subscriber2.subscribe(props.getProperty(Statics.HOST_PROPERTY),
- props.getProperty(Statics.USER_PROPERTY), props.getProperty(Statics.PWD_PROPERTY),
- props.getProperty(Statics.VIRTUAL_PATH_PROPERTY),props.getProperty(Statics.QUEUE_PROPERTY));
+ subscriber1.subscribe();
+ subscriber2.subscribe();
}
diff --git a/java/client/src/test/java/org/apache/qpid/example/test/TestPublisher.java b/java/client/src/test/java/org/apache/qpid/example/test/TestPublisher.java
index aa6a54cb0e..6ff6028ccd 100644
--- a/java/client/src/test/java/org/apache/qpid/example/test/TestPublisher.java
+++ b/java/client/src/test/java/org/apache/qpid/example/test/TestPublisher.java
@@ -1,9 +1,20 @@
-/**
- * Class that uses an input file for message content to publish and doesn't archive it
- * Author: Marnie McCormack
- * Date: 18-Jul-2006
- * Time: 14:54:31
- * Copyright JPMorgan Chase 2006
+/*
+ * 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.test;
@@ -18,9 +29,7 @@ import org.apache.log4j.BasicConfigurator;
public class TestPublisher {
private static final Logger _logger = Logger.getLogger(TestAMSPubSub.class);
- private static final String _defaultPayloadPath = "C:/Requirements/examplexml/test.xml";
-
- private static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml";
+ private static final String _defaultPayloadPath = "/tmp";
/**
* Test main for class using default of local file for message payload
diff --git a/java/client/src/test/java/org/apache/qpid/example/test/TestSubscriber.java b/java/client/src/test/java/org/apache/qpid/example/test/TestSubscriber.java
index 01c02fe5e4..7f0189886c 100644
--- a/java/client/src/test/java/org/apache/qpid/example/test/TestSubscriber.java
+++ b/java/client/src/test/java/org/apache/qpid/example/test/TestSubscriber.java
@@ -1,10 +1,20 @@
-/**
- * Class that uses an input file for message content and doesn't archive it up after passing
- * to the AMS publisher
- * Author: Marnie McCormack
- * Date: 18-Jul-2006
- * Time: 14:54:31
- * Copyright JPMorgan Chase 2006
+/*
+ * 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.test;
diff --git a/java/client/src/test/java/org/apache/qpid/failover/FailoverBrokerTester.java b/java/client/src/test/java/org/apache/qpid/failover/FailoverBrokerTester.java
deleted file mode 100644
index f20b0e1409..0000000000
--- a/java/client/src/test/java/org/apache/qpid/failover/FailoverBrokerTester.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.failover;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-
-public class FailoverBrokerTester implements Runnable
-{
- private static final Logger _logger = Logger.getLogger(FailoverBrokerTester.class);
-
- private int[] _brokers;
- private int[] _brokersKilling;
- private long _delayBeforeKillingStart;
- private long _delayBetweenCullings;
- private long _delayBetweenRecreates;
- private boolean _recreateBrokers;
- private long _delayBeforeReCreationStart;
-
- private volatile boolean RUNNING;
-
-
- /**
- * An InVM Broker Tester. Creates then kills VM brokers to allow failover testing.
- *
- * @param brokerCount The number of brokers to create
- * @param delay The delay before and between broker killings
- */
- public FailoverBrokerTester(int brokerCount, long delay)
- {
- this(brokerCount, delay, delay, false, 0, 0);
- }
-
- /**
- * An InVM Broker Tester. Creates then kills VM brokers to allow failover testing.
- *
- * @param brokerCount The number of brokers
- * @param delayBeforeKillingStart
- * @param delayBetweenCullings
- * @param recreateBrokers
- * @param delayBeforeReCreationStart
- * @param delayBetweenRecreates
- */
- public FailoverBrokerTester(int brokerCount, long delayBeforeKillingStart,
- long delayBetweenCullings, boolean recreateBrokers,
- long delayBeforeReCreationStart, long delayBetweenRecreates)
- {
- int[] brokers = new int[brokerCount];
-
- for (int n = 0; n < brokerCount; n++)
- {
- brokers[n] = n + 1;
- }
- _brokersKilling = _brokers = brokers;
- _recreateBrokers = recreateBrokers;
- _delayBeforeKillingStart = delayBeforeKillingStart;
- _delayBetweenCullings = delayBetweenCullings;
- _delayBetweenRecreates = delayBetweenRecreates;
- _delayBeforeReCreationStart = delayBeforeReCreationStart;
-
- createWorld();
- }
-
- /**
- * An InVM Broker Tester. Creates then kills VM brokers to allow failover testing.
- *
- * @param brokerArray Array for broker creation and killing order
- * @param delayBeforeKillingStart
- * @param delayBetweenCullings
- * @param recreateBrokers
- * @param delayBeforeReCreationStart
- * @param delayBetweenRecreates
- */
- public FailoverBrokerTester(int[] brokerArray, long delayBeforeKillingStart,
- long delayBetweenCullings, boolean recreateBrokers,
- long delayBeforeReCreationStart, long delayBetweenRecreates)
- {
- _brokersKilling = _brokers = brokerArray;
- _recreateBrokers = recreateBrokers;
- _delayBeforeKillingStart = delayBeforeKillingStart;
- _delayBetweenCullings = delayBetweenCullings;
- _delayBetweenRecreates = delayBetweenRecreates;
- _delayBeforeReCreationStart = delayBeforeReCreationStart;
-
- createWorld();
- }
-
- /**
- * An InVM Broker Tester. Creates then kills VM brokers to allow failover testing.
- *
- * @param brokerCreateOrder Array for broker creation order
- * @param brokerKillOrder Array for broker killing order
- * @param delayBeforeKillingStart
- * @param delayBetweenCullings
- * @param recreateBrokers
- * @param delayBeforeReCreationStart
- * @param delayBetweenRecreates
- */
- public FailoverBrokerTester(int[] brokerCreateOrder, int[] brokerKillOrder, long delayBeforeKillingStart,
- long delayBetweenCullings, boolean recreateBrokers,
- long delayBeforeReCreationStart, long delayBetweenRecreates)
- {
- _brokers = brokerCreateOrder;
- _brokersKilling = brokerKillOrder;
- _recreateBrokers = recreateBrokers;
- _delayBeforeKillingStart = delayBeforeKillingStart;
- _delayBetweenCullings = delayBetweenCullings;
- _delayBetweenRecreates = delayBetweenRecreates;
- _delayBeforeReCreationStart = delayBeforeReCreationStart;
-
- createWorld();
- }
-
- private void createWorld()
- {
- System.setProperty("amqj.NoAutoCreateVMBroker", "true");
-
- genesis();
-
- Thread brokerGod = new Thread(this);
- brokerGod.setName("Broker God");
- brokerGod.start();
- }
-
-
- private void genesis()
- {
- _logger.info("Creating " + _brokers.length + " VM Brokers.");
- for (int count = 0; count < _brokers.length; count++)
- {
- try
- {
- TransportConnection.createVMBroker(_brokers[count]);
- }
- catch (AMQVMBrokerCreationException e)
- {
- ;
- }
- }
- }
-
- public void run()
- {
-
- RUNNING = true;
- try
- {
- _logger.info("Sleeping before culling starts.");
- Thread.sleep(_delayBeforeKillingStart);
- }
- catch (InterruptedException e)
- {
- _logger.info("Interupted sleeping before killing starts.");
- }
-
- Thread brokerGod = new Thread(new BrokerDestroyer());
- brokerGod.setName("Broker Destroyer");
- brokerGod.start();
-
- if (_recreateBrokers)
- {
- try
- {
- _logger.info("Sleeping before recreation starts.");
- Thread.sleep(_delayBeforeReCreationStart - _delayBeforeKillingStart);
- }
- catch (InterruptedException e)
- {
- _logger.info("Interupted sleeping before recreation starts.");
- }
-
- brokerGod = new Thread(new BrokerCreator());
- brokerGod.setName("Broker Creator");
- brokerGod.start();
- }
- }
-
-
- public void stopTesting()
- {
- _logger.info("Stopping Broker Tester.");
- RUNNING = false;
- }
-
- class BrokerCreator implements Runnable
- {
- public void run()
- {
- _logger.info("Created Broker Creator.");
- while (RUNNING)
- {
- for (int count = 0; count < _brokers.length; count++)
- {
- try
- {
- _logger.info("Creating Broker:" + _brokers[count]);
- TransportConnection.createVMBroker(_brokers[count]);
- }
- catch (AMQVMBrokerCreationException e)
- {
- _logger.info("Unable to recreate broker:" + count + ", Port:" + _brokers[count]);
- }
- try
- {
- Thread.sleep(_delayBetweenRecreates);
- }
- catch (InterruptedException e)
- {
- _logger.info("Interupted between broker recreates.");
- }
- }
- }
- _logger.info("Ending Broker Creator.");
- }
- }
-
- class BrokerDestroyer implements Runnable
- {
- public void run()
- {
- _logger.info("Created Broker Destroyer.");
- while (RUNNING)
- {
- for (int count = 0; count < _brokersKilling.length; count++)
- {
- _logger.info("Destroying Broker:" + _brokersKilling[count]);
- killNextBroker(_brokersKilling[count], _delayBetweenCullings);
- }
- }
- _logger.info("Ending Broker Destroyer.");
- }
-
- private void killNextBroker(int broker, long delay)
- {
-
- //Kill the broker
- TransportConnection.killVMBroker(broker);
-
- //Give the client time to get up and going
- try
- {
- Thread.sleep(delay);
- }
- catch (InterruptedException e)
- {
- _logger.info("Sleeping before broker killing was interrupted,");
- }
-
-
- }
- }
-
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/failover/FailoverMultiMethodTest.java b/java/client/src/test/java/org/apache/qpid/failover/FailoverMultiMethodTest.java
deleted file mode 100644
index b9f4c1c0dc..0000000000
--- a/java/client/src/test/java/org/apache/qpid/failover/FailoverMultiMethodTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.failover;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.jms.ConnectionListener;
-import org.apache.qpid.jms.ConnectionURL;
-
-import javax.jms.*;
-import java.util.Timer;
-import java.util.TimerTask;
-
-public class FailoverMultiMethodTest implements MessageListener, ConnectionListener
-{
- private static final long TIMEOUT = 10000;
- private static final long INTERVAL = 5000;
- private final Timer _timer = new Timer(true);
- private final Connection _connection;
- private final Session _session;
- private final MessageProducer _producer;
- private Timeout _timeout;
- private int _count;
-
- FailoverMultiMethodTest(String connectionString) throws JMSException, AMQException, URLSyntaxException
- {
- // Parse the incomming broker strings
-
- ConnectionURL connection = new AMQConnectionURL(connectionString);
-
- /*
- if (!(connection.getBrokerCount() > 0))
- {
- throw new IllegalArgumentException("BrokerDetails details must specify at least one broker");
- }
-
- // Create a FailoverMethod. In this case a SingleServer Method
- // This Method will retry the given server once before failing.
- FailoverMethod singleMethod = new FailoverSingleServer(connection);
-
- // Create the policy with the Failover Method
- FailoverPolicy policy = new FailoverPolicy(singleMethod);
-
- // Create a new method that will Cycle through all servers using the default values.
- FailoverMethod cycleMethod = new FailoverRoundRobinServers(connection);
-
- // Set the retry per server to 1
- cycleMethod.setRetries(1);
-
- // Add the failover method to the policy.
- policy.addMethod(cycleMethod);
-
- policy.setMethodRetries(1);
- */
-
- _connection = new AMQConnection(connection);
-
-
- ((AMQConnection) _connection).setConnectionListener(this);
-
- _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Topic topic = _session.createTopic("BLZ-24");
- Queue queue = _session.createTemporaryQueue();
- _producer = _session.createProducer(topic);
- _session.createConsumer(queue).setMessageListener(this);
- //new TopicListener(_session, topic);
- new TopicListener(_connection.createSession(false, Session.AUTO_ACKNOWLEDGE), topic);
-
- _connection.start();
-
- Message msg = _session.createTextMessage("Init");
- msg.setJMSReplyTo(queue);
- send(msg);
- }
-
- public synchronized void onMessage(Message message)
- {
- try
- {
- //cancel timeout:
- _timeout.clear();
- new DelayedSend(_session.createTextMessage("Message" + (++_count)), INTERVAL);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
-
- private synchronized void send(Message msg) throws JMSException
- {
- _producer.send(msg);
- //start timeout:
- _timeout = new Timeout(TIMEOUT);
- }
-
- private void error(Exception e)
- {
- e.printStackTrace();
- stop();
- }
-
- private void stop()
- {
- System.out.println("Stopping...");
- try
- {
- _connection.close();
- }
- catch (JMSException e)
- {
- System.out.println("Failed to shutdown: " + e);
- e.printStackTrace();
- }
- }
-
- private void timeout()
- {
- error(new RuntimeException("Timed out: count = " + _count));
- }
-
- public void bytesSent(long count)
- {
- }
-
- public void bytesReceived(long count)
- {
- }
-
- public boolean preFailover(boolean redirect)
- {
- System.out.println("preFailover(" + redirect + ") called");
- return true;
- }
-
- public boolean preResubscribe()
- {
- System.out.println("preResubscribe() called");
- return true;
- }
-
- public void failoverComplete()
- {
- System.out.println("failoverComplete() called");
- }
-
- private class TopicListener implements MessageListener
- {
- private final Session _session;
- private MessageProducer _producer;
- private int _received;
-
- TopicListener(Session session, Topic topic) throws JMSException
- {
- _session = session;
- _session.createConsumer(topic).setMessageListener(this);
- }
-
- public void onMessage(Message message)
- {
- try
- {
- //if(_received++ % 100 == 0)
- {
- System.out.println("Received: " + ((TextMessage) message).getText());
- }
- if (_producer == null)
- {
- _producer = init(message);
- }
- reply(message);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
-
- private void reply(Message message) throws JMSException
- {
- _producer.send(_session.createTextMessage(((TextMessage) message).getText()));
- }
-
- private MessageProducer init(Message message) throws JMSException
- {
- return _session.createProducer(message.getJMSReplyTo());
- }
- }
-
- private class Timeout extends TimerTask
- {
- private volatile boolean _cancelled;
-
- Timeout(long time)
- {
- _timer.schedule(this, time);
- }
-
- void clear()
- {
- _cancelled = true;
- }
-
- public void run()
- {
- if (!_cancelled)
- {
- timeout();
- }
- }
- }
-
- private class DelayedSend extends TimerTask
- {
- private final Message _msg;
-
- DelayedSend(Message msg, long delay)
- {
- _msg = msg;
- _timer.schedule(this, delay);
- }
-
- public void run()
- {
- try
- {
- send(_msg);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
- }
-
- public static void main(final String[] argv) throws Exception
- {
- final String connection = argv.length == 0 ? "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'" : argv[0];
- new FailoverMultiMethodTest(connection);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/failover/FailoverRoundRobinTest.java b/java/client/src/test/java/org/apache/qpid/failover/FailoverRoundRobinTest.java
deleted file mode 100644
index 23119f2394..0000000000
--- a/java/client/src/test/java/org/apache/qpid/failover/FailoverRoundRobinTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.failover;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.jms.ConnectionListener;
-
-import javax.jms.*;
-import java.util.Timer;
-import java.util.TimerTask;
-
-public class FailoverRoundRobinTest implements MessageListener, ConnectionListener
-{
- private static final long TIMEOUT = 10000;
- private static final long INTERVAL = 5000;
- private final Timer _timer = new Timer(true);
- private final Connection _connection;
- private final Session _session;
- private final MessageProducer _producer;
- private Timeout _timeout;
- private int _count;
-
-
- FailoverRoundRobinTest(String connectionString) throws JMSException, AMQException, URLSyntaxException
- {
- ConnectionURL connection = new AMQConnectionURL(connectionString);
- _connection = new AMQConnection(connection);
-
- ((AMQConnection) _connection).setConnectionListener(this);
-
- _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Topic topic = _session.createTopic("BLZ-24");
- Queue queue = _session.createTemporaryQueue();
- _producer = _session.createProducer(topic);
- _session.createConsumer(queue).setMessageListener(this);
- //new TopicListener(_session, topic);
- new TopicListener(_connection.createSession(false, Session.AUTO_ACKNOWLEDGE), topic);
- _connection.start();
-
- Message msg = _session.createTextMessage("Init");
- msg.setJMSReplyTo(queue);
- send(msg);
- }
-
- public synchronized void onMessage(Message message)
- {
- try
- {
- //cancel timeout:
- _timeout.clear();
- new DelayedSend(_session.createTextMessage("Message" + (++_count)), INTERVAL);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
-
- private synchronized void send(Message msg) throws JMSException
- {
- _producer.send(msg);
- //start timeout:
- _timeout = new Timeout(TIMEOUT);
- }
-
- private void error(Exception e)
- {
- e.printStackTrace();
- stop();
- }
-
- private void stop()
- {
- System.out.println("Stopping...");
- try
- {
- _connection.close();
- }
- catch (JMSException e)
- {
- System.out.println("Failed to shutdown: " + e);
- e.printStackTrace();
- }
- }
-
- private void timeout()
- {
- error(new RuntimeException("Timed out: count = " + _count));
- }
-
- public void bytesSent(long count)
- {
- }
-
- public void bytesReceived(long count)
- {
- }
-
- public boolean preFailover(boolean redirect)
- {
- System.out.println("preFailover(" + redirect + ") called");
- return true;
- }
-
- public boolean preResubscribe()
- {
- System.out.println("preResubscribe() called");
- return true;
- }
-
- public void failoverComplete()
- {
- System.out.println("failoverComplete() called");
- }
-
- private class TopicListener implements MessageListener
- {
- private final Session _session;
- private MessageProducer _producer;
- private int _received;
-
- TopicListener(Session session, Topic topic) throws JMSException
- {
- _session = session;
- _session.createConsumer(topic).setMessageListener(this);
- }
-
- public void onMessage(Message message)
- {
- try
- {
- //if(_received++ % 100 == 0)
- {
- System.out.println("Received: " + ((TextMessage) message).getText());
- }
- if (_producer == null)
- {
- _producer = init(message);
- }
- reply(message);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
-
- private void reply(Message message) throws JMSException
- {
- _producer.send(_session.createTextMessage(((TextMessage) message).getText()));
- }
-
- private MessageProducer init(Message message) throws JMSException
- {
- return _session.createProducer(message.getJMSReplyTo());
- }
- }
-
- private class Timeout extends TimerTask
- {
- private volatile boolean _cancelled;
-
- Timeout(long time)
- {
- _timer.schedule(this, time);
- }
-
- void clear()
- {
- _cancelled = true;
- }
-
- public void run()
- {
- if (!_cancelled)
- {
- timeout();
- }
- }
- }
-
- private class DelayedSend extends TimerTask
- {
- private final Message _msg;
-
- DelayedSend(Message msg, long delay)
- {
- _msg = msg;
- _timer.schedule(this, delay);
- }
-
- public void run()
- {
- try
- {
- send(_msg);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
- }
-
- public static void main(final String[] argv) throws Exception
- {
- //Default failover is to use single server
- String url = "amqp://guest:guest@test/clientID?"+
- "brokerlist='tcp://localhost:5672?retries='2';"+
- "tcp://localhost:5673''&failover='roundrobin'";
- final String broker = argv.length == 0? url : argv[0];
- new FailoverRoundRobinTest(broker);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/failover/FailoverSingleServerTest.java b/java/client/src/test/java/org/apache/qpid/failover/FailoverSingleServerTest.java
deleted file mode 100644
index 7f3b058438..0000000000
--- a/java/client/src/test/java/org/apache/qpid/failover/FailoverSingleServerTest.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.failover;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.jms.*;
-
-import javax.jms.*;
-import javax.jms.Connection;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import java.util.Timer;
-import java.util.TimerTask;
-
-public class FailoverSingleServerTest implements MessageListener, ConnectionListener
-{
- private static final long TIMEOUT = 10000;
- private static final long INTERVAL = 5000;
- private final Timer _timer = new Timer(true);
- private final Connection _connection;
- private final Session _session;
- private final MessageProducer _producer;
- private Timeout _timeout;
- private int _count;
-
- private
-
-
- FailoverSingleServerTest(String connectionString) throws JMSException, AMQException, URLSyntaxException
- {
-
-
- ConnectionURL connection = new AMQConnectionURL(connectionString);
-
-/*
- BrokerDetails[] details = BrokerDetails.parseBrokerDetails(brokers);
-
-
-
- if (!(details.length > 0))
- {
- throw new IllegalArgumentException("BrokerDetails details must specify at least one broker");
- }
-
- // Create a cycling Server Failover that tries twice for the server
- FailoverMethod singleMethod = new FailoverSingleServer(details[0]);
-
- singleMethod.setRetries(2);
-
- FailoverPolicy policy = new FailoverPolicy(singleMethod);
-*/
-
-
- _connection = new AMQConnection(connection);
-
- ((AMQConnection) _connection).setConnectionListener(this);
- _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Topic topic = _session.createTopic("BLZ-24");
- Queue queue = _session.createTemporaryQueue();
- _producer = _session.createProducer(topic);
- _session.createConsumer(queue).setMessageListener(this);
- //new TopicListener(_session, topic);
- new TopicListener(_connection.createSession(false, Session.AUTO_ACKNOWLEDGE), topic);
- _connection.start();
-
- Message msg = _session.createTextMessage("Init");
- msg.setJMSReplyTo(queue);
- send(msg);
- }
-
- public synchronized void onMessage(Message message)
- {
- try
- {
- //cancel timeout:
- _timeout.clear();
- new DelayedSend(_session.createTextMessage("Message" + (++_count)), INTERVAL);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
-
- private synchronized void send(Message msg) throws JMSException
- {
- _producer.send(msg);
- //start timeout:
- _timeout = new Timeout(TIMEOUT);
- }
-
- private void error(Exception e)
- {
- e.printStackTrace();
- stop();
- }
-
- private void stop()
- {
- System.out.println("Stopping...");
- try
- {
- _connection.close();
- }
- catch (JMSException e)
- {
- System.out.println("Failed to shutdown: " + e);
- e.printStackTrace();
- }
- }
-
- private void timeout()
- {
- error(new RuntimeException("Timed out: count = " + _count));
- }
-
- public void bytesSent(long count)
- {
- }
-
- public void bytesReceived(long count)
- {
- }
-
- public boolean preFailover(boolean redirect)
- {
- System.out.println("preFailover(" + redirect + ") called");
- return true;
- }
-
- public boolean preResubscribe()
- {
- System.out.println("preResubscribe() called");
- return true;
- }
-
- public void failoverComplete()
- {
- System.out.println("failoverComplete() called");
- }
-
- private class TopicListener implements MessageListener
- {
- private final Session _session;
- private MessageProducer _producer;
- private int _received;
-
- TopicListener(Session session, Topic topic) throws JMSException
- {
- _session = session;
- _session.createConsumer(topic).setMessageListener(this);
- }
-
- public void onMessage(Message message)
- {
- try
- {
- //if(_received++ % 100 == 0)
- {
- System.out.println("Received: " + ((TextMessage) message).getText());
- }
- if(_producer == null)
- {
- _producer = init(message);
- }
- reply(message);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
-
- private void reply(Message message) throws JMSException
- {
- _producer.send(_session.createTextMessage(((TextMessage) message).getText()));
- }
-
- private MessageProducer init(Message message) throws JMSException
- {
- return _session.createProducer(message.getJMSReplyTo());
- }
- }
-
- private class Timeout extends TimerTask
- {
- private volatile boolean _cancelled;
-
- Timeout(long time)
- {
- _timer.schedule(this, time);
- }
-
- void clear()
- {
- _cancelled = true;
- }
-
- public void run()
- {
- if(!_cancelled)
- {
- timeout();
- }
- }
- }
-
- private class DelayedSend extends TimerTask
- {
- private final Message _msg;
-
- DelayedSend(Message msg, long delay)
- {
- _msg = msg;
- _timer.schedule(this, delay);
- }
-
- public void run()
- {
- try
- {
- send(_msg);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
- }
-
- public static void main(final String[] argv) throws Exception
- {
- //Default failover is to use single server
- String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672?retries='2''";
- final String broker = argv.length == 0? url : argv[0];
- new FailoverSingleServerTest(broker);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/failover/FailoverTest.java b/java/client/src/test/java/org/apache/qpid/failover/FailoverTest.java
deleted file mode 100644
index 4905bf5614..0000000000
--- a/java/client/src/test/java/org/apache/qpid/failover/FailoverTest.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.failover;
-
-import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.jms.ConnectionListener;
-
-import javax.jms.*;
-import java.util.Timer;
-import java.util.TimerTask;
-
-public class FailoverTest implements MessageListener, ConnectionListener
-{
- private static final long TIMEOUT = 10 * 1000;
- private static final long INTERVAL = 500;
- private final Timer _timer = new Timer(true);
- private final Connection _connection;
- private final Session _session;
- private final MessageProducer _producer;
- private Timeout _timeout;
- private int _count;
- private Queue _tempQueue;
-
- FailoverTest(String connectionUrl) throws JMSException, AMQException, URLSyntaxException
- {
- this(new AMQConnection(connectionUrl));
- ((AMQConnection) _connection).setConnectionListener(this);
- }
-
- FailoverTest(Connection connection) throws JMSException
- {
- AMQConnection amqConnection = (AMQConnection) connection;
- System.out.println("connection.url = " + amqConnection.toURL());
- _connection = connection;
- _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Topic topic = _session.createTopic("topic1");
- _tempQueue = _session.createTemporaryQueue();
- _producer = _session.createProducer(topic);
- _session.createConsumer(_tempQueue).setMessageListener(this);
- //new TopicListener(_session, topic);
- new TopicListener(_connection.createSession(false, Session.AUTO_ACKNOWLEDGE), topic);
- _connection.start();
-
- Message msg = _session.createTextMessage("Init");
- msg.setJMSReplyTo(_tempQueue);
- send(msg);
- }
-
- public synchronized void onMessage(Message message)
- {
- try
- {
- //cancel timeout:
- _timeout.clear();
- new DelayedSend(_session.createTextMessage("Message" + (++_count)), INTERVAL);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
-
- private synchronized void send(Message msg) throws JMSException
- {
- _producer.send(msg);
- //start timeout:
- _timeout = new Timeout(TIMEOUT);
- }
-
- private void error(Exception e)
- {
- e.printStackTrace();
- stop();
- }
-
- private void stop()
- {
- System.out.println("Stopping...");
- try
- {
- _connection.close();
- }
- catch (JMSException e)
- {
- System.out.println("Failed to shutdown: " + e);
- e.printStackTrace();
- }
- }
-
- private void timeout()
- {
- try {
- System.out.println("timed out. Resending init message");
- Message msg = _session.createTextMessage("Init");
- msg.setJMSReplyTo(_tempQueue);
- send(msg);
- } catch (JMSException e) {
- throw new RuntimeException("Got JMSException", e);
- }
-// error(new RuntimeException("Timed out: count = " + _count));
- }
-
- public void bytesSent(long count)
- {
- }
-
- public void bytesReceived(long count)
- {
- }
-
- public boolean preFailover(boolean redirect)
- {
- System.out.println("preFailover(" + redirect + ") called");
- return true;
- }
-
- public boolean preResubscribe()
- {
- System.out.println("preResubscribe() called");
- return true;
- }
-
- public void failoverComplete()
- {
- System.out.println("failoverComplete() called");
- }
-
- private class TopicListener implements MessageListener
- {
- private final Session _session;
- private MessageProducer _producer;
- private int _received;
-
- TopicListener(Session session, Topic topic) throws JMSException
- {
- _session = session;
- _session.createConsumer(topic).setMessageListener(this);
- }
-
- public void onMessage(Message message)
- {
- try
- {
- //if(_received++ % 100 == 0)
- {
- System.out.println("Received: " + ((TextMessage) message).getText());
- }
- if(_producer == null)
- {
- _producer = init(message);
- }
- reply(message);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
-
- private void reply(Message message) throws JMSException
- {
- _producer.send(_session.createTextMessage(((TextMessage) message).getText()));
- }
-
- private MessageProducer init(Message message) throws JMSException
- {
- return _session.createProducer(message.getJMSReplyTo());
- }
- }
-
- private class Timeout extends TimerTask
- {
- private volatile boolean _cancelled;
-
- Timeout(long time)
- {
- _timer.schedule(this, time);
- }
-
- void clear()
- {
- _cancelled = true;
- }
-
- public void run()
- {
- if(!_cancelled)
- {
- timeout();
- System.out.println("would have timed out!");
- }
- }
- }
-
- private class DelayedSend extends TimerTask
- {
- private final Message _msg;
-
- DelayedSend(Message msg, long delay)
- {
- _msg = msg;
- _timer.schedule(this, delay);
- }
-
- public void run()
- {
- try
- {
- send(_msg);
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
- }
-
- public static void main(final String[] argv) throws Exception
- {
- final String clientId = "failover" + System.currentTimeMillis();
- final String defaultUrl = "amqp://guest:guest@" + clientId + "/test" +
- "?brokerlist='tcp://localhost:5672;tcp://localhost:5673'&failover='roundrobin'";
-
- System.out.println("url = [" + defaultUrl + "]");
-
- System.out.println("connection url = [" + new AMQConnectionURL(defaultUrl) + "]");
-
- final String broker = argv.length == 0? defaultUrl : argv[0];
- new FailoverTest(broker);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/failover/FailoverTxTest.java b/java/client/src/test/java/org/apache/qpid/failover/FailoverTxTest.java
deleted file mode 100644
index 10ec682bf5..0000000000
--- a/java/client/src/test/java/org/apache/qpid/failover/FailoverTxTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.failover;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.jms.ConnectionListener;
-import org.junit.Assert;
-
-import javax.jms.*;
-import javax.jms.IllegalStateException;
-
-public class FailoverTxTest implements ConnectionListener
-{
- private static Logger _log = Logger.getLogger(FailoverTxTest.class);
-
- AMQConnection _connection;
-
- FailoverTxTest(String connectionUrl) throws Exception
- {
- _connection = new AMQConnection(connectionUrl);
- _connection.setConnectionListener(this);
- System.out.println("connection.url = " + _connection.toURL());
- Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Destination queue = session.createTemporaryQueue();
-
- session.createConsumer(queue).setMessageListener(new MessageListener()
- {
- public void onMessage(Message message)
- {
- try
- {
- _log.info("Received: " + ((TextMessage) message).getText());
- }
- catch (JMSException e)
- {
- error(e);
- }
- }
- });
-
- _connection.start();
-
- sendInTx(queue);
-
- _connection.close();
- _log.info("FailoverTxText complete");
- }
-
- private void sendInTx(Destination queue) throws JMSException
- {
- Session session = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = session.createProducer(queue);
- for (int i = 1; i <= 10; ++i)
- {
- for (int j = 1; j <= 10; ++j)
- {
- TextMessage msg = session.createTextMessage("Tx=" + i + " msg=" + j);
- _log.info("sending message = " + msg.getText());
- producer.send(msg);
- try
- {
- Thread.sleep(1000);
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException("Someone interrupted me!", e);
- }
- }
- session.commit();
- }
- }
-
- private void error(Exception e)
- {
- _log.fatal("Exception received. About to stop.", e);
- stop();
- }
-
- private void stop()
- {
- System.out.println("Stopping...");
- try
- {
- _connection.close();
- }
- catch (JMSException e)
- {
- System.out.println("Failed to shutdown: " + e);
- e.printStackTrace();
- }
- }
-
- public void bytesSent(long count)
- {
- }
-
- public void bytesReceived(long count)
- {
- }
-
- public boolean preFailover(boolean redirect)
- {
- System.out.println("preFailover(" + redirect + ") called");
- return true;
- }
-
- public boolean preResubscribe()
- {
- System.out.println("preResubscribe() called");
- return true;
- }
-
- public void failoverComplete()
- {
- System.out.println("failoverComplete() called");
- }
-
- public static void main(final String[] argv) throws Exception
- {
- int[] creationOrder = {1, 2, 3};
- int[] killingOrder = {1, 2, 3};
- long delayBeforeKillingStart = 2000;
- long delayBetweenCullings = 2000;
- boolean recreateBrokers = true;
- long delayBeforeReCreationStart = 4000;
- long delayBetweenRecreates = 3000;
-
- FailoverBrokerTester tester = new FailoverBrokerTester(creationOrder, killingOrder, delayBeforeKillingStart, delayBetweenCullings,
- recreateBrokers, delayBeforeReCreationStart, delayBetweenRecreates);
-
- try
- {
- final String clientId = "failover" + System.currentTimeMillis();
- final String defaultUrl = "amqp://guest:guest@" + clientId + "/test" +
- "?brokerlist='vm://:1;vm://:2;vm://:3'&failover='roundrobin?cyclecount='2''";
-
- System.out.println("url = [" + defaultUrl + "]");
-
- System.out.println("connection url = [" + new AMQConnectionURL(defaultUrl) + "]");
-
- final String url = argv.length == 0 ? defaultUrl : argv[0];
- new FailoverTxTest(url);
-
- }
- catch (Throwable t)
- {
-
- if (t instanceof IllegalStateException)
- {
- t.getMessage().endsWith("has been closed");
- }
- else
- {
- Assert.fail("Unexpected Exception occured:" + t.getMessage());
- }
- }
- finally
- {
- tester.stopTesting();
- }
- }
-}
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
index fad1849fed..0c57a73d5d 100644
--- a/java/client/src/test/java/org/apache/qpid/flow/ChannelFlowTest.java
+++ b/java/client/src/test/java/org/apache/qpid/flow/ChannelFlowTest.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
diff --git a/java/client/src/test/java/org/apache/qpid/forwardall/Combined.java b/java/client/src/test/java/org/apache/qpid/forwardall/Combined.java
deleted file mode 100644
index ea5216dd2d..0000000000
--- a/java/client/src/test/java/org/apache/qpid/forwardall/Combined.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.forwardall;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.Assert;
-import org.junit.After;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-
-/**
- * Runs the Service's and Client parts of the test in the same process
- * as the broker
- */
-public class Combined
-{
- @Test
- public void forwardAll() throws Exception
- {
- int services = 2;
- ServiceCreator.start("vm://:1", services);
-
- //give them time to get registered etc.
- System.out.println("Services started, waiting for them to initialise...");
- Thread.sleep(5 * 1000);
- System.out.println("Starting client...");
-
- new Client("vm://:1", services).waitUntilComplete();
-
- System.out.println("Completed successfully!");
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(Combined.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/forwardall/ServiceCreator.java b/java/client/src/test/java/org/apache/qpid/forwardall/ServiceCreator.java
deleted file mode 100644
index 6d43f85cf2..0000000000
--- a/java/client/src/test/java/org/apache/qpid/forwardall/ServiceCreator.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.forwardall;
-
-public class ServiceCreator implements Runnable
-{
- private final String broker;
-
- ServiceCreator(String broker)
- {
- this.broker = broker;
- }
-
- public void run()
- {
- try
- {
- new Service(broker);
- }
- catch (Exception e)
- {
- e.printStackTrace(System.out);
- }
- }
-
- static void start(String broker, int services) throws InterruptedException
- {
- Thread[] threads = new Thread[services];
- ServiceCreator runner = new ServiceCreator(broker);
- //start services
- System.out.println("Starting " + services + " services...");
- for (int i = 0; i < services; i++)
- {
- threads[i] = new Thread(runner);
- threads[i].start();
- }
-
- for (int i = 0; i < threads.length; i++)
- {
- threads[i].join();
- }
- }
-
- public static void main(String[] argv) throws Exception
- {
- final String connectionString;
- final int services;
- if (argv.length == 0) {
- connectionString = "localhost:5672";
- services = 100;
- }
- else
- {
- connectionString = argv[0];
- services = Integer.parseInt(argv[1]);
- }
- start(connectionString, services);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/forwardall/SpecialQueue.java b/java/client/src/test/java/org/apache/qpid/forwardall/SpecialQueue.java
deleted file mode 100644
index efa633033f..0000000000
--- a/java/client/src/test/java/org/apache/qpid/forwardall/SpecialQueue.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.forwardall;
-
-import org.apache.qpid.client.AMQQueue;
-
-/**
- * Queue that allows several private queues to be registered and bound
- * to an exchange with the same routing key.
- *
- */
-class SpecialQueue extends AMQQueue
-{
- private final String name;
-
- SpecialQueue(String name)
- {
- super(name, true);
- this.name = name;
- }
-
- public String getRoutingKey()
- {
- return name;
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/forwardall/UnitTests.java b/java/client/src/test/java/org/apache/qpid/forwardall/UnitTests.java
deleted file mode 100644
index c62acce11d..0000000000
--- a/java/client/src/test/java/org/apache/qpid/forwardall/UnitTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.forwardall;
-
-import junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- Combined.class
-})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
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
index 161f225d08..983186a545 100644
--- a/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargePublisher.java
+++ b/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargePublisher.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 5268884b93..03ace4a8d9 100644
--- a/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargeSubscriber.java
+++ b/java/client/src/test/java/org/apache/qpid/fragmentation/TestLargeSubscriber.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
diff --git a/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java b/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java
index c76596ac5c..49e1630f15 100644
--- a/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java
+++ b/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java
@@ -1,28 +1,26 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.framing;
-import junit.framework.JUnit4TestAdapter;
import org.apache.mina.common.ByteBuffer;
-import org.apache.xml.security.utils.Base64;
-import org.apache.xml.security.exceptions.Base64DecodingException;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
import java.io.BufferedReader;
import java.io.IOException;
@@ -31,10 +29,11 @@ import java.io.Reader;
import java.util.Enumeration;
import java.util.Properties;
-public class FieldTableTest
+import junit.framework.TestCase;
+
+public class FieldTableTest extends TestCase
{
- @Test
- public void dataDump() throws IOException, AMQFrameDecodingException, Base64DecodingException
+ public void testDataDump() throws IOException, AMQFrameDecodingException
{
byte[] data = readBase64("content.txt");
System.out.println("Got " + data.length + " bytes of data");
@@ -51,19 +50,17 @@ public class FieldTableTest
}
/*
- @Test
- public void case1() throws AMQFrameDecodingException, IOException
+ public void testCase1() throws AMQFrameDecodingException, IOException
{
- testEncoding(load("FieldTableTest.properties"));
+ doTestEncoding(load("FieldTableTest.properties"));
}
- @Test
- public void case2() throws AMQFrameDecodingException, IOException
+ public void testCase2() throws AMQFrameDecodingException, IOException
{
- testEncoding(load("FieldTableTest2.properties"));
+ doTestEncoding(load("FieldTableTest2.properties"));
}
*/
- void testEncoding(FieldTable table) throws AMQFrameDecodingException
+ void doTestEncoding(FieldTable table) throws AMQFrameDecodingException
{
assertEquivalent(table, encodeThenDecode(table));
}
@@ -101,10 +98,11 @@ public class FieldTableTest
return ((BasicContentHeaderProperties) header.properties).getHeaders();
}
- byte[] readBase64(String name) throws IOException, Base64DecodingException
+ byte[] readBase64(String name) throws IOException
{
String content = read(new InputStreamReader(getClass().getResourceAsStream(name)));
- return Base64.decode(content);
+
+ return org.apache.commons.codec.binary.Base64.decodeBase64(content.getBytes());
}
FieldTable load(String name) throws IOException
@@ -155,6 +153,6 @@ public class FieldTableTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(FieldTableTest.class);
+ return new junit.framework.TestSuite(FieldTableTest.class);
}
}
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
index 480596b022..d97fc22a35 100644
--- a/java/client/src/test/java/org/apache/qpid/headers/Listener.java
+++ b/java/client/src/test/java/org/apache/qpid/headers/Listener.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index fc976766e4..f1f310c6e5 100644
--- a/java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java
+++ b/java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 16113037d1..a4ac5f670d 100644
--- a/java/client/src/test/java/org/apache/qpid/headers/Publisher.java
+++ b/java/client/src/test/java/org/apache/qpid/headers/Publisher.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 3715ef7cc4..ee6a12c233 100644
--- 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
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 05098269c1..1c9d8b0fd5 100644
--- 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
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 1e9f57c07f..1acead674c 100644
--- 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
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
diff --git a/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/JNDIReferenceableTest.java b/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/JNDIReferenceableTest.java
deleted file mode 100644
index 7c7d32991f..0000000000
--- a/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/JNDIReferenceableTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.referenceabletest;
-
-import org.junit.Test;
-import org.junit.Assert;
-import junit.framework.JUnit4TestAdapter;
-
-import javax.naming.NamingException;
-import javax.naming.NameAlreadyBoundException;
-import javax.naming.NoInitialContextException;
-
-
-/**
- * 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
-{
-
- @Test
- public void referenceable()
- {
- Bind b = null;
- try
- {
- try
- {
- b = new Bind();
- }
- catch (NameAlreadyBoundException e)
- {
- if (new Unbind().unbound())
- {
- try
- {
- b = new Bind();
- }
- catch (NameAlreadyBoundException ee)
- {
- Assert.fail("Unable to clear bound objects for test.");
- }
- }
- else
- {
- Assert.fail("Unable to clear bound objects for test.");
- }
- }
- }
- catch (NoInitialContextException e)
- {
- Assert.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.");
- }
-
- Assert.assertTrue(b.bound());
-
- Lookup l = new Lookup();
-
- Assert.assertTrue(l.connectionFactoryValue().equals(b.connectionFactoryValue()));
-
- Assert.assertTrue(l.connectionValue().equals(b.connectionValue()));
-
- Assert.assertTrue(l.topicValue().equals(b.topicValue()));
-
-
- Unbind u = new Unbind();
-
- Assert.assertTrue(u.unbound());
-
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(JNDIReferenceableTest.class);
- }
-}
diff --git a/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/UnitTests.java b/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/UnitTests.java
deleted file mode 100644
index f7b3889d22..0000000000
--- a/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/UnitTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.referenceabletest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.apache.qpid.ack.*;
-import junit.framework.JUnit4TestAdapter;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({JNDIReferenceableTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(org.apache.qpid.destinationurl.UnitTests.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
index 981bfdc3a6..ebc9488f68 100644
--- a/java/client/src/test/java/org/apache/qpid/latency/LatencyTest.java
+++ b/java/client/src/test/java/org/apache/qpid/latency/LatencyTest.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index f0a80f2ead..de3d558f7c 100644
--- a/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java
+++ b/java/client/src/test/java/org/apache/qpid/mina/AcceptorTest.java
@@ -1,23 +1,25 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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 junit.framework.JUnit4TestAdapter;
import org.apache.log4j.Logger;
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoAcceptor;
@@ -26,17 +28,18 @@ 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.junit.Test;
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
+public class AcceptorTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(AcceptorTest.class);
@@ -68,8 +71,7 @@ public class AcceptorTest
}
}
- @Test
- public void startAcceptor() throws IOException
+ public void testStartAcceptor() throws IOException
{
IoAcceptor acceptor = null;
acceptor = new SocketAcceptor();
@@ -87,14 +89,14 @@ public class AcceptorTest
_logger.info("Bound on port " + PORT);
}
- public static junit.framework.Test suite()
+ public static void main(String[] args) throws IOException
{
- return new JUnit4TestAdapter(AcceptorTest.class);
+ AcceptorTest a = new AcceptorTest();
+ a.testStartAcceptor();
}
- public static void main(String[] args) throws IOException
+ public static junit.framework.Test suite()
{
- AcceptorTest a = new AcceptorTest();
- a.startAcceptor();
+ 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
index 547ffc9dcb..bfe29c47e6 100644
--- a/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java
+++ b/java/client/src/test/java/org/apache/qpid/mina/BlockingAcceptorTest.java
@@ -1,25 +1,26 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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 junit.framework.JUnit4TestAdapter;
import org.apache.log4j.Logger;
-import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@@ -27,19 +28,15 @@ import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
-public class BlockingAcceptorTest
+import junit.framework.TestCase;
+
+public class BlockingAcceptorTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(BlockingAcceptorTest.class);
public static int PORT = 9999;
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(AcceptorTest.class);
- }
-
- @Test
- public void startAcceptor() throws IOException
+ public void testStartAcceptor() throws IOException
{
ServerSocket sock = new ServerSocket(PORT);
@@ -86,6 +83,11 @@ public class BlockingAcceptorTest
public static void main(String[] args) throws IOException
{
BlockingAcceptorTest a = new BlockingAcceptorTest();
- a.startAcceptor();
+ 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
index ae0b7ea522..910345624f 100644
--- a/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
+++ b/java/client/src/test/java/org/apache/qpid/mina/WriterTest.java
@@ -1,256 +1,256 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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 junit.framework.JUnit4TestAdapter;
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 org.junit.Test;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
-public class WriterTest implements Runnable
+import junit.framework.TestCase;
+
+public class WriterTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(WriterTest.class);
- private IoSession _session;
+ private static class RunnableWriterTest implements Runnable
+ {
+ private Logger _logger;
- private long _startTime;
+ private IoSession _session;
- private long[] _chunkTimes;
+ private long _startTime;
- private int _chunkCount = 500000;
+ private long[] _chunkTimes;
- private int _chunkSize = 1024;
+ private int _chunkCount = 500000;
- private CountDownLatch _notifier;
+ private int _chunkSize = 1024;
- 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);
- }
+ private CountDownLatch _notifier;
- try
- {
- _logger.info("All buffers sent; waiting for receipt from server");
- _notifier.await();
- }
- catch (InterruptedException e)
+ public RunnableWriterTest(Logger logger)
{
+ _logger = logger;
}
- _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++)
+
+ public void run()
{
- if (i == 0)
+ _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)
{
- average = _chunkTimes[i] - _startTime;
}
- else
+ _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++)
{
- long delta = _chunkTimes[i] - lastChunkTime;
- if (delta != 0)
+ if (i == 0)
+ {
+ average = _chunkTimes[i] - _startTime;
+ }
+ else
{
- average = (average + delta)/2;
+ long delta = _chunkTimes[i] - lastChunkTime;
+ if (delta != 0)
+ {
+ average = (average + delta)/2;
+ }
}
+ lastChunkTime = _chunkTimes[i];
}
- lastChunkTime = _chunkTimes[i];
+ _logger.info("Average chunk time: " + average + "ms");
+ CloseFuture cf = _session.close();
+ cf.join();
}
- _logger.info("Average chunk time: " + average + "ms");
- CloseFuture cf = _session.close();
- cf.join();
- }
- private class WriterHandler extends IoHandlerAdapter
- {
- private int _chunksReceived = 0;
+ private class WriterHandler extends IoHandlerAdapter
+ {
+ private int _chunksReceived = 0;
- private int _partialBytesRead = 0;
+ private int _partialBytesRead = 0;
- private byte _partialCheckNumber;
+ private byte _partialCheckNumber;
- private int _totalBytesReceived = 0;
+ 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)
+ public void messageReceived(IoSession session, Object message) throws Exception
{
- int offset = _chunkSize - _partialBytesRead;
- if (size >= offset)
+ ByteBuffer result = (ByteBuffer) message;
+ _totalBytesReceived += result.remaining();
+ int size = result.remaining();
+ long now = System.currentTimeMillis();
+ if (_partialBytesRead > 0)
{
- _chunkTimes[_chunksReceived++] = now;
- result.position(offset);
+ 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;
+ }
}
- else
- {
- // have not read even one chunk, including the previous partial bytes
- _partialBytesRead += size;
- return;
- }
- }
- int chunkCount = result.remaining()/_chunkSize;
+ 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))
+ for (int i = 0; i < chunkCount; i++)
{
- _logger.error("Check number " + check + " read when expected " + (_chunksReceived%128));
+ _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("Chunk times recorded");
+ _logger.debug("Chunks received now " + _chunksReceived);
+ _logger.debug("Bytes received: " + _totalBytesReceived);
+ _partialBytesRead = result.remaining();
- try
+ if (_partialBytesRead > 0)
{
- result.skip(_chunkSize - 1);
+ _partialCheckNumber = result.get();
}
- catch (IllegalArgumentException e)
+
+ if (_chunksReceived >= _chunkCount)
{
- _logger.error("Position was: " + result.position());
- _logger.error("Tried to skip to: " + (_chunkSize * i));
- _logger.error("limit was; " + result.limit());
+ _notifier.countDown();
}
- }
- _logger.debug("Chunks received now " + _chunksReceived);
- _logger.debug("Bytes received: " + _totalBytesReceived);
- _partialBytesRead = result.remaining();
- if (_partialBytesRead > 0)
- {
- _partialCheckNumber = result.get();
}
- if (_chunksReceived >= _chunkCount)
+ public void exceptionCaught(IoSession session, Throwable cause) throws Exception
{
- _notifier.countDown();
+ _logger.error("Error: " + cause, cause);
}
-
}
- public void exceptionCaught(IoSession session, Throwable cause) throws Exception
+ public void startWriter(int chunkSize) throws IOException, InterruptedException
{
- _logger.error("Error: " + cause, cause);
- }
- }
+ _chunkSize = chunkSize;
- public void startWriter() throws IOException, InterruptedException
- {
- IoConnector ioConnector = null;
+ IoConnector ioConnector = null;
- ioConnector = new SocketConnector();
+ 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");
+ 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");
+ }
}
- @Test
+ private RunnableWriterTest _runnableWriterTest = new RunnableWriterTest(_logger);
+
public void test1k() throws IOException, InterruptedException
{
_logger.info("Starting 1k test");
- _chunkSize = 1024;
- startWriter();
+ _runnableWriterTest.startWriter(1024);
}
- @Test
public void test2k() throws IOException, InterruptedException
{
_logger.info("Starting 2k test");
- _chunkSize = 2048;
- startWriter();
+ _runnableWriterTest.startWriter(2048);
}
- @Test
public void test4k() throws IOException, InterruptedException
{
_logger.info("Starting 4k test");
- _chunkSize = 4096;
- startWriter();
+ _runnableWriterTest.startWriter(4096);
}
- @Test
public void test8k() throws IOException, InterruptedException
{
_logger.info("Starting 8k test");
- _chunkSize = 8192;
- startWriter();
+ _runnableWriterTest.startWriter(8192);
}
- @Test
public void test16k() throws IOException, InterruptedException
{
_logger.info("Starting 16k test");
- _chunkSize = 16384;
- startWriter();
+ _runnableWriterTest.startWriter(16384);
}
- @Test
public void test32k() throws IOException, InterruptedException
{
_logger.info("Starting 32k test");
- _chunkSize = 32768;
- startWriter();
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(WriterTest.class);
+ _runnableWriterTest.startWriter(32768);
}
public static void main(String[] args) throws IOException, InterruptedException
@@ -263,4 +263,9 @@ public class WriterTest implements Runnable
//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
index 66bb2e5e01..10e03d3522 100644
--- a/java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java
+++ b/java/client/src/test/java/org/apache/qpid/multiconsumer/AMQTest.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 77c5bb648c..b060498d9b 100644
--- a/java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java
+++ b/java/client/src/test/java/org/apache/qpid/ping/TestPingClient.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 999f593131..458dca0d56 100644
--- a/java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java
+++ b/java/client/src/test/java/org/apache/qpid/ping/TestPingProducer.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index b297cf8610..c7742be042 100644
--- a/java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java
+++ b/java/client/src/test/java/org/apache/qpid/ping/TestPingPublisher.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 8e6a4a125e..8e8c3f2e6e 100644
--- a/java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java
+++ b/java/client/src/test/java/org/apache/qpid/ping/TestPingSubscriber.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index c3e4fb9e0d..45b241975d 100644
--- a/java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java
+++ b/java/client/src/test/java/org/apache/qpid/pubsub1/TestPublisher.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 968cd23880..14cf206f50 100644
--- a/java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java
+++ b/java/client/src/test/java/org/apache/qpid/pubsub1/TestSubscriber.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 276eec3e11..7cbec7c85c 100644
--- a/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java
+++ b/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceProvidingClient.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
@@ -40,8 +43,7 @@ public class ServiceProvidingClient
private AMQConnection _connection;
public ServiceProvidingClient(String brokerDetails, String username, String password,
- String clientName, String virtualPath, String serviceName,
- final boolean persistent)
+ String clientName, String virtualPath, String serviceName)
throws AMQException, JMSException, URLSyntaxException
{
_connection = new AMQConnection(brokerDetails, username, password,
@@ -107,8 +109,7 @@ public class ServiceProvidingClient
_logger.info("About to create a producer");
_destinationProducer = session.createProducer(responseDest);
_destinationProducer.setDisableMessageTimestamp(true);
- _destinationProducer.setDeliveryMode(persistent?DeliveryMode.PERSISTENT:
- DeliveryMode.NON_PERSISTENT);
+ _destinationProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
_logger.info("After create a producer");
}
}
@@ -176,7 +177,7 @@ public class ServiceProvidingClient
try
{
ServiceProvidingClient client = new ServiceProvidingClient(args[0], args[1], args[2],
- clientId, args[3], args[4], true);
+ clientId, args[3], args[4]);
client.run();
}
catch (JMSException 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
index 29eaf02701..5dc57364b3 100644
--- a/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java
+++ b/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
@@ -165,15 +168,14 @@ public class ServiceRequestingClient implements ExceptionListener
}
public ServiceRequestingClient(String brokerHosts, String clientID, String username, String password,
String vpath, String commandQueueName,
- final int messageCount, final int messageDataLength, boolean persistent) throws AMQException, URLSyntaxException
+ 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);
- _session = (Session) _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+ _session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
_connection.setExceptionListener(this);
@@ -182,7 +184,7 @@ public class ServiceRequestingClient implements ExceptionListener
AMQQueue destination = new AMQQueue(commandQueueName);
_producer = (MessageProducer) _session.createProducer(destination);
_producer.setDisableMessageTimestamp(true);
- _producer.setDeliveryMode(persistent?DeliveryMode.PERSISTENT:DeliveryMode.NON_PERSISTENT);
+ _producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
_tempDestination = new AMQQueue("TempResponse" +
Long.toString(System.currentTimeMillis()), true);
@@ -193,7 +195,6 @@ public class ServiceRequestingClient implements ExceptionListener
TextMessage first = _session.createTextMessage(MESSAGE_DATA);
first.setJMSReplyTo(_tempDestination);
_producer.send(first);
- _session.commit(); // TODO REMOVE
try
{
Thread.sleep(1000);
@@ -233,7 +234,6 @@ public class ServiceRequestingClient implements ExceptionListener
}
_producer.send(msg);
}
- _session.commit(); // TODO REMOVE
_log.info("Finished sending " + _messageCount + " messages");
}
@@ -268,7 +268,7 @@ public class ServiceRequestingClient implements ExceptionListener
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, true);
+ messageDataLength);
Object waiter = new Object();
client.run(waiter);
synchronized (waiter)
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
index a9357ae2ae..56d1ce9b6d 100644
--- a/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
+++ b/java/client/src/test/java/org/apache/qpid/requestreply1/VmRequestReply.java
@@ -1,63 +1,44 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.junit.Test;
-import org.junit.Before;
-import org.junit.Assert;
-import org.junit.After;
+import org.apache.qpid.test.VMBrokerSetup;
import org.apache.log4j.Logger;
-import junit.framework.JUnit4TestAdapter;
-public class VmRequestReply
+import junit.framework.TestCase;
+
+public class VmRequestReply extends TestCase
{
private static final Logger _logger = Logger.getLogger(VmRequestReply.class);
- @Before
- public void startVmBrokers()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create VM Broker");
- }
- }
-
- @After
- public void stopVmBrokers()
- {
- TransportConnection.killVMBroker(1);
- }
-
- @Test
- public void simpleClient() throws Exception
+ public void testSimpleClient() throws Exception
{
ServiceProvidingClient serviceProvider = new ServiceProvidingClient("vm://:1", "guest", "guest",
"serviceProvidingClient", "/test",
- "serviceQ", false);
+ "serviceQ");
ServiceRequestingClient serviceRequester = new ServiceRequestingClient("vm://:1", "myClient", "guest", "guest",
- "/test", "serviceQ", 5000, 512, false);
+ "/test", "serviceQ", 5000, 512);
serviceProvider.run();
Object waiter = new Object();
@@ -71,21 +52,21 @@ public class VmRequestReply
}
}
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(VmRequestReply.class);
- }
-
public static void main(String[] args)
{
VmRequestReply rr = new VmRequestReply();
try
{
- rr.simpleClient();
+ 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/VMBrokerSetup.java b/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
new file mode 100644
index 0000000000..e859fac4af
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/VMBrokerSetup.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.apache.qpid.client.transport.TransportConnection;
+
+public class VMBrokerSetup extends TestSetup
+{
+ public VMBrokerSetup(Test t)
+ {
+ super(t);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ try
+ {
+ TransportConnection.createVMBroker(1);
+ }
+ catch (Exception e)
+ {
+ fail("Unable to create broker: " + e);
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ TransportConnection.killVMBroker(1);
+ super.tearDown();
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/ack/RecoverTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
index 0feecb5a79..5161705ef2 100644
--- a/java/client/src/test/java/org/apache/qpid/ack/RecoverTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
@@ -1,23 +1,24 @@
/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.ack;
+package org.apache.qpid.test.unit.ack;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
@@ -25,31 +26,29 @@ 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.junit.Assert;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.*;
-public class RecoverTest
+import junit.framework.TestCase;
+
+public class RecoverTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(RecoverTest.class);
static
{
- //DOMConfigurator.configure("../etc/log4j.xml");
- DOMConfigurator.configure("broker/etc/log4j.xml");
+ String workdir = System.getProperty("QPID_WORK");
+ if (workdir == null || workdir.equals(""))
+ {
+ String tempdir = System.getProperty("java.io.tmpdir");
+ System.out.println("QPID_WORK not set using tmp directory: " + tempdir);
+ System.setProperty("QPID_WORK", tempdir);
+ }
+ DOMConfigurator.configure("../broker/etc/log4j.xml");
}
- @After
- public void stopVmBroker()
- {
- TransportConnection.killVMBroker(1);
- }
-
- @Test
- public void recoverResendsMsgs() throws Exception
+ public void testRecoverResendsMsgs() throws Exception
{
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
@@ -83,13 +82,13 @@ public class RecoverTest
// no ack for last three messages so when I call recover I expect to get three messages back
consumerSession.recover();
tm = (TextMessage) consumer.receive(3000);
- Assert.assertEquals("msg2", tm.getText());
+ assertEquals("msg2", tm.getText());
tm = (TextMessage) consumer.receive(3000);
- Assert.assertEquals("msg3", tm.getText());
+ assertEquals("msg3", tm.getText());
tm = (TextMessage) consumer.receive(3000);
- Assert.assertEquals("msg4", tm.getText());
+ assertEquals("msg4", tm.getText());
_logger.info("Received redelivery of three messages. Acknowledging last message");
tm.acknowledge();
@@ -99,16 +98,14 @@ public class RecoverTest
consumerSession.recover();
tm = (TextMessage) consumer.receiveNoWait();
- Assert.assertNull(tm);
+ assertNull(tm);
_logger.info("No messages redelivered as is expected");
con.close();
-
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(RecoverTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(RecoverTest.class));
}
}
-
diff --git a/java/client/src/test/java/org/apache/qpid/basic/BytesMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
index e8a9debe1d..4d37c5d2a6 100644
--- a/java/client/src/test/java/org/apache/qpid/basic/BytesMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
@@ -1,37 +1,43 @@
/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.basic;
+package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
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 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.mina.common.ByteBuffer;
-import org.junit.Test;
-import javax.jms.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import javax.jms.*;
-public class BytesMessageTest implements MessageListener
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+public class BytesMessageTest extends TestCase implements MessageListener
{
private Connection _connection;
private Destination _destination;
@@ -41,11 +47,17 @@ public class BytesMessageTest implements MessageListener
private int _count = 100;
public String _connectionString = "vm://:1";
- void init() throws Exception
+ protected void setUp() throws Exception
{
+ super.setUp();
init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
}
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
void init(AMQConnection connection) throws Exception
{
init(connection, new AMQQueue(randomize("BytesMessageTest"), true));
@@ -62,11 +74,8 @@ public class BytesMessageTest implements MessageListener
connection.start();
}
- @Test
public void test() throws Exception
{
- init();
-
try
{
send(_count);
@@ -87,6 +96,17 @@ public class BytesMessageTest implements MessageListener
for (int i = 0; i < count; i++)
{
BytesMessage msg = _session.createBytesMessage();
+
+ try
+ {
+ msg.readFloat();
+ Assert.fail("Message should not be readable");
+ }
+ catch (MessageNotReadableException mnwe)
+ {
+ //normal execution
+ }
+
byte[] data = ("Message " + i).getBytes();
msg.writeBytes(data);
messages.add(data);
@@ -96,7 +116,7 @@ public class BytesMessageTest implements MessageListener
void waitFor(int count) throws InterruptedException
{
- synchronized (received)
+ synchronized(received)
{
while (received.size() < count)
{
@@ -114,6 +134,16 @@ public class BytesMessageTest implements MessageListener
byte[] data = new byte[buffer.remaining()];
buffer.get(data);
actual.add(data);
+
+ try
+ {
+ m.writeBoolean(true);
+ Assert.fail("Message should not be writeable");
+ }
+ catch (MessageNotWriteableException mnwe)
+ {
+ //normal execution
+ }
}
assertEqual(messages.iterator(), actual.iterator());
@@ -164,7 +194,7 @@ public class BytesMessageTest implements MessageListener
public void onMessage(Message message)
{
- synchronized (received)
+ synchronized(received)
{
received.add((JMSBytesMessage) message);
received.notify();
@@ -202,6 +232,6 @@ public class BytesMessageTest implements MessageListener
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(BytesMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(BytesMessageTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
new file mode 100644
index 0000000000..079def81d0
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
@@ -0,0 +1,81 @@
+/*
+ *
+ * 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.basic;
+
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.client.message.JMSTextMessage;
+import org.apache.qpid.client.message.TestMessageHelper;
+
+import java.util.Enumeration;
+
+import javax.jms.JMSException;
+
+import junit.framework.TestCase;
+
+public class FieldTableKeyEnumeratorTest extends TestCase
+{
+ public void testKeyEnumeration()
+ {
+ FieldTable result = new FieldTable();
+ result.put("one", 1L);
+ result.put("two", 2L);
+ result.put("three", 3L);
+ result.put("four", 4L);
+ result.put("five", 5L);
+
+ Enumeration e = result.keys();
+
+ assertTrue("one".equals(e.nextElement()));
+ assertTrue("two".equals(e.nextElement()));
+ assertTrue("three".equals(e.nextElement()));
+ assertTrue("four".equals(e.nextElement()));
+ assertTrue("five".equals(e.nextElement()));
+ }
+
+ public void testPropertEnu()
+ {
+ try
+ {
+ JMSTextMessage text = TestMessageHelper.newJMSTextMessage();
+
+ text.setBooleanProperty("Boolean1", true);
+ text.setBooleanProperty("Boolean2", true);
+ text.setIntProperty("Int", 2);
+ text.setLongProperty("Long", 2);
+
+ Enumeration e = text.getPropertyNames();
+
+ assertTrue("Boolean1".equals(e.nextElement()));
+ assertTrue("Boolean2".equals(e.nextElement()));
+ assertTrue("Int".equals(e.nextElement()));
+ assertTrue("Long".equals(e.nextElement()));
+ }
+ catch (JMSException e)
+ {
+
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(FieldTableKeyEnumeratorTest.class);
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/basic/FieldTableMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
index 82e43773a4..67b7f49565 100644
--- a/java/client/src/test/java/org/apache/qpid/basic/FieldTableMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
@@ -1,23 +1,25 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.basic;
+package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
@@ -26,16 +28,16 @@ import org.apache.qpid.client.message.JMSBytesMessage;
import org.apache.qpid.framing.AMQFrameDecodingException;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.framing.FieldTableTest;
+import org.apache.qpid.test.VMBrokerSetup;
import org.apache.mina.common.ByteBuffer;
-import org.junit.Before;
-import org.junit.Test;
-import javax.jms.*;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Enumeration;
+import javax.jms.*;
-public class FieldTableMessageTest implements MessageListener
+import junit.framework.TestCase;
+
+public class FieldTableMessageTest extends TestCase implements MessageListener
{
private AMQConnection _connection;
private AMQDestination _destination;
@@ -45,12 +47,18 @@ public class FieldTableMessageTest implements MessageListener
private int _count = 10;
public String _connectionString = "vm://:1";
- @Before
- public void init() throws Exception
+ protected void setUp() throws Exception
{
- init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
+ super.setUp();
+ init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
}
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+
private void init(AMQConnection connection) throws Exception
{
init(connection, new AMQQueue(randomize("FieldTableMessageTest"), true));
@@ -82,7 +90,6 @@ public class FieldTableMessageTest implements MessageListener
return result;
}
- @Test
public void test() throws Exception
{
int count = _count;
@@ -109,7 +116,7 @@ public class FieldTableMessageTest implements MessageListener
{
synchronized(received)
{
- while(received.size() < count)
+ while (received.size() < count)
{
received.wait();
}
@@ -144,13 +151,13 @@ public class FieldTableMessageTest implements MessageListener
{
FieldTableMessageTest test = new FieldTableMessageTest();
test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
- test.init();
+ test.setUp();
test._count = argv.length > 1 ? Integer.parseInt(argv[1]) : 5;
test.test();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(FieldTableMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(FieldTableMessageTest.class));
}
}
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
new file mode 100644
index 0000000000..f25d2887ae
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
@@ -0,0 +1,218 @@
+/*
+ *
+ * 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.basic;
+
+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 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 java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.jms.*;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+public class MapMessageTest extends TestCase implements MessageListener
+{
+ private AMQConnection _connection;
+ private Destination _destination;
+ private AMQSession _session;
+ private final List<JMSMapMessage> received = new ArrayList<JMSMapMessage>();
+ private final List<String> messages = new ArrayList<String>();
+ private int _count = 100;
+ public String _connectionString = "vm://:1";
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ try
+ {
+ init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
+ }
+ catch (Exception e)
+ {
+ fail("Unable to initialilse connection: " + e);
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ private void init(AMQConnection connection) throws Exception
+ {
+ Destination destination = new AMQQueue(randomize("MapMessageTest"), true);
+ init(connection, destination);
+ }
+
+ private void init(AMQConnection connection, Destination destination) throws Exception
+ {
+ _connection = connection;
+ _destination = destination;
+ _session = (AMQSession) connection.createSession(false, AMQSession.AUTO_ACKNOWLEDGE);
+
+ //set up a slow consumer
+ _session.createConsumer(destination).setMessageListener(this);
+ connection.start();
+ }
+
+ public void test() throws Exception
+ {
+ int count = _count;
+ send(count);
+ waitFor(count);
+ check();
+ System.out.println("Completed without failure");
+ _connection.close();
+ }
+
+ void send(int count) throws JMSException
+ {
+ //create a publisher
+ MessageProducer producer = _session.createProducer(_destination);
+ for (int i = 0; i < count; i++)
+ {
+ String text = "Message " + i;
+ messages.add(text);
+ MapMessage message = _session.createMapMessage();
+
+ message.setBoolean("odd", i / 2 == 0);
+ message.setInt("messageNumber", i);
+ message.setString("message", text);
+
+ producer.send(message);
+ }
+ }
+
+ void waitFor(int count) throws InterruptedException
+ {
+ synchronized(received)
+ {
+ while (received.size() < count)
+ {
+ received.wait();
+ }
+ }
+ }
+
+ void check() throws JMSException
+ {
+ List<String> actual = new ArrayList<String>();
+ int count = 0;
+ for (JMSMapMessage m : received)
+ {
+ actual.add(m.getString("message"));
+ assertEqual(m.getInt("messageNumber"), count);
+ assertEqual(m.getBoolean("odd"), count / 2 == 0);
+
+// try
+// {
+// m.setInt("testint", 3);
+// fail("Message should not be writeable");
+// }
+// catch (MessageNotWriteableException mnwe)
+// {
+// //normal execution
+// }
+
+
+ count++;
+ }
+
+ assertEqual(messages.iterator(), actual.iterator());
+ }
+
+ private static void assertEqual(Iterator expected, Iterator actual)
+ {
+ List<String> errors = new ArrayList<String>();
+ while (expected.hasNext() && actual.hasNext())
+ {
+ try
+ {
+ assertEqual(expected.next(), actual.next());
+ }
+ catch (Exception e)
+ {
+ errors.add(e.getMessage());
+ }
+ }
+ while (expected.hasNext())
+ {
+ errors.add("Expected " + expected.next() + " but no more actual values.");
+ }
+ while (actual.hasNext())
+ {
+ errors.add("Found " + actual.next() + " but no more expected values.");
+ }
+ if (!errors.isEmpty())
+ {
+ throw new RuntimeException(errors.toString());
+ }
+ }
+
+ private static void assertEqual(Object expected, Object actual)
+ {
+ if (!expected.equals(actual))
+ {
+ throw new RuntimeException("Expected '" + expected + "' found '" + actual + "'");
+ }
+ }
+
+ public void onMessage(Message message)
+ {
+ synchronized(received)
+ {
+ received.add((JMSMapMessage) message);
+ received.notify();
+ }
+ }
+
+ private static String randomize(String in)
+ {
+ return in + System.currentTimeMillis();
+ }
+
+ public static void main(String[] argv) throws Exception
+ {
+ MapMessageTest test = new MapMessageTest();
+ test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
+ test.setUp();
+ if (argv.length > 1)
+ {
+ test._count = Integer.parseInt(argv[1]);
+ }
+ test.test();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new VMBrokerSetup(new junit.framework.TestSuite(MapMessageTest.class));
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/basic/MultipleConnectionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
index 8bf6fc1991..16ac8596c3 100644
--- a/java/client/src/test/java/org/apache/qpid/basic/MultipleConnectionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
@@ -1,37 +1,40 @@
/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.basic;
+package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
-import org.junit.Test;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.*;
-/**
- * This is a slow test.
- */
-public class MultipleConnectionTest
+import junit.framework.TestCase;
+
+public class MultipleConnectionTest extends TestCase
{
- public static String _connectionString="vm://:1";
+ public static final String _defaultBroker = "vm://:1";
+ public static String _connectionString = _defaultBroker;
private static class Receiver
{
@@ -106,19 +109,21 @@ public class MultipleConnectionTest
public synchronized void onMessage(Message message)
{
_count++;
- notifyAll();
+ notify();
}
synchronized boolean waitUntil(int expected, long maxWait) throws InterruptedException
{
long start = System.currentTimeMillis();
- long timeLeft = maxWait;
- do
+ while (expected > _count)
{
+ long timeLeft = maxWait - timeSince(start);
+ if (timeLeft < 0)
+ {
+ break;
+ }
wait(timeLeft);
- timeLeft = maxWait - timeSince(start);
}
- while (expected > _count && timeLeft > 0);
return expected <= _count;
}
@@ -135,7 +140,7 @@ public class MultipleConnectionTest
private static void waitForCompletion(int expected, long wait, Receiver[] receivers) throws InterruptedException
{
- for(int i = 0; i < receivers.length; i++)
+ for (int i = 0; i < receivers.length; i++)
{
waitForCompletion(expected, wait, receivers[i]._counters);
}
@@ -143,12 +148,12 @@ public class MultipleConnectionTest
private static void waitForCompletion(int expected, long wait, MessageCounter[] counters) throws InterruptedException
{
- for(int i = 0; i < counters.length; i++)
+ for (int i = 0; i < counters.length; i++)
{
- if(!counters[i].waitUntil(expected, wait))
+ if (!counters[i].waitUntil(expected, wait))
{
throw new RuntimeException("Expected: " + expected + " got " + counters[i]);
- };
+ }
}
}
@@ -159,7 +164,7 @@ public class MultipleConnectionTest
public static void main(String[] argv) throws Exception
{
- String broker = argv.length > 0 ? argv[0] : "vm://:1";
+ String broker = argv.length > 0 ? argv[0] : _defaultBroker;
int connections = 7;
int sessions = 2;
@@ -169,7 +174,6 @@ public class MultipleConnectionTest
test.test();
}
- @Test
public void test() throws Exception
{
String broker = _connectionString;
@@ -177,21 +181,13 @@ public class MultipleConnectionTest
AMQTopic topic = new AMQTopic("amq.topic");
- /*
- Receiver[] receivers = new Receiver[connections];
- for(int i = 0; i < receivers.length; i++)
- {
- receivers[i] = new Receiver(broker, topic, sessions);
- }
- */
-
Receiver[] receivers = new Receiver[]{
new Receiver(broker, topic, 2),
new Receiver(broker, topic, 14)
};
Publisher publisher = new Publisher(broker, topic);
- for(int i = 0; i < messages; i++)
+ for (int i = 0; i < messages; i++)
{
publisher.send("Message " + (i + 1));
}
@@ -204,7 +200,7 @@ public class MultipleConnectionTest
finally
{
publisher.close();
- for(int i = 0; i < receivers.length; i++)
+ for (int i = 0; i < receivers.length; i++)
{
receivers[i].close();
}
@@ -213,6 +209,6 @@ public class MultipleConnectionTest
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(MultipleConnectionTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(MultipleConnectionTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/basic/ObjectMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
index a78cd6f72b..dfb1b26454 100644
--- a/java/client/src/test/java/org/apache/qpid/basic/ObjectMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
@@ -1,41 +1,47 @@
/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.basic;
+package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
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 org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSObjectMessage;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
+import javax.jms.MessageNotWriteableException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-public class ObjectMessageTest implements MessageListener
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+public class ObjectMessageTest extends TestCase implements MessageListener
{
private AMQConnection _connection;
private AMQDestination _destination;
@@ -45,11 +51,22 @@ public class ObjectMessageTest implements MessageListener
private int _count = 100;
public String _connectionString = "vm://:1";
- @Before
- public void init() throws Exception
+ protected void setUp() throws Exception
{
- String broker = _connectionString;
- init(new AMQConnection(broker, "guest", "guest", randomize("Client"), "/test_path"));
+ super.setUp();
+ try
+ {
+ init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
+ }
+ catch (Exception e)
+ {
+ fail("Uable to initialise: " + e);
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
}
private void init(AMQConnection connection) throws Exception
@@ -68,7 +85,6 @@ public class ObjectMessageTest implements MessageListener
connection.start();
}
- @Test
public void test() throws Exception
{
int count = _count;
@@ -95,7 +111,7 @@ public class ObjectMessageTest implements MessageListener
{
synchronized(received)
{
- while(received.size() < count)
+ while (received.size() < count)
{
received.wait();
}
@@ -108,6 +124,17 @@ public class ObjectMessageTest implements MessageListener
for (JMSObjectMessage m : received)
{
actual.add(m.getObject());
+
+// try
+// {
+// m.setObject("Test text");
+// Assert.fail("Message should not be writeable");
+// }
+// catch (MessageNotWriteableException mnwe)
+// {
+// //normal execution
+// }
+
}
assertEqual(messages.iterator(), actual.iterator());
@@ -116,25 +143,26 @@ public class ObjectMessageTest implements MessageListener
private static void assertEqual(Iterator expected, Iterator actual)
{
List<String> errors = new ArrayList<String>();
- while(expected.hasNext() && actual.hasNext())
+ while (expected.hasNext() && actual.hasNext())
{
- try{
+ try
+ {
assertEqual(expected.next(), actual.next());
}
- catch(Exception e)
+ catch (Exception e)
{
errors.add(e.getMessage());
}
}
- while(expected.hasNext())
+ while (expected.hasNext())
{
errors.add("Expected " + expected.next() + " but no more actual values.");
}
- while(actual.hasNext())
+ while (actual.hasNext())
{
errors.add("Found " + actual.next() + " but no more expected values.");
}
- if(!errors.isEmpty())
+ if (!errors.isEmpty())
{
throw new RuntimeException(errors.toString());
}
@@ -142,7 +170,7 @@ public class ObjectMessageTest implements MessageListener
private static void assertEqual(Object expected, Object actual)
{
- if(!expected.equals(actual))
+ if (!expected.equals(actual))
{
throw new RuntimeException("Expected '" + expected + "' found '" + actual + "'");
}
@@ -183,7 +211,7 @@ public class ObjectMessageTest implements MessageListener
public String toString()
{
- return "Payload[" + data +"]";
+ return "Payload[" + data + "]";
}
}
@@ -191,7 +219,7 @@ public class ObjectMessageTest implements MessageListener
{
ObjectMessageTest test = new ObjectMessageTest();
test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
- test.init();
+ test.setUp();
if (argv.length > 1)
{
test._count = Integer.parseInt(argv[1]);
@@ -201,6 +229,6 @@ public class ObjectMessageTest implements MessageListener
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(ObjectMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(ObjectMessageTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
new file mode 100644
index 0000000000..302551b05c
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ReceiveTest.java
@@ -0,0 +1,115 @@
+/*
+ *
+ * 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.basic;
+
+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 org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
+
+import javax.jms.MessageConsumer;
+
+import junit.framework.TestCase;
+
+public class ReceiveTest extends TestCase
+{
+ private AMQConnection _connection;
+ private AMQDestination _destination;
+ private AMQSession _session;
+ private MessageConsumer _consumer;
+
+ private static final String VM_BROKER = "vm://:1";
+ public String _connectionString = VM_BROKER;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ if (_connectionString.equals(VM_BROKER))
+ {
+ createVMBroker();
+ String broker = _connectionString;
+ init(new AMQConnection(broker, "guest", "guest", "ReceiveTestClient", "/test_path"));
+ }
+ }
+
+ public void createVMBroker()
+ {
+ try
+ {
+ TransportConnection.createVMBroker(1);
+ }
+ catch (AMQVMBrokerCreationException e)
+ {
+ fail("Unable to create broker: " + e);
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ if (_connectionString.equals(VM_BROKER))
+ {
+ TransportConnection.killVMBroker(1);
+ }
+ super.tearDown();
+ }
+
+ private void init(AMQConnection connection) throws Exception
+ {
+ init(connection, new AMQQueue("ReceiveTest", true));
+ }
+
+ private void init(AMQConnection connection, AMQDestination destination) throws Exception
+ {
+ _connection = connection;
+ _destination = destination;
+ _session = (AMQSession) connection.createSession(true, AMQSession.NO_ACKNOWLEDGE);
+ _consumer = _session.createConsumer(_destination);
+ _connection.start();
+ }
+
+ public void test() throws Exception
+ {
+ _consumer.receive(5000);
+ _connection.close();
+ }
+
+ public static void main(String[] argv) throws Exception
+ {
+ ReceiveTest test = new ReceiveTest();
+ test._connectionString = argv.length == 0 ? VM_BROKER : argv[0];
+ test.setUp();
+ test.test();
+ test.tearDown();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ // TODO: note that this test doesn't use the VMBrokerSetup
+ // test helper class to create and tear down its
+ // VMBroker. This is because the main() above seems to
+ // indicate that it's also used outside of the surefire test
+ // framework. If it isn't, then this test should also be
+ // changed to use VMBrokerSetup here.
+ return new junit.framework.TestSuite(ReceiveTest.class);
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/basic/SessionStartTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
index f201f23681..6fa8ab95bf 100644
--- a/java/client/src/test/java/org/apache/qpid/basic/SessionStartTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/SessionStartTest.java
@@ -1,53 +1,58 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.basic;
+package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
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 org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-import org.junit.After;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
-public class SessionStartTest implements MessageListener
+import junit.framework.TestCase;
+
+public class SessionStartTest extends TestCase implements MessageListener
{
private AMQConnection _connection;
private AMQDestination _destination;
private AMQSession _session;
private int count;
- public String _connectionString = "vm://:1";
+ public String _connectionString = "vm://:1";
- @Before
- public void init() throws Exception
+ protected void setUp() throws Exception
{
+ super.setUp();
init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
}
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
private void init(AMQConnection connection) throws Exception
{
init(connection, new AMQQueue(randomize("SessionStartTest"), true));
@@ -63,7 +68,6 @@ public class SessionStartTest implements MessageListener
_session.createConsumer(destination).setMessageListener(this);
}
- @Test
public synchronized void test() throws JMSException, InterruptedException
{
try
@@ -102,12 +106,12 @@ public class SessionStartTest implements MessageListener
{
SessionStartTest test = new SessionStartTest();
test._connectionString = argv.length == 0 ? "localhost:5672" : argv[0];
- test.init();
+ test.setUp();
test.test();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(SessionStartTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(SessionStartTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/basic/TextMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
index 2b76f64659..04a9185fa6 100644
--- a/java/client/src/test/java/org/apache/qpid/basic/TextMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
@@ -1,37 +1,43 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.basic;
+package org.apache.qpid.test.unit.basic;
-import junit.framework.JUnit4TestAdapter;
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 org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSTextMessage;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.qpid.test.VMBrokerSetup;
-import javax.jms.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import javax.jms.*;
-public class TextMessageTest implements MessageListener
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+public class TextMessageTest extends TestCase implements MessageListener
{
private AMQConnection _connection;
private Destination _destination;
@@ -41,10 +47,22 @@ public class TextMessageTest implements MessageListener
private int _count = 100;
public String _connectionString = "vm://:1";
- @Before
- public void init() throws Exception
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ try
+ {
+ init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
+ }
+ catch (Exception e)
+ {
+ fail("Unable to initialilse connection: " + e);
+ }
+ }
+
+ protected void tearDown() throws Exception
{
- init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
+ super.tearDown();
}
private void init(AMQConnection connection) throws Exception
@@ -64,7 +82,6 @@ public class TextMessageTest implements MessageListener
connection.start();
}
- @Test
public void test() throws Exception
{
int count = _count;
@@ -91,7 +108,7 @@ public class TextMessageTest implements MessageListener
{
synchronized(received)
{
- while(received.size() < count)
+ while (received.size() < count)
{
received.wait();
}
@@ -104,6 +121,17 @@ public class TextMessageTest implements MessageListener
for (JMSTextMessage m : received)
{
actual.add(m.getText());
+
+// try
+// {
+// m.setText("Test text");
+// Assert.fail("Message should not be writeable");
+// }
+// catch (MessageNotWriteableException mnwe)
+// {
+// //normal execution
+// }
+
}
assertEqual(messages.iterator(), actual.iterator());
@@ -112,25 +140,26 @@ public class TextMessageTest implements MessageListener
private static void assertEqual(Iterator expected, Iterator actual)
{
List<String> errors = new ArrayList<String>();
- while(expected.hasNext() && actual.hasNext())
+ while (expected.hasNext() && actual.hasNext())
{
- try{
+ try
+ {
assertEqual(expected.next(), actual.next());
}
- catch(Exception e)
+ catch (Exception e)
{
errors.add(e.getMessage());
}
}
- while(expected.hasNext())
+ while (expected.hasNext())
{
errors.add("Expected " + expected.next() + " but no more actual values.");
}
- while(actual.hasNext())
+ while (actual.hasNext())
{
errors.add("Found " + actual.next() + " but no more expected values.");
}
- if(!errors.isEmpty())
+ if (!errors.isEmpty())
{
throw new RuntimeException(errors.toString());
}
@@ -138,7 +167,7 @@ public class TextMessageTest implements MessageListener
private static void assertEqual(Object expected, Object actual)
{
- if(!expected.equals(actual))
+ if (!expected.equals(actual))
{
throw new RuntimeException("Expected '" + expected + "' found '" + actual + "'");
}
@@ -162,13 +191,16 @@ public class TextMessageTest implements MessageListener
{
TextMessageTest test = new TextMessageTest();
test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
- test.init();
- if (argv.length > 1) test._count = Integer.parseInt(argv[1]);
+ test.setUp();
+ if (argv.length > 1)
+ {
+ test._count = Integer.parseInt(argv[1]);
+ }
test.test();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(TextMessageTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(TextMessageTest.class));
}
}
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
new file mode 100644
index 0000000000..9b46c5b18a
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
@@ -0,0 +1,205 @@
+/*
+ *
+ * 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;
+
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.client.AMQConnection;
+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 java.lang.reflect.Method;
+import javax.jms.*;
+
+import junit.framework.TestCase;
+
+public class AMQConnectionTest extends TestCase
+{
+ private static AMQConnection _connection;
+ private static AMQTopic _topic;
+ private static AMQQueue _queue;
+ private static QueueSession _queueSession;
+ private static TopicSession _topicSession;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ _connection = new AMQConnection("vm://:1", "guest", "guest", "fred", "/test");
+ _topic = new AMQTopic("mytopic");
+ _queue = new AMQQueue("myqueue");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ _connection.close();
+ }
+ catch (JMSException e)
+ {
+ //ignore
+ }
+ super.tearDown();
+ }
+
+ /**
+ * Simple tests to check we can create TopicSession and QueueSession ok
+ * And that they throw exceptions where appropriate as per JMS spec
+ */
+
+ public void testCreateQueueSession() throws JMSException
+ {
+ _queueSession = _connection.createQueueSession(false, AMQSession.NO_ACKNOWLEDGE);
+ }
+
+ public void testCreateTopicSession() throws JMSException
+ {
+ _topicSession = _connection.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE);
+ }
+
+ public void testTopicSessionCreateBrowser() throws JMSException
+ {
+ try
+ {
+ _topicSession.createBrowser(_queue);
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
+ }
+
+ public void testTopicSessionCreateQueue() throws JMSException
+ {
+ try
+ {
+ _topicSession.createQueue("abc");
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
+ }
+
+ public void testTopicSessionCreateTemporaryQueue() throws JMSException
+ {
+ try
+ {
+ _topicSession.createTemporaryQueue();
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
+ }
+
+ public void testQueueSessionCreateTemporaryTopic() throws JMSException
+ {
+ try
+ {
+ _queueSession.createTemporaryTopic();
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
+ }
+
+ public void testQueueSessionCreateTopic() throws JMSException
+ {
+ try
+ {
+ _queueSession.createTopic("abc");
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
+ }
+
+ public void testQueueSessionDurableSubscriber() throws JMSException
+ {
+ try
+ {
+ _queueSession.createDurableSubscriber(_topic, "abc");
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
+ }
+
+ public void testQueueSessionUnsubscribe() throws JMSException
+ {
+ try
+ {
+ _queueSession.unsubscribe("abc");
+ fail("expected exception did not occur");
+ }
+ catch (javax.jms.IllegalStateException s)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected javax.jms.IllegalStateException, got " + e);
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new VMBrokerSetup(new junit.framework.TestSuite(AMQConnectionTest.class));
+ }
+}
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
new file mode 100644
index 0000000000..af4673856e
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/AMQSessionTest.java
@@ -0,0 +1,119 @@
+/*
+ *
+ * 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;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+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.url.URLSyntaxException;
+
+import javax.jms.JMSException;
+import javax.jms.TopicSubscriber;
+import javax.jms.QueueReceiver;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for QueueReceiver and TopicSubscriber creation methods on AMQSession
+ */
+public class AMQSessionTest extends TestCase
+{
+
+ private static AMQSession _session;
+ private static AMQTopic _topic;
+ private static AMQQueue _queue;
+ private static AMQConnection _connection;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ _connection = new AMQConnection("vm://:1", "guest", "guest", "fred", "/test");
+ _topic = new AMQTopic("mytopic");
+ _queue = new AMQQueue("myqueue");
+ _session = (AMQSession) _connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ _connection.close();
+ }
+ catch (JMSException e)
+ {
+ //just close
+ }
+ super.tearDown();
+ }
+
+ public void testCreateSubscriber() throws JMSException
+ {
+ TopicSubscriber subscriber = _session.createSubscriber(_topic);
+ assertEquals("Topic names should match from TopicSubscriber", _topic.getTopicName(), subscriber.getTopic().getTopicName());
+
+ subscriber = _session.createSubscriber(_topic, "abc", false);
+ assertEquals("Topic names should match from TopicSubscriber with selector", _topic.getTopicName(), subscriber.getTopic().getTopicName());
+ }
+
+ public void testCreateDurableSubscriber() throws JMSException
+ {
+ TopicSubscriber subscriber = _session.createDurableSubscriber(_topic, "mysubname");
+ assertEquals("Topic names should match from durable TopicSubscriber", _topic.getTopicName(), subscriber.getTopic().getTopicName());
+
+ subscriber = _session.createDurableSubscriber(_topic, "mysubname", "abc", false);
+ assertEquals("Topic names should match from durable TopicSubscriber with selector", _topic.getTopicName(), subscriber.getTopic().getTopicName());
+ }
+
+ public void testCreateQueueReceiver() throws JMSException
+ {
+ QueueReceiver receiver = _session.createQueueReceiver(_queue);
+ assertEquals("Queue names should match from QueueReceiver", _queue.getQueueName(), receiver.getQueue().getQueueName());
+
+ receiver = _session.createQueueReceiver(_queue, "abc");
+ assertEquals("Queue names should match from QueueReceiver with selector", _queue.getQueueName(), receiver.getQueue().getQueueName());
+ }
+
+ public void testCreateReceiver() throws JMSException
+ {
+ QueueReceiver receiver = _session.createReceiver(_queue);
+ assertEquals("Queue names should match from QueueReceiver", _queue.getQueueName(), receiver.getQueue().getQueueName());
+
+ receiver = _session.createReceiver(_queue, "abc");
+ assertEquals("Queue names should match from QueueReceiver with selector", _queue.getQueueName(), receiver.getQueue().getQueueName());
+ }
+
+ public static void stopVmBrokers()
+ {
+ _queue = null;
+ _topic = null;
+ _session = null;
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new VMBrokerSetup(new junit.framework.TestSuite(AMQSessionTest.class));
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/client/channelclose/ChannelCloseOkTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
index e12d6c0fc5..d3a05c3d75 100644
--- a/java/client/src/test/java/org/apache/qpid/client/channelclose/ChannelCloseOkTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
@@ -1,50 +1,54 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.channelclose;
+package org.apache.qpid.test.unit.client.channelclose;
-import junit.framework.JUnit4TestAdapter;
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.log4j.Logger;
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
import javax.jms.*;
import java.util.ArrayList;
import java.util.List;
+import junit.framework.TestCase;
+import junit.textui.TestRunner;
+
/**
* Due to bizarre exception handling all sessions are closed if you get
* a channel close request and no exception listener is registered.
- *
+ * <p/>
* JIRA issue IBTBLZ-10.
- *
+ * <p/>
* Simulate by:
- *
+ * <p/>
* 0. Create two sessions with no exception listener.
* 1. Publish message to queue/topic that does not exist (wrong routing key).
* 2. This will cause a channel close.
* 3. Since client does not have an exception listener, currently all sessions are
- * closed.
+ * closed.
*/
-public class ChannelCloseOkTest
+public class ChannelCloseOkTest extends TestCase
{
private Connection _connection;
private Destination _destination1;
@@ -57,18 +61,22 @@ public class ChannelCloseOkTest
private final static Logger _log = Logger.getLogger(ChannelCloseOkTest.class);
public String _connectionString = "vm://:1";
- @Before
- public void init() throws Exception
+
+ protected void setUp() throws Exception
{
+ super.setUp();
+
_connection = new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path");
+
_destination1 = new AMQQueue("q1", true);
_destination2 = new AMQQueue("q2", true);
_session1 = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- _session1.createConsumer(_destination1).setMessageListener(new MessageListener() {
+ _session1.createConsumer(_destination1).setMessageListener(new MessageListener()
+ {
public void onMessage(Message message)
{
_log.debug("consumer 1 got message [" + getTextMessage(message) + "]");
- synchronized (_received1)
+ synchronized(_received1)
{
_received1.add(message);
_received1.notify();
@@ -76,11 +84,12 @@ public class ChannelCloseOkTest
}
});
_session2 = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- _session2.createConsumer(_destination2).setMessageListener(new MessageListener() {
+ _session2.createConsumer(_destination2).setMessageListener(new MessageListener()
+ {
public void onMessage(Message message)
{
- _log.debug("consumer 2 got message [" + getTextMessage(message) + "]");
- synchronized (_received2)
+ _log.debug("consumer 2 got message [" + getTextMessage(message) + "]");
+ synchronized(_received2)
{
_received2.add(message);
_received2.notify();
@@ -93,7 +102,7 @@ public class ChannelCloseOkTest
private String getTextMessage(Message message)
{
- TextMessage tm = (TextMessage)message;
+ TextMessage tm = (TextMessage) message;
try
{
return tm.getText();
@@ -104,7 +113,12 @@ public class ChannelCloseOkTest
}
}
- @After
+ protected void tearDown() throws Exception
+ {
+ closeConnection();
+ super.tearDown();
+ }
+
public void closeConnection() throws JMSException
{
if (_connection != null)
@@ -114,26 +128,25 @@ public class ChannelCloseOkTest
}
}
- @Test
public void testWithoutExceptionListener() throws Exception
{
- test();
+ doTest();
}
- @Test
public void testWithExceptionListener() throws Exception
{
- _connection.setExceptionListener(new ExceptionListener() {
+ _connection.setExceptionListener(new ExceptionListener()
+ {
public void onException(JMSException jmsException)
{
_log.error("onException - ", jmsException);
}
});
- test();
+ doTest();
}
- public void test() throws Exception
+ public void doTest() throws Exception
{
// Check both sessions are ok.
sendAndWait(_session1, _destination1, "first", _received1, 1);
@@ -177,7 +190,7 @@ public class ChannelCloseOkTest
private void waitFor(List<Message> received, int count) throws InterruptedException
{
- synchronized (received)
+ synchronized(received)
{
while (received.size() < count)
{
@@ -191,16 +204,13 @@ public class ChannelCloseOkTest
return in + System.currentTimeMillis();
}
- /**
- * For Junit 3 compatibility.
- */
- public static junit.framework.Test suite()
+ public static void main(String[] args)
{
- return new JUnit4TestAdapter(ChannelCloseOkTest.class);
+ TestRunner.run(ChannelCloseOkTest.class);
}
- public static void main(String[] args)
+ public static junit.framework.Test suite()
{
- org.junit.runner.JUnitCore.main(ChannelCloseOkTest.class.getName());
+ return new VMBrokerSetup(new junit.framework.TestSuite(ChannelCloseOkTest.class));
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
new file mode 100644
index 0000000000..d7862d047f
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
@@ -0,0 +1,109 @@
+/*
+ *
+ * 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.client.AMQConnection;
+import org.apache.qpid.client.AMQAuthenticationException;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.AMQConnectionException;
+import org.apache.qpid.AMQUnresolvedAddressException;
+import org.apache.qpid.test.VMBrokerSetup;
+
+import javax.jms.Connection;
+
+import junit.framework.TestCase;
+
+public class ConnectionTest extends TestCase
+{
+
+ String _broker = "vm://:1";
+ String _broker_NotRunning = "vm://:2";
+ String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs";
+
+ public void testSimpleConnection()
+ {
+ try
+ {
+ Connection connection = new AMQConnection(_broker, "guest", "guest",
+ "fred", "/test");
+ }
+ catch (Exception e)
+ {
+ fail("Connection to " + _broker + " should succeed. Reason: " + e);
+ }
+ }
+
+ // FIXME The inVM broker currently has no authentication .. Needs added QPID-70
+ public void passwordFailureConnection() throws Exception
+ {
+ try
+ {
+ new AMQConnection("amqp://guest:rubbishpassword@clientid/testpath?brokerlist='" + _broker + "?retries='1''");
+ fail("Connection should not be established password is wrong.");
+ }
+ catch (AMQException amqe)
+ {
+ if (!(amqe instanceof AMQAuthenticationException))
+ {
+ fail("Correct exception not thrown. Excpected 'AMQAuthenticationException' got: " + amqe);
+ }
+ }
+ }
+
+ public void testConnectionFailure() throws Exception
+ {
+ try
+ {
+ new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='" + _broker_NotRunning + "?retries='0''");
+ fail("Connection should not be established");
+ }
+ catch (AMQException amqe)
+ {
+ if (!(amqe instanceof AMQConnectionException))
+ {
+ fail("Correct exception not thrown. Excpected 'AMQConnectionException' got: " + amqe);
+ }
+ }
+ }
+
+ public void testUnresolvedHostFailure() throws Exception
+ {
+ try
+ {
+ new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='" + _broker_BadDNS + "?retries='0''");
+ fail("Connection should not be established");
+ }
+ catch (AMQException amqe)
+ {
+ if (!(amqe instanceof AMQUnresolvedAddressException))
+ {
+ fail("Correct exception not thrown. Excpected 'AMQUnresolvedAddressException' got: " + amqe);
+ }
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new VMBrokerSetup(new junit.framework.TestSuite(ConnectionTest.class));
+ }
+}
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
new file mode 100644
index 0000000000..d89bc4a771
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/TestManyConnections.java
@@ -0,0 +1,95 @@
+/*
+ *
+ * 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/connectionurl/ConnectionURLTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
new file mode 100644
index 0000000000..13a6d214ba
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
@@ -0,0 +1,434 @@
+/*
+ *
+ * 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.connectionurl;
+
+import org.apache.qpid.client.AMQConnectionURL;
+import org.apache.qpid.client.AMQBrokerDetails;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.url.URLSyntaxException;
+
+import junit.framework.TestCase;
+
+public class ConnectionURLTest extends TestCase
+{
+
+ public void testFailoverURL() throws URLSyntaxException
+ {
+ String url = "amqp://ritchiem:bob@/temp?brokerlist='tcp://localhost:5672;tcp://fancyserver:3000/',failover='roundrobin'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+ assertTrue(connectionurl.getFailoverMethod().equals("roundrobin"));
+ assertTrue(connectionurl.getUsername().equals("ritchiem"));
+ assertTrue(connectionurl.getPassword().equals("bob"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+
+ assertTrue(connectionurl.getBrokerCount() == 2);
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
+
+ service = connectionurl.getBrokerDetails(1);
+
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("fancyserver"));
+ assertTrue(service.getPort() == 3000);
+
+ }
+
+ public void testSingleTransportUsernamePasswordURL() throws URLSyntaxException
+ {
+ String url = "amqp://ritchiem:bob@/temp?brokerlist='tcp://localhost:5672'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("ritchiem"));
+ assertTrue(connectionurl.getPassword().equals("bob"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+
+ assertTrue(connectionurl.getBrokerCount() == 1);
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
+ }
+
+ public void testSingleTransportUsernameBlankPasswordURL() throws URLSyntaxException
+ {
+ String url = "amqp://ritchiem:@/temp?brokerlist='tcp://localhost:5672'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("ritchiem"));
+ assertTrue(connectionurl.getPassword().equals(""));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+
+ assertTrue(connectionurl.getBrokerCount() == 1);
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
+ }
+
+ public void testFailedURLNullPassword()
+ {
+ String url = "amqp://ritchiem@/temp?brokerlist='tcp://localhost:5672'";
+
+ try
+ {
+ new AMQConnectionURL(url);
+ fail("URL has null password");
+ }
+ catch (URLSyntaxException e)
+ {
+ assertTrue(e.getReason().equals("Null password in user information not allowed."));
+ assertTrue(e.getIndex() == 7);
+ }
+ }
+
+
+ public void testSingleTransportURL() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/test"));
+
+
+ assertTrue(connectionurl.getBrokerCount() == 1);
+
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
+ }
+
+ public void testSingleTransportWithClientURLURL() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@clientname/temp?brokerlist='tcp://localhost:5672'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+ assertTrue(connectionurl.getClientName().equals("clientname"));
+
+
+ assertTrue(connectionurl.getBrokerCount() == 1);
+
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("tcp"));
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
+ }
+
+ public void testSingleTransport1OptionURL() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@/temp?brokerlist='tcp://localhost:5672',routingkey='jim'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+
+
+ assertTrue(connectionurl.getBrokerCount() == 1);
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("tcp"));
+
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
+ assertTrue(connectionurl.getOption("routingkey").equals("jim"));
+ }
+
+ public void testSingleTransportDefaultedBroker() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@/temp?brokerlist='localhost'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+
+
+ assertTrue(connectionurl.getBrokerCount() == 1);
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("tcp"));
+
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
+ }
+
+
+ public void testSingleTransportMultiOptionURL() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@/temp?brokerlist='tcp://localhost:5672',routingkey='jim',timeout='200',immediatedelivery='true'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+
+ assertTrue(connectionurl.getBrokerCount() == 1);
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("tcp"));
+
+ assertTrue(service.getHost().equals("localhost"));
+ assertTrue(service.getPort() == 5672);
+
+ assertTrue(connectionurl.getOption("routingkey").equals("jim"));
+ assertTrue(connectionurl.getOption("timeout").equals("200"));
+ assertTrue(connectionurl.getOption("immediatedelivery").equals("true"));
+ }
+
+ public void testSinglevmURL() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@/messages?brokerlist='vm://:2'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+ assertTrue(connectionurl.getFailoverMethod() == null);
+ assertTrue(connectionurl.getUsername().equals("guest"));
+ assertTrue(connectionurl.getPassword().equals("guest"));
+ assertTrue(connectionurl.getVirtualHost().equals("/messages"));
+
+ assertTrue(connectionurl.getBrokerCount() == 1);
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("vm"));
+ assertTrue(service.getHost().equals(""));
+ assertTrue(service.getPort() == 2);
+
+ }
+
+ public void testFailoverVMURL() throws URLSyntaxException
+ {
+ String url = "amqp://ritchiem:bob@/temp?brokerlist='vm://:2;vm://:3',failover='roundrobin'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+ assertTrue(connectionurl.getFailoverMethod().equals("roundrobin"));
+ assertTrue(connectionurl.getUsername().equals("ritchiem"));
+ assertTrue(connectionurl.getPassword().equals("bob"));
+ assertTrue(connectionurl.getVirtualHost().equals("/temp"));
+
+ assertTrue(connectionurl.getBrokerCount() == 2);
+
+ BrokerDetails service = connectionurl.getBrokerDetails(0);
+
+ assertTrue(service.getTransport().equals("vm"));
+ assertTrue(service.getHost().equals(""));
+ assertTrue(service.getPort() == 2);
+
+ service = connectionurl.getBrokerDetails(1);
+ assertTrue(service.getTransport().equals("vm"));
+ assertTrue(service.getHost().equals(""));
+ assertTrue(service.getPort() == 3);
+ }
+
+
+ public void testNoVirtualHostURL()
+ {
+ String url = "amqp://user@?brokerlist='tcp://localhost:5672'";
+
+ try
+ {
+ new AMQConnectionURL(url);
+ fail("URL has no virtual host should not parse");
+ }
+ catch (URLSyntaxException e)
+ {
+ // This should occur.
+ }
+ }
+
+ public void testNoClientID() throws URLSyntaxException
+ {
+ String url = "amqp://user:@/test?brokerlist='tcp://localhost:5672'";
+
+ ConnectionURL connectionurl = new AMQConnectionURL(url);
+
+ assertTrue(connectionurl.getUsername().equals("user"));
+ assertTrue(connectionurl.getPassword().equals(""));
+ assertTrue(connectionurl.getVirtualHost().equals("/test"));
+
+ assertTrue(connectionurl.getBrokerCount() == 1);
+ }
+
+ // FIXME Connection now parses but result is wrong QPID-71
+ /*
+ public void testWrongOptionSeparatorInBroker()
+ {
+ String url = "amqp://user:@/test?brokerlist='tcp://localhost:5672+option='value''";
+
+ try
+ {
+ AMQConnectionURL connection = new AMQConnectionURL(url);
+
+ Float version = Float.parseFloat(System.getProperty("java.specification.version"));
+ if (version > 1.5)
+ {
+ fail("URL Should not parse on Java " + version + " Connection is:" + connection);
+ }
+ }
+ catch (URLSyntaxException urise)
+ {
+ assertTrue(urise.getReason().equals("Illegal character in port number"));
+ }
+
+ }
+ */
+
+ public void testWrongOptionSeparatorInOptions()
+ {
+ String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'+failover='roundrobin'";
+ try
+ {
+ new AMQConnectionURL(url);
+ fail("URL Should not parse");
+ }
+ catch (URLSyntaxException urise)
+ {
+ assertTrue(urise.getReason().equals("Unterminated option. Possible illegal option separator:'+'"));
+ }
+
+ }
+
+ public void testTransportsDefaultToTCP() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@/test?brokerlist='localhost:5672;myhost:5673'&failover='roundrobin'";
+
+ AMQConnectionURL connection = new AMQConnectionURL(url);
+
+ BrokerDetails broker = connection.getBrokerDetails(0);
+ assertTrue(broker.getTransport().equals("tcp"));
+
+ broker = connection.getBrokerDetails(1);
+ assertTrue(broker.getTransport().equals("tcp"));
+ }
+
+ public void testNoUserDetailsProvidedWithClientID()
+
+ {
+ String url = "amqp://clientID/test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'";
+ try
+ {
+ new AMQConnectionURL(url);
+ fail("URL Should not parse");
+ }
+ catch (URLSyntaxException urise)
+ {
+ assertTrue(urise.getMessage().startsWith("User information not found on url"));
+ }
+
+ }
+
+ public void testNoUserDetailsProvidedNOClientID()
+
+ {
+ String url = "amqp:///test?brokerlist='tcp://localhost:5672;tcp://localhost:5673'";
+ try
+ {
+ new AMQConnectionURL(url);
+ fail("URL Should not parse");
+ }
+ catch (URLSyntaxException urise)
+ {
+ assertTrue(urise.getMessage().startsWith("User information not found on url"));
+ }
+
+ }
+
+ public void testCheckVirtualhostFormat() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@/t.-_+!=:?brokerlist='tcp://localhost:5672'";
+
+ AMQConnectionURL connection = new AMQConnectionURL(url);
+ assertTrue(connection.getVirtualHost().equals("/t.-_+!=:"));
+ }
+
+ public void testCheckDefaultPort() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@/test=:?brokerlist='tcp://localhost'";
+
+ AMQConnectionURL connection = new AMQConnectionURL(url);
+
+ BrokerDetails broker = connection.getBrokerDetails(0);
+ assertTrue(broker.getPort() == AMQBrokerDetails.DEFAULT_PORT);
+
+ }
+
+ public void testCheckMissingFinalQuote() throws URLSyntaxException
+ {
+ String url = "amqp://guest:guest@id/test" + "?brokerlist='tcp://localhost:5672";
+
+ try
+ {
+ new AMQConnectionURL(url);
+ }
+ catch (URLSyntaxException e)
+ {
+ assertEquals(e.getMessage(), "Unterminated option at index 32: brokerlist='tcp://localhost:5672");
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(ConnectionURLTest.class);
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
new file mode 100644
index 0000000000..58a3c8c282
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/destinationurl/DestinationURLTest.java
@@ -0,0 +1,145 @@
+/*
+ *
+ * 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.destinationurl;
+
+import org.apache.qpid.url.AMQBindingURL;
+import org.apache.qpid.url.URLSyntaxException;
+import org.apache.qpid.exchange.ExchangeDefaults;
+
+import junit.framework.TestCase;
+
+public class DestinationURLTest extends TestCase
+{
+ public void testFullURL() throws URLSyntaxException
+ {
+
+ String url = "exchange.Class://exchangeName/Destination/Queue";
+
+ AMQBindingURL dest = new AMQBindingURL(url);
+
+ assertTrue(url.equals(dest.toString()));
+
+ assertTrue(dest.getExchangeClass().equals("exchange.Class"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals("Destination"));
+ assertTrue(dest.getQueueName().equals("Queue"));
+ }
+
+ public void testQueue() throws URLSyntaxException
+ {
+
+ String url = "exchangeClass://exchangeName//Queue";
+
+ AMQBindingURL dest = new AMQBindingURL(url);
+
+ assertTrue(url.equals(dest.toString()));
+
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals(""));
+ assertTrue(dest.getQueueName().equals("Queue"));
+ }
+
+ public void testQueueWithOption() throws URLSyntaxException
+ {
+
+ String url = "exchangeClass://exchangeName//Queue?option='value'";
+
+ AMQBindingURL dest = new AMQBindingURL(url);
+
+ assertTrue(url.equals(dest.toString()));
+
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals(""));
+ assertTrue(dest.getQueueName().equals("Queue"));
+ assertTrue(dest.getOption("option").equals("value"));
+ }
+
+
+ public void testDestination() throws URLSyntaxException
+ {
+
+ String url = "exchangeClass://exchangeName/Destination/";
+
+ AMQBindingURL dest = new AMQBindingURL(url);
+
+ assertTrue(url.equals(dest.toString()));
+
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals("Destination"));
+ assertTrue(dest.getQueueName().equals(""));
+ }
+
+ public void testDestinationWithOption() throws URLSyntaxException
+ {
+
+ String url = "exchangeClass://exchangeName/Destination/?option='value'";
+
+ AMQBindingURL dest = new AMQBindingURL(url);
+
+ assertTrue(url.equals(dest.toString()));
+
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals("Destination"));
+ assertTrue(dest.getQueueName().equals(""));
+
+ assertTrue(dest.getOption("option").equals("value"));
+ }
+
+ public void testDestinationWithMultiOption() throws URLSyntaxException
+ {
+
+ String url = "exchangeClass://exchangeName/Destination/?option='value',option2='value2'";
+
+ AMQBindingURL dest = new AMQBindingURL(url);
+
+ assertTrue(dest.getExchangeClass().equals("exchangeClass"));
+ assertTrue(dest.getExchangeName().equals("exchangeName"));
+ assertTrue(dest.getDestinationName().equals("Destination"));
+ assertTrue(dest.getQueueName().equals(""));
+
+ assertTrue(dest.getOption("option").equals("value"));
+ assertTrue(dest.getOption("option2").equals("value2"));
+ }
+
+ public void testDestinationWithNoExchangeDefaultsToDirect() throws URLSyntaxException
+ {
+
+ String url = "IBMPerfQueue1?durable='true'";
+
+ AMQBindingURL dest = new AMQBindingURL(url);
+
+ assertTrue(dest.getExchangeClass().equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS));
+ assertTrue(dest.getExchangeName().equals(ExchangeDefaults.DIRECT_EXCHANGE_NAME));
+ assertTrue(dest.getDestinationName().equals(""));
+ assertTrue(dest.getQueueName().equals("IBMPerfQueue1"));
+
+ assertTrue(dest.getOption("durable").equals("true"));
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(DestinationURLTest.class);
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/forwardall/Client.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/Client.java
index 4ad8587ae0..6c2c684362 100644
--- a/java/client/src/test/java/org/apache/qpid/forwardall/Client.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/Client.java
@@ -1,21 +1,24 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.forwardall;
+package org.apache.qpid.test.unit.client.forwardall;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
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
new file mode 100644
index 0000000000..9218424a5e
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.forwardall;
+
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.test.VMBrokerSetup;
+
+import junit.framework.TestCase;
+
+/**
+ * Runs the Service's and Client parts of the test in the same process
+ * as the broker
+ */
+public class CombinedTest extends TestCase
+{
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ ServiceCreator.closeAll();
+ super.tearDown();
+ }
+
+ public void testForwardAll() throws Exception
+ {
+ int services = 2;
+ ServiceCreator.start("vm://:1", services);
+
+ System.out.println("Starting client...");
+
+ new Client("vm://:1", services).shutdownWhenComplete();
+
+ System.out.println("Completed successfully!");
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new VMBrokerSetup(new junit.framework.TestSuite(CombinedTest.class));
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/forwardall/Service.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/Service.java
index bc3cc4c1f4..a1c64e2246 100644
--- a/java/client/src/test/java/org/apache/qpid/forwardall/Service.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/Service.java
@@ -1,21 +1,24 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.forwardall;
+package org.apache.qpid.test.unit.client.forwardall;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
@@ -24,6 +27,7 @@ import org.apache.qpid.client.AMQSession;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageListener;
+import javax.jms.JMSException;
/**
* Declare a queue and bind it to amq.direct with a 'well known' routing key,
@@ -56,12 +60,17 @@ public class Service implements MessageListener
Destination replyTo = request.getJMSReplyTo();
_session.createProducer(replyTo).send(response);
}
- catch(Exception e)
+ catch (Exception e)
{
e.printStackTrace(System.out);
}
}
+ public void close() throws JMSException
+ {
+ _connection.close();
+ }
+
static AMQConnection connect(String broker) throws Exception
{
return new AMQConnection(broker, "guest", "guest", "Client" + System.currentTimeMillis(), "/test_path");
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/ServiceCreator.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/ServiceCreator.java
new file mode 100644
index 0000000000..4cb6fab91f
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/ServiceCreator.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * 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.forwardall;
+
+import javax.jms.JMSException;
+
+public class ServiceCreator implements Runnable
+{
+ private static Thread[] threads;
+ private static ServiceCreator[] _services;
+
+ private final String broker;
+ private Service service;
+
+ ServiceCreator(String broker)
+ {
+ this.broker = broker;
+ }
+
+ public void run()
+ {
+ try
+ {
+ service = new Service(broker);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void closeSC() throws JMSException
+ {
+ service.close();
+ }
+
+ static void closeAll()
+ {
+ for (int i = 0; i < _services.length; i++)
+ {
+ try
+ {
+ _services[i].closeSC();
+ }
+ catch (JMSException e)
+ {
+ //ignore
+ }
+ }
+ }
+
+ static void start(String broker, int services) throws InterruptedException
+ {
+ threads = new Thread[services];
+ _services = new ServiceCreator[services];
+ ServiceCreator runner = new ServiceCreator(broker);
+ //start services
+ System.out.println("Starting " + services + " services...");
+ for (int i = 0; i < services; i++)
+ {
+ threads[i] = new Thread(runner);
+ _services[i] = runner;
+ threads[i].start();
+ }
+
+ for (int i = 0; i < threads.length; i++)
+ {
+ threads[i].join();
+ }
+ }
+
+ public static void main(String[] argv) throws Exception
+ {
+ final String connectionString;
+ final int services;
+ if (argv.length == 0)
+ {
+ connectionString = "localhost:5672";
+ services = 100;
+ }
+ else
+ {
+ connectionString = argv[0];
+ services = Integer.parseInt(argv[1]);
+ }
+ start(connectionString, services);
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java
new file mode 100644
index 0000000000..22015dbc93
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.forwardall;
+
+import org.apache.qpid.client.AMQQueue;
+
+/**
+ * Queue that allows several private queues to be registered and bound
+ * to an exchange with the same routing key.
+ *
+ */
+class SpecialQueue extends AMQQueue
+{
+ private final String name;
+
+ SpecialQueue(String name)
+ {
+ super(name, true);
+ this.name = name;
+ }
+
+ public String getRoutingKey()
+ {
+ return name;
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java
new file mode 100644
index 0000000000..2a76c920b1
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java
@@ -0,0 +1,433 @@
+/*
+ *
+ * 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.message;
+
+import org.apache.qpid.client.message.JMSBytesMessage;
+import org.apache.qpid.client.message.TestMessageHelper;
+
+import javax.jms.MessageNotReadableException;
+import javax.jms.MessageNotWriteableException;
+import javax.jms.MessageEOFException;
+
+import junit.framework.TestCase;
+
+public class BytesMessageTest extends TestCase
+{
+ /**
+ * Tests that on creation a call to getBodyLength() throws an exception
+ * if null was passed in during creation
+ */
+ public void testNotReadableOnCreationWithNull() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.getBodyLength();
+ fail("expected exception did not occur");
+ }
+ catch (MessageNotReadableException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageNotReadableException, got " + e);
+ }
+ }
+
+ public void testResetMakesReadble() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeInt(10);
+ bm.reset();
+ bm.writeInt(12);
+ fail("expected exception did not occur");
+ }
+ catch (MessageNotWriteableException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageNotWriteableException, got " + e);
+ }
+ }
+
+ public void testClearBodyMakesWritable() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeInt(10);
+ bm.reset();
+ bm.clearBody();
+ bm.writeInt(10);
+ }
+
+ public void testWriteInt() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeInt(10);
+ bm.reset();
+ long len = bm.getBodyLength();
+ assertTrue(len == 4);
+ int val = bm.readInt();
+ assertTrue(val == 10);
+ }
+
+ public void testWriteString() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeUTF("Bananas");
+ bm.reset();
+ String res = bm.readUTF();
+ assertEquals("Bananas", res);
+ }
+
+ public void testWriteObjectThrowsNPE() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeObject(null);
+ fail("expected exception did not occur");
+ }
+ catch (NullPointerException n)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected NullPointerException, got " + e);
+ }
+ }
+
+ public void testReadBoolean() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeBoolean(true);
+ bm.reset();
+ boolean result = bm.readBoolean();
+ assertTrue(result);
+ }
+
+ public void testEOFByte() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeByte((byte)1);
+ bm.reset();
+ bm.readByte();
+ // should throw
+ bm.readByte();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ public void testEOFUnsignedByte() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeByte((byte)1);
+ bm.reset();
+ bm.readByte();
+ // should throw
+ bm.readUnsignedByte();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ public void testEOFBoolean() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeBoolean(true);
+ bm.reset();
+ bm.readBoolean();
+ // should throw
+ bm.readBoolean();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ public void testEOFChar() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeChar('A');
+ bm.reset();
+ bm.readChar();
+ // should throw
+ bm.readChar();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ public void testEOFDouble() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeDouble(1.3d);
+ bm.reset();
+ bm.readDouble();
+ // should throw
+ bm.readDouble();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ public void testEOFFloat() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeFloat(1.3f);
+ bm.reset();
+ bm.readFloat();
+ // should throw
+ bm.readFloat();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ public void testEOFInt() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeInt(99);
+ bm.reset();
+ bm.readInt();
+ // should throw
+ bm.readInt();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ public void testEOFLong() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeLong(4L);
+ bm.reset();
+ bm.readLong();
+ // should throw
+ bm.readLong();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ public void testEOFShort() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeShort((short)4);
+ bm.reset();
+ bm.readShort();
+ // should throw
+ bm.readShort();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ public void testEOFUnsignedShort() throws Exception
+ {
+ try
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeShort((short)4);
+ bm.reset();
+ bm.readUnsignedShort();
+ // should throw
+ bm.readUnsignedShort();
+ fail("expected exception did not occur");
+ }
+ catch (MessageEOFException m)
+ {
+ // ok
+ }
+ catch (Exception e)
+ {
+ fail("expected MessageEOFException, got " + e);
+ }
+ }
+
+ /**
+ * Tests that the readBytes() method populates the passed in array
+ * correctly
+ * @throws Exception
+ */
+ public void testReadBytes() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeByte((byte)3);
+ bm.writeByte((byte)4);
+ bm.reset();
+ byte[] result = new byte[2];
+ int count = bm.readBytes(result);
+ assertEquals((byte)3, result[0]);
+ assertEquals((byte)4, result[1]);
+ assertEquals(2, count);
+ }
+
+ public void testReadBytesEOF() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeByte((byte)3);
+ bm.writeByte((byte)4);
+ bm.reset();
+ byte[] result = new byte[2];
+ bm.readBytes(result);
+ int count = bm.readBytes(result);
+ assertEquals(-1, count);
+ }
+
+ public void testReadBytesWithLargerArray() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeByte((byte)3);
+ bm.writeByte((byte)4);
+ bm.reset();
+ byte[] result = new byte[3];
+ int count = bm.readBytes(result);
+ assertEquals(2, count);
+ assertEquals((byte)3, result[0]);
+ assertEquals((byte)4, result[1]);
+ assertEquals((byte)0, result[2]);
+ }
+
+ public void testReadBytesWithCount() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.writeByte((byte)3);
+ bm.writeByte((byte)4);
+ bm.writeByte((byte)5);
+ bm.reset();
+ byte[] result = new byte[3];
+ int count = bm.readBytes(result, 2);
+ assertEquals(2, count);
+ assertEquals((byte)3, result[0]);
+ assertEquals((byte)4, result[1]);
+ assertEquals((byte)0, result[2]);
+ }
+
+ public void testToBodyString() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ final String testText = "This is a test";
+ bm.writeUTF(testText);
+ bm.reset();
+ String result = bm.toBodyString();
+ assertEquals(testText, result);
+ }
+
+ public void testToBodyStringWithNull() throws Exception
+ {
+ JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage();
+ bm.reset();
+ String result = bm.toBodyString();
+ assertNull(result);
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(BytesMessageTest.class);
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
new file mode 100644
index 0000000000..f55f2428ce
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
@@ -0,0 +1,357 @@
+/*
+ * 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.message;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.apache.qpid.framing.PropertyFieldTable;
+import org.apache.qpid.client.message.JMSMapMessage;
+import org.apache.qpid.client.message.TestMessageHelper;
+
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
+
+
+public class MapMessageTest extends TestCase
+{
+
+ //Test Lookups
+
+ public void testBooleanLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+
+ mm.setBoolean("value", true);
+ Assert.assertEquals(true, mm.getBoolean("value"));
+ Assert.assertEquals("true", mm.getString("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testByteLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setByte("value", Byte.MAX_VALUE);
+
+ Assert.assertEquals(Byte.MAX_VALUE, mm.getByte("value"));
+ Assert.assertEquals((short) Byte.MAX_VALUE, mm.getShort("value"));
+ Assert.assertEquals(Byte.MAX_VALUE, mm.getInt("value"));
+ Assert.assertEquals((long) Byte.MAX_VALUE, mm.getLong("value"));
+ Assert.assertEquals("" + Byte.MAX_VALUE, mm.getString("value"));
+
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testShortLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setShort("value", Short.MAX_VALUE);
+ Assert.assertEquals(Short.MAX_VALUE, mm.getShort("value"));
+ Assert.assertEquals((int) Short.MAX_VALUE, mm.getInt("value"));
+ Assert.assertEquals((long) Short.MAX_VALUE, mm.getLong("value"));
+ Assert.assertEquals("" + Short.MAX_VALUE, mm.getString("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+
+ public void testCharLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+
+ mm.setChar("value", 'c');
+ Assert.assertEquals('c', mm.getChar("value"));
+ Assert.assertEquals("c", mm.getString("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testDoubleLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setDouble("value", Double.MAX_VALUE);
+ Assert.assertEquals(Double.MAX_VALUE, mm.getDouble("value"));
+ Assert.assertEquals("" + Double.MAX_VALUE, mm.getString("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testFloatLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setFloat("value", Float.MAX_VALUE);
+ Assert.assertEquals(Float.MAX_VALUE, mm.getFloat("value"));
+ Assert.assertEquals((double) Float.MAX_VALUE, mm.getDouble("value"));
+ Assert.assertEquals("" + Float.MAX_VALUE, mm.getString("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testIntLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setInt("value", Integer.MAX_VALUE);
+ Assert.assertEquals(Integer.MAX_VALUE, mm.getInt("value"));
+ Assert.assertEquals((long) Integer.MAX_VALUE, mm.getLong("value"));
+ Assert.assertEquals("" + Integer.MAX_VALUE, mm.getString("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testLongLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setLong("value", Long.MAX_VALUE);
+ Assert.assertEquals(Long.MAX_VALUE, mm.getLong("value"));
+ Assert.assertEquals("" + Long.MAX_VALUE, mm.getString("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testBytesLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ byte[] bytes = {99, 98, 97, 96, 95};
+ mm.setBytes("bytes", bytes);
+ assertBytesEqual(bytes, mm.getBytes("bytes"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ // Failed Lookups
+
+ public void testFailedBooleanLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ Assert.assertEquals(false, mm.getBoolean("int"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testFailedByteLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getByte("random");
+ Assert.fail("NumberFormatException should be received.");
+ }
+ catch (NumberFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+
+ }
+
+ public void testFailedBytesLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ Assert.assertEquals(null, mm.getBytes("random"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedCharLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getChar("random");
+ Assert.fail("NullPointerException should be received.");
+ }
+ catch (NullPointerException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedDoubleLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getDouble("random");
+ Assert.fail("NullPointerException should be received.");
+ }
+ catch (NullPointerException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedFloatLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getFloat("random");
+ Assert.fail("NullPointerException should be received.");
+ }
+ catch (NullPointerException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedIntLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getInt("random");
+ Assert.fail("NumberFormatException should be received.");
+ }
+ catch (NumberFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedLongLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getLong("random");
+ Assert.fail("NumberFormatException should be received.");
+ }
+ catch (NumberFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedShortLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getShort("random");
+ Assert.fail("NumberFormatException should be received.");
+ }
+ catch (NumberFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+
+ private void assertBytesEqual(byte[] expected, byte[] actual)
+ {
+ Assert.assertEquals(expected.length, actual.length);
+
+ for (int index = 0; index < expected.length; index++)
+ {
+ Assert.assertEquals(expected[index], actual[index]);
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(MapMessageTest.class);
+ }
+
+
+}
diff --git a/java/client/src/test/java/org/apache/qpid/client/message/ObjectMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
index a5e1a0d558..9425b7c304 100644
--- a/java/client/src/test/java/org/apache/qpid/client/message/ObjectMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
@@ -1,28 +1,32 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
+package org.apache.qpid.test.unit.client.message;
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.junit.Before;
-import org.junit.Test;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.test.VMBrokerSetup;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
@@ -33,32 +37,25 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.ArrayList;
-import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
-public class ObjectMessageTest implements MessageListener
+public class ObjectMessageTest extends TestCase implements MessageListener
{
- private final AMQConnection connection;
- private final AMQDestination destination;
- private final AMQSession session;
- private final Serializable[] data;
+ private AMQConnection connection;
+ private AMQDestination destination;
+ private AMQSession session;
+ private Serializable[] data;
private volatile boolean waiting;
private int received;
private final ArrayList items = new ArrayList();
- ObjectMessageTest(String broker) throws Exception
- {
- this(new AMQConnection(broker, "guest", "guest", randomize("Client"), "/test_path"));
- }
+ private String _broker = "vm://:1";
- ObjectMessageTest(AMQConnection connection) throws Exception
+ protected void setUp() throws Exception
{
- this(connection, new AMQQueue(randomize("LatencyTest"), true));
- }
-
- ObjectMessageTest(AMQConnection connection, AMQDestination destination) throws Exception
- {
- this.connection = connection;
- this.destination = destination;
+ super.setUp();
+ connection = new AMQConnection(_broker, "guest", "guest", randomize("Client"), "/test_path");
+ destination = new AMQQueue(randomize("LatencyTest"), true);
session = (AMQSession) connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
A a1 = new A(1, "A");
A a2 = new A(2, "a");
@@ -72,6 +69,20 @@ public class ObjectMessageTest implements MessageListener
data = new Serializable[]{a1, a2, b, c, "Hello World!", new Integer(1001)};
}
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public ObjectMessageTest()
+ {
+ }
+
+ ObjectMessageTest(String broker) throws Exception
+ {
+ _broker = broker;
+ }
+
public void test() throws Exception
{
try
@@ -81,6 +92,10 @@ public class ObjectMessageTest implements MessageListener
check();
System.out.println("All " + data.length + " items matched.");
}
+ catch (Exception e)
+ {
+ fail("This Test should succeed but failed due to: " + e);
+ }
finally
{
close();
@@ -97,10 +112,10 @@ public class ObjectMessageTest implements MessageListener
MessageProducer producer = session.createProducer(destination, false, false, true);
- for(int i = 0; i < data.length; i++)
+ for (int i = 0; i < data.length; i++)
{
ObjectMessage msg;
- if(i % 2 == 0)
+ if (i % 2 == 0)
{
msg = session.createObjectMessage(data[i]);
}
@@ -116,21 +131,21 @@ public class ObjectMessageTest implements MessageListener
public void check() throws Exception
{
Object[] actual = (Object[]) items.toArray();
- if(actual.length != data.length)
+ if (actual.length != data.length)
{
throw new Exception("Expected " + data.length + " objects, got " + actual.length);
}
- for(int i = 0; i < data.length; i++)
+ for (int i = 0; i < data.length; i++)
{
- if(actual[i] instanceof Exception)
+ if (actual[i] instanceof Exception)
{
throw new Exception("Error on receive of " + data[i], ((Exception) actual[i]));
}
- if(actual[i] == null)
+ if (actual[i] == null)
{
throw new Exception("Expected " + data[i] + " got null");
}
- if(!data[i].equals(actual[i]))
+ if (!data[i].equals(actual[i]))
{
throw new Exception("Expected " + data[i] + " got " + actual[i]);
}
@@ -147,7 +162,7 @@ public class ObjectMessageTest implements MessageListener
private synchronized void waitUntilReceived(int count) throws InterruptedException
{
waiting = true;
- while(received < count)
+ while (received < count)
{
wait();
}
@@ -159,7 +174,7 @@ public class ObjectMessageTest implements MessageListener
received++;
try
{
- if(message instanceof ObjectMessage)
+ if (message instanceof ObjectMessage)
{
items.add(((ObjectMessage) message).getObject());
}
@@ -175,7 +190,8 @@ public class ObjectMessageTest implements MessageListener
items.add(e);
}
- if(waiting){
+ if (waiting)
+ {
synchronized(this)
{
notify();
@@ -183,15 +199,17 @@ public class ObjectMessageTest implements MessageListener
}
}
+
public static void main(String[] argv) throws Exception
{
String broker = argv.length > 0 ? argv[0] : "vm://:1";
- if("-help".equals(broker))
+ if ("-help".equals(broker))
{
System.out.println("Usage: <broker>");
}
new ObjectMessageTest(broker).test();
}
+
private static class A implements Serializable
{
private String sValue;
@@ -249,4 +267,8 @@ public class ObjectMessageTest implements MessageListener
return in + System.currentTimeMillis();
}
+ public static junit.framework.Test suite()
+ {
+ return new VMBrokerSetup(new junit.framework.TestSuite(ObjectMessageTest.class));
+ }
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
new file mode 100644
index 0000000000..337b0f3bbc
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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.message;
+
+import org.apache.qpid.client.message.TestMessageHelper;
+import org.apache.qpid.client.message.JMSTextMessage;
+
+import junit.framework.TestCase;
+
+public class TextMessageTest extends TestCase
+{
+ public void testTextOnConstruction() throws Exception
+ {
+ JMSTextMessage tm = TestMessageHelper.newJMSTextMessage();
+ tm.setText("pies");
+ String val = tm.getText();
+ assertEquals(val, "pies");
+ }
+
+ public void testClearBody() throws Exception
+ {
+ JMSTextMessage tm = TestMessageHelper.newJMSTextMessage();
+ tm.setText("pies");
+ tm.clearBody();
+ String val = tm.getText();
+ assertNull(val);
+ tm.setText("Banana");
+ val = tm.getText();
+ assertEquals(val, "Banana");
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(TextMessageTest.class);
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
new file mode 100644
index 0000000000..98e355b0da
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
@@ -0,0 +1,122 @@
+/*
+ *
+ * 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.protocol;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.protocol.AMQProtocolHandler;
+import org.apache.qpid.client.protocol.AMQProtocolSession;
+import org.apache.mina.common.IoSession;
+
+import junit.framework.TestCase;
+
+public class AMQProtocolSessionTest extends TestCase
+{
+ private static class AMQProtSession extends AMQProtocolSession
+ {
+ public AMQProtSession()
+ {
+ }
+
+ public AMQProtSession(AMQProtocolHandler protocolHandler, IoSession protocolSession, AMQConnection connection)
+ {
+ super(protocolHandler,protocolSession,connection);
+ }
+
+ public TestIoSession getMinaProtocolSession()
+ {
+ return (TestIoSession) _minaProtocolSession;
+ }
+
+ public String genQueueName()
+ {
+ return generateQueueName();
+ }
+ }
+
+ //private Strings for test values and expected results
+ private String _brokenAddress;
+ private String _generatedAddress;
+ private String _emptyAddress;
+ private String _generatedAddress_2;
+ private String _validAddress;
+ private String _generatedAddress_3;
+ private int _port;
+ private AMQProtSession _testSession;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ //don't care about the values set here apart from the dummy IoSession
+ _testSession = new AMQProtSession(null,new TestIoSession(),null);
+
+ //initialise addresses for test and expected results
+ _port = 123;
+ _brokenAddress = "tcp://myAddress;:";
+ _generatedAddress = "tmp_tcpmyAddress123_1";
+ _emptyAddress = "";
+ _generatedAddress_2 = "tmp_localhost127.0.0.1123_2";
+ _validAddress = "abc";
+ _generatedAddress_3 = "tmp_abc123_3";
+ }
+
+ public void testGenerateQueueName()
+ {
+ String testAddress;
+
+ //test address with / and ; chars which generateQueueName should remove
+ _testSession.getMinaProtocolSession().setStringLocalAddress(_brokenAddress);
+ _testSession.getMinaProtocolSession().setLocalPort(_port);
+
+ testAddress = _testSession.genQueueName();
+ assertEquals("Failure when generating a queue name from an address with special chars",_generatedAddress,testAddress);
+
+ //test empty address
+ _testSession.getMinaProtocolSession().setStringLocalAddress(_emptyAddress);
+
+ testAddress = _testSession.genQueueName();
+ assertEquals("Failure when generating a queue name from an empty address",_generatedAddress_2,testAddress);
+
+ //test address with no special chars
+ _testSession.getMinaProtocolSession().setStringLocalAddress(_validAddress);
+
+ testAddress = _testSession.genQueueName();
+ assertEquals("Failure when generating a queue name from an address with no special chars",_generatedAddress_3,testAddress);
+
+ }
+
+ protected void tearDown() throws Exception
+ {
+ _testSession = null;
+ _brokenAddress = null;
+ _generatedAddress = null;
+ _emptyAddress = null;
+ _generatedAddress_2 = null;
+ _validAddress = null;
+ _generatedAddress_3 = null;
+ super.tearDown();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new junit.framework.TestSuite(AMQProtocolSessionTest.class);
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/TestIoSession.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/TestIoSession.java
new file mode 100644
index 0000000000..e800afc7ba
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/TestIoSession.java
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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.protocol;
+
+import org.apache.mina.common.support.BaseIoSession;
+import org.apache.mina.common.*;
+
+import java.net.SocketAddress;
+import java.net.InetSocketAddress;
+
+public class TestIoSession extends BaseIoSession {
+
+ private String _stringLocalAddress;
+ private int _localPort;
+
+ public SocketAddress getLocalAddress()
+ {
+ //create a new address for testing purposes using member variables
+ return new InetSocketAddress(_stringLocalAddress,_localPort);
+ }
+
+ protected void updateTrafficMask() {
+ //dummy
+ }
+
+ public IoService getService() {
+ return null;
+ }
+
+ public IoServiceConfig getServiceConfig() {
+ return null;
+ }
+
+ public IoHandler getHandler() {
+ return null;
+ }
+
+ public IoSessionConfig getConfig() {
+ return null;
+ }
+
+ public IoFilterChain getFilterChain() {
+ return null;
+ }
+
+ public TransportType getTransportType() {
+ return null;
+ }
+
+ public SocketAddress getRemoteAddress() {
+ return null;
+ }
+
+ public SocketAddress getServiceAddress() {
+ return null;
+ }
+
+ public int getScheduledWriteRequests() {
+ return 0;
+ }
+
+ public int getScheduledWriteBytes() {
+ return 0;
+ }
+
+ public String getStringLocalAddress() {
+ return _stringLocalAddress;
+ }
+
+ public void setStringLocalAddress(String _stringLocalAddress) {
+ this._stringLocalAddress = _stringLocalAddress;
+ }
+
+ public int getLocalPort() {
+ return _localPort;
+ }
+
+ public void setLocalPort(int _localPort) {
+ this._localPort = _localPort;
+ }
+}
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
index 27a92d334a..cdb00240b6 100644
--- 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
@@ -1,110 +1,153 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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 junit.framework.JUnit4TestAdapter;
import org.apache.qpid.client.AMQConnectionFactory;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQTopic;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
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
+public class PropertiesFileInitialContextFactoryTest extends TestCase
{
InitialContextFactory contextFactory;
Properties _properties;
+ Properties _fileProperties;
- @Before
- public void setupProperties()
+ 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
- public void test()
+ /**
+ * Test using hardcoded properties
+ */
+ public void testWithoutFile()
{
Context ctx = null;
+
try
{
ctx = new InitialContext(_properties);
}
catch (NamingException ne)
{
- Assert.fail("Error loading context:" + 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");
- Assert.assertEquals("amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'", cf.getConnectionURL().toString());
+ assertEquals("amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'", cf.getConnectionURL().toString());
}
catch (NamingException ne)
{
- Assert.fail("Unable to create Connection Factory:" + ne);
+ fail(errorInfo + "Unable to create Connection Factory:" + ne);
}
try
{
AMQQueue queue = (AMQQueue) ctx.lookup("MyQueue");
- Assert.assertEquals("example.MyQueue", queue.getRoutingKey());
+ assertEquals("example.MyQueue", queue.getRoutingKey());
}
catch (NamingException ne)
{
- Assert.fail("Unable to create queue:" + ne);
+ fail(errorInfo + "Unable to create queue:" + ne);
}
try
{
AMQTopic topic = (AMQTopic) ctx.lookup("ibmStocks");
- Assert.assertEquals("stocks.nyse.ibm", topic.getTopicName());
+ assertEquals("stocks.nyse.ibm", topic.getTopicName());
}
catch (Exception ne)
{
- Assert.fail("Unable to create topic:" + ne);
+ fail(errorInfo + "Unable to create topic:" + ne);
}
try
{
AMQQueue direct = (AMQQueue) ctx.lookup("direct");
- Assert.assertEquals("directQueue", direct.getRoutingKey());
+ assertEquals("directQueue", direct.getRoutingKey());
}
catch (NamingException ne)
{
- Assert.fail("Unable to create direct destination:" + ne);
+ fail(errorInfo + "Unable to create direct destination:" + ne);
}
-
-
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(PropertiesFileInitialContextFactoryTest.class);
}
}
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
new file mode 100644
index 0000000000..82de41908f
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/example.properties
@@ -0,0 +1,21 @@
+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/jndi/referenceabletest/Bind.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java
index 221237a37c..db871281bf 100644
--- a/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/Bind.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java
@@ -1,27 +1,29 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.referenceabletest;
+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 org.junit.Assert;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -36,6 +38,8 @@ 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:
@@ -46,10 +50,11 @@ import java.util.Hashtable;
* <p/>
* Also you need to create the directory /temp/qpid-jndi-test
*/
-class Bind
+class Bind extends TestCase
{
- public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest";
- public static final String PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
+ 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 = "";
@@ -60,15 +65,24 @@ class Bind
public Bind() throws NameAlreadyBoundException, NoInitialContextException
{
- this(false);
+ 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);
@@ -91,7 +105,7 @@ class Bind
}
}
-
+ Connection connection = null;
try
{
// Create the initial context
@@ -100,7 +114,7 @@ class Bind
// Create the connection factory to be bound
ConnectionFactory connectionFactory = null;
// Create the Connection to be bound
- Connection connection = null;
+
try
{
@@ -111,11 +125,11 @@ class Bind
}
catch (JMSException jmsqe)
{
- Assert.fail("Unable to create Connection:" + jmsqe);
+ fail("Unable to create Connection:" + jmsqe);
}
catch (URLSyntaxException urlse)
{
- Assert.fail("Unable to create Connection:" + urlse);
+ fail("Unable to create Connection:" + urlse);
}
try
@@ -166,21 +180,57 @@ class Bind
throw(NoInitialContextException) e;
}
}
+ finally
+ {
+ try
+ {
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
+ catch (JMSException e)
+ {
+ //ignore just want it closed
+ }
+ }
}
public String connectionFactoryValue()
{
- return _connectionFactoryString;
+ if (_connectionFactoryString != null)
+ {
+ return _connectionFactoryString;
+ }
+ else
+ {
+ return "";
+ }
}
public String connectionValue()
{
- return _connectionString;
+ if (_connectionString != null)
+ {
+ return _connectionString;
+ }
+ else
+ {
+ return "";
+ }
}
public String topicValue()
{
- return ((AMQTopic) _topic).toURL();
+ if (_topic != null)
+ {
+ return ((AMQTopic) _topic).toURL();
+ }
+ else
+ {
+ return "";
+ }
+
}
public boolean bound()
@@ -188,9 +238,13 @@ class Bind
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
new file mode 100644
index 0000000000..4731caca98
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java
@@ -0,0 +1,104 @@
+/*
+ *
+ * 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/jndi/referenceabletest/Lookup.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Lookup.java
index 481500b8f0..b804ccb30c 100644
--- a/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/Lookup.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Lookup.java
@@ -1,21 +1,24 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.referenceabletest;
+package org.apache.qpid.test.unit.jndi.referenceabletest;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionFactory;
@@ -24,6 +27,7 @@ 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;
@@ -41,18 +45,30 @@ import java.util.Hashtable;
class Lookup
{
public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest";
- public static final String PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
+ 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));
@@ -83,6 +99,8 @@ class Lookup
_connection = (AMQConnection) ctx.lookup("Connection");
+ _connectionURL = _connection.toURL();
+
_connectionFactory = (AMQConnectionFactory) ctx.lookup("ConnectionFactory");
//System.out.println(topic);
@@ -93,21 +111,52 @@ class Lookup
{
System.out.println("Operation failed: " + e);
}
+ finally
+ {
+ try
+ {
+ if (_connection != null)
+ {
+ _connection.close();
+ }
+ }
+ catch (JMSException e)
+ {
+ //ignore just need to close
+ }
+ }
}
public String connectionFactoryValue()
{
- return _connectionFactory.getConnectionURL().toString();
+ if (_connectionFactory != null)
+ {
+ return _connectionFactory.getConnectionURL().toString();
+ }
+ return "";
}
public String connectionValue()
{
- return _connection.toURL();
+ if (_connectionURL != null)
+ {
+ return _connectionURL;
+ }
+ return "";
}
public String topicValue()
{
- return _topic.toURL();
+ if (_topic != null)
+ {
+ return _topic.toURL();
+ }
+ return "";
+ }
+
+ public String getProviderURL()
+ {
+ return PROVIDER_URL;
}
public static void main(String[] args)
diff --git a/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/Unbind.java b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java
index 767f7c5737..869bc55d8f 100644
--- a/java/client/src/test/java/org/apache/qpid/jndi/referenceabletest/Unbind.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java
@@ -1,26 +1,31 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.referenceabletest;
+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;
@@ -36,19 +41,30 @@ import java.util.Hashtable;
*/
class Unbind
{
- public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest";
- public static final String PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH;
+ 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);
+ this(false, DEFAULT_PROVIDER_URL);
+ }
+
+ public Unbind(Boolean output)
+ {
+ this(output, DEFAULT_PROVIDER_URL);
}
- public Unbind(boolean output)
+ 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,
@@ -99,6 +115,14 @@ class Unbind
try
{
obj = ctx.lookup("Connection");
+ try
+ {
+ ((Connection) obj).close();
+ }
+ catch (JMSException e)
+ {
+ //ignore just need to close
+ }
}
catch (NameNotFoundException ne2)
{
@@ -125,7 +149,9 @@ class Unbind
//System.out.println("unbind failed; object still there: " + obj);
// Close the context when we're done
+
ctx.close();
+
}
catch (NamingException e)
{
diff --git a/java/client/src/test/java/org/apache/qpid/topic/DurableSubscriptionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
index 7acf2a262f..b20cfa046a 100644
--- a/java/client/src/test/java/org/apache/qpid/topic/DurableSubscriptionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
@@ -1,27 +1,25 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
+package org.apache.qpid.test.unit.topic;
-import junit.framework.JUnit4TestAdapter;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
import org.apache.qpid.AMQException;
import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.url.URLSyntaxException;
@@ -29,6 +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 javax.jms.JMSException;
import javax.jms.Message;
@@ -38,30 +37,11 @@ import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.TopicSubscriber;
-public class DurableSubscriptionTest
-{
-
- @Before
- public void startVmBrokers()
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create VM Broker");
- }
- }
+import junit.framework.TestCase;
- @After
- public void stopVmBrokers()
- {
- TransportConnection.killVMBroker(1);
- }
-
- @Test
- public void unsubscribe() throws AMQException, JMSException, URLSyntaxException
+public class DurableSubscriptionTest extends TestCase
+{
+ public void testUnsubscribe() throws AMQException, JMSException, URLSyntaxException
{
AMQTopic topic = new AMQTopic("MyTopic");
AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "test", "/test");
@@ -72,38 +52,37 @@ public class DurableSubscriptionTest
Session session2 = con.createSession(false, AMQSession.NO_ACKNOWLEDGE);
TopicSubscriber consumer2 = session2.createDurableSubscriber(topic, "MySubscription");
- con.start();
+ con.start();
producer.send(session1.createTextMessage("A"));
Message msg;
msg = consumer1.receive();
- Assert.assertEquals("A", ((TextMessage) msg).getText());
+ assertEquals("A", ((TextMessage) msg).getText());
msg = consumer1.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
msg = consumer2.receive();
- Assert.assertEquals("A", ((TextMessage) msg).getText());
+ assertEquals("A", ((TextMessage) msg).getText());
msg = consumer2.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
session2.unsubscribe("MySubscription");
producer.send(session1.createTextMessage("B"));
msg = consumer1.receive();
- Assert.assertEquals("B", ((TextMessage) msg).getText());
+ assertEquals("B", ((TextMessage) msg).getText());
msg = consumer1.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
msg = consumer2.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
con.close();
}
- @Test
- public void durability() throws AMQException, JMSException, URLSyntaxException
+ public void testDurability() throws AMQException, JMSException, URLSyntaxException
{
AMQTopic topic = new AMQTopic("MyTopic");
AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "test", "/test");
@@ -120,14 +99,14 @@ public class DurableSubscriptionTest
Message msg;
msg = consumer1.receive();
- Assert.assertEquals("A", ((TextMessage) msg).getText());
+ assertEquals("A", ((TextMessage) msg).getText());
msg = consumer1.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
msg = consumer2.receive();
- Assert.assertEquals("A", ((TextMessage) msg).getText());
+ assertEquals("A", ((TextMessage) msg).getText());
msg = consumer2.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
consumer2.close();
@@ -137,21 +116,20 @@ public class DurableSubscriptionTest
producer.send(session1.createTextMessage("B"));
msg = consumer1.receive();
- Assert.assertEquals("B", ((TextMessage) msg).getText());
+ assertEquals("B", ((TextMessage) msg).getText());
msg = consumer1.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
msg = consumer3.receive();
- Assert.assertEquals("B", ((TextMessage) msg).getText());
+ assertEquals("B", ((TextMessage) msg).getText());
msg = consumer3.receive(1000);
- Assert.assertEquals(null, msg);
+ assertEquals(null, msg);
con.close();
}
public static junit.framework.Test suite()
{
- return new JUnit4TestAdapter(DurableSubscriptionTest.class);
+ return new VMBrokerSetup(new junit.framework.TestSuite(DurableSubscriptionTest.class));
}
-
}
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
new file mode 100644
index 0000000000..92f3234bba
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/transacted/TransactedTest.java
@@ -0,0 +1,147 @@
+/*
+ *
+ * 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.transacted;
+
+import org.apache.qpid.client.AMQConnection;
+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 javax.jms.*;
+
+import junit.framework.TestCase;
+
+public class TransactedTest extends TestCase
+{
+ private AMQQueue queue1;
+ private AMQQueue queue2;
+
+ private AMQConnection con;
+ private Session session;
+ private MessageConsumer consumer1;
+ private MessageProducer producer2;
+
+ private AMQConnection prepCon;
+ private Session prepSession;
+ private MessageProducer prepProducer1;
+
+ private AMQConnection testCon;
+ private Session testSession;
+ private MessageConsumer testConsumer1;
+ private MessageConsumer testConsumer2;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ queue1 = new AMQQueue("Q1", false);
+ queue2 = new AMQQueue("Q2", false);
+
+ con = new AMQConnection("vm://:1", "guest", "guest", "TransactedTest", "/test");
+ session = con.createSession(true, 0);
+ consumer1 = session.createConsumer(queue1);
+ //Dummy just to create the queue.
+ MessageConsumer consumer2 = session.createConsumer(queue2);
+ consumer2.close();
+ producer2 = session.createProducer(queue2);
+ con.start();
+
+ prepCon = new AMQConnection("vm://:1", "guest", "guest", "PrepConnection", "/test");
+ prepSession = prepCon.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+ prepProducer1 = prepSession.createProducer(queue1);
+ prepCon.start();
+
+
+ //add some messages
+ prepProducer1.send(prepSession.createTextMessage("A"));
+ prepProducer1.send(prepSession.createTextMessage("B"));
+ prepProducer1.send(prepSession.createTextMessage("C"));
+
+ testCon = new AMQConnection("vm://:1", "guest", "guest", "TestConnection", "/test");
+ testSession = testCon.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+ testConsumer1 = testSession.createConsumer(queue1);
+ testConsumer2 = testSession.createConsumer(queue2);
+ testCon.start();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ con.close();
+ testCon.close();
+ prepCon.close();
+ super.tearDown();
+ }
+
+ public void testCommit() throws Exception
+ {
+ //send and receive some messages
+ producer2.send(session.createTextMessage("X"));
+ producer2.send(session.createTextMessage("Y"));
+ producer2.send(session.createTextMessage("Z"));
+ expect("A", consumer1.receive(1000));
+ expect("B", consumer1.receive(1000));
+ expect("C", consumer1.receive(1000));
+
+ //commit
+ session.commit();
+
+ //ensure sent messages can be received and received messages are gone
+ expect("X", testConsumer2.receive(1000));
+ expect("Y", testConsumer2.receive(1000));
+ expect("Z", testConsumer2.receive(1000));
+
+ assertTrue(null == testConsumer1.receive(1000));
+ assertTrue(null == testConsumer2.receive(1000));
+ }
+
+ public void testRollback() throws Exception
+ {
+ producer2.send(session.createTextMessage("X"));
+ producer2.send(session.createTextMessage("Y"));
+ producer2.send(session.createTextMessage("Z"));
+ expect("A", consumer1.receive(1000));
+ expect("B", consumer1.receive(1000));
+ expect("C", consumer1.receive(1000));
+
+ //rollback
+ session.rollback();
+
+ //ensure sent messages are not visible and received messages are requeued
+ expect("A", consumer1.receive(1000));
+ expect("B", consumer1.receive(1000));
+ expect("C", consumer1.receive(1000));
+
+ assertTrue(null == testConsumer1.receive(1000));
+ assertTrue(null == testConsumer2.receive(1000));
+ }
+
+ private void expect(String text, Message msg) throws JMSException
+ {
+ assertTrue(msg instanceof TextMessage);
+ assertEquals(text, ((TextMessage) msg).getText());
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new VMBrokerSetup(new junit.framework.TestSuite(TransactedTest.class));
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/testutil/Config.java b/java/client/src/test/java/org/apache/qpid/testutil/Config.java
index b5ec9c8c0c..68e1e80044 100644
--- a/java/client/src/test/java/org/apache/qpid/testutil/Config.java
+++ b/java/client/src/test/java/org/apache/qpid/testutil/Config.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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.testutil;
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
index e77b1098c2..bb740f9094 100644
--- a/java/client/src/test/java/org/apache/qpid/topic/Config.java
+++ b/java/client/src/test/java/org/apache/qpid/topic/Config.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index cb4ef6c0d2..47c608cfe4 100644
--- a/java/client/src/test/java/org/apache/qpid/topic/Listener.java
+++ b/java/client/src/test/java/org/apache/qpid/topic/Listener.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index fff85d1290..1520f18408 100644
--- a/java/client/src/test/java/org/apache/qpid/topic/MessageFactory.java
+++ b/java/client/src/test/java/org/apache/qpid/topic/MessageFactory.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 3b8c7ce810..d788029ee9 100644
--- a/java/client/src/test/java/org/apache/qpid/topic/Publisher.java
+++ b/java/client/src/test/java/org/apache/qpid/topic/Publisher.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
@@ -154,7 +157,8 @@ public class Publisher implements MessageListener
}
sum -= min;
sum -= max;
- return (sum / times.length - 2);
+
+ return (sum / (times.length - 2));
}
public static void main(String[] argv) throws Exception
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
index 3312d20b0a..bd104e5407 100644
--- a/java/client/src/test/java/org/apache/qpid/transacted/Config.java
+++ b/java/client/src/test/java/org/apache/qpid/transacted/Config.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 9d6287549c..e0af4422a6 100644
--- a/java/client/src/test/java/org/apache/qpid/transacted/Ping.java
+++ b/java/client/src/test/java/org/apache/qpid/transacted/Ping.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index d9e5618a3b..13295c137a 100644
--- a/java/client/src/test/java/org/apache/qpid/transacted/Pong.java
+++ b/java/client/src/test/java/org/apache/qpid/transacted/Pong.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 96a7a71ac0..cede95e5f0 100644
--- a/java/client/src/test/java/org/apache/qpid/transacted/Relay.java
+++ b/java/client/src/test/java/org/apache/qpid/transacted/Relay.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index 85a633fc4f..5564ed93ab 100644
--- a/java/client/src/test/java/org/apache/qpid/transacted/Start.java
+++ b/java/client/src/test/java/org/apache/qpid/transacted/Start.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
diff --git a/java/client/src/test/java/org/apache/qpid/transacted/TransactedTest.java b/java/client/src/test/java/org/apache/qpid/transacted/TransactedTest.java
deleted file mode 100644
index 200c89bebe..0000000000
--- a/java/client/src/test/java/org/apache/qpid/transacted/TransactedTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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 junit.framework.JUnit4TestAdapter;
-import org.apache.qpid.client.AMQConnection;
-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.junit.After;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.Assert;
-
-import javax.jms.*;
-
-public class TransactedTest
-{
- private AMQQueue queue1;
- private AMQQueue queue2;
-
- private AMQConnection con;
- private Session session;
- private MessageConsumer consumer;
- private MessageProducer producer;
-
- private AMQConnection prepCon;
- private Session prepSession;
- private MessageProducer prepProducer;
-
- private AMQConnection testCon;
- private Session testSession;
- private MessageConsumer testConsumer1;
- private MessageConsumer testConsumer2;
-
- @Before
- public void setup() throws Exception
- {
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- Assert.fail("Unable to create VM Broker");
- }
-
- queue1 = new AMQQueue("Q1", false);
- queue2 = new AMQQueue("Q2", false);
-
- con = new AMQConnection("vm://:1", "guest", "guest", "TransactedTest", "/test");
- session = con.createSession(true, 0);
- consumer = session.createConsumer(queue1);
- producer = session.createProducer(queue2);
- con.start();
-
- prepCon = new AMQConnection("vm://:1", "guest", "guest", "PrepConnection", "/test");
- prepSession = prepCon.createSession(false, AMQSession.NO_ACKNOWLEDGE);
- prepProducer = prepSession.createProducer(queue1);
- prepCon.start();
-
- //add some messages
- prepProducer.send(prepSession.createTextMessage("A"));
- prepProducer.send(prepSession.createTextMessage("B"));
- prepProducer.send(prepSession.createTextMessage("C"));
-
-
- testCon = new AMQConnection("vm://:1", "guest", "guest", "TestConnection", "/test");
- testSession = testCon.createSession(false, AMQSession.NO_ACKNOWLEDGE);
- testConsumer1 = testSession.createConsumer(queue1);
- testConsumer2 = testSession.createConsumer(queue2);
- testCon.start();
- }
-
- @After
- public void shutdown() throws Exception
- {
- con.close();
- testCon.close();
- prepCon.close();
-
- TransportConnection.killVMBroker(1);
- }
-
- @Test
- public void commit() throws Exception
- {
- //send and receive some messages
- producer.send(session.createTextMessage("X"));
- producer.send(session.createTextMessage("Y"));
- producer.send(session.createTextMessage("Z"));
- expect("A", consumer.receive(1000));
- expect("B", consumer.receive(1000));
- expect("C", consumer.receive(1000));
-
- //commit
- session.commit();
-
- //ensure sent messages can be received and received messages are gone
- expect("X", testConsumer2.receive(1000));
- expect("Y", testConsumer2.receive(1000));
- expect("Z", testConsumer2.receive(1000));
-
- assertTrue(null == testConsumer1.receive(1000));
- assertTrue(null == testConsumer2.receive(1000));
- }
-
- @Test
- public void rollback() throws Exception
- {
- producer.send(session.createTextMessage("X"));
- producer.send(session.createTextMessage("Y"));
- producer.send(session.createTextMessage("Z"));
- expect("A", consumer.receive(1000));
- expect("B", consumer.receive(1000));
- expect("C", consumer.receive(1000));
-
- //rollback
- session.rollback();
-
- //ensure sent messages are not visible and received messages are requeued
- expect("A", consumer.receive(1000));
- expect("B", consumer.receive(1000));
- expect("C", consumer.receive(1000));
-
- assertTrue(null == testConsumer1.receive(1000));
- assertTrue(null == testConsumer2.receive(1000));
- }
-
- private void expect(String text, Message msg) throws JMSException
- {
- assertTrue(msg instanceof TextMessage);
- assertEquals(text, ((TextMessage) msg).getText());
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(TransactedTest.class);
- }
-
-}
diff --git a/java/client/src/test/java/org/apache/qpid/transacted/UnitTests.java b/java/client/src/test/java/org/apache/qpid/transacted/UnitTests.java
deleted file mode 100644
index 8d43287d6f..0000000000
--- a/java/client/src/test/java/org/apache/qpid/transacted/UnitTests.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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 junit.framework.JUnit4TestAdapter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({TransactedTest.class})
-public class UnitTests
-{
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(UnitTests.class);
- }
-}
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
index 8c6f6ab62e..71d806b338 100644
--- a/java/client/src/test/java/org/apache/qpid/weblogic/ServiceProvider.java
+++ b/java/client/src/test/java/org/apache/qpid/weblogic/ServiceProvider.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;
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
index b2d24cd1c1..a1e15258c3 100644
--- a/java/client/src/test/java/org/apache/qpid/weblogic/ServiceRequestingClient.java
+++ b/java/client/src/test/java/org/apache/qpid/weblogic/ServiceRequestingClient.java
@@ -1,18 +1,21 @@
/*
*
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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.
+ * 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;