Repository: qpid-broker-j Updated Branches: refs/heads/master d3ca1343b -> 46f6c2648
QPID-7896: [Java System Tests] fix issues with End-to-end-conversion-tests * make sure to shutdown task executor * improve logging * fix ConcurrentModificationException in ClasspathQuery * use different Queues for each test 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/46f6c264 Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/46f6c264 Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/46f6c264 Branch: refs/heads/master Commit: 46f6c26489f821d29d2b682a260789fdcfecaeed Parents: d3ca134 Author: Lorenz Quack <lqu...@apache.org> Authored: Tue Aug 29 10:58:51 2017 +0100 Committer: Lorenz Quack <lqu...@apache.org> Committed: Tue Aug 29 10:58:51 2017 +0100 ---------------------------------------------------------------------- .../EndToEndConversionTestBase.java | 37 ++++++++++++++++---- .../dependency_resolution/ClasspathQuery.java | 5 +-- .../SimpleConversionTest.java | 16 +++++---- 3 files changed, 43 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/46f6c264/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 index 234d67a..66e601a 100644 --- 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 @@ -33,13 +33,16 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; 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.After; import org.junit.AfterClass; +import org.junit.Before; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.event.Level; @@ -63,8 +66,27 @@ public class EndToEndConversionTestBase extends BrokerAdminUsingTestBase private static final int SERVER_SOCKET_TIMEOUT = 30000; private static final Logger LOGGER = LoggerFactory.getLogger(EndToEndConversionTestBase.class); private static final Logger CLIENT_LOGGER = LoggerFactory.getLogger(Client.class); - private final ListeningExecutorService _executorService = - MoreExecutors.listeningDecorator(Executors.newCachedThreadPool()); + private ListeningExecutorService _executorService; + + @Before + public void setupExecutor() + { + _executorService = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool()); + } + + @After + public void teardownExecutor() throws InterruptedException + { + if (_executorService != null) + { + _executorService.shutdown(); + if (!_executorService.awaitTermination(10, TimeUnit.SECONDS)) + { + _executorService.shutdownNow(); + } + _executorService = null; + } + } @AfterClass public static void reportStats() @@ -198,6 +220,7 @@ public class EndToEndConversionTestBase extends BrokerAdminUsingTestBase isAmqp0xClient(clientGavs)); final ClasspathQuery classpathQuery = new ClasspathQuery(Client.class, clientGavs); + LOGGER.debug("starting server socket"); try (final ServerSocket serverSocket = new ServerSocket(0)) { serverSocket.setSoTimeout(SERVER_SOCKET_TIMEOUT); @@ -217,15 +240,13 @@ public class EndToEndConversionTestBase extends BrokerAdminUsingTestBase { final LoggingThread loggingThread = new LoggingThread(pInputStream, loggingOutputStream); loggingThread.start(); - LOGGER.debug("client process {} started", serverSocket.getLocalPort()); + LOGGER.debug("client process started listening on port {}", 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()); + LOGGER.debug("client process connected from port {}", clientSocket.getPort()); clientSocket.setSoTimeout(CLIENT_SOCKET_TIMEOUT); outputStream.writeObject(clientInstructions); final Object result = inputStream.readObject(); @@ -251,14 +272,16 @@ public class EndToEndConversionTestBase extends BrokerAdminUsingTestBase } } - LOGGER.debug("client process {} finished exit value: {}", serverSocket.getLocalPort(), p.exitValue()); + LOGGER.debug("client process finished exit value: {}", p.exitValue()); } catch (RuntimeException e) { + LOGGER.debug("client process finished with exception: {}", e); throw e; } catch (Exception e) { + LOGGER.error("client process finished with exception: {}", e); throw new RuntimeException(e); } finally http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/46f6c264/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 index 2337317..921d214 100644 --- 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 @@ -26,6 +26,7 @@ import java.net.URL; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -87,7 +88,7 @@ public class ClasspathQuery private static List<File> doBuildClassPath(final Collection<String> gavs) { - return new ArrayList<>(getJarFiles(gavs)); + return Collections.unmodifiableList(new ArrayList<>(getJarFiles(gavs))); } private static Set<File> getJarFiles(final Collection<String> gavs) @@ -152,7 +153,7 @@ public class ClasspathQuery private String buildClassPath(final Class<?> clientClazz, final Collection<String> gavs) { - List<File> classpathElements = _classpathCache.getUnchecked(gavs); + List<File> classpathElements = new ArrayList<>(_classpathCache.getUnchecked(gavs)); classpathElements.add(getLocalClasspathElement(clientClazz)); final String collect = classpathElements.stream() http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/46f6c264/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 index c53d4a3..dbad8fd 100644 --- 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 @@ -34,7 +34,9 @@ import com.google.common.collect.Lists; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestName; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.systests.end_to_end_conversion.client.ClientInstruction; @@ -45,18 +47,20 @@ import org.apache.qpid.systests.end_to_end_conversion.client.VerificationExcepti public class SimpleConversionTest extends EndToEndConversionTestBase { private static final long TEST_TIMEOUT = 30000L; - private static final String QUEUE_NAME = "testQueue"; private static final String QUEUE_JNDI_NAME = "queue"; private HashMap<String, String> _defaultDestinations; + @Rule + public TestName _testName = new TestName(); @Before public void setup() { - getBrokerAdmin().createQueue(QUEUE_NAME); + final String queueName = _testName.getMethodName(); + getBrokerAdmin().createQueue(queueName); _defaultDestinations = new HashMap<>(); - _defaultDestinations.put("queue." + QUEUE_JNDI_NAME, QUEUE_NAME); + _defaultDestinations.put("queue." + QUEUE_JNDI_NAME, queueName); } @Test @@ -192,7 +196,7 @@ public class SimpleConversionTest extends EndToEndConversionTestBase @Test public void replyToStaticQueue() throws Exception { - final String replyQueueName = "testReplyQueue"; + final String replyQueueName = _testName.getMethodName() + "ReplyQueue"; final String replyQueueJndiName = "replyQueue"; _defaultDestinations.put("queue." + replyQueueJndiName, replyQueueName); getBrokerAdmin().createQueue(replyQueueName); @@ -234,7 +238,7 @@ public class SimpleConversionTest extends EndToEndConversionTestBase EnumSet.of(Protocol.AMQP_1_0).contains(getPublisherProtocolVersion())); String jndiName = "testDestination"; - String testDestination = "myQueue"; + String testDestination = _testName.getMethodName() + "MyQueue"; _defaultDestinations.put("destination." + jndiName, String.format("BURL:direct://amq.direct//%s?routingkey='%s'", testDestination, testDestination)); @@ -254,7 +258,7 @@ public class SimpleConversionTest extends EndToEndConversionTestBase String replyToJndiName = "replyToJndiName"; String consumeReplyToJndiName = "consumeReplyToJndiName"; - String testDestination = "myQueue"; + String testDestination = _testName.getMethodName() + "MyQueue"; _defaultDestinations.put("destination." + replyToJndiName, "ADDR: amq.fanout/testReplyToQueue"); _defaultDestinations.put("destination." + consumeReplyToJndiName, "ADDR: testReplyToQueue; {create:always, node: {type: queue, x-bindings:[{exchange: 'amq.fanout', key: testReplyToQueue}]}}"); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org