You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2017/08/23 15:36:46 UTC
[1/4] qpid-broker-j git commit: QPID-7434: [Java Broker] Fix AMQP
0-10 to 1.0 correlationId conversion
Repository: qpid-broker-j
Updated Branches:
refs/heads/master a10f3063b -> d12b40a4d
QPID-7434: [Java Broker] Fix AMQP 0-10 to 1.0 correlationId conversion
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/d12b40a4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/d12b40a4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/d12b40a4
Branch: refs/heads/master
Commit: d12b40a4d066d79e5dc38b7b137a73b776817f0a
Parents: a7e4a71
Author: Lorenz Quack <lq...@apache.org>
Authored: Wed Aug 23 15:30:22 2017 +0100
Committer: Lorenz Quack <lq...@apache.org>
Committed: Wed Aug 23 16:36:38 2017 +0100
----------------------------------------------------------------------
.../MessageConverter_0_10_to_1_0.java | 25 ++++++++++++++++----
.../PropertyConverter_0_10_to_1_0Test.java | 23 ++++++++++++++----
2 files changed, 39 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d12b40a4/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0.java b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0.java
index 5bdfbf5..af4bd9a 100644
--- a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0.java
+++ b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0.java
@@ -21,6 +21,11 @@
package org.apache.qpid.server.protocol.converter.v0_10_v1_0;
+import java.nio.ByteBuffer;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CodingErrorAction;
+import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -28,6 +33,9 @@ import java.util.Map;
import org.apache.qpid.server.plugin.PluggableService;
import org.apache.qpid.server.protocol.converter.MessageConversionException;
import org.apache.qpid.server.protocol.v0_10.MessageTransferMessage;
+import org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties;
+import org.apache.qpid.server.protocol.v0_10.transport.MessageDeliveryMode;
+import org.apache.qpid.server.protocol.v0_10.transport.MessageProperties;
import org.apache.qpid.server.protocol.v0_10.transport.ReplyTo;
import org.apache.qpid.server.protocol.v1_0.MessageConverter_to_1_0;
import org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0;
@@ -37,15 +45,11 @@ import org.apache.qpid.server.protocol.v1_0.type.Symbol;
import org.apache.qpid.server.protocol.v1_0.type.UnsignedByte;
import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
import org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties;
-import org.apache.qpid.server.protocol.v1_0.type.messaging.Data;
import org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection;
import org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection;
import org.apache.qpid.server.protocol.v1_0.type.messaging.Header;
import org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations;
import org.apache.qpid.server.protocol.v1_0.type.messaging.Properties;
-import org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties;
-import org.apache.qpid.server.protocol.v0_10.transport.MessageDeliveryMode;
-import org.apache.qpid.server.protocol.v0_10.transport.MessageProperties;
import org.apache.qpid.server.util.GZIPUtils;
@PluggableService
@@ -123,7 +127,18 @@ public class MessageConverter_0_10_to_1_0 extends MessageConverter_to_1_0<Messa
if(msgProps.hasCorrelationId())
{
- props.setCorrelationId(new Binary(msgProps.getCorrelationId()));
+ CharsetDecoder charsetDecoder = StandardCharsets.UTF_8.newDecoder()
+ .onMalformedInput(CodingErrorAction.REPORT)
+ .onUnmappableCharacter(CodingErrorAction.REPORT);
+ try
+ {
+ String correlationIdAsString = charsetDecoder.decode(ByteBuffer.wrap(msgProps.getCorrelationId())).toString();
+ props.setCorrelationId(correlationIdAsString);
+ }
+ catch (CharacterCodingException e)
+ {
+ props.setCorrelationId(new Binary(msgProps.getCorrelationId()));
+ }
}
if(msgProps.hasMessageId())
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d12b40a4/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java
index 30eed53..f9b90f6 100644
--- a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java
+++ b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java
@@ -22,6 +22,7 @@
package org.apache.qpid.server.protocol.converter.v0_10_v1_0;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertArrayEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -178,15 +179,29 @@ public class PropertyConverter_0_10_to_1_0Test extends QpidTestCase
{
final String correlationId = "testCorrelationId";
final MessageProperties messageProperties = new MessageProperties();
- messageProperties.setCorrelationId(correlationId.getBytes());
+ messageProperties.setCorrelationId(correlationId.getBytes(UTF_8));
MessageTransferMessage message = createTestMessage(messageProperties);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Properties properties = convertedMessage.getPropertiesSection().getValue();
- assertEquals("Unexpected correlationId",
- correlationId,
- new String(((Binary) properties.getCorrelationId()).getArray(), UTF_8));
+ assertEquals("Unexpected correlationId", correlationId, properties.getCorrelationId());
+ }
+
+ public void testBinaryCorrelationIdConversion()
+ {
+ final byte[] correlationId = new byte[]{0x00, (byte) 0xff, (byte) 0xc3};
+ final MessageProperties messageProperties = new MessageProperties();
+ messageProperties.setCorrelationId(correlationId);
+ MessageTransferMessage message = createTestMessage(messageProperties);
+
+ final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
+
+ Properties properties = convertedMessage.getPropertiesSection().getValue();
+ assertTrue(String.format("Unexpected correlationId type. expected 'Binary' actual '%s'",
+ properties.getCorrelationId().getClass().getSimpleName()),
+ properties.getCorrelationId() instanceof Binary);
+ assertArrayEquals("Unexpected correlationId", correlationId, ((Binary) properties.getCorrelationId()).getArray());
}
public void testReplyToConversionWhenExchangeAndRoutingKeySpecified()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/4] qpid-broker-j git commit: QPID-7896: [Java System Tests] Create
system tests testing end-to-end message conversion
Posted by lq...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/TransactionalTransferTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/TransactionalTransferTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/TransactionalTransferTest.java
index 6fe0b55..64094aa 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/TransactionalTransferTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/TransactionalTransferTest.java
@@ -46,15 +46,15 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
import org.apache.qpid.server.protocol.v1_0.type.transport.ReceiverSettleMode;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
import org.apache.qpid.server.protocol.v1_0.type.transport.Transfer;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
import org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
import org.apache.qpid.tests.protocol.v1_0.Utils;
-public class TransactionalTransferTest extends ProtocolTestBase
+public class TransactionalTransferTest extends BrokerAdminUsingTestBase
{
private static final String TEST_MESSAGE_CONTENT = "testMessageContent";
private InetSocketAddress _brokerAddress;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/ProtocolHeaderTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/ProtocolHeaderTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/ProtocolHeaderTest.java
index 3b8f03b..619e5d9 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/ProtocolHeaderTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/ProtocolHeaderTest.java
@@ -27,13 +27,12 @@ import java.nio.charset.StandardCharsets;
import org.junit.Test;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
-import org.apache.qpid.tests.protocol.v1_0.HeaderResponse;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
-public class ProtocolHeaderTest extends ProtocolTestBase
+public class ProtocolHeaderTest extends BrokerAdminUsingTestBase
{
@Test
@SpecificationTest(section = "2.2",
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/connection/OpenTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/connection/OpenTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/connection/OpenTest.java
index 56d9eb1..b3f57c1 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/connection/OpenTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/connection/OpenTest.java
@@ -38,14 +38,14 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
-public class OpenTest extends ProtocolTestBase
+public class OpenTest extends BrokerAdminUsingTestBase
{
@Test
@SpecificationTest(section = "1.3.4",
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/AttachTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/AttachTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/AttachTest.java
index eb17d2b..0e33f3a 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/AttachTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/AttachTest.java
@@ -38,12 +38,12 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Begin;
import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
-public class AttachTest extends ProtocolTestBase
+public class AttachTest extends BrokerAdminUsingTestBase
{
@Test
@SpecificationTest(section = "1.3.4",
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/FlowTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/FlowTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/FlowTest.java
index 52b5011..a5537f0 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/FlowTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/FlowTest.java
@@ -39,13 +39,13 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
import org.apache.qpid.server.protocol.v1_0.type.transport.Flow;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
import org.apache.qpid.tests.protocol.v1_0.Utils;
-public class FlowTest extends ProtocolTestBase
+public class FlowTest extends BrokerAdminUsingTestBase
{
@Test
@SpecificationTest(section = "1.3.4",
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/ResumeDeliveriesTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/ResumeDeliveriesTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/ResumeDeliveriesTest.java
index 6124ae9..5769255 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/ResumeDeliveriesTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/ResumeDeliveriesTest.java
@@ -67,15 +67,15 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.ReceiverSettleMode;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
import org.apache.qpid.server.protocol.v1_0.type.transport.SenderSettleMode;
import org.apache.qpid.server.protocol.v1_0.type.transport.Transfer;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.Response;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
import org.apache.qpid.tests.protocol.v1_0.Utils;
-public class ResumeDeliveriesTest extends ProtocolTestBase
+public class ResumeDeliveriesTest extends BrokerAdminUsingTestBase
{
private static final int MIN_MAX_FRAME_SIZE = 512;
private static final String TEST_MESSAGE_CONTENT = "foo";
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java
index bc89d96..cf12b05 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/SaslTest.java
@@ -45,13 +45,13 @@ import org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge;
import org.apache.qpid.server.protocol.v1_0.type.security.SaslCode;
import org.apache.qpid.server.protocol.v1_0.type.security.SaslMechanisms;
import org.apache.qpid.server.protocol.v1_0.type.security.SaslOutcome;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
-public class SaslTest extends ProtocolTestBase
+public class SaslTest extends BrokerAdminUsingTestBase
{
private static final Symbol CRAM_MD5 = Symbol.getSymbol("CRAM-MD5");
private static final Symbol PLAIN = Symbol.getSymbol("PLAIN");
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/session/BeginTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/session/BeginTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/session/BeginTest.java
index e3f83f6..352fd19 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/session/BeginTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/session/BeginTest.java
@@ -36,12 +36,12 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Begin;
import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
-public class BeginTest extends ProtocolTestBase
+public class BeginTest extends BrokerAdminUsingTestBase
{
@Test
@SpecificationTest(section = "1.3.4",
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/systests-utils/pom.xml
----------------------------------------------------------------------
diff --git a/systests/systests-utils/pom.xml b/systests/systests-utils/pom.xml
new file mode 100644
index 0000000..1e42dd4
--- /dev/null
+++ b/systests/systests-utils/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-parent</artifactId>
+ <version>7.0.0-SNAPSHOT</version>
+ <relativePath>../../qpid-systests-parent/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>qpid-systests-utils</artifactId>
+ <name>Apache Qpid System Test Utils</name>
+ <description>Utility classes for Apache Qpid system tests</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-codegen</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-test-utils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-logging-logback</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker-plugins-memory-store</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdmin.java
----------------------------------------------------------------------
diff --git a/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdmin.java b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdmin.java
new file mode 100644
index 0000000..6875460
--- /dev/null
+++ b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdmin.java
@@ -0,0 +1,66 @@
+/*
+ * 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.tests.utils;
+
+import java.lang.reflect.Method;
+import java.net.InetSocketAddress;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+import org.apache.qpid.server.plugin.Pluggable;
+
+public interface BrokerAdmin extends Pluggable
+{
+ String TEST_QUEUE_NAME = "testQueue";
+ Long RESTART_TIMEOUT = Long.getLong("brokerAdmin.restart_timeout", 10000);
+
+ void beforeTestClass(final Class testClass);
+ void beforeTestMethod(final Class testClass, final Method method);
+ void afterTestMethod(final Class testClass, final Method method);
+ void afterTestClass(final Class testClass);
+
+ InetSocketAddress getBrokerAddress(PortType portType);
+
+ void createQueue(String queueName);
+ void deleteQueue(String queueName);
+ void putMessageOnQueue(String queueName, String... messages);
+ int getQueueDepthMessages(String testQueueName);
+
+ boolean supportsRestart();
+ ListenableFuture<Void> restart();
+
+ boolean isSASLSupported();
+ boolean isSASLMechanismSupported(String mechanismName);
+ boolean isWebSocketSupported();
+ boolean isQueueDepthSupported();
+
+ String getValidUsername();
+ String getValidPassword();
+
+
+
+ enum PortType
+ {
+ ANONYMOUS_AMQP,
+ ANONYMOUS_AMQPWS,
+ AMQP
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdminFactory.java
----------------------------------------------------------------------
diff --git a/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdminFactory.java b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdminFactory.java
new file mode 100644
index 0000000..64d4eff
--- /dev/null
+++ b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdminFactory.java
@@ -0,0 +1,39 @@
+/*
+ * 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.tests.utils;
+
+import java.util.Map;
+
+import org.apache.qpid.server.plugin.QpidServiceLoader;
+
+public class BrokerAdminFactory
+{
+ BrokerAdmin createInstance(String type)
+ {
+ Map<String, BrokerAdmin> adminFacades = new QpidServiceLoader().getInstancesByType(BrokerAdmin.class);
+ BrokerAdmin brokerAdmin = adminFacades.get(type);
+ if (brokerAdmin == null)
+ {
+ throw new RuntimeException(String.format("Could not find BrokerAdmin implementation of type '%s'", type));
+ }
+ return brokerAdmin;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdminUsingTestBase.java
----------------------------------------------------------------------
diff --git a/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdminUsingTestBase.java b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdminUsingTestBase.java
new file mode 100644
index 0000000..73149af
--- /dev/null
+++ b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/BrokerAdminUsingTestBase.java
@@ -0,0 +1,43 @@
+/*
+ * 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.tests.utils;
+
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(QpidTestRunner.class)
+public abstract class BrokerAdminUsingTestBase
+{
+ private static final Logger LOGGER = LoggerFactory.getLogger(BrokerAdminUsingTestBase.class);
+
+ private BrokerAdmin _brokerAdmin;
+
+ public void init(final BrokerAdmin brokerAdmin)
+ {
+ _brokerAdmin = brokerAdmin;
+ }
+
+ public BrokerAdmin getBrokerAdmin()
+ {
+ return _brokerAdmin;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/EmbeddedBrokerPerClassAdminImpl.java
----------------------------------------------------------------------
diff --git a/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/EmbeddedBrokerPerClassAdminImpl.java b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/EmbeddedBrokerPerClassAdminImpl.java
new file mode 100644
index 0000000..68f0ab4
--- /dev/null
+++ b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/EmbeddedBrokerPerClassAdminImpl.java
@@ -0,0 +1,508 @@
+/*
+ * 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.tests.utils;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.InetSocketAddress;
+import java.nio.file.Files;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import ch.qos.logback.classic.LoggerContext;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.server.SystemLauncher;
+import org.apache.qpid.server.SystemLauncherListener;
+import org.apache.qpid.server.logging.logback.LogbackLoggingSystemLauncherListener;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Container;
+import org.apache.qpid.server.model.Exchange;
+import org.apache.qpid.server.model.IllegalStateTransitionException;
+import org.apache.qpid.server.model.ManageableMessage;
+import org.apache.qpid.server.model.NotFoundException;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.Queue;
+import org.apache.qpid.server.model.SystemConfig;
+import org.apache.qpid.server.model.VirtualHostNode;
+import org.apache.qpid.server.plugin.PluggableService;
+import org.apache.qpid.server.store.MemoryConfigurationStore;
+import org.apache.qpid.server.util.FileUtils;
+import org.apache.qpid.server.virtualhost.QueueManagingVirtualHost;
+import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNode;
+import org.apache.qpid.test.utils.LogbackPropertyValueDiscriminator;
+
+@SuppressWarnings("unused")
+@PluggableService
+public class EmbeddedBrokerPerClassAdminImpl implements BrokerAdmin
+{
+ private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedBrokerPerClassAdminImpl.class);
+ private final Map<String, Integer> _ports = new HashMap<>();
+ private SystemLauncher _systemLauncher;
+ private Container<?> _broker;
+ private VirtualHostNode<?> _currentVirtualHostNode;
+ private String _currentWorkDirectory;
+ private boolean _isPersistentStore;
+
+ @Override
+ public void beforeTestClass(final Class testClass)
+ {
+ setClassQualifiedTestName(testClass.getName());
+ LOGGER.info("========================= starting broker for test class : " + testClass.getSimpleName());
+ try
+ {
+ String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
+ _currentWorkDirectory = Files.createTempDirectory(String.format("qpid-work-%s-%s-", timestamp, testClass.getSimpleName())).toString();
+
+ Map<String,String> context = new HashMap<>();
+ context.put("qpid.work_dir", _currentWorkDirectory);
+ context.put("qpid.port.protocol_handshake_timeout", "1000000");
+
+ Map<String,Object> systemConfigAttributes = new HashMap<>();
+ //systemConfigAttributes.put(SystemConfig.INITIAL_CONFIGURATION_LOCATION, "classpath:config-protocol-tests.json");
+ systemConfigAttributes.put(ConfiguredObject.CONTEXT, context);
+ systemConfigAttributes.put(ConfiguredObject.TYPE, System.getProperty("broker.config-store-type", "JSON"));
+ systemConfigAttributes.put(SystemConfig.STARTUP_LOGGED_TO_SYSTEM_OUT, Boolean.FALSE);
+
+ if (Thread.getDefaultUncaughtExceptionHandler() == null)
+ {
+ Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
+ }
+
+ LOGGER.info("Starting internal broker (same JVM)");
+
+ List<SystemLauncherListener> systemLauncherListeners = new ArrayList<>();
+ systemLauncherListeners.add(new LogbackLoggingSystemLauncherListener());
+ systemLauncherListeners.add(new ShutdownLoggingSystemLauncherListener());
+ systemLauncherListeners.add(new PortExtractingLauncherListener());
+ _systemLauncher = new SystemLauncher(systemLauncherListeners.toArray(new SystemLauncherListener[systemLauncherListeners.size()]));
+
+ _systemLauncher.startup(systemConfigAttributes);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to start broker for test class", e);
+ }
+ }
+
+ @Override
+ public void beforeTestMethod(final Class testClass, final Method method)
+ {
+ LOGGER.info("========================= prepare test environment for test : " + testClass.getSimpleName() + "#" + method.getName());
+
+ final String virtualHostNodeName = testClass.getSimpleName() + "_" + method.getName();
+ final String storeType = System.getProperty("virtualhostnode.type");
+ _isPersistentStore = !"Memory".equals(storeType);
+
+ String storeDir = null;
+ if (System.getProperty("profile", "").startsWith("java-dby-mem"))
+ {
+ storeDir = ":memory:";
+ }
+ else if (!MemoryConfigurationStore.TYPE.equals(storeType))
+ {
+ storeDir = "${qpid.work_dir}" + File.separator + virtualHostNodeName;
+ }
+
+ String blueprint = System.getProperty("virtualhostnode.context.blueprint");
+
+ Map<String, Object> attributes = new HashMap<>();
+ attributes.put(VirtualHostNode.NAME, virtualHostNodeName);
+ attributes.put(VirtualHostNode.TYPE, storeType);
+ attributes.put(VirtualHostNode.CONTEXT, Collections.singletonMap("virtualhostBlueprint", blueprint));
+ attributes.put(VirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE, true);
+ attributes.put(VirtualHostNode.VIRTUALHOST_INITIAL_CONFIGURATION, blueprint);
+ if (storeDir != null)
+ {
+ attributes.put(JsonVirtualHostNode.STORE_PATH, storeDir);
+ }
+
+ _currentVirtualHostNode = _broker.createChild(VirtualHostNode.class, attributes);
+
+ LOGGER.info("========================= executing test : " + testClass.getSimpleName() + "#" + method.getName());
+ setClassQualifiedTestName(testClass.getName() + "." + method.getName());
+ LOGGER.info("========================= start executing test : " + testClass.getSimpleName() + "#" + method.getName());
+ }
+
+ @Override
+ public void afterTestMethod(final Class testClass, final Method method)
+ {
+ LOGGER.info("========================= stop executing test : " + testClass.getSimpleName() + "#" + method.getName());
+ setClassQualifiedTestName(testClass.getName());
+ LOGGER.info("========================= cleaning up test environment for test : " + testClass.getSimpleName() + "#" + method.getName());
+ if (Boolean.getBoolean("broker.clean.between.tests"))
+ {
+ _currentVirtualHostNode.delete();
+ }
+ else
+ {
+ _currentVirtualHostNode.setAttributes(Collections.singletonMap(VirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE,
+ false));
+ }
+ setClassQualifiedTestName(testClass.getName());
+ LOGGER.info("========================= cleaning done for test : " + testClass.getSimpleName() + "#" + method.getName());
+ }
+
+ @Override
+ public void afterTestClass(final Class testClass)
+ {
+ LOGGER.info("========================= stopping broker for test class: " + testClass.getSimpleName());
+ _systemLauncher.shutdown();
+ _ports.clear();
+ if (Boolean.getBoolean("broker.clean.between.tests"))
+ {
+ FileUtils.delete(new File(_currentWorkDirectory), true);
+ }
+ LOGGER.info("========================= stopping broker done for test class : " + testClass.getSimpleName());
+ setClassQualifiedTestName(null);
+ }
+
+ @Override
+ public InetSocketAddress getBrokerAddress(final PortType portType)
+ {
+ Integer port = _ports.get(portType.name());
+ if (port == null)
+ {
+ throw new IllegalStateException(String.format("Could not find port with name '%s' on the Broker", portType.name()));
+ }
+ return new InetSocketAddress(port);
+ }
+
+ @Override
+ public void createQueue(final String queueName)
+ {
+ final Map<String, Object> attributes = new HashMap<>();
+ attributes.put(Queue.NAME, queueName);
+ attributes.put(Queue.TYPE, "standard");
+ final Queue queue = _currentVirtualHostNode.getVirtualHost().createChild(Queue.class, attributes);
+ final Exchange exchange = _currentVirtualHostNode.getVirtualHost().getChildByName(Exchange.class, "amq.direct");
+ exchange.bind(queueName, queueName, Collections.emptyMap(), false);
+ }
+
+ @Override
+ public void deleteQueue(final String queueName)
+ {
+ getQueue(queueName).delete();
+ }
+
+ @Override
+ public void putMessageOnQueue(final String queueName, final String... messages)
+ {
+ for (String message : messages)
+ {
+ ((QueueManagingVirtualHost<?>) _currentVirtualHostNode.getVirtualHost()).publishMessage(new ManageableMessage()
+ {
+ @Override
+ public String getAddress()
+ {
+ return queueName;
+ }
+
+ @Override
+ public boolean isPersistent()
+ {
+ return false;
+ }
+
+ @Override
+ public Date getExpiration()
+ {
+ return null;
+ }
+
+ @Override
+ public String getCorrelationId()
+ {
+ return null;
+ }
+
+ @Override
+ public String getAppId()
+ {
+ return null;
+ }
+
+ @Override
+ public String getMessageId()
+ {
+ return null;
+ }
+
+ @Override
+ public String getMimeType()
+ {
+ return "text/plain";
+ }
+
+ @Override
+ public String getEncoding()
+ {
+ return null;
+ }
+
+ @Override
+ public int getPriority()
+ {
+ return 0;
+ }
+
+ @Override
+ public Date getNotValidBefore()
+ {
+ return null;
+ }
+
+ @Override
+ public String getReplyTo()
+ {
+ return null;
+ }
+
+ @Override
+ public Map<String, Object> getHeaders()
+ {
+ return null;
+ }
+
+ @Override
+ public Object getContent()
+ {
+ return message;
+ }
+
+ @Override
+ public String getContentTransferEncoding()
+ {
+ return null;
+ }
+ });
+ }
+
+ }
+
+ @Override
+ public int getQueueDepthMessages(final String testQueueName)
+ {
+ Queue queue = _currentVirtualHostNode.getVirtualHost().getChildByName(Queue.class, testQueueName);
+ return queue.getQueueDepthMessages();
+ }
+
+ @Override
+ public boolean supportsRestart()
+ {
+ return _isPersistentStore;
+ }
+
+ @Override
+ public ListenableFuture<Void> restart()
+ {
+ try
+ {
+ LOGGER.info("Stopping VirtualHostNode for restart");
+ _currentVirtualHostNode.stop();
+ LOGGER.info("Starting VirtualHostNode for restart");
+ _currentVirtualHostNode.start();
+ LOGGER.info("Restarting VirtualHostNode completed");
+ }
+ catch (Exception e)
+ {
+ return Futures.immediateFailedFuture(e);
+ }
+ return Futures.immediateFuture(null);
+ }
+
+ @Override
+ public boolean isSASLSupported()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isSASLMechanismSupported(final String mechanismName)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isWebSocketSupported()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isQueueDepthSupported()
+ {
+ return true;
+ }
+
+ @Override
+ public String getValidUsername()
+ {
+ return "guest";
+ }
+
+ @Override
+ public String getValidPassword()
+ {
+ return "guest";
+ }
+
+ @Override
+ public String getType()
+ {
+ return "EMBEDDED_BROKER_PER_CLASS";
+ }
+
+ private Queue getQueue(final String queueName)
+ {
+ Collection<Queue> queues = _currentVirtualHostNode.getVirtualHost().getChildren(Queue.class);
+ for (Queue queue : queues)
+ {
+ if (queue.getName().equals(queueName))
+ {
+ return queue;
+ }
+ }
+ throw new NotFoundException(String.format("Queue '%s' not found", queueName));
+ }
+
+ private void setClassQualifiedTestName(final String name)
+ {
+ final LoggerContext loggerContext = ((ch.qos.logback.classic.Logger) LOGGER).getLoggerContext();
+ loggerContext.putProperty(LogbackPropertyValueDiscriminator.CLASS_QUALIFIED_TEST_NAME, name);
+ }
+
+ private class PortExtractingLauncherListener implements SystemLauncherListener
+ {
+ private SystemConfig<?> _systemConfig;
+
+ @Override
+ public void beforeStartup()
+ {
+
+ }
+
+ @Override
+ public void errorOnStartup(final RuntimeException e)
+ {
+
+ }
+
+ @Override
+ public void afterStartup()
+ {
+
+ if (_systemConfig == null)
+ {
+ throw new IllegalStateException("System config is required");
+ }
+
+ _broker = _systemConfig.getContainer();
+ Collection<Port> ports = _broker.getChildren(Port.class);
+ for (Port port : ports)
+ {
+ _ports.put(port.getName(), port.getBoundPort());
+ }
+ }
+
+ @Override
+ public void onContainerResolve(final SystemConfig<?> systemConfig)
+ {
+ _systemConfig = systemConfig;
+ }
+
+ @Override
+ public void onContainerClose(final SystemConfig<?> systemConfig)
+ {
+
+ }
+
+ @Override
+ public void onShutdown(final int exitCode)
+ {
+
+ }
+
+ @Override
+ public void exceptionOnShutdown(final Exception e)
+ {
+
+ }
+ }
+
+
+ private static class UncaughtExceptionHandler implements Thread.UncaughtExceptionHandler
+ {
+ private final AtomicInteger _count = new AtomicInteger(0);
+
+ @Override
+ public void uncaughtException(final Thread t, final Throwable e)
+ {
+ System.err.print("Thread terminated due to uncaught exception");
+ e.printStackTrace();
+
+ LOGGER.error("Uncaught exception from thread {}", t.getName(), e);
+ _count.getAndIncrement();
+ }
+
+ public int getAndResetCount()
+ {
+ int count;
+ do
+ {
+ count = _count.get();
+ }
+ while (!_count.compareAndSet(count, 0));
+ return count;
+ }
+ }
+
+ private class ShutdownLoggingSystemLauncherListener extends SystemLauncherListener.DefaultSystemLauncherListener
+ {
+ @Override
+ public void onShutdown(final int exitCode)
+ {
+ _systemLauncher = null;
+ }
+
+ @Override
+ public void exceptionOnShutdown(final Exception e)
+ {
+ if (e instanceof IllegalStateException
+ || e instanceof IllegalStateTransitionException)
+ {
+ System.out.println(
+ "IllegalStateException occurred on broker shutdown in test ");
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/ExternalQpidBrokerAdminImpl.java
----------------------------------------------------------------------
diff --git a/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/ExternalQpidBrokerAdminImpl.java b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/ExternalQpidBrokerAdminImpl.java
new file mode 100644
index 0000000..e935067
--- /dev/null
+++ b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/ExternalQpidBrokerAdminImpl.java
@@ -0,0 +1,157 @@
+/*
+ * 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.tests.utils;
+
+import java.lang.reflect.Method;
+import java.net.InetSocketAddress;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.server.plugin.PluggableService;
+
+@SuppressWarnings("unused")
+@PluggableService
+public class ExternalQpidBrokerAdminImpl implements BrokerAdmin
+{
+ private static final Logger LOGGER = LoggerFactory.getLogger(ExternalQpidBrokerAdminImpl.class);
+
+ @Override
+ public void beforeTestClass(final Class testClass)
+ {
+ LOGGER.debug("beforeTestClass");
+ }
+
+ @Override
+ public void beforeTestMethod(final Class testClass, final Method method)
+ {
+ LOGGER.debug("beforeTestMethod");
+ }
+
+ @Override
+ public void afterTestMethod(final Class testClass, final Method method)
+ {
+ LOGGER.debug("afterTestMethod");
+ }
+
+ @Override
+ public void afterTestClass(final Class testClass)
+ {
+ LOGGER.debug("afterTestClass");
+ }
+
+ @Override
+ public InetSocketAddress getBrokerAddress(final PortType portType)
+ {
+ Integer port;
+ switch (portType)
+ {
+ case AMQP:
+ port = Integer.getInteger("qpid.tests.protocol.broker.external.port.standard");
+ break;
+ case ANONYMOUS_AMQP:
+ port = Integer.getInteger("qpid.tests.protocol.broker.external.port.anonymous");
+ break;
+ default:
+ throw new IllegalArgumentException(String.format("Unknown port type '%s'", portType));
+ }
+ return new InetSocketAddress(port);
+ }
+
+ @Override
+ public void createQueue(final String queueName)
+ {
+ LOGGER.debug(String.format("creation of queue '%s' requested", queueName));
+ }
+
+ @Override
+ public void deleteQueue(final String queueName)
+ {
+ LOGGER.debug(String.format("deletion of queue '%s' requested", queueName));
+ }
+
+ @Override
+ public void putMessageOnQueue(final String queueName, final String... messages)
+ {
+ LOGGER.debug(String.format("puting of %d messages on queue '%s' requested", messages.length, queueName));
+ }
+
+ @Override
+ public int getQueueDepthMessages(final String testQueueName)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean supportsRestart()
+ {
+ return false;
+ }
+
+ @Override
+ public ListenableFuture<Void> restart()
+ {
+ throw new UnsupportedOperationException("External Qpid Broker does not support restart.");
+ }
+
+ @Override
+ public boolean isSASLSupported()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isWebSocketSupported()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isQueueDepthSupported()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isSASLMechanismSupported(final String mechanismName)
+ {
+ return true;
+ }
+
+ @Override
+ public String getValidUsername()
+ {
+ return "guest";
+ }
+
+ @Override
+ public String getValidPassword()
+ {
+ return "guest";
+ }
+
+ @Override
+ public String getType()
+ {
+ return "EXTERNAL_BROKER";
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/QpidTestRunner.java
----------------------------------------------------------------------
diff --git a/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/QpidTestRunner.java b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/QpidTestRunner.java
new file mode 100644
index 0000000..02cec34
--- /dev/null
+++ b/systests/systests-utils/src/main/java/org/apache/qpid/tests/utils/QpidTestRunner.java
@@ -0,0 +1,76 @@
+/*
+ * 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.tests.utils;
+
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+
+public class QpidTestRunner extends BlockJUnit4ClassRunner
+{
+ private final BrokerAdmin _brokerAdmin;
+ private final Class _testClass;
+
+ public QpidTestRunner(final Class<?> klass) throws InitializationError
+ {
+ super(klass);
+ _testClass = klass;
+ _brokerAdmin = (new BrokerAdminFactory()).createInstance("EMBEDDED_BROKER_PER_CLASS");
+ }
+
+ @Override
+ protected Object createTest() throws Exception
+ {
+ Object test = super.createTest();
+ BrokerAdminUsingTestBase qpidTest = ((BrokerAdminUsingTestBase) test);
+ qpidTest.init(_brokerAdmin);
+ return test;
+ }
+
+ @Override
+ public void run(final RunNotifier notifier)
+ {
+ _brokerAdmin.beforeTestClass(_testClass);
+ try
+ {
+ super.run(notifier);
+ }
+ finally
+ {
+ _brokerAdmin.afterTestClass(_testClass);
+ }
+ }
+
+ @Override
+ protected void runChild(final FrameworkMethod method, final RunNotifier notifier)
+ {
+ _brokerAdmin.beforeTestMethod(_testClass, method.getMethod());
+ try
+ {
+ super.runChild(method, notifier);
+ }
+ finally
+ {
+ _brokerAdmin.afterTestMethod(_testClass, method.getMethod());
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[4/4] qpid-broker-j git commit: QPID-7896: [Java System Tests] Create
system tests testing end-to-end message conversion
Posted by lq...@apache.org.
QPID-7896: [Java System Tests] Create system tests testing end-to-end message conversion
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/a7e4a716
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/a7e4a716
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/a7e4a716
Branch: refs/heads/master
Commit: a7e4a716b3a8792a3e53e50f82c897a3ff33de08
Parents: a10f306
Author: Lorenz Quack <lq...@apache.org>
Authored: Wed Aug 16 14:59:43 2017 +0100
Committer: Lorenz Quack <lq...@apache.org>
Committed: Wed Aug 23 16:36:38 2017 +0100
----------------------------------------------------------------------
broker/pom.xml | 3 -
pom.xml | 8 +
systests/end-to-end-conversion-tests/pom.xml | 140 +++++
.../EndToEndConversionTestBase.java | 304 +++++++++++
.../JmsInstructionBuilder.java | 107 ++++
.../end_to_end_conversion/JmsInstructions.java | 165 ++++++
.../LoggingOutputStream.java | 277 ++++++++++
.../end_to_end_conversion/client/Client.java | 216 ++++++++
.../client/ClientInstructions.java | 86 ++++
.../client/ClientResult.java | 43 ++
.../client/MessageCreator.java | 190 +++++++
.../client/MessageVerifier.java | 306 +++++++++++
.../client/VerificationException.java | 29 ++
.../dependency_resolution/Booter.java | 103 ++++
.../dependency_resolution/ClasspathQuery.java | 201 ++++++++
.../ConsoleRepositoryListener.java | 128 +++++
.../ConsoleTransferListener.java | 175 +++++++
.../ManualRepositorySystemFactory.java | 58 +++
.../config-end-to-end-conversion-tests.json | 47 ++
.../src/main/resources/logback-test.xml | 48 ++
.../SimpleConversionTest.java | 135 +++++
systests/protocol-tests-amqp-1-0/pom.xml | 19 +
.../qpid/tests/protocol/v1_0/BrokerAdmin.java | 65 ---
.../tests/protocol/v1_0/BrokerAdminFactory.java | 38 --
.../v1_0/EmbeddedBrokerPerClassAdminImpl.java | 506 ------------------
.../v1_0/ExternalQpidBrokerAdminImpl.java | 156 ------
.../tests/protocol/v1_0/ProtocolTestBase.java | 42 --
.../tests/protocol/v1_0/QpidTestRunner.java | 77 ---
.../bindmapjms/TemporaryDestinationTest.java | 6 +-
.../soleconn/CloseExistingPolicy.java | 6 +-
.../v1_0/extensions/soleconn/MixedPolicy.java | 6 +-
.../soleconn/RefuseConnectionPolicy.java | 6 +-
.../extensions/websocket/WebSocketTest.java | 7 +-
.../v1_0/messaging/DeleteOnCloseTest.java | 6 +-
.../protocol/v1_0/messaging/MessageFormat.java | 6 +-
.../v1_0/messaging/MultiTransferTest.java | 6 +-
.../protocol/v1_0/messaging/TransferTest.java | 6 +-
.../v1_0/transaction/DischargeTest.java | 6 +-
.../transaction/TransactionalTransferTest.java | 6 +-
.../v1_0/transport/ProtocolHeaderTest.java | 7 +-
.../v1_0/transport/connection/OpenTest.java | 6 +-
.../v1_0/transport/link/AttachTest.java | 6 +-
.../protocol/v1_0/transport/link/FlowTest.java | 6 +-
.../transport/link/ResumeDeliveriesTest.java | 6 +-
.../v1_0/transport/security/sasl/SaslTest.java | 6 +-
.../v1_0/transport/session/BeginTest.java | 6 +-
systests/systests-utils/pom.xml | 68 +++
.../apache/qpid/tests/utils/BrokerAdmin.java | 66 +++
.../qpid/tests/utils/BrokerAdminFactory.java | 39 ++
.../tests/utils/BrokerAdminUsingTestBase.java | 43 ++
.../utils/EmbeddedBrokerPerClassAdminImpl.java | 508 +++++++++++++++++++
.../utils/ExternalQpidBrokerAdminImpl.java | 157 ++++++
.../apache/qpid/tests/utils/QpidTestRunner.java | 76 +++
53 files changed, 3796 insertions(+), 943 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/broker/pom.xml
----------------------------------------------------------------------
diff --git a/broker/pom.xml b/broker/pom.xml
index b8ac0cb..5fff92a 100644
--- a/broker/pom.xml
+++ b/broker/pom.xml
@@ -143,19 +143,16 @@
<scope>runtime</scope>
</dependency>
- <!-- optional modules -->
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-bdbstore</artifactId>
<scope>runtime</scope>
- <optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store</artifactId>
<scope>runtime</scope>
- <optional>true</optional>
</dependency>
<!-- test dependencies -->
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3b5b6b8..b5028af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -186,8 +186,10 @@
<module>qpid-systests-parent</module>
<module>qpid-test-utils</module>
<module>systests</module>
+ <module>systests/systests-utils</module>
<module>systests/qpid-systests-jms_2.0</module>
<module>systests/protocol-tests-amqp-1-0</module>
+ <module>systests/end-to-end-conversion-tests</module>
<module>perftests</module>
<module>qpid-perftests-systests</module>
@@ -375,6 +377,12 @@
<dependency>
<groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
<artifactId>qpid-systests</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/pom.xml
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/pom.xml b/systests/end-to-end-conversion-tests/pom.xml
new file mode 100644
index 0000000..0253f0a
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/pom.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ ~
+ -->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-parent</artifactId>
+ <version>7.0.0-SNAPSHOT</version>
+ <relativePath>../../qpid-systests-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>qpid-systests-end-to-end-conversion-tests</artifactId>
+ <name>Apache Qpid End to End Conversion Tests</name>
+ <description>End to end conversion tests</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <resolverVersion>1.0.3</resolverVersion>
+ <mavenVersion>3.5.0</mavenVersion>
+ <client1Gavs>org.apache.qpid:qpid-jms-client:${qpid-jms-client-version}</client1Gavs>
+ <client1AdditionalJavaArguments></client1AdditionalJavaArguments>
+ <client2Gavs>org.apache.qpid:qpid-client:${qpid-jms-client-amqp-0-x-version},org.apache.geronimo.specs:geronimo-jms_1.1_spec:${geronimo-jms-1-1-version}</client2Gavs>
+ <client2AdditionalJavaArguments>-Dqpid.amqp.version=0-9-1</client2AdditionalJavaArguments>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-connector-basic</artifactId>
+ <version>${resolverVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-transport-file</artifactId>
+ <version>${resolverVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.resolver</groupId>
+ <artifactId>maven-resolver-transport-http</artifactId>
+ <version>${resolverVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-utils</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ <workingDirectory>${project.basedir}</workingDirectory>
+ <systemPropertyVariables>
+ <qpid.initialConfigurationLocation>classpath:config-end-to-end-conversion-tests.json</qpid.initialConfigurationLocation>
+ <qpid.systests.end_to_end_conversion.localRepository>${settings.localRepository}</qpid.systests.end_to_end_conversion.localRepository>
+ <qpid.systests.end_to_end_conversion.remoteRepository>https://repo.maven.apache.org/maven2/</qpid.systests.end_to_end_conversion.remoteRepository>
+ </systemPropertyVariables>
+ </configuration>
+ <executions>
+ <execution>
+ <id>client1 -> client2</id>
+ <configuration>
+ <skip>false</skip>
+ <systemPropertyVariables>
+ <qpid.systests.end_to_end_conversion.executionId>c1_c2</qpid.systests.end_to_end_conversion.executionId>
+ <qpid.systests.end_to_end_conversion.publisherGavs>${client1Gavs}</qpid.systests.end_to_end_conversion.publisherGavs>
+ <qpid.systests.end_to_end_conversion.publisherAdditionalJavaArguments>${client1AdditionalJavaArguments}</qpid.systests.end_to_end_conversion.publisherAdditionalJavaArguments>
+ <qpid.systests.end_to_end_conversion.subscriberGavs>${client2Gavs}</qpid.systests.end_to_end_conversion.subscriberGavs>
+ <qpid.systests.end_to_end_conversion.subscriberAdditionalJavaArguments>${client2AdditionalJavaArguments}</qpid.systests.end_to_end_conversion.subscriberAdditionalJavaArguments>
+ </systemPropertyVariables>
+ </configuration>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>client2 -> client1</id>
+ <configuration>
+ <skip>false</skip>
+ <systemPropertyVariables>
+ <qpid.systests.end_to_end_conversion.executionId>c2_c1</qpid.systests.end_to_end_conversion.executionId>
+ <qpid.systests.end_to_end_conversion.publisherGavs>${client2Gavs}</qpid.systests.end_to_end_conversion.publisherGavs>
+ <qpid.systests.end_to_end_conversion.publisherAdditionalJavaArguments>${client2AdditionalJavaArguments}</qpid.systests.end_to_end_conversion.publisherAdditionalJavaArguments>
+ <qpid.systests.end_to_end_conversion.subscriberGavs>${client1Gavs}</qpid.systests.end_to_end_conversion.subscriberGavs>
+ <qpid.systests.end_to_end_conversion.subscriberAdditionalJavaArguments>${client1AdditionalJavaArguments}</qpid.systests.end_to_end_conversion.subscriberAdditionalJavaArguments>
+ </systemPropertyVariables>
+ </configuration>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/EndToEndConversionTestBase.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/EndToEndConversionTestBase.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/EndToEndConversionTestBase.java
new file mode 100644
index 0000000..28b1c6e
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/EndToEndConversionTestBase.java
@@ -0,0 +1,304 @@
+/*
+ * 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.systests.end_to_end_conversion;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.event.Level;
+
+import org.apache.qpid.systests.end_to_end_conversion.client.Client;
+import org.apache.qpid.systests.end_to_end_conversion.client.ClientInstructions;
+import org.apache.qpid.systests.end_to_end_conversion.client.ClientResult;
+import org.apache.qpid.systests.end_to_end_conversion.dependency_resolution.ClasspathQuery;
+import org.apache.qpid.tests.utils.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
+
+
+public class EndToEndConversionTestBase extends BrokerAdminUsingTestBase
+{
+ public static final String QUEUE_NAME = "queue";
+ public static final int CLIENT_SOCKET_TIMEOUT = 30000;
+ private static final Logger LOGGER = LoggerFactory.getLogger(EndToEndConversionTestBase.class);
+ private static final Logger CLIENT_LOGGER = LoggerFactory.getLogger(Client.class);
+ private static final int SERVER_SOCKET_TIMEOUT = 30000;
+ private ListeningExecutorService _executorService =
+ MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
+
+ @Before
+ public void setUp()
+ {
+ getBrokerAdmin().createQueue(QUEUE_NAME);
+ }
+
+ @AfterClass
+ public static void reportStats()
+ {
+ System.out.println("LQDEBUG: " + ClasspathQuery.getCacheStats());
+ }
+
+ protected ListenableFuture<?> runPublisher(final List<JmsInstructions> jmsInstructions)
+ {
+ List<String> gavs = Arrays.asList(System.getProperty("qpid.systests.end_to_end_conversion.publisherGavs",
+ "org.apache.qpid:qpid-jms-client:LATEST")
+ .split(","));
+ List<String> additionalJavaArgs = Arrays.stream(System.getProperty(
+ "qpid.systests.end_to_end_conversion.publisherAdditionalJavaArguments",
+ "").split(" ")).filter(s -> !s.isEmpty()).collect(Collectors.toList());
+
+ return _executorService.submit(() -> {
+ Thread.currentThread().setName("Publisher");
+ runClient(gavs, additionalJavaArgs, jmsInstructions);
+ });
+ }
+
+ protected ListenableFuture<?> runSubscriber(final List<JmsInstructions> jmsInstructions)
+ {
+ List<String> gavs = Arrays.asList(System.getProperty("qpid.systests.end_to_end_conversion.subscriberGavs",
+ "org.apache.qpid:qpid-client:LATEST,org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1")
+ .split(","));
+
+ List<String> additionalJavaArgs = Arrays.stream(System.getProperty(
+ "qpid.systests.end_to_end_conversion.subscriberAdditionalJavaArguments",
+ "-Dqpid.amqp.version=0-9-1").split(" ")).filter(s -> !s.isEmpty()).collect(Collectors.toList());
+
+ return _executorService.submit(() -> {
+ Thread.currentThread().setName("Subscriber");
+ runClient(gavs, additionalJavaArgs, jmsInstructions);
+ });
+ }
+
+ private ClientInstructions getClientInstructions(final List<JmsInstructions> jmsInstructions,
+ final boolean amqp0xClient)
+ {
+ ClientInstructions clientInstructions = new ClientInstructions();
+ clientInstructions.setJmsInstructions(jmsInstructions);
+ if (amqp0xClient)
+ {
+ clientInstructions.setContextFactory(getAmqp0xContextFactory());
+ clientInstructions.setConnectionUrl(getAmqp0xConnectionUrl());
+ }
+ else
+ {
+ clientInstructions.setContextFactory(getAmqp10ContextFactory());
+ clientInstructions.setConnectionUrl(getAmqp10ConnectionUrl());
+ }
+ clientInstructions.setQueueName(QUEUE_NAME);
+ return clientInstructions;
+ }
+
+ private void runClient(final Collection<String> clientGavs,
+ final List<String> additionalJavaArguments,
+ final List<JmsInstructions> jmsInstructions)
+ {
+ final ClientInstructions clientInstructions = getClientInstructions(jmsInstructions, isAmqp0xClient(clientGavs));
+ final ClasspathQuery classpathQuery = new ClasspathQuery(Client.class, clientGavs);
+
+ try (final ServerSocket serverSocket = new ServerSocket(0))
+ {
+ serverSocket.setSoTimeout(SERVER_SOCKET_TIMEOUT);
+ String classPath = classpathQuery.getClasspath();
+ final List<String> arguments = Lists.newArrayList("java", "-showversion",
+ "-cp", classPath);
+ arguments.addAll(additionalJavaArguments);
+ arguments.add(classpathQuery.getClientClass().getName());
+ arguments.add(String.valueOf(serverSocket.getLocalPort()));
+
+ LOGGER.debug("starting client process with arguments: {}", arguments);
+ ProcessBuilder processBuilder = new ProcessBuilder(arguments);
+ Process p = processBuilder.start();
+ try (final InputStream pInputStream = p.getInputStream();
+ final LoggingOutputStream loggingOutputStream = new LoggingOutputStream(CLIENT_LOGGER, Level.DEBUG))
+ {
+ final LoggingThread loggingThread = new LoggingThread(pInputStream, loggingOutputStream);
+ loggingThread.start();
+ LOGGER.debug("client process {} started", serverSocket.getLocalPort());
+
+ try (final Socket clientSocket = serverSocket.accept();
+ final ObjectOutputStream outputStream = new ObjectOutputStream(clientSocket.getOutputStream());
+ final ObjectInputStream inputStream = new ObjectInputStream(clientSocket.getInputStream()))
+ {
+ LOGGER.debug("client process {} connected from port {}",
+ clientSocket.getLocalPort(),
+ clientSocket.getPort());
+ clientSocket.setSoTimeout(CLIENT_SOCKET_TIMEOUT);
+ outputStream.writeObject(clientInstructions);
+ final Object result = inputStream.readObject();
+ if (result instanceof ClientResult)
+ {
+ final ClientResult publisherResult = (ClientResult) result;
+ if (publisherResult.getException() != null)
+ {
+ throw publisherResult.getException();
+ }
+ }
+ else
+ {
+ throw new RuntimeException("did not receive client results");
+ }
+ }
+ finally
+ {
+ loggingThread.flush();
+ p.waitFor();
+ loggingThread.flush();
+ loggingThread.stop();
+ }
+ }
+
+ LOGGER.debug("client process {} finished exit value: {}", serverSocket.getLocalPort(), p.exitValue());
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ LOGGER.debug("execution of runClient finished!");
+ }
+ }
+
+ private String getAmqp0xContextFactory()
+ {
+ return "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
+ }
+
+ private String getAmqp0xConnectionUrl()
+ {
+ InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ int port = brokerAddress.getPort();
+ String hostString = "localhost";
+ return String.format("amqp://clientid/?brokerlist='tcp://%s:%d'", hostString, port);
+ }
+
+ private String getAmqp10ContextFactory()
+ {
+ return "org.apache.qpid.jms.jndi.JmsInitialContextFactory";
+ }
+
+ private String getAmqp10ConnectionUrl()
+ {
+ InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ int port = brokerAddress.getPort();
+ String hostString = "localhost";
+ int connectTimeout = 30000;
+ return String.format("amqp://%s:%d?jms.connectTimeout=%d", hostString, port, connectTimeout);
+ }
+
+ private boolean isAmqp0xClient(final Collection<String> gavs)
+ {
+ for (String gav : gavs)
+ {
+ if (gav.contains("qpid-client"))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static class LoggingThread
+ {
+ private static final int BUFFER_SIZE = 2048;
+ private final InputStream _in;
+ private final OutputStream _out;
+ private final Thread _loggingThread;
+
+ private volatile boolean _stop;
+
+ public LoggingThread(final InputStream in, final OutputStream out)
+ {
+ _in = in;
+ _out = out;
+ _stop = false;
+ _loggingThread = new Thread(this::run);
+ _loggingThread.setName(Thread.currentThread().getName() + "-Client");
+ }
+
+ public void start()
+ {
+ _loggingThread.start();
+ }
+
+ public void stop()
+ {
+ _stop = true;
+ _loggingThread.interrupt();
+ }
+
+ private void run()
+ {
+ try
+ {
+ final byte[] buffer = new byte[BUFFER_SIZE];
+ while (!_stop)
+ {
+ final int read = _in.read(buffer);
+ if (read == -1)
+ {
+ break;
+ }
+ _out.write(buffer, 0, read);
+ }
+ _out.flush();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void flush()
+ {
+ try
+ {
+ _loggingThread.join(CLIENT_SOCKET_TIMEOUT);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/JmsInstructionBuilder.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/JmsInstructionBuilder.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/JmsInstructionBuilder.java
new file mode 100644
index 0000000..3561ed8
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/JmsInstructionBuilder.java
@@ -0,0 +1,107 @@
+/*
+ * 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.systests.end_to_end_conversion;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JmsInstructionBuilder
+{
+ private List<JmsInstructions> _jmsInstructions = new ArrayList<>();
+ private JmsInstructions.MessageDescription _latestMessageDescription;
+
+ public static List<JmsInstructions> publishSingleMessage(final JmsInstructions.MessageDescription messageDescription)
+ {
+ return new JmsInstructionBuilder().publishMessage(messageDescription).build();
+ }
+
+ public static List<JmsInstructions> receiveSingleMessage(final JmsInstructions.MessageDescription messageDescription)
+ {
+ return new JmsInstructionBuilder().receiveMessage(messageDescription).build();
+ }
+
+ public JmsInstructionBuilder publishMessage()
+ {
+ return publishMessage(new JmsInstructions.MessageDescription());
+ }
+
+ public JmsInstructionBuilder publishMessage(final JmsInstructions.MessageDescription messageDescription)
+ {
+ _latestMessageDescription = messageDescription;
+ _jmsInstructions.add(new JmsInstructions.PublishMessage(_latestMessageDescription));
+ return this;
+ }
+
+ public JmsInstructionBuilder withMessageType(JmsInstructions.MessageDescription.MessageType messageType)
+ {
+ _latestMessageDescription.setMessageType(messageType);
+ return this;
+ }
+
+ public JmsInstructionBuilder withMessageContent(Serializable content)
+ {
+ _latestMessageDescription.setContent(content);
+ return this;
+ }
+
+ public JmsInstructionBuilder withHeader(final JmsInstructions.MessageDescription.MessageHeader header,
+ final Serializable value)
+ {
+ _latestMessageDescription.setHeader(header, value);
+ return this;
+ }
+
+ public JmsInstructionBuilder withProperty(final String property, final Serializable value)
+ {
+ _latestMessageDescription.setProperty(property, value);
+ return this;
+ }
+
+ public JmsInstructionBuilder receiveMessage()
+ {
+ return receiveMessage(new JmsInstructions.MessageDescription());
+ }
+
+ public JmsInstructionBuilder receiveMessage(final JmsInstructions.MessageDescription messageDescription)
+ {
+ _latestMessageDescription = messageDescription;
+ _jmsInstructions.add(new JmsInstructions.ReceiveMessage(_latestMessageDescription));
+ return this;
+ }
+
+ public JmsInstructionBuilder replyToMessage()
+ {
+ return replyToMessage(new JmsInstructions.MessageDescription());
+ }
+
+ public JmsInstructionBuilder replyToMessage(final JmsInstructions.MessageDescription latestMessageDescription)
+ {
+ _latestMessageDescription = latestMessageDescription;
+ _jmsInstructions.add(new JmsInstructions.ReplyToMessage(_latestMessageDescription));
+ return this;
+ }
+
+ public List<JmsInstructions> build()
+ {
+ return _jmsInstructions;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/JmsInstructions.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/JmsInstructions.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/JmsInstructions.java
new file mode 100644
index 0000000..c3b43ad
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/JmsInstructions.java
@@ -0,0 +1,165 @@
+/*
+ * 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.systests.end_to_end_conversion;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+public abstract class JmsInstructions implements Serializable
+{
+ private final MessageDescription _messageDescription;
+
+ public JmsInstructions(final MessageDescription messageDescription)
+ {
+ _messageDescription = messageDescription;
+ }
+
+ public MessageDescription getMessageDescription()
+ {
+ return _messageDescription;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName() + "{" +
+ "_messageDescription=" + _messageDescription +
+ '}';
+ }
+
+ public static class PublishMessage extends JmsInstructions
+ {
+ PublishMessage(final MessageDescription messageDescription)
+ {
+ super(messageDescription);
+ }
+ }
+
+ public static class ReceiveMessage extends JmsInstructions
+ {
+ public ReceiveMessage(final MessageDescription messageDescription)
+ {
+ super(messageDescription);
+ }
+ }
+
+ public static class ReplyToMessage extends JmsInstructions
+ {
+ public ReplyToMessage(final MessageDescription messageDescription)
+ {
+ super(messageDescription);
+ }
+ }
+
+ public static class MessageDescription implements Serializable
+ {
+ private final HashMap<MessageDescription.MessageHeader, Serializable> _header;
+ private final HashMap<String, Serializable> _properties;
+ private MessageDescription.MessageType _messageType;
+ private Object _content;
+ public MessageDescription()
+ {
+ _header = new HashMap<>();
+ _properties = new HashMap<>();
+ _messageType = MessageType.MESSAGE;
+ }
+
+ public MessageDescription.MessageType getMessageType()
+ {
+ return _messageType;
+ }
+
+ public void setMessageType(final MessageDescription.MessageType messageType)
+ {
+ _messageType = messageType;
+ }
+
+ public Object getContent()
+ {
+ return _content;
+ }
+
+ public void setContent(final Object content)
+ {
+ _content = content;
+ }
+
+ public HashMap<MessageDescription.MessageHeader, Serializable> getHeaders()
+ {
+ return _header;
+ }
+
+ public <T extends Serializable> T getHeader(final MessageDescription.MessageHeader header, final T defaultValue)
+ {
+ return (T) (_header != null ? _header.getOrDefault(header, defaultValue) : defaultValue);
+ }
+
+ public void setHeader(final MessageDescription.MessageHeader header, final Serializable value)
+ {
+ _header.put(header, value);
+ }
+
+ public HashMap<String, Serializable> getProperties()
+ {
+ return _properties;
+ }
+
+ public void setProperty(final String property, final Serializable value)
+ {
+ _properties.put(property, value);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "MessageDescription{" +
+ "_messageType=" + _messageType +
+ ", _content=" + _content +
+ ", _header=" + _header +
+ ", _properties=" + _properties +
+ '}';
+ }
+
+ public enum MessageType
+ {
+ MESSAGE,
+ BYTES_MESSAGE,
+ MAP_MESSAGE,
+ OBJECT_MESSAGE,
+ STREAM_MESSAGE,
+ TEXT_MESSAGE;
+ }
+
+ public enum MessageHeader
+ {
+ DESTINATION,
+ DELIVERY_MODE,
+ MESSAGE_ID,
+ TIMESTAMP,
+ CORRELATION_ID,
+ REPLY_TO,
+ REDELIVERED,
+ TYPE,
+ EXPIRATION,
+ PRIORITY
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/LoggingOutputStream.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/LoggingOutputStream.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/LoggingOutputStream.java
new file mode 100644
index 0000000..83940b2
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/LoggingOutputStream.java
@@ -0,0 +1,277 @@
+/*
+ * 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.systests.end_to_end_conversion;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.slf4j.Logger;
+import org.slf4j.event.Level;
+
+/*
+ * Original code by Jim Moore
+ * See: https://www.mail-archive.com/user@slf4j.org/msg00673.html
+ * Adapted for Qpid needs.
+ */
+
+/**
+ * An OutputStream that flushes out to a Category.<p>
+ * <p/>
+ * Note that no data is written out to the Category until the stream is
+ * flushed or closed.<p>
+ * <p/>
+ * Example:<pre>
+ * // make sure everything sent to System.err is logged
+ * System.setErr(new PrintStream(new
+ * LoggingOutputStream(Logger.getRootCategory(),
+ * Level.WARN), true));
+ * <p/>
+ * // make sure everything sent to System.out is also logged
+ * System.setOut(new PrintStream(new
+ * LoggingOutputStream(Logger.getRootCategory(),
+ * Level.INFO), true));
+ * </pre>
+ *
+ * @author <a href="[EMAIL PROTECTED]">Jim Moore</a>
+ */
+
+//
+public class LoggingOutputStream extends OutputStream
+{
+ /**
+ * Platform dependant line separator
+ */
+ private static final byte[] LINE_SEPARATOR_BYTES = System.getProperty("line.separator").getBytes();
+ /**
+ * The default number of bytes in the buffer. =2048
+ */
+ private static final int DEFAULT_BUFFER_LENGTH = 2048;
+ /**
+ * Used to maintain the contract of [EMAIL PROTECTED] #close()}.
+ */
+ private boolean hasBeenClosed = false;
+ /**
+ * The internal buffer where data is stored.
+ */
+ private byte[] buf;
+ /**
+ * The number of valid bytes in the buffer. This value is always
+ * in the range <tt>0</tt> through <tt>buf.length</tt>; elements
+ * <tt>buf[0]</tt> through <tt>buf[count-1]</tt> contain valid
+ * byte data.
+ */
+ private int count;
+ /**
+ * Remembers the size of the buffer for speed.
+ */
+ private int bufLength;
+ /**
+ * The category to write to.
+ */
+ private Logger logger;
+
+ /**
+ * The priority to use when writing to the Category.
+ */
+ private Level level;
+
+ /**
+ * Creates the LoggingOutputStream to flush to the given Category.
+ *
+ * @param log the Logger to write to
+ * @param level the Level to use when writing to the Logger
+ * @throws IllegalArgumentException if cat == null or priority ==
+ * null
+ */
+ public LoggingOutputStream(Logger log, Level level) throws IllegalArgumentException
+ {
+ if (log == null)
+ {
+ throw new IllegalArgumentException("cat == null");
+ }
+ if (level == null)
+ {
+ throw new IllegalArgumentException("priority == null");
+ }
+
+ this.level = level;
+
+ logger = log;
+ bufLength = DEFAULT_BUFFER_LENGTH;
+ buf = new byte[DEFAULT_BUFFER_LENGTH];
+ count = 0;
+ }
+
+
+ /**
+ * Closes this output stream and releases any system resources
+ * associated with this stream. The general contract of
+ * <code>close</code>
+ * is that it closes the output stream. A closed stream cannot
+ * perform
+ * output operations and cannot be reopened.
+ */
+ public void close()
+ {
+ flush();
+ hasBeenClosed = true;
+ }
+
+
+ /**
+ * Writes the specified byte to this output stream. The general
+ * contract for <code>write</code> is that one byte is written
+ * to the output stream. The byte to be written is the eight
+ * low-order bits of the argument <code>b</code>. The 24
+ * high-order bits of <code>b</code> are ignored.
+ *
+ * @param b the <code>byte</code> to write
+ * @throws java.io.IOException if an I/O error occurs. In particular, an
+ * <code>IOException</code> may be
+ * thrown if the output stream has been closed.
+ */
+ public void write(final int b) throws IOException
+ {
+ if (hasBeenClosed)
+ {
+ throw new IOException("The stream has been closed.");
+ }
+
+ // would this be writing past the buffer?
+
+ if (count == bufLength)
+ {
+ // grow the buffer
+ final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH;
+ final byte[] newBuf = new byte[newBufLength];
+
+ System.arraycopy(buf, 0, newBuf, 0, bufLength);
+ buf = newBuf;
+
+ bufLength = newBufLength;
+ }
+
+ buf[count] = (byte) b;
+
+ count++;
+
+ if (endsWithNewLine())
+ {
+ flush();
+ }
+ }
+
+ private boolean endsWithNewLine()
+ {
+ if (count >= LINE_SEPARATOR_BYTES.length)
+ {
+ for (int i = 0; i < LINE_SEPARATOR_BYTES.length; i++)
+ {
+ if (buf[count - LINE_SEPARATOR_BYTES.length + i] != LINE_SEPARATOR_BYTES[i])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ /**
+ * Flushes this output stream and forces any buffered output bytes
+ * to be written out. The general contract of <code>flush</code> is
+ * that calling it is an indication that, if any bytes previously
+ * written have been buffered by the implementation of the output
+ * stream, such bytes should immediately be written to their
+ * intended destination.
+ */
+ public void flush()
+ {
+
+ if (count == 0)
+ {
+ return;
+ }
+
+ // don't print out blank lines; flushing from PrintStream puts
+
+ // For linux system
+
+ if (count == 1 && ((char) buf[0]) == '\n')
+ {
+ reset();
+ return;
+ }
+
+ // For mac system
+
+ if (count == 1 && ((char) buf[0]) == '\r')
+ {
+ reset();
+ return;
+ }
+
+ // On windows system
+
+ if (count == 2 && (char) buf[0] == '\r' && (char) buf[1] == '\n')
+ {
+ reset();
+ return;
+ }
+
+ while (endsWithNewLine())
+ {
+ count -= LINE_SEPARATOR_BYTES.length;
+ }
+ final byte[] theBytes = new byte[count];
+ System.arraycopy(buf, 0, theBytes, 0, count);
+ final String message = new String(theBytes);
+ switch (level)
+ {
+ case ERROR:
+ logger.error(message);
+ break;
+ case WARN:
+ logger.warn(message);
+ break;
+ case INFO:
+ logger.info(message);
+ break;
+ case DEBUG:
+ logger.debug(message);
+ break;
+ case TRACE:
+ logger.trace(message);
+ break;
+ }
+ reset();
+ }
+
+ private void reset()
+ {
+ // not resetting the buffer -- assuming that if it grew then it will likely grow similarly again
+ count = 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/Client.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/Client.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/Client.java
new file mode 100644
index 0000000..9236c1e
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/Client.java
@@ -0,0 +1,216 @@
+/*
+ * 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.systests.end_to_end_conversion.client;
+
+import java.io.ByteArrayOutputStream;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.Socket;
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.qpid.systests.end_to_end_conversion.EndToEndConversionTestBase;
+import org.apache.qpid.systests.end_to_end_conversion.JmsInstructions;
+
+public class Client
+{
+ private static final long RECEIVE_TIMEOUT = 30000L;
+
+ public static void main(String... args)
+ {
+ new Client().start(args);
+ }
+
+ private void start(String... args)
+ {
+ System.out.println(String.format("Client started with classpath: %s", System.getProperty("java.class.path")));
+ System.out.println(String.format("Client started with args: %s", Arrays.asList(args)));
+
+ int controllerPort = Integer.parseInt(args[0]);
+
+ try (final Socket socket = new Socket("localhost", controllerPort);
+ final ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());
+ final ObjectOutputStream objectOutputStream = new ObjectOutputStream(socket.getOutputStream());)
+ {
+ System.out.println(String.format("Connected to controller %d -> %d", socket.getLocalPort(), socket.getPort()));
+ socket.setSoTimeout(EndToEndConversionTestBase.CLIENT_SOCKET_TIMEOUT);
+ try
+ {
+ final Object o = inputStream.readObject();
+ final ClientInstructions instructions;
+ if (o instanceof ClientInstructions)
+ {
+ instructions = (ClientInstructions) o;
+ }
+ else
+ {
+ throw new RuntimeException("Did not receive ClientInstructions");
+ }
+ System.out.println(String.format("Received instructions : %s", instructions.toString()));
+
+ String contextFactory = instructions.getContextFactory();
+ String connectionUrl = instructions.getConnectionUrl();
+ String queueName = instructions.getQueueName();
+
+ Connection connection = null;
+ try
+ {
+ Hashtable<Object, Object> env = new Hashtable<>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
+ env.put("connectionfactory.myFactoryLookup", connectionUrl);
+ env.put("queue.myQueueLookup", queueName);
+
+ javax.naming.Context context = new InitialContext(env);
+
+ ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup");
+ Destination queue = (Destination) context.lookup("myQueueLookup");
+
+ System.out.println(String.format("Connecting to broker: %s", connectionUrl));
+ connection = factory.createConnection();
+
+ handleInstructions(connection, queue, instructions.getJmsInstructions());
+ }
+ finally
+ {
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
+ System.out.println("Finished successfully");
+ objectOutputStream.writeObject(new ClientResult());
+ }
+ catch (Exception e)
+ {
+ System.out.println("Encountered exception: " + e.getMessage());
+ try (OutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos))
+ {
+ oos.writeObject(e);
+ objectOutputStream.writeObject(new ClientResult(e));
+ }
+ catch (NotSerializableException nse)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ e.printStackTrace(pw);
+ final RuntimeException serializableException = new RuntimeException(
+ "Client failed with non-serializable exception",
+ new Exception(sw.toString()));
+ objectOutputStream.writeObject(new ClientResult(serializableException));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ System.out.println("Encountered exception: " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ private void handleInstructions(final Connection connection,
+ final Destination queue,
+ final List<JmsInstructions> jmsInstructions) throws Exception
+ {
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try
+ {
+ for (JmsInstructions jmsInstruction : jmsInstructions)
+ {
+ System.out.println(String.format("Process instruction: %s", jmsInstruction));
+ if (jmsInstruction instanceof JmsInstructions.PublishMessage)
+ {
+ publishMessage(session, queue, jmsInstruction.getMessageDescription());
+ }
+ else if (jmsInstruction instanceof JmsInstructions.ReceiveMessage)
+ {
+ connection.start();
+ receiveMessage(session, queue, jmsInstruction.getMessageDescription());
+ }
+ else if (jmsInstruction instanceof JmsInstructions.ReplyToMessage)
+ {
+ throw new RuntimeException("ReplyTo is not implemented, yet.");
+ }
+ else
+ {
+ throw new RuntimeException(String.format("Unknown jmsInstruction class: '%s'",
+ jmsInstruction.getClass().getName()));
+ }
+ }
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ private void receiveMessage(final Session session,
+ final Destination queue,
+ final JmsInstructions.MessageDescription messageDescription) throws Exception
+ {
+ MessageConsumer consumer = session.createConsumer(queue);
+
+ final Message message = consumer.receive(RECEIVE_TIMEOUT);
+ MessageVerifier.verifyMessage(messageDescription, message);
+ System.out.println(String.format("Received message: %s", message));
+ }
+
+
+ private void publishMessage(final Session session,
+ final Destination queue,
+ final JmsInstructions.MessageDescription messageDescription)
+ throws Exception
+ {
+ MessageProducer messageProducer = session.createProducer(queue);
+ try
+ {
+ Message message = MessageCreator.fromMessageDescription(session, messageDescription);
+ messageProducer.send(message,
+ messageDescription.getHeader(JmsInstructions.MessageDescription.MessageHeader.DELIVERY_MODE,
+ DeliveryMode.NON_PERSISTENT),
+ messageDescription.getHeader(JmsInstructions.MessageDescription.MessageHeader.PRIORITY,
+ Message.DEFAULT_PRIORITY),
+ messageDescription.getHeader(JmsInstructions.MessageDescription.MessageHeader.EXPIRATION,
+ Message.DEFAULT_TIME_TO_LIVE));
+ System.out.println(String.format("Sent message: %s", message));
+ }
+ finally
+ {
+ messageProducer.close();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/ClientInstructions.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/ClientInstructions.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/ClientInstructions.java
new file mode 100644
index 0000000..791eed3
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/ClientInstructions.java
@@ -0,0 +1,86 @@
+/*
+ * 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.systests.end_to_end_conversion.client;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.qpid.systests.end_to_end_conversion.JmsInstructions;
+
+public class ClientInstructions implements Serializable
+{
+ private String _contextFactory;
+ private String _connectionUrl;
+ private String _queueName;
+ private ArrayList<JmsInstructions> _jmsInstructions;
+
+ public String getContextFactory()
+ {
+ return _contextFactory;
+ }
+
+ public void setContextFactory(final String contextFactory)
+ {
+ _contextFactory = contextFactory;
+ }
+
+ public String getConnectionUrl()
+ {
+ return _connectionUrl;
+ }
+
+ public void setConnectionUrl(final String connectionUrl)
+ {
+ _connectionUrl = connectionUrl;
+ }
+
+ public String getQueueName()
+ {
+ return _queueName;
+ }
+
+ public void setQueueName(final String queueName)
+ {
+ _queueName = queueName;
+ }
+
+ public List<JmsInstructions> getJmsInstructions()
+ {
+ return _jmsInstructions;
+ }
+
+ public void setJmsInstructions(final List<JmsInstructions> jmsInstructions)
+ {
+ _jmsInstructions = new ArrayList<>(jmsInstructions);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ClientInstructions{" +
+ "_contextFactory='" + _contextFactory + '\'' +
+ ", _connectionUrl='" + _connectionUrl + '\'' +
+ ", _queueName='" + _queueName + '\'' +
+ ", _jmsInstructions=" + _jmsInstructions +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/ClientResult.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/ClientResult.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/ClientResult.java
new file mode 100644
index 0000000..f8eef68
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/ClientResult.java
@@ -0,0 +1,43 @@
+/*
+ * 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.systests.end_to_end_conversion.client;
+
+import java.io.Serializable;
+
+public class ClientResult implements Serializable
+{
+ private final Exception _exception;
+
+ public ClientResult()
+ {
+ this(null);
+ }
+
+ public ClientResult(final Exception exception)
+ {
+ _exception = exception;
+ }
+
+ public Exception getException()
+ {
+ return _exception;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageCreator.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageCreator.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageCreator.java
new file mode 100644
index 0000000..669b941
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageCreator.java
@@ -0,0 +1,190 @@
+/*
+ * 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.systests.end_to_end_conversion.client;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jms.BytesMessage;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+
+import org.apache.qpid.systests.end_to_end_conversion.JmsInstructions;
+
+public class MessageCreator
+{
+ public static Message fromMessageDescription(final Session session,
+ final JmsInstructions.MessageDescription messageDescription)
+ throws Exception
+ {
+ Message message = createMessage(messageDescription, session);
+ setJmsHeader(messageDescription, message);
+ setProperties(messageDescription, message);
+ return message;
+ }
+
+ private static void setProperties(final JmsInstructions.MessageDescription messageDescription,
+ final Message message)
+ {
+ final HashMap<String, Serializable> properties = messageDescription.getProperties();
+ if (properties == null)
+ {
+ return;
+ }
+
+ for (Map.Entry<String, Serializable> entry : properties.entrySet())
+ {
+ try
+ {
+ message.setObjectProperty(entry.getKey(), entry.getValue());
+ }
+ catch (JMSException e)
+ {
+ throw new RuntimeException(String.format("Could not set message property '%s' to this value: %s",
+ entry.getKey(),
+ entry.getValue().toString()), e);
+ }
+ }
+ }
+
+ private static Message createMessage(final JmsInstructions.MessageDescription messageDescription,
+ final Session session)
+ throws Exception
+ {
+ Message message;
+ try
+ {
+ switch (messageDescription.getMessageType())
+ {
+ case MESSAGE:
+ message = session.createMessage();
+ break;
+ case BYTES_MESSAGE:
+ message = session.createBytesMessage();
+ ((BytesMessage) message).writeBytes(((byte[]) messageDescription.getContent()));
+ break;
+ case MAP_MESSAGE:
+ message = session.createMapMessage();
+ for (Map.Entry<String, Object> entry : ((Map<String, Object>) messageDescription.getContent()).entrySet())
+ {
+ ((MapMessage) message).setObject(entry.getKey(), entry.getValue());
+ }
+ break;
+ case OBJECT_MESSAGE:
+ message = session.createObjectMessage((Serializable) messageDescription.getContent());
+ break;
+ case STREAM_MESSAGE:
+ message = session.createStreamMessage();
+ for (Object item : (Collection<?>) messageDescription.getContent())
+ {
+ ((StreamMessage) message).writeObject(item);
+ }
+ break;
+ case TEXT_MESSAGE:
+ message = session.createTextMessage(messageDescription.getContent().toString());
+ break;
+ default:
+ throw new RuntimeException(String.format("unexpected message type '%s'",
+ messageDescription.getMessageType()));
+ }
+ }
+ catch (ClassCastException e)
+ {
+ throw new RuntimeException(String.format("Could not create message of type '%s' with this body: %s",
+ messageDescription.getMessageType(),
+ messageDescription.getContent().toString()), e);
+ }
+ return message;
+ }
+
+ private static void setJmsHeader(final JmsInstructions.MessageDescription messageDescription, final Message message)
+ throws JMSException
+ {
+ final HashMap<JmsInstructions.MessageDescription.MessageHeader, Serializable> header =
+ messageDescription.getHeaders();
+
+ if (header == null)
+ {
+ return;
+ }
+
+ for (Map.Entry<JmsInstructions.MessageDescription.MessageHeader, Serializable> entry : header.entrySet())
+ {
+ try
+ {
+ switch (entry.getKey())
+ {
+ case DESTINATION:
+ message.setJMSDestination((Destination) entry.getValue());
+ break;
+ case DELIVERY_MODE:
+ message.setJMSDeliveryMode((Integer) entry.getValue());
+ break;
+ case MESSAGE_ID:
+ message.setJMSMessageID((String) entry.getValue());
+ break;
+ case TIMESTAMP:
+ message.setJMSTimestamp((Long) entry.getValue());
+ break;
+ case CORRELATION_ID:
+ if (entry.getValue() instanceof byte[])
+ {
+ message.setJMSCorrelationIDAsBytes((byte[]) entry.getValue());
+ }
+ else
+ {
+ message.setJMSCorrelationID((String) entry.getValue());
+ }
+ break;
+ case REPLY_TO:
+ message.setJMSReplyTo((Destination) entry.getValue());
+ break;
+ case REDELIVERED:
+ message.setJMSRedelivered((Boolean) entry.getValue());
+ break;
+ case TYPE:
+ message.setJMSType((String) entry.getValue());
+ break;
+ case EXPIRATION:
+ message.setJMSExpiration((Long) entry.getValue());
+ break;
+ case PRIORITY:
+ message.setJMSPriority((Integer) entry.getValue());
+ break;
+ default:
+ throw new RuntimeException(String.format("unexpected message header '%s'", entry.getKey()));
+ }
+ }
+ catch (ClassCastException e)
+ {
+ throw new RuntimeException(String.format("Could not set message header '%s' to this value: %s",
+ entry.getKey(),
+ entry.getValue()), e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageVerifier.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageVerifier.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageVerifier.java
new file mode 100644
index 0000000..63cb89c
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageVerifier.java
@@ -0,0 +1,306 @@
+/*
+ * 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.systests.end_to_end_conversion.client;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageEOFException;
+import javax.jms.ObjectMessage;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.xml.bind.DatatypeConverter;
+
+import org.apache.qpid.systests.end_to_end_conversion.JmsInstructions;
+
+public class MessageVerifier
+{
+ public static void verifyMessage(final JmsInstructions.MessageDescription messageDescription, final Message message)
+ throws VerificationException
+ {
+ verifyNotNull("No message received", message);
+ verifyMessageTypeAndContent(messageDescription, message);
+ verifyMessageHeaders(messageDescription, message);
+ verifyMessageProperties(messageDescription, message);
+ }
+
+ private static void verifyMessageTypeAndContent(final JmsInstructions.MessageDescription messageDescription,
+ final Message message) throws VerificationException
+ {
+ final JmsInstructions.MessageDescription.MessageType messageType = messageDescription.getMessageType();
+ Object expectedMessageContent = messageDescription.getContent();
+ Serializable actualContent;
+ Class<? extends Message> expectedMessageClass;
+
+ try
+ {
+ switch (messageType)
+ {
+ case MESSAGE:
+ expectedMessageClass = Message.class;
+ actualContent = null;
+ break;
+ case BYTES_MESSAGE:
+ expectedMessageClass = BytesMessage.class;
+ final int bodyLength = (int) ((BytesMessage) message).getBodyLength();
+ actualContent = new byte[bodyLength];
+ ((BytesMessage) message).readBytes((byte[]) actualContent);
+ break;
+ case MAP_MESSAGE:
+ expectedMessageClass = MapMessage.class;
+ final HashMap<Object, Object> content = new HashMap<>();
+ final MapMessage mapMessage = (MapMessage) message;
+ for (Object name : Collections.list(mapMessage.getMapNames()))
+ {
+ content.put(name, mapMessage.getObject((String) name));
+ }
+ actualContent = content;
+ break;
+ case OBJECT_MESSAGE:
+ expectedMessageClass = ObjectMessage.class;
+ actualContent = ((ObjectMessage) message).getObject();
+ break;
+ case STREAM_MESSAGE:
+ expectedMessageClass = StreamMessage.class;
+ actualContent = new ArrayList<>();
+ try
+ {
+ while (true)
+ {
+ ((List) actualContent).add(((StreamMessage) message).readObject());
+ }
+ }
+ catch (MessageEOFException e)
+ {
+ // pass
+ }
+ break;
+ case TEXT_MESSAGE:
+ expectedMessageClass = TextMessage.class;
+ actualContent = ((TextMessage) message).getText();
+ break;
+ default:
+ throw new RuntimeException(String.format("unexpected message type '%s'",
+ messageType));
+ }
+ verifyEquals("Unexpected message type", expectedMessageClass, message.getClass());
+ verifyEquals("Unexpected message content", expectedMessageContent, actualContent);
+ }
+ catch (JMSException e)
+ {
+ throw new RuntimeException("Unexpected exception during message type and/or content verification", e);
+ }
+ }
+
+ private static void verifyMessageHeaders(final JmsInstructions.MessageDescription messageDescription,
+ final Message message) throws VerificationException
+ {
+ try
+ {
+ for (Map.Entry<JmsInstructions.MessageDescription.MessageHeader, Serializable> entry : messageDescription.getHeaders()
+ .entrySet())
+ {
+ Object actualValue;
+
+ switch (entry.getKey())
+ {
+ case DESTINATION:
+ actualValue = message.getJMSDestination();
+ break;
+ case DELIVERY_MODE:
+ actualValue = message.getJMSDeliveryMode();
+ break;
+ case MESSAGE_ID:
+ actualValue = message.getJMSMessageID();
+ break;
+ case TIMESTAMP:
+ actualValue = message.getJMSTimestamp();
+ break;
+ case CORRELATION_ID:
+ if (entry.getValue() instanceof byte[])
+ {
+ actualValue = message.getJMSCorrelationIDAsBytes();
+ }
+ else
+ {
+ actualValue = message.getJMSCorrelationID();
+ }
+ break;
+ case REPLY_TO:
+ actualValue = message.getJMSReplyTo();
+ break;
+ case REDELIVERED:
+ actualValue = message.getJMSRedelivered();
+ break;
+ case TYPE:
+ actualValue = message.getJMSType();
+ break;
+ case EXPIRATION:
+ actualValue = message.getJMSExpiration();
+ break;
+ case PRIORITY:
+ actualValue = message.getJMSPriority();
+ break;
+ default:
+ throw new RuntimeException(String.format("unexpected message header '%s'", entry.getKey()));
+ }
+
+ verifyEquals(String.format("Unexpected message header '%s'", entry.getKey()),
+ entry.getValue(),
+ actualValue);
+ }
+ }
+ catch (JMSException e)
+ {
+ throw new RuntimeException("Unexpected exception during message header verification", e);
+ }
+ }
+
+ private static void verifyMessageProperties(final JmsInstructions.MessageDescription messageDescription,
+ final Message message) throws VerificationException
+ {
+ try
+ {
+ final ArrayList<String> actualPropertyNames =
+ Collections.list(((Enumeration<String>) message.getPropertyNames()));
+ final HashMap<String, Serializable> properties = messageDescription.getProperties();
+ for (Map.Entry<String, Serializable> entry : properties.entrySet())
+ {
+ final String key = entry.getKey();
+ verifyEquals(String.format("expected property '%s' not set", key),
+ true,
+ actualPropertyNames.contains(key));
+ final Object actualValue = message.getObjectProperty(key);
+ verifyEquals(String.format("Unexpected message property '%s'", key),
+ entry.getValue(),
+ actualValue);
+ }
+ }
+ catch (JMSException e)
+ {
+ throw new RuntimeException("Unexpected exception during message property verification", e);
+ }
+ }
+
+ private static <T, S> void verifyNotNull(final String failureMessage, final S actualValue)
+ {
+ if (actualValue == null)
+ {
+ throw new VerificationException(String.format("%s: expected non-null value", failureMessage));
+ }
+ }
+
+ private static <T, S> void verifyEquals(final String failureMessage,
+ final T expectedValue,
+ final S actualValue)
+ {
+ final String failureTemplate = "%s: expected <%s>, actual <%s>";
+ final String typeFailureTemplate = "%s: expected type <%s>, actual type <%s>";
+ final String arraySizeFailureTemplate = "%s: expected array of length <%d>, actual length <%d> ('%s' vs '%s')";
+ final String arrayFailureTemplate = "%s: arrays do not match ('%s' vs '%s')";
+ final String subclassFailureTemplate = "%s: expected subclass of <%s>, actual <%s>";
+ if (expectedValue == null && actualValue == null)
+ {
+ return;
+ }
+ else if (expectedValue == null && actualValue != null)
+ {
+ throw new VerificationException(String.format(failureTemplate, failureMessage, null, actualValue));
+ }
+ else if (expectedValue != null && actualValue == null)
+ {
+ throw new VerificationException(String.format(failureTemplate, failureMessage, expectedValue, null));
+ }
+ else if (expectedValue.getClass() != actualValue.getClass())
+ {
+ throw new VerificationException(String.format(typeFailureTemplate,
+ failureMessage,
+ expectedValue.getClass(),
+ actualValue.getClass()));
+ }
+ else
+ {
+ if (expectedValue instanceof Class && ((Class<?>) expectedValue).isInterface())
+ {
+ if (!((Class<?>) expectedValue).isAssignableFrom(((Class<?>) actualValue)))
+ {
+ throw new VerificationException(String.format(subclassFailureTemplate,
+ failureMessage,
+ ((Class<?>) expectedValue).getName(),
+ ((Class<?>) actualValue).getName()));
+ }
+ }
+ else if (expectedValue instanceof byte[])
+ {
+ final byte[] expectedValueAsBytes = (byte[]) expectedValue;
+ final byte[] actualValueAsBytes = (byte[]) actualValue;
+ String expectedValueAsString = DatatypeConverter.printHexBinary(expectedValueAsBytes);
+ if (expectedValueAsString.length() > 20)
+ {
+ expectedValueAsString = expectedValueAsString.substring(0, 20) + "...";
+ }
+ String actualValueAsString = DatatypeConverter.printHexBinary(actualValueAsBytes);
+ if (actualValueAsString.length() > 20)
+ {
+ actualValueAsString = actualValueAsString.substring(0, 20) + "...";
+ }
+ if (expectedValueAsBytes.length != actualValueAsBytes.length)
+ {
+ throw new VerificationException(String.format(arraySizeFailureTemplate,
+ failureMessage,
+ expectedValueAsBytes.length,
+ actualValueAsBytes.length,
+ expectedValueAsString,
+ actualValueAsString));
+ }
+ if (!Arrays.equals(expectedValueAsBytes, actualValueAsBytes))
+ {
+ throw new VerificationException(String.format(arrayFailureTemplate,
+ failureMessage,
+ expectedValueAsString,
+ actualValueAsString));
+ }
+ }
+ else
+ {
+ if (!expectedValue.equals(actualValue))
+ {
+ throw new VerificationException(String.format(failureTemplate,
+ failureMessage,
+ expectedValue,
+ actualValue));
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/VerificationException.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/VerificationException.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/VerificationException.java
new file mode 100644
index 0000000..32d9d08
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/VerificationException.java
@@ -0,0 +1,29 @@
+/*
+ * 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.systests.end_to_end_conversion.client;
+
+public class VerificationException extends RuntimeException
+{
+ public VerificationException(final String message)
+ {
+ super(message);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[3/4] qpid-broker-j git commit: QPID-7896: [Java System Tests] Create
system tests testing end-to-end message conversion
Posted by lq...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/Booter.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/Booter.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/Booter.java
new file mode 100644
index 0000000..a15b00b
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/Booter.java
@@ -0,0 +1,103 @@
+/*
+ * 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.systests.end_to_end_conversion.dependency_resolution;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+
+public class Booter
+{
+ private static final String FALLBACK_LOCAL_REPO_URL = Stream.of(System.getProperty("user.home"),
+ ".m2", "repository")
+ .collect(Collectors.joining(File.pathSeparator));
+ private static final String REMOTE_REPO_URL = System.getProperty(
+ "qpid.systests.end_to_end_conversion.remoteRepository",
+ "https://repo.maven.apache.org/maven2/");
+ private static final String LOCAL_REPO =
+ System.getProperty("qpid.systests.end_to_end_conversion.localRepository", FALLBACK_LOCAL_REPO_URL);
+
+ public static RepositorySystem newRepositorySystem()
+ {
+ return ManualRepositorySystemFactory.newRepositorySystem();
+ }
+
+ public static DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system)
+ {
+ DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
+
+ LocalRepository localRepo = new LocalRepository("target/local-repo");
+ session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
+
+ session.setTransferListener(new ConsoleTransferListener());
+ session.setRepositoryListener(new ConsoleRepositoryListener());
+
+ // uncomment to generate dirty trees
+ // session.setDependencyGraphTransformer( null );
+
+ return session;
+ }
+
+ public static List<RemoteRepository> newRepositories()
+ {
+ return Arrays.asList(newLocalRepository(), newCentralRepository());
+ }
+
+ private static RemoteRepository newCentralRepository()
+ {
+ return new RemoteRepository.Builder("central", "default", REMOTE_REPO_URL).build();
+ }
+
+ private static RemoteRepository newLocalRepository()
+ {
+ final URL localRepoUrl = toUrl(LOCAL_REPO);
+ return new RemoteRepository.Builder("local", "default", localRepoUrl.toString()).build();
+ }
+
+ private static URL toUrl(final String localRepo)
+ {
+ try
+ {
+ return new URL(localRepo);
+ }
+ catch (MalformedURLException e)
+ {
+ try
+ {
+ return new File(localRepo).toURI().toURL();
+ }
+ catch (MalformedURLException e1)
+ {
+ throw new RuntimeException(String.format("Failed to convert '%s' into a URL", localRepo), e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ClasspathQuery.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ClasspathQuery.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ClasspathQuery.java
new file mode 100644
index 0000000..78c8736
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ClasspathQuery.java
@@ -0,0 +1,201 @@
+/*
+ * 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.systests.end_to_end_conversion.dependency_resolution;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.resolution.DependencyRequest;
+import org.eclipse.aether.resolution.DependencyResolutionException;
+import org.eclipse.aether.util.artifact.JavaScopes;
+import org.eclipse.aether.util.filter.DependencyFilterUtils;
+
+public class ClasspathQuery
+{
+ private static final LoadingCache<Collection<String>, List<File>> _classpathCache;
+ private static final RepositorySystem _mavenRepositorySystem;
+ private static final RepositorySystemSession _mavenRepositorySession;
+ static
+ {
+ _mavenRepositorySystem = Booter.newRepositorySystem();
+ _mavenRepositorySession = Booter.newRepositorySystemSession(_mavenRepositorySystem);
+ _classpathCache = CacheBuilder.newBuilder()
+ .maximumSize(8)
+ .recordStats()
+ .build(new CacheLoader<Collection<String>, List<File>>()
+ {
+ @Override
+ public List<File> load(final Collection<String> key) throws Exception
+ {
+ return doBuildClassPath(key);
+ }
+ });
+ }
+ private final Class<?> _clientClass;
+ private final Collection<String> _clientGavs;
+
+
+ public ClasspathQuery(final Class<?> clientClass, final Collection<String> gavs)
+ {
+ _clientClass = clientClass;
+ _clientGavs = gavs;
+ }
+
+ public Class<?> getClientClass()
+ {
+ return _clientClass;
+ }
+
+ public Collection<String> getClientGavs()
+ {
+ return _clientGavs;
+ }
+
+ public String getClasspath()
+ {
+ return buildClassPath(_clientClass, _clientGavs);
+ }
+
+ public static String getCacheStats()
+ {
+ return _classpathCache.stats().toString();
+ }
+
+ private static List<File> doBuildClassPath(final Collection<String> gavs)
+ {
+ return new ArrayList<>(getJarFiles(gavs));
+ }
+
+ private static Set<File> getJarFiles(final Collection<String> gavs)
+ {
+ Set<File> jars = new HashSet<>();
+
+ for (final String gav : gavs)
+ {
+ Artifact artifact = new DefaultArtifact(gav);
+
+ DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
+
+ CollectRequest collectRequest = new CollectRequest();
+ collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
+ collectRequest.setRepositories(Booter.newRepositories());
+
+ DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);
+
+ List<ArtifactResult> artifactResults = null;
+ try
+ {
+ artifactResults = _mavenRepositorySystem.resolveDependencies(_mavenRepositorySession, dependencyRequest)
+ .getArtifactResults();
+ }
+ catch (DependencyResolutionException e)
+ {
+ throw new RuntimeException(String.format("Error while dependency resolution for '%s'", gav), e);
+ }
+
+ if (artifactResults == null)
+ {
+ throw new RuntimeException(String.format("Could not resolve dependency for '%s'", gav));
+ }
+
+ for (ArtifactResult artifactResult : artifactResults)
+ {
+ System.out.println(artifactResult.getArtifact() + " resolved to "
+ + artifactResult.getArtifact().getFile());
+ }
+
+ jars.addAll(artifactResults.stream()
+ .map(result -> result.getArtifact().getFile())
+ .collect(Collectors.toSet()));
+ }
+ return jars;
+ }
+
+ private String buildClassPath(final Class<?> clientClazz, final Collection<String> gavs)
+ {
+ List<File> classpathElements = _classpathCache.getUnchecked(gavs);
+ classpathElements.add(getLocalClasspathElement(clientClazz));
+
+ final String collect = classpathElements.stream()
+ .map(File::toString)
+ .collect(Collectors.joining(System.getProperty("path.separator")));
+ return collect;
+ }
+
+ private File getLocalClasspathElement(final Class<?> clazz)
+ {
+ int packageDepth = getPackageDepth(clazz);
+ final URL resource = clazz.getResource("/" + clazz.getName().replace(".", "/") + ".class");
+ // TODO handle JAR case
+ try
+ {
+ Path path = new File(resource.toURI()).toPath();
+ for (int i = 0; i < packageDepth + 1; ++i)
+ {
+ path = path.getParent();
+ }
+
+ return path.toFile();
+ }
+ catch (URISyntaxException e)
+ {
+ throw new RuntimeException(String.format("Failed to get classpath element for %s", clazz), e);
+ }
+ }
+
+ private int getPackageDepth(Class clazz)
+ {
+ final String publisherClassName = clazz.getName();
+ int lastIndex = 0;
+ int count = 0;
+
+ while (lastIndex != -1)
+ {
+ lastIndex = publisherClassName.indexOf(".", lastIndex);
+
+ if (lastIndex != -1)
+ {
+ count++;
+ lastIndex += 1;
+ }
+ }
+ return count;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ConsoleRepositoryListener.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ConsoleRepositoryListener.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ConsoleRepositoryListener.java
new file mode 100644
index 0000000..9725a41
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ConsoleRepositoryListener.java
@@ -0,0 +1,128 @@
+/*
+ * 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.systests.end_to_end_conversion.dependency_resolution;
+
+import java.io.PrintStream;
+
+import org.eclipse.aether.AbstractRepositoryListener;
+import org.eclipse.aether.RepositoryEvent;
+
+public class ConsoleRepositoryListener extends AbstractRepositoryListener
+{
+
+ private PrintStream _out;
+
+ public ConsoleRepositoryListener()
+ {
+ this(null);
+ }
+
+ public ConsoleRepositoryListener(PrintStream out)
+ {
+ this._out = (out != null) ? out : System.out;
+ }
+
+ public void artifactDeployed(RepositoryEvent event)
+ {
+ _out.println("Deployed " + event.getArtifact() + " to " + event.getRepository());
+ }
+
+ public void artifactDeploying(RepositoryEvent event)
+ {
+ _out.println("Deploying " + event.getArtifact() + " to " + event.getRepository());
+ }
+
+ public void artifactDescriptorInvalid(RepositoryEvent event)
+ {
+ _out.println("Invalid artifact descriptor for " + event.getArtifact() + ": "
+ + event.getException().getMessage());
+ }
+
+ public void artifactDescriptorMissing(RepositoryEvent event)
+ {
+ _out.println("Missing artifact descriptor for " + event.getArtifact());
+ }
+
+ public void artifactInstalled(RepositoryEvent event)
+ {
+ _out.println("Installed " + event.getArtifact() + " to " + event.getFile());
+ }
+
+ public void artifactInstalling(RepositoryEvent event)
+ {
+ _out.println("Installing " + event.getArtifact() + " to " + event.getFile());
+ }
+
+ public void artifactResolved(RepositoryEvent event)
+ {
+ _out.println("Resolved artifact " + event.getArtifact() + " from " + event.getRepository());
+ }
+
+ public void artifactDownloading(RepositoryEvent event)
+ {
+ _out.println("Downloading artifact " + event.getArtifact() + " from " + event.getRepository());
+ }
+
+ public void artifactDownloaded(RepositoryEvent event)
+ {
+ _out.println("Downloaded artifact " + event.getArtifact() + " from " + event.getRepository());
+ }
+
+ public void artifactResolving(RepositoryEvent event)
+ {
+ _out.println("Resolving artifact " + event.getArtifact());
+ }
+
+ public void metadataDeployed(RepositoryEvent event)
+ {
+ _out.println("Deployed " + event.getMetadata() + " to " + event.getRepository());
+ }
+
+ public void metadataDeploying(RepositoryEvent event)
+ {
+ _out.println("Deploying " + event.getMetadata() + " to " + event.getRepository());
+ }
+
+ public void metadataInstalled(RepositoryEvent event)
+ {
+ _out.println("Installed " + event.getMetadata() + " to " + event.getFile());
+ }
+
+ public void metadataInstalling(RepositoryEvent event)
+ {
+ _out.println("Installing " + event.getMetadata() + " to " + event.getFile());
+ }
+
+ public void metadataInvalid(RepositoryEvent event)
+ {
+ _out.println("Invalid metadata " + event.getMetadata());
+ }
+
+ public void metadataResolved(RepositoryEvent event)
+ {
+ _out.println("Resolved metadata " + event.getMetadata() + " from " + event.getRepository());
+ }
+
+ public void metadataResolving(RepositoryEvent event)
+ {
+ _out.println("Resolving metadata " + event.getMetadata() + " from " + event.getRepository());
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ConsoleTransferListener.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ConsoleTransferListener.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ConsoleTransferListener.java
new file mode 100644
index 0000000..765974b
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ConsoleTransferListener.java
@@ -0,0 +1,175 @@
+/*
+ * 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.systests.end_to_end_conversion.dependency_resolution;
+
+import java.io.PrintStream;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.eclipse.aether.transfer.AbstractTransferListener;
+import org.eclipse.aether.transfer.MetadataNotFoundException;
+import org.eclipse.aether.transfer.TransferEvent;
+import org.eclipse.aether.transfer.TransferResource;
+
+public class ConsoleTransferListener extends AbstractTransferListener
+{
+
+ private PrintStream _out;
+
+ private Map<TransferResource, Long> _downloads = new ConcurrentHashMap<>();
+
+ private int _lastLength;
+
+ public ConsoleTransferListener()
+ {
+ this(null);
+ }
+
+ public ConsoleTransferListener(PrintStream out)
+ {
+ this._out = (out != null) ? out : System.out;
+ }
+
+ @Override
+ public void transferInitiated(TransferEvent event)
+ {
+ String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";
+
+ _out.println(message + ": " + event.getResource().getRepositoryUrl() + event.getResource()
+ .getResourceName());
+ }
+
+ @Override
+ public void transferProgressed(TransferEvent event)
+ {
+ TransferResource resource = event.getResource();
+ _downloads.put(resource, Long.valueOf(event.getTransferredBytes()));
+
+ StringBuilder buffer = new StringBuilder(64);
+
+ for (Map.Entry<TransferResource, Long> entry : _downloads.entrySet())
+ {
+ long total = entry.getKey().getContentLength();
+ long complete = entry.getValue().longValue();
+
+ buffer.append(getStatus(complete, total)).append(" ");
+ }
+
+ int pad = _lastLength - buffer.length();
+ _lastLength = buffer.length();
+ pad(buffer, pad);
+ buffer.append('\r');
+
+ _out.print(buffer);
+ }
+
+ private String getStatus(long complete, long total)
+ {
+ if (total >= 1024)
+ {
+ return toKB(complete) + "/" + toKB(total) + " KB ";
+ }
+ else if (total >= 0)
+ {
+ return complete + "/" + total + " B ";
+ }
+ else if (complete >= 1024)
+ {
+ return toKB(complete) + " KB ";
+ }
+ else
+ {
+ return complete + " B ";
+ }
+ }
+
+ private void pad(StringBuilder buffer, int spaces)
+ {
+ String block = " ";
+ while (spaces > 0)
+ {
+ int n = Math.min(spaces, block.length());
+ buffer.append(block, 0, n);
+ spaces -= n;
+ }
+ }
+
+ @Override
+ public void transferSucceeded(TransferEvent event)
+ {
+ transferCompleted(event);
+
+ TransferResource resource = event.getResource();
+ long contentLength = event.getTransferredBytes();
+ if (contentLength >= 0)
+ {
+ String type = (event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded");
+ String len = contentLength >= 1024 ? toKB(contentLength) + " KB" : contentLength + " B";
+
+ String throughput = "";
+ long duration = System.currentTimeMillis() - resource.getTransferStartTime();
+ if (duration > 0)
+ {
+ long bytes = contentLength - resource.getResumeOffset();
+ DecimalFormat format = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH));
+ double kbPerSec = (bytes / 1024.0) / (duration / 1000.0);
+ throughput = " at " + format.format(kbPerSec) + " KB/sec";
+ }
+
+ _out.println(type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len
+ + throughput + ")");
+ }
+ }
+
+ @Override
+ public void transferFailed(TransferEvent event)
+ {
+ transferCompleted(event);
+
+ if (!(event.getException() instanceof MetadataNotFoundException))
+ {
+ event.getException().printStackTrace(_out);
+ }
+ }
+
+ private void transferCompleted(TransferEvent event)
+ {
+ _downloads.remove(event.getResource());
+
+ StringBuilder buffer = new StringBuilder(64);
+ pad(buffer, _lastLength);
+ buffer.append('\r');
+ _out.print(buffer);
+ }
+
+ public void transferCorrupted(TransferEvent event)
+ {
+ event.getException().printStackTrace(_out);
+ }
+
+ protected long toKB(long bytes)
+ {
+ return (bytes + 1023) / 1024;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ManualRepositorySystemFactory.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ManualRepositorySystemFactory.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ManualRepositorySystemFactory.java
new file mode 100644
index 0000000..a488fac
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/dependency_resolution/ManualRepositorySystemFactory.java
@@ -0,0 +1,58 @@
+/*
+ * 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.systests.end_to_end_conversion.dependency_resolution;
+
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
+import org.eclipse.aether.impl.DefaultServiceLocator;
+import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
+import org.eclipse.aether.spi.connector.transport.TransporterFactory;
+import org.eclipse.aether.transport.file.FileTransporterFactory;
+import org.eclipse.aether.transport.http.HttpTransporterFactory;
+
+public class ManualRepositorySystemFactory
+{
+
+ public static RepositorySystem newRepositorySystem()
+ {
+ /*
+ * Aether's components implement org.eclipse.aether.spi.locator.Service to ease manual wiring and using the
+ * prepopulated DefaultServiceLocator, we only need to register the repository connector and transporter
+ * factories.
+ */
+ DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
+ locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
+ locator.addService(TransporterFactory.class, FileTransporterFactory.class);
+ locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
+
+ locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler()
+ {
+ @Override
+ public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception)
+ {
+ exception.printStackTrace();
+ }
+ });
+
+ return locator.getService(RepositorySystem.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/resources/config-end-to-end-conversion-tests.json
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/resources/config-end-to-end-conversion-tests.json b/systests/end-to-end-conversion-tests/src/main/resources/config-end-to-end-conversion-tests.json
new file mode 100644
index 0000000..c9fe08e
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/resources/config-end-to-end-conversion-tests.json
@@ -0,0 +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.
+ *
+ */
+{
+ "name" : "${broker.name}",
+ "modelVersion" : "7.0",
+ "authenticationproviders" : [ {
+ "name" : "anon",
+ "type" : "Anonymous"
+ } ],
+ "ports" : [ {
+ "name" : "ANONYMOUS_AMQP",
+ "type" : "AMQP",
+ "authenticationProvider" : "anon",
+ "port" : "0",
+ "virtualhostaliases" : [ {
+ "name" : "defaultAlias",
+ "type" : "defaultAlias",
+ "durable" : true
+ }, {
+ "name": "patternMatchingAlias",
+ "type": "patternMatchingAlias"
+ }, {
+ "name" : "nameAlias",
+ "type" : "nameAlias",
+ "durable" : true
+ } ]
+ } ],
+ "virtualhostnodes" : []
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/main/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/main/resources/logback-test.xml b/systests/end-to-end-conversion-tests/src/main/resources/logback-test.xml
new file mode 100644
index 0000000..fb5a387
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/main/resources/logback-test.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ ~
+ -->
+<configuration debug="true">
+
+ <contextName>qpid-systests-end-to-end-conversion</contextName>
+
+ <!-- Logging configuration used for this module. This is named
+ logback-test.xml in order that it is found in preference to the logback.xml
+ found in qpid-test-utils (which is used for other, non-systests, modules). -->
+
+ <appender name="RootSiftAppender" class="ch.qos.logback.classic.sift.SiftingAppender">
+ <discriminator class="org.apache.qpid.test.utils.LogbackPropertyValueDiscriminator">
+ <Key>classQualifiedTestName</Key>
+ <DefaultValue>testrun</DefaultValue>
+ </discriminator>
+ <sift>
+ <appender name="FILE-${classQualifiedTestName}" class="ch.qos.logback.core.FileAppender">
+ <File>${test.output.dir}${file.separator}TEST-${classQualifiedTestName}-${qpid.systests.end_to_end_conversion.executionId}.txt</File>
+ <Append>False</Append>
+ <encoder>
+ <pattern>%date %-5level [%thread] %logger{10} %msg%n</pattern>
+ </encoder>
+ </appender>
+ </sift>
+ </appender>
+ <root level="debug">
+ <appender-ref ref="RootSiftAppender"/>
+ </root>
+ <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
+</configuration>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/end-to-end-conversion-tests/src/test/java/org/apache/qpid/systests/end_to_end_conversion/SimpleConversionTest.java
----------------------------------------------------------------------
diff --git a/systests/end-to-end-conversion-tests/src/test/java/org/apache/qpid/systests/end_to_end_conversion/SimpleConversionTest.java b/systests/end-to-end-conversion-tests/src/test/java/org/apache/qpid/systests/end_to_end_conversion/SimpleConversionTest.java
new file mode 100644
index 0000000..79812f0
--- /dev/null
+++ b/systests/end-to-end-conversion-tests/src/test/java/org/apache/qpid/systests/end_to_end_conversion/SimpleConversionTest.java
@@ -0,0 +1,135 @@
+/*
+ * 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.systests.end_to_end_conversion;
+
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.apache.qpid.systests.end_to_end_conversion.client.VerificationException;
+
+public class SimpleConversionTest extends EndToEndConversionTestBase
+{
+ private static final long TEST_TIMEOUT = 30000L;
+
+ @Test
+ public void textMessage() throws Exception
+ {
+ final JmsInstructions.MessageDescription messageDescription = new JmsInstructions.MessageDescription();
+ messageDescription.setMessageType(JmsInstructions.MessageDescription.MessageType.TEXT_MESSAGE);
+ messageDescription.setContent("foobar");
+
+ performSimpleTest(messageDescription);
+ }
+
+ @Test
+ public void bytesMessage() throws Exception
+ {
+ final JmsInstructions.MessageDescription messageDescription = new JmsInstructions.MessageDescription();
+ messageDescription.setMessageType(JmsInstructions.MessageDescription.MessageType.BYTES_MESSAGE);
+ messageDescription.setContent(new byte[]{0x00, (byte) 0xFF, (byte) 0xc3});
+
+ performSimpleTest(messageDescription);
+ }
+
+ @Test
+ public void mapMessage() throws Exception
+ {
+ final JmsInstructions.MessageDescription messageDescription = new JmsInstructions.MessageDescription();
+ messageDescription.setMessageType(JmsInstructions.MessageDescription.MessageType.MAP_MESSAGE);
+ HashMap<String, Object> content = new HashMap<>();
+ content.put("int", 42);
+ content.put("boolean", true);
+ content.put("string", "testString");
+ messageDescription.setContent(content);
+
+ performSimpleTest(messageDescription);
+ }
+
+ @Test
+ public void correlationId() throws Exception
+ {
+ final String correlationId = "myCorrelationId";
+ final JmsInstructions.MessageDescription messageDescription = new JmsInstructions.MessageDescription();
+ messageDescription.setHeader(JmsInstructions.MessageDescription.MessageHeader.CORRELATION_ID, correlationId);
+
+ performSimpleTest(messageDescription);
+ }
+
+ @Ignore("QPID-7897")
+ @Test
+ public void correlationIdAsBytes() throws Exception
+ {
+ final byte[] correlationId = new byte[]{(byte) 0xFF, 0x00, (byte) 0xC3};
+ final JmsInstructions.MessageDescription messageDescription = new JmsInstructions.MessageDescription();
+ messageDescription.setHeader(JmsInstructions.MessageDescription.MessageHeader.CORRELATION_ID, correlationId);
+
+ performSimpleTest(messageDescription);
+ }
+
+ @Test
+ public void property() throws Exception
+ {
+ final JmsInstructions.MessageDescription messageDescription = new JmsInstructions.MessageDescription();
+ messageDescription.setProperty("intProperty", 42);
+ messageDescription.setProperty("stringProperty", "foobar");
+ messageDescription.setProperty("booleanProperty", true);
+ messageDescription.setProperty("doubleProperty", 37.5);
+
+ performSimpleTest(messageDescription);
+ }
+
+ public void performSimpleTest(final JmsInstructions.MessageDescription messageDescription) throws Exception
+ {
+ final ListenableFuture<?> publisherFuture =
+ runPublisher(JmsInstructionBuilder.publishSingleMessage(messageDescription));
+ final ListenableFuture<?> subscriberFuture =
+ runSubscriber(JmsInstructionBuilder.receiveSingleMessage(messageDescription));
+ try
+ {
+ Futures.allAsList(publisherFuture, subscriberFuture).get(TEST_TIMEOUT, TimeUnit.MILLISECONDS);
+ }
+ catch (ExecutionException e)
+ {
+ final Throwable cause = e.getCause();
+ if (cause instanceof VerificationException)
+ {
+ throw new AssertionError("Client failed verification", cause);
+ }
+ else if (cause instanceof Exception)
+ {
+ throw ((Exception) cause);
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/pom.xml
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/pom.xml b/systests/protocol-tests-amqp-1-0/pom.xml
index d90f967..a3108b5 100644
--- a/systests/protocol-tests-amqp-1-0/pom.xml
+++ b/systests/protocol-tests-amqp-1-0/pom.xml
@@ -55,6 +55,11 @@
<dependency>
<groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-systests-utils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
<artifactId>qpid-broker-plugins-logging-logback</artifactId>
</dependency>
@@ -129,4 +134,18 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <qpid.initialConfigurationLocation>classpath:config-protocol-tests.json</qpid.initialConfigurationLocation>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/BrokerAdmin.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/BrokerAdmin.java b/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/BrokerAdmin.java
deleted file mode 100644
index 303cc28..0000000
--- a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/BrokerAdmin.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.qpid.tests.protocol.v1_0;
-
-import java.lang.reflect.Method;
-import java.net.InetSocketAddress;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-import org.apache.qpid.server.plugin.Pluggable;
-
-public interface BrokerAdmin extends Pluggable
-{
- String TEST_QUEUE_NAME = "testQueue";
- Long RESTART_TIMEOUT = Long.getLong("brokerAdmin.restart_timeout", 10000);
-
- void beforeTestClass(final Class testClass);
- void beforeTestMethod(final Class testClass, final Method method);
- void afterTestMethod(final Class testClass, final Method method);
- void afterTestClass(final Class testClass);
-
- InetSocketAddress getBrokerAddress(PortType portType);
-
- void createQueue(String queueName);
- void deleteQueue(String queueName);
- void putMessageOnQueue(String queueName, String... messages);
- int getQueueDepthMessages(String testQueueName);
-
- boolean supportsRestart();
- ListenableFuture<Void> restart();
-
- boolean isSASLSupported();
- boolean isSASLMechanismSupported(String mechanismName);
- boolean isWebSocketSupported();
- boolean isQueueDepthSupported();
-
- String getValidUsername();
- String getValidPassword();
-
-
-
- enum PortType
- {
- ANONYMOUS_AMQP,
- ANONYMOUS_AMQPWS,
- AMQP
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/BrokerAdminFactory.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/BrokerAdminFactory.java b/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/BrokerAdminFactory.java
deleted file mode 100644
index 6ecc02f..0000000
--- a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/BrokerAdminFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.qpid.tests.protocol.v1_0;
-
-import java.util.Map;
-
-import org.apache.qpid.server.plugin.QpidServiceLoader;
-
-public class BrokerAdminFactory
-{
- BrokerAdmin createInstance(String type)
- {
- Map<String, BrokerAdmin> adminFacades = new QpidServiceLoader().getInstancesByType(BrokerAdmin.class);
- BrokerAdmin brokerAdmin = adminFacades.get(type);
- if (brokerAdmin == null)
- {
- throw new RuntimeException(String.format("Could not find BrokerAdmin implementation of type '%s'", type));
- }
- return brokerAdmin;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/EmbeddedBrokerPerClassAdminImpl.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/EmbeddedBrokerPerClassAdminImpl.java b/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/EmbeddedBrokerPerClassAdminImpl.java
deleted file mode 100644
index e4dd859..0000000
--- a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/EmbeddedBrokerPerClassAdminImpl.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.qpid.tests.protocol.v1_0;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.net.InetSocketAddress;
-import java.nio.file.Files;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import ch.qos.logback.classic.LoggerContext;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.server.SystemLauncher;
-import org.apache.qpid.server.SystemLauncherListener;
-import org.apache.qpid.server.logging.logback.LogbackLoggingSystemLauncherListener;
-import org.apache.qpid.server.message.MessageDestination;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.Container;
-import org.apache.qpid.server.model.IllegalStateTransitionException;
-import org.apache.qpid.server.model.ManageableMessage;
-import org.apache.qpid.server.model.NotFoundException;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.model.SystemConfig;
-import org.apache.qpid.server.model.VirtualHostNode;
-import org.apache.qpid.server.plugin.PluggableService;
-import org.apache.qpid.server.store.MemoryConfigurationStore;
-import org.apache.qpid.server.util.FileUtils;
-import org.apache.qpid.server.virtualhost.QueueManagingVirtualHost;
-import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNode;
-import org.apache.qpid.test.utils.LogbackPropertyValueDiscriminator;
-
-@SuppressWarnings("unused")
-@PluggableService
-public class EmbeddedBrokerPerClassAdminImpl implements BrokerAdmin
-{
- private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedBrokerPerClassAdminImpl.class);
- private final Map<String, Integer> _ports = new HashMap<>();
- private SystemLauncher _systemLauncher;
- private Container<?> _broker;
- private VirtualHostNode<?> _currentVirtualHostNode;
- private String _currentWorkDirectory;
- private boolean _isPersistentStore;
-
- @Override
- public void beforeTestClass(final Class testClass)
- {
- setClassQualifiedTestName(testClass.getName());
- LOGGER.info("========================= starting broker for test class : " + testClass.getSimpleName());
- try
- {
- String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis()));
- _currentWorkDirectory = Files.createTempDirectory(String.format("qpid-work-%s-%s-", timestamp, testClass.getSimpleName())).toString();
-
- Map<String,String> context = new HashMap<>();
- context.put("qpid.work_dir", _currentWorkDirectory);
- context.put("qpid.port.protocol_handshake_timeout", "1000000");
-
- Map<String,Object> systemConfigAttributes = new HashMap<>();
- systemConfigAttributes.put(SystemConfig.INITIAL_CONFIGURATION_LOCATION, "classpath:config-protocol-tests.json");
- systemConfigAttributes.put(ConfiguredObject.CONTEXT, context);
- systemConfigAttributes.put(ConfiguredObject.TYPE, System.getProperty("broker.config-store-type", "JSON"));
- systemConfigAttributes.put(SystemConfig.STARTUP_LOGGED_TO_SYSTEM_OUT, Boolean.FALSE);
-
- if (Thread.getDefaultUncaughtExceptionHandler() == null)
- {
- Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
- }
-
- LOGGER.info("Starting internal broker (same JVM)");
-
- List<SystemLauncherListener> systemLauncherListeners = new ArrayList<>();
- systemLauncherListeners.add(new LogbackLoggingSystemLauncherListener());
- systemLauncherListeners.add(new ShutdownLoggingSystemLauncherListener());
- systemLauncherListeners.add(new PortExtractingLauncherListener());
- _systemLauncher = new SystemLauncher(systemLauncherListeners.toArray(new SystemLauncherListener[systemLauncherListeners.size()]));
-
- _systemLauncher.startup(systemConfigAttributes);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to start broker for test class", e);
- }
- }
-
- @Override
- public void beforeTestMethod(final Class testClass, final Method method)
- {
- LOGGER.info("========================= prepare test environment for test : " + testClass.getSimpleName() + "#" + method.getName());
-
- final String virtualHostNodeName = testClass.getSimpleName() + "_" + method.getName();
- final String storeType = System.getProperty("virtualhostnode.type");
- _isPersistentStore = !"Memory".equals(storeType);
-
- String storeDir = null;
- if (System.getProperty("profile", "").startsWith("java-dby-mem"))
- {
- storeDir = ":memory:";
- }
- else if (!MemoryConfigurationStore.TYPE.equals(storeType))
- {
- storeDir = "${qpid.work_dir}" + File.separator + virtualHostNodeName;
- }
-
- String blueprint = System.getProperty("virtualhostnode.context.blueprint");
-
- Map<String, Object> attributes = new HashMap<>();
- attributes.put(VirtualHostNode.NAME, virtualHostNodeName);
- attributes.put(VirtualHostNode.TYPE, storeType);
- attributes.put(VirtualHostNode.CONTEXT, Collections.singletonMap("virtualhostBlueprint", blueprint));
- attributes.put(VirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE, true);
- attributes.put(VirtualHostNode.VIRTUALHOST_INITIAL_CONFIGURATION, blueprint);
- if (storeDir != null)
- {
- attributes.put(JsonVirtualHostNode.STORE_PATH, storeDir);
- }
-
- _currentVirtualHostNode = _broker.createChild(VirtualHostNode.class, attributes);
-
- LOGGER.info("========================= executing test : " + testClass.getSimpleName() + "#" + method.getName());
- setClassQualifiedTestName(testClass.getName() + "." + method.getName());
- LOGGER.info("========================= start executing test : " + testClass.getSimpleName() + "#" + method.getName());
- }
-
- @Override
- public void afterTestMethod(final Class testClass, final Method method)
- {
- LOGGER.info("========================= stop executing test : " + testClass.getSimpleName() + "#" + method.getName());
- setClassQualifiedTestName(testClass.getName());
- LOGGER.info("========================= cleaning up test environment for test : " + testClass.getSimpleName() + "#" + method.getName());
- if (Boolean.getBoolean("broker.clean.between.tests"))
- {
- _currentVirtualHostNode.delete();
- }
- else
- {
- _currentVirtualHostNode.setAttributes(Collections.singletonMap(VirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE,
- false));
- }
- setClassQualifiedTestName(testClass.getName());
- LOGGER.info("========================= cleaning done for test : " + testClass.getSimpleName() + "#" + method.getName());
- }
-
- @Override
- public void afterTestClass(final Class testClass)
- {
- LOGGER.info("========================= stopping broker for test class: " + testClass.getSimpleName());
- _systemLauncher.shutdown();
- _ports.clear();
- if (Boolean.getBoolean("broker.clean.between.tests"))
- {
- FileUtils.delete(new File(_currentWorkDirectory), true);
- }
- LOGGER.info("========================= stopping broker done for test class : " + testClass.getSimpleName());
- setClassQualifiedTestName(null);
- }
-
- @Override
- public InetSocketAddress getBrokerAddress(final PortType portType)
- {
- Integer port = _ports.get(portType.name());
- if (port == null)
- {
- throw new IllegalStateException(String.format("Could not find port with name '%s' on the Broker", portType.name()));
- }
- return new InetSocketAddress(port);
- }
-
- @Override
- public void createQueue(final String queueName)
- {
- final Map<String, Object> attributes = new HashMap<>();
- attributes.put(Queue.NAME, queueName);
- attributes.put(Queue.TYPE, "standard");
- _currentVirtualHostNode.getVirtualHost().createChild(Queue.class, attributes);
- }
-
- @Override
- public void deleteQueue(final String queueName)
- {
- getQueue(queueName).delete();
- }
-
- @Override
- public void putMessageOnQueue(final String queueName, final String... messages)
- {
- for (String message : messages)
- {
- ((QueueManagingVirtualHost<?>) _currentVirtualHostNode.getVirtualHost()).publishMessage(new ManageableMessage()
- {
- @Override
- public String getAddress()
- {
- return queueName;
- }
-
- @Override
- public boolean isPersistent()
- {
- return false;
- }
-
- @Override
- public Date getExpiration()
- {
- return null;
- }
-
- @Override
- public String getCorrelationId()
- {
- return null;
- }
-
- @Override
- public String getAppId()
- {
- return null;
- }
-
- @Override
- public String getMessageId()
- {
- return null;
- }
-
- @Override
- public String getMimeType()
- {
- return "text/plain";
- }
-
- @Override
- public String getEncoding()
- {
- return null;
- }
-
- @Override
- public int getPriority()
- {
- return 0;
- }
-
- @Override
- public Date getNotValidBefore()
- {
- return null;
- }
-
- @Override
- public String getReplyTo()
- {
- return null;
- }
-
- @Override
- public Map<String, Object> getHeaders()
- {
- return null;
- }
-
- @Override
- public Object getContent()
- {
- return message;
- }
-
- @Override
- public String getContentTransferEncoding()
- {
- return null;
- }
- });
- }
-
- }
-
- @Override
- public int getQueueDepthMessages(final String testQueueName)
- {
- Queue queue = _currentVirtualHostNode.getVirtualHost().getChildByName(Queue.class, testQueueName);
- return queue.getQueueDepthMessages();
- }
-
- @Override
- public boolean supportsRestart()
- {
- return _isPersistentStore;
- }
-
- @Override
- public ListenableFuture<Void> restart()
- {
- try
- {
- LOGGER.info("Stopping VirtualHostNode for restart");
- _currentVirtualHostNode.stop();
- LOGGER.info("Starting VirtualHostNode for restart");
- _currentVirtualHostNode.start();
- LOGGER.info("Restarting VirtualHostNode completed");
- }
- catch (Exception e)
- {
- return Futures.immediateFailedFuture(e);
- }
- return Futures.immediateFuture(null);
- }
-
- @Override
- public boolean isSASLSupported()
- {
- return true;
- }
-
- @Override
- public boolean isSASLMechanismSupported(final String mechanismName)
- {
- return true;
- }
-
- @Override
- public boolean isWebSocketSupported()
- {
- return true;
- }
-
- @Override
- public boolean isQueueDepthSupported()
- {
- return true;
- }
-
- @Override
- public String getValidUsername()
- {
- return "guest";
- }
-
- @Override
- public String getValidPassword()
- {
- return "guest";
- }
-
- @Override
- public String getType()
- {
- return "EMBEDDED_BROKER_PER_CLASS";
- }
-
- private Queue getQueue(final String queueName)
- {
- Collection<Queue> queues = _currentVirtualHostNode.getVirtualHost().getChildren(Queue.class);
- for (Queue queue : queues)
- {
- if (queue.getName().equals(queueName))
- {
- return queue;
- }
- }
- throw new NotFoundException(String.format("Queue '%s' not found", queueName));
- }
-
- private void setClassQualifiedTestName(final String name)
- {
- final LoggerContext loggerContext = ((ch.qos.logback.classic.Logger) LOGGER).getLoggerContext();
- loggerContext.putProperty(LogbackPropertyValueDiscriminator.CLASS_QUALIFIED_TEST_NAME, name);
- }
-
- private class PortExtractingLauncherListener implements SystemLauncherListener
- {
- private SystemConfig<?> _systemConfig;
-
- @Override
- public void beforeStartup()
- {
-
- }
-
- @Override
- public void errorOnStartup(final RuntimeException e)
- {
-
- }
-
- @Override
- public void afterStartup()
- {
-
- if (_systemConfig == null)
- {
- throw new IllegalStateException("System config is required");
- }
-
- _broker = _systemConfig.getContainer();
- Collection<Port> ports = _broker.getChildren(Port.class);
- for (Port port : ports)
- {
- _ports.put(port.getName(), port.getBoundPort());
- }
- }
-
- @Override
- public void onContainerResolve(final SystemConfig<?> systemConfig)
- {
- _systemConfig = systemConfig;
- }
-
- @Override
- public void onContainerClose(final SystemConfig<?> systemConfig)
- {
-
- }
-
- @Override
- public void onShutdown(final int exitCode)
- {
-
- }
-
- @Override
- public void exceptionOnShutdown(final Exception e)
- {
-
- }
- }
-
-
- private static class UncaughtExceptionHandler implements Thread.UncaughtExceptionHandler
- {
- private final AtomicInteger _count = new AtomicInteger(0);
-
- @Override
- public void uncaughtException(final Thread t, final Throwable e)
- {
- System.err.print("Thread terminated due to uncaught exception");
- e.printStackTrace();
-
- LOGGER.error("Uncaught exception from thread {}", t.getName(), e);
- _count.getAndIncrement();
- }
-
- public int getAndResetCount()
- {
- int count;
- do
- {
- count = _count.get();
- }
- while (!_count.compareAndSet(count, 0));
- return count;
- }
- }
-
- private class ShutdownLoggingSystemLauncherListener extends SystemLauncherListener.DefaultSystemLauncherListener
- {
- @Override
- public void onShutdown(final int exitCode)
- {
- _systemLauncher = null;
- }
-
- @Override
- public void exceptionOnShutdown(final Exception e)
- {
- if (e instanceof IllegalStateException
- || e instanceof IllegalStateTransitionException)
- {
- System.out.println(
- "IllegalStateException occurred on broker shutdown in test ");
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/ExternalQpidBrokerAdminImpl.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/ExternalQpidBrokerAdminImpl.java b/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/ExternalQpidBrokerAdminImpl.java
deleted file mode 100644
index a580333..0000000
--- a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/ExternalQpidBrokerAdminImpl.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.qpid.tests.protocol.v1_0;
-
-import java.lang.reflect.Method;
-import java.net.InetSocketAddress;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.server.plugin.PluggableService;
-
-@SuppressWarnings("unused")
-@PluggableService
-public class ExternalQpidBrokerAdminImpl implements BrokerAdmin
-{
- private static final Logger LOGGER = LoggerFactory.getLogger(ExternalQpidBrokerAdminImpl.class);
-
- @Override
- public void beforeTestClass(final Class testClass)
- {
- LOGGER.debug("beforeTestClass");
- }
-
- @Override
- public void beforeTestMethod(final Class testClass, final Method method)
- {
- LOGGER.debug("beforeTestMethod");
- }
-
- @Override
- public void afterTestMethod(final Class testClass, final Method method)
- {
- LOGGER.debug("afterTestMethod");
- }
-
- @Override
- public void afterTestClass(final Class testClass)
- {
- LOGGER.debug("afterTestClass");
- }
-
- @Override
- public InetSocketAddress getBrokerAddress(final PortType portType)
- {
- Integer port;
- switch (portType)
- {
- case AMQP:
- port = Integer.getInteger("qpid.tests.protocol.broker.external.port.standard");
- break;
- case ANONYMOUS_AMQP:
- port = Integer.getInteger("qpid.tests.protocol.broker.external.port.anonymous");
- break;
- default:
- throw new IllegalArgumentException(String.format("Unknown port type '%s'", portType));
- }
- return new InetSocketAddress(port);
- }
-
- @Override
- public void createQueue(final String queueName)
- {
- LOGGER.debug(String.format("creation of queue '%s' requested", queueName));
- }
-
- @Override
- public void deleteQueue(final String queueName)
- {
- LOGGER.debug(String.format("deletion of queue '%s' requested", queueName));
- }
-
- @Override
- public void putMessageOnQueue(final String queueName, final String... messages)
- {
- LOGGER.debug(String.format("puting of %d messages on queue '%s' requested", messages.length, queueName));
- }
-
- @Override
- public int getQueueDepthMessages(final String testQueueName)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean supportsRestart()
- {
- return false;
- }
-
- @Override
- public ListenableFuture<Void> restart()
- {
- throw new UnsupportedOperationException("External Qpid Broker does not support restart.");
- }
-
- @Override
- public boolean isSASLSupported()
- {
- return true;
- }
-
- @Override
- public boolean isWebSocketSupported()
- {
- return true;
- }
-
- @Override
- public boolean isQueueDepthSupported()
- {
- return false;
- }
-
- @Override
- public boolean isSASLMechanismSupported(final String mechanismName)
- {
- return true;
- }
-
- @Override
- public String getValidUsername()
- {
- return "guest";
- }
-
- @Override
- public String getValidPassword()
- {
- return "guest";
- }
-
- @Override
- public String getType()
- {
- return "EXTERNAL_BROKER";
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/ProtocolTestBase.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/ProtocolTestBase.java b/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/ProtocolTestBase.java
deleted file mode 100644
index 846bed3..0000000
--- a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/ProtocolTestBase.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.qpid.tests.protocol.v1_0;
-
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@RunWith(QpidTestRunner.class)
-public abstract class ProtocolTestBase
-{
- private static final Logger LOGGER = LoggerFactory.getLogger(ProtocolTestBase.class);
-
- private BrokerAdmin _brokerAdmin;
-
- public void init(final BrokerAdmin brokerAdmin)
- {
- _brokerAdmin = brokerAdmin;
- }
-
- public BrokerAdmin getBrokerAdmin()
- {
- return _brokerAdmin;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/QpidTestRunner.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/QpidTestRunner.java b/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/QpidTestRunner.java
deleted file mode 100644
index 740bf32..0000000
--- a/systests/protocol-tests-amqp-1-0/src/main/java/org/apache/qpid/tests/protocol/v1_0/QpidTestRunner.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.qpid.tests.protocol.v1_0;
-
-import org.junit.runner.notification.RunNotifier;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.InitializationError;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class QpidTestRunner extends BlockJUnit4ClassRunner
-{
- private final BrokerAdmin _brokerAdmin;
- private final Class _testClass;
-
- public QpidTestRunner(final Class<?> klass) throws InitializationError
- {
- super(klass);
- _testClass = klass;
- _brokerAdmin = (new BrokerAdminFactory()).createInstance("EMBEDDED_BROKER_PER_CLASS");
- }
-
- @Override
- protected Object createTest() throws Exception
- {
- Object test = super.createTest();
- ProtocolTestBase qpidTest = ((ProtocolTestBase) test);
- qpidTest.init(_brokerAdmin);
- return test;
- }
-
- @Override
- public void run(final RunNotifier notifier)
- {
- _brokerAdmin.beforeTestClass(_testClass);
- try
- {
- super.run(notifier);
- }
- finally
- {
- _brokerAdmin.afterTestClass(_testClass);
- }
- }
-
- @Override
- protected void runChild(final FrameworkMethod method, final RunNotifier notifier)
- {
- _brokerAdmin.beforeTestMethod(_testClass, method.getMethod());
- try
- {
- super.runChild(method, notifier);
- }
- finally
- {
- _brokerAdmin.afterTestMethod(_testClass, method.getMethod());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/bindmapjms/TemporaryDestinationTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/bindmapjms/TemporaryDestinationTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/bindmapjms/TemporaryDestinationTest.java
index 1a1c8bf..817be05 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/bindmapjms/TemporaryDestinationTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/bindmapjms/TemporaryDestinationTest.java
@@ -40,14 +40,14 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Begin;
import org.apache.qpid.server.protocol.v1_0.type.transport.Flow;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
import org.apache.qpid.tests.protocol.v1_0.Utils;
-public class TemporaryDestinationTest extends ProtocolTestBase
+public class TemporaryDestinationTest extends BrokerAdminUsingTestBase
{
private InetSocketAddress _brokerAddress;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/CloseExistingPolicy.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/CloseExistingPolicy.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/CloseExistingPolicy.java
index 83303ad..4bee689 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/CloseExistingPolicy.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/CloseExistingPolicy.java
@@ -45,12 +45,12 @@ import org.apache.qpid.server.protocol.v1_0.type.extensions.soleconn.SoleConnect
import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
-public class CloseExistingPolicy extends ProtocolTestBase
+public class CloseExistingPolicy extends BrokerAdminUsingTestBase
{
private InetSocketAddress _brokerAddress;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/MixedPolicy.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/MixedPolicy.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/MixedPolicy.java
index d11e2fc..0c9ce9f 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/MixedPolicy.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/MixedPolicy.java
@@ -33,12 +33,12 @@ import org.junit.Test;
import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
-public class MixedPolicy extends ProtocolTestBase
+public class MixedPolicy extends BrokerAdminUsingTestBase
{
private InetSocketAddress _brokerAddress;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/RefuseConnectionPolicy.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/RefuseConnectionPolicy.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/RefuseConnectionPolicy.java
index 404e067..dea12a3 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/RefuseConnectionPolicy.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/soleconn/RefuseConnectionPolicy.java
@@ -46,12 +46,12 @@ import org.apache.qpid.server.protocol.v1_0.type.extensions.soleconn.SoleConnect
import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
-public class RefuseConnectionPolicy extends ProtocolTestBase
+public class RefuseConnectionPolicy extends BrokerAdminUsingTestBase
{
private InetSocketAddress _brokerAddress;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/websocket/WebSocketTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/websocket/WebSocketTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/websocket/WebSocketTest.java
index 41b2dc3..a39b1b3 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/websocket/WebSocketTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/extensions/websocket/WebSocketTest.java
@@ -39,13 +39,12 @@ import org.junit.Test;
import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
import org.apache.qpid.server.protocol.v1_0.type.UnsignedShort;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
-import org.apache.qpid.tests.protocol.v1_0.HeaderResponse;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
-public class WebSocketTest extends ProtocolTestBase
+public class WebSocketTest extends BrokerAdminUsingTestBase
{
public static final byte[] AMQP_HEADER = "AMQP\0\1\0\0".getBytes(StandardCharsets.UTF_8);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/DeleteOnCloseTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/DeleteOnCloseTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/DeleteOnCloseTest.java
index 6327051..6ba9058 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/DeleteOnCloseTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/DeleteOnCloseTest.java
@@ -44,14 +44,14 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Detach;
import org.apache.qpid.server.protocol.v1_0.type.transport.Flow;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
import org.apache.qpid.tests.protocol.v1_0.Utils;
-public class DeleteOnCloseTest extends ProtocolTestBase
+public class DeleteOnCloseTest extends BrokerAdminUsingTestBase
{
private InetSocketAddress _brokerAddress;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java
index ea7d52a..4f3491f 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java
@@ -43,13 +43,13 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
import org.apache.qpid.server.protocol.v1_0.type.transport.Flow;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.Response;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
-public class MessageFormat extends ProtocolTestBase
+public class MessageFormat extends BrokerAdminUsingTestBase
{
private InetSocketAddress _brokerAddress;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MultiTransferTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MultiTransferTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MultiTransferTest.java
index 1c09bb6..5c7a7f5 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MultiTransferTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MultiTransferTest.java
@@ -51,15 +51,15 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Flow;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
import org.apache.qpid.server.protocol.v1_0.type.transport.ReceiverSettleMode;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.Response;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
import org.apache.qpid.tests.protocol.v1_0.Utils;
-public class MultiTransferTest extends ProtocolTestBase
+public class MultiTransferTest extends BrokerAdminUsingTestBase
{
private InetSocketAddress _brokerAddress;
private String _originalMmsMessageStorePersistence;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/TransferTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/TransferTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/TransferTest.java
index 1bfe7c0..fdebd11 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/TransferTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/TransferTest.java
@@ -69,16 +69,16 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.ReceiverSettleMode;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
import org.apache.qpid.server.protocol.v1_0.type.transport.SenderSettleMode;
import org.apache.qpid.server.protocol.v1_0.type.transport.Transfer;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
import org.apache.qpid.tests.protocol.v1_0.MessageDecoder;
import org.apache.qpid.tests.protocol.v1_0.MessageEncoder;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.Response;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
-public class TransferTest extends ProtocolTestBase
+public class TransferTest extends BrokerAdminUsingTestBase
{
private static final String TEST_MESSAGE_DATA = "foo";
private InetSocketAddress _brokerAddress;
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a7e4a716/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java
index f63d85e..d1a47db 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transaction/DischargeTest.java
@@ -49,13 +49,13 @@ import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
import org.apache.qpid.server.protocol.v1_0.type.transport.Flow;
import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
-import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdmin;
import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
import org.apache.qpid.tests.protocol.v1_0.Interaction;
-import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
import org.apache.qpid.tests.protocol.v1_0.SpecificationTest;
-public class DischargeTest extends ProtocolTestBase
+public class DischargeTest extends BrokerAdminUsingTestBase
{
private InetSocketAddress _brokerAddress;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org