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:49 UTC
[4/4] qpid-broker-j git commit: QPID-7896: [Java System Tests] Create
system tests testing end-to-end message conversion
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