From d101bcbf59bdbd1ad587b65c39903bcd70092fb4 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Fri, 6 Mar 2015 22:17:14 -0500 Subject: [PATCH 1/4] Fixing ServiceLocator on the testsuite My previous commit broke the location of the ServiceUtil / TransactionManagerLocator This commit is setting a new DummyTM on the integration-tests-suite and the proper TM Locator on the extra-tests --- ...ons.transactions.TransactionManagerLocator | 1 + .../largemessage/LargeMessageTestBase.java | 705 ------------------ .../DummyTransactionManagerLocator.java | 94 +++ .../TransactionManagerLocatorTest.java | 35 + ...ons.transactions.TransactionManagerLocator | 2 +- 5 files changed, 131 insertions(+), 706 deletions(-) create mode 100644 tests/extra-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator delete mode 100644 tests/integration-tests/src/test/java/org/apache/activemq/tests/largemessage/LargeMessageTestBase.java create mode 100644 tests/integration-tests/src/test/java/org/apache/activemq/tests/util/transactions/DummyTransactionManagerLocator.java create mode 100644 tests/integration-tests/src/test/java/org/apache/activemq/tests/util/transactions/TransactionManagerLocatorTest.java diff --git a/tests/extra-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator b/tests/extra-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator new file mode 100644 index 0000000000..e9ef6bf146 --- /dev/null +++ b/tests/extra-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator @@ -0,0 +1 @@ +org.apache.activemq.tests.extras.jms.bridge.TransactionManagerLocatorImpl diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/largemessage/LargeMessageTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/largemessage/LargeMessageTestBase.java deleted file mode 100644 index 89cb696211..0000000000 --- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/largemessage/LargeMessageTestBase.java +++ /dev/null @@ -1,705 +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.activemq.tests.largemessage; - -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.io.IOException; -import java.io.OutputStream; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; - -import org.apache.activemq.api.core.ActiveMQBuffer; -import org.apache.activemq.api.core.ActiveMQBuffers; -import org.apache.activemq.api.core.ActiveMQException; -import org.apache.activemq.api.core.Message; -import org.apache.activemq.api.core.SimpleString; -import org.apache.activemq.api.core.client.ClientConsumer; -import org.apache.activemq.api.core.client.ClientMessage; -import org.apache.activemq.api.core.client.ClientProducer; -import org.apache.activemq.api.core.client.ClientSession; -import org.apache.activemq.api.core.client.ClientSessionFactory; -import org.apache.activemq.api.core.client.MessageHandler; -import org.apache.activemq.api.core.client.ServerLocator; -import org.apache.activemq.core.server.ActiveMQServer; -import org.apache.activemq.core.server.Queue; -import org.apache.activemq.tests.integration.IntegrationTestLogger; -import org.apache.activemq.tests.util.ServiceTestBase; -import org.apache.activemq.tests.util.UnitTestCase; -import org.apache.activemq.utils.DataConstants; -import org.junit.After; -import org.junit.Assert; - -/** - * A LargeMessageTestBase - * - * @author Clebert Suconic - *

- * Created Oct 29, 2008 11:43:52 AM - */ -public abstract class LargeMessageTestBase extends ServiceTestBase -{ - - // Constants ----------------------------------------------------- - private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; - - protected final SimpleString ADDRESS = new SimpleString("SimpleAddress"); - - protected ActiveMQServer server; - - // Attributes ---------------------------------------------------- - - // Static -------------------------------------------------------- - - // Constructors -------------------------------------------------- - - // Public -------------------------------------------------------- - - // Package protected --------------------------------------------- - - // Protected ----------------------------------------------------- - - @Override - @After - public void tearDown() throws Exception - { - if (server != null && server.isStarted()) - { - try - { - server.stop(); - } - catch (Exception e) - { - LargeMessageTestBase.log.warn(e.getMessage(), e); - } - } - - server = null; - - super.tearDown(); - } - - protected void testChunks(final boolean isXA, - final boolean restartOnXA, - final boolean rollbackFirstSend, - final boolean useStreamOnConsume, - final boolean realFiles, - final boolean preAck, - final boolean sendingBlocking, - final boolean testBrowser, - final boolean useMessageConsumer, - final int numberOfMessages, - final long numberOfBytes, - final int waitOnConsumer, - final long delayDelivery) throws Exception - { - testChunks(isXA, - restartOnXA, - rollbackFirstSend, - useStreamOnConsume, - realFiles, - preAck, - sendingBlocking, - testBrowser, - useMessageConsumer, - numberOfMessages, - numberOfBytes, - waitOnConsumer, - delayDelivery, - -1, - 10 * 1024); - } - - protected void testChunks(final boolean isXA, - final boolean restartOnXA, - final boolean rollbackFirstSend, - final boolean useStreamOnConsume, - final boolean realFiles, - final boolean preAck, - final boolean sendingBlocking, - final boolean testBrowser, - final boolean useMessageConsumer, - final int numberOfMessages, - final long numberOfBytes, - final int waitOnConsumer, - final long delayDelivery, - final int producerWindow, - final int minSize) throws Exception - { - clearDataRecreateServerDirs(); - - server = createServer(realFiles); - server.start(); - - ServerLocator locator = createInVMNonHALocator(); - try - { - - if (sendingBlocking) - { - locator.setBlockOnNonDurableSend(true); - locator.setBlockOnDurableSend(true); - locator.setBlockOnAcknowledge(true); - } - - if (producerWindow > 0) - { - locator.setConfirmationWindowSize(producerWindow); - } - - locator.setMinLargeMessageSize(minSize); - - ClientSessionFactory sf = locator.createSessionFactory(); - - ClientSession session; - - Xid xid = null; - session = sf.createSession(null, null, isXA, false, false, preAck, 0); - - if (isXA) - { - xid = newXID(); - session.start(xid, XAResource.TMNOFLAGS); - } - - session.createQueue(ADDRESS, ADDRESS, null, true); - - ClientProducer producer = session.createProducer(ADDRESS); - - if (rollbackFirstSend) - { - sendMessages(numberOfMessages, numberOfBytes, delayDelivery, session, producer); - - if (isXA) - { - session.end(xid, XAResource.TMSUCCESS); - session.prepare(xid); - - session.close(); - - if (realFiles && restartOnXA) - { - server.stop(); - server.start(); - sf = locator.createSessionFactory(); - } - - session = sf.createSession(null, null, isXA, false, false, preAck, 0); - - Xid[] xids = session.recover(XAResource.TMSTARTRSCAN); - Assert.assertEquals(1, xids.length); - Assert.assertEquals(xid, xids[0]); - - session.rollback(xid); - producer = session.createProducer(ADDRESS); - xid = newXID(); - session.start(xid, XAResource.TMNOFLAGS); - } - else - { - session.rollback(); - } - - validateNoFilesOnLargeDir(); - } - - sendMessages(numberOfMessages, numberOfBytes, delayDelivery, session, producer); - - if (isXA) - { - session.end(xid, XAResource.TMSUCCESS); - session.prepare(xid); - - session.close(); - - if (realFiles && restartOnXA) - { - server.stop(); - server.start(); - //we need to recreate sf's - sf = locator.createSessionFactory(); - } - - session = sf.createSession(null, null, isXA, false, false, preAck, 0); - - Xid[] xids = session.recover(XAResource.TMSTARTRSCAN); - Assert.assertEquals(1, xids.length); - Assert.assertEquals(xid, xids[0]); - - producer = session.createProducer(ADDRESS); - - session.commit(xid, false); - xid = newXID(); - session.start(xid, XAResource.TMNOFLAGS); - } - else - { - session.commit(); - } - - session.close(); - - if (realFiles) - { - server.stop(); - - server = createServer(realFiles); - server.start(); - - sf = locator.createSessionFactory(); - } - - session = sf.createSession(null, null, isXA, false, false, preAck, 0); - - if (isXA) - { - xid = newXID(); - session.start(xid, XAResource.TMNOFLAGS); - } - - ClientConsumer consumer = null; - - for (int iteration = testBrowser ? 0 : 1; iteration < 2; iteration++) - { - session.stop(); - - // first time with a browser - consumer = session.createConsumer(ADDRESS, null, iteration == 0); - - if (useMessageConsumer) - { - final CountDownLatch latchDone = new CountDownLatch(numberOfMessages); - final AtomicInteger errors = new AtomicInteger(0); - - MessageHandler handler = new MessageHandler() - { - int msgCounter; - - public void onMessage(final ClientMessage message) - { - try - { - if (delayDelivery > 0) - { - long originalTime = (Long) message.getObjectProperty(new SimpleString("original-time")); - Assert.assertTrue(System.currentTimeMillis() - originalTime + "<" + delayDelivery, - System.currentTimeMillis() - originalTime >= delayDelivery); - } - - if (!preAck) - { - message.acknowledge(); - } - - Assert.assertNotNull(message); - - if (delayDelivery <= 0) - { - // right now there is no guarantee of ordered delivered on multiple scheduledMessages with - // the same - // scheduled delivery time - Assert.assertEquals(msgCounter, - ((Integer) message.getObjectProperty(new SimpleString("counter-message"))).intValue()); - } - - if (useStreamOnConsume) - { - final AtomicLong bytesRead = new AtomicLong(0); - message.saveToOutputStream(new OutputStream() - { - - @Override - public void write(final byte[] b) throws IOException - { - if (b[0] == UnitTestCase.getSamplebyte(bytesRead.get())) - { - bytesRead.addAndGet(b.length); - LargeMessageTestBase.log.debug("Read position " + bytesRead.get() + " on consumer"); - } - else - { - LargeMessageTestBase.log.warn("Received invalid packet at position " + bytesRead.get()); - } - } - - @Override - public void write(final int b) throws IOException - { - if (b == UnitTestCase.getSamplebyte(bytesRead.get())) - { - bytesRead.incrementAndGet(); - } - else - { - LargeMessageTestBase.log.warn("byte not as expected!"); - } - } - }); - - Assert.assertEquals(numberOfBytes, bytesRead.get()); - } - else - { - - ActiveMQBuffer buffer = message.getBodyBuffer(); - buffer.resetReaderIndex(); - for (long b = 0; b < numberOfBytes; b++) - { - if (b % (1024L * 1024L) == 0) - { - LargeMessageTestBase.log.debug("Read " + b + " bytes"); - } - - Assert.assertEquals(UnitTestCase.getSamplebyte(b), buffer.readByte()); - } - - try - { - buffer.readByte(); - Assert.fail("Supposed to throw an exception"); - } - catch (Exception e) - { - } - } - } - catch (Throwable e) - { - e.printStackTrace(); - LargeMessageTestBase.log.warn("Got an error", e); - errors.incrementAndGet(); - } - finally - { - latchDone.countDown(); - msgCounter++; - } - } - }; - - session.start(); - - consumer.setMessageHandler(handler); - - Assert.assertTrue(latchDone.await(waitOnConsumer, TimeUnit.SECONDS)); - Assert.assertEquals(0, errors.get()); - } - else - { - - session.start(); - - for (int i = 0; i < numberOfMessages; i++) - { - System.currentTimeMillis(); - - ClientMessage message = consumer.receive(waitOnConsumer + delayDelivery); - - Assert.assertNotNull(message); - - System.currentTimeMillis(); - - if (delayDelivery > 0) - { - long originalTime = (Long) message.getObjectProperty(new SimpleString("original-time")); - Assert.assertTrue(System.currentTimeMillis() - originalTime + "<" + delayDelivery, - System.currentTimeMillis() - originalTime >= delayDelivery); - } - - if (!preAck) - { - message.acknowledge(); - } - - Assert.assertNotNull(message); - - if (delayDelivery <= 0) - { - // right now there is no guarantee of ordered delivered on multiple scheduledMessages with the same - // scheduled delivery time - Assert.assertEquals(i, - ((Integer) message.getObjectProperty(new SimpleString("counter-message"))).intValue()); - } - - if (useStreamOnConsume) - { - final AtomicLong bytesRead = new AtomicLong(0); - message.saveToOutputStream(new OutputStream() - { - - @Override - public void write(final byte[] b) throws IOException - { - if (b[0] == UnitTestCase.getSamplebyte(bytesRead.get())) - { - bytesRead.addAndGet(b.length); - } - else - { - LargeMessageTestBase.log.warn("Received invalid packet at position " + bytesRead.get()); - } - - } - - @Override - public void write(final int b) throws IOException - { - if (bytesRead.get() % (1024L * 1024L) == 0) - { - LargeMessageTestBase.log.debug("Read " + bytesRead.get() + " bytes"); - } - if (b == (byte) 'a') - { - bytesRead.incrementAndGet(); - } - else - { - LargeMessageTestBase.log.warn("byte not as expected!"); - } - } - }); - - Assert.assertEquals(numberOfBytes, bytesRead.get()); - } - else - { - ActiveMQBuffer buffer = message.getBodyBuffer(); - buffer.resetReaderIndex(); - - for (long b = 0; b < numberOfBytes; b++) - { - if (b % (1024L * 1024L) == 0L) - { - LargeMessageTestBase.log.debug("Read " + b + " bytes"); - } - Assert.assertEquals(UnitTestCase.getSamplebyte(b), buffer.readByte()); - } - } - - } - - } - consumer.close(); - - if (iteration == 0) - { - if (isXA) - { - session.end(xid, XAResource.TMSUCCESS); - session.rollback(xid); - xid = newXID(); - session.start(xid, XAResource.TMNOFLAGS); - } - else - { - session.rollback(); - } - } - else - { - if (isXA) - { - session.end(xid, XAResource.TMSUCCESS); - session.commit(xid, true); - xid = newXID(); - session.start(xid, XAResource.TMNOFLAGS); - } - else - { - session.commit(); - } - } - } - - session.close(); - - Assert.assertEquals(0, ((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable()).getDeliveringCount()); - Assert.assertEquals(0, getMessageCount((Queue) server.getPostOffice().getBinding(ADDRESS).getBindable())); - - validateNoFilesOnLargeDir(); - - } - finally - { - locator.close(); - try - { - server.stop(); - } - catch (Throwable ignored) - { - } - } - } - - /** - * @param numberOfMessages - * @param numberOfBytes - * @param delayDelivery - * @param session - * @param producer - * @throws FileNotFoundException - * @throws IOException - * @throws org.apache.activemq.api.core.ActiveMQException - */ - private void sendMessages(final int numberOfMessages, - final long numberOfBytes, - final long delayDelivery, - final ClientSession session, - final ClientProducer producer) throws Exception - { - LargeMessageTestBase.log.debug("NumberOfBytes = " + numberOfBytes); - for (int i = 0; i < numberOfMessages; i++) - { - ClientMessage message = session.createMessage(true); - - // If the test is using more than 1M, we will only use the Streaming, as it require too much memory from the - // test - if (numberOfBytes > 1024 * 1024 || i % 2 == 0) - { - LargeMessageTestBase.log.debug("Sending message (stream)" + i); - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(numberOfBytes)); - } - else - { - LargeMessageTestBase.log.debug("Sending message (array)" + i); - byte[] bytes = new byte[(int) numberOfBytes]; - for (int j = 0; j < bytes.length; j++) - { - bytes[j] = UnitTestCase.getSamplebyte(j); - } - message.getBodyBuffer().writeBytes(bytes); - } - message.putIntProperty(new SimpleString("counter-message"), i); - if (delayDelivery > 0) - { - long time = System.currentTimeMillis(); - message.putLongProperty(new SimpleString("original-time"), time); - message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, time + delayDelivery); - - producer.send(message); - } - else - { - producer.send(message); - } - } - } - - protected ActiveMQBuffer createLargeBuffer(final int numberOfIntegers) - { - ActiveMQBuffer body = ActiveMQBuffers.fixedBuffer(DataConstants.SIZE_INT * numberOfIntegers); - - for (int i = 0; i < numberOfIntegers; i++) - { - body.writeInt(i); - } - - return body; - - } - - protected ClientMessage createLargeClientMessage(final ClientSession session, final int numberOfBytes) throws Exception - { - return createLargeClientMessage(session, numberOfBytes, true); - } - - protected ClientMessage createLargeClientMessage(final ClientSession session, final byte[] buffer, final boolean durable) throws Exception - { - ClientMessage msgs = session.createMessage(durable); - msgs.getBodyBuffer().writeBytes(buffer); - return msgs; - } - - protected ClientMessage createLargeClientMessage(final ClientSession session, - final long numberOfBytes, - final boolean persistent) throws Exception - { - - ClientMessage clientMessage = session.createMessage(persistent); - - clientMessage.setBodyInputStream(UnitTestCase.createFakeLargeStream(numberOfBytes)); - - return clientMessage; - } - - /** - * @param session - * @param queueToRead - * @param numberOfBytes - * @throws org.apache.activemq.api.core.ActiveMQException - * @throws FileNotFoundException - * @throws IOException - */ - protected void readMessage(final ClientSession session, final SimpleString queueToRead, final int numberOfBytes) throws ActiveMQException, - IOException - { - session.start(); - - ClientConsumer consumer = session.createConsumer(queueToRead); - - ClientMessage clientMessage = consumer.receive(5000); - - Assert.assertNotNull(clientMessage); - - clientMessage.acknowledge(); - - session.commit(); - - consumer.close(); - } - - protected OutputStream createFakeOutputStream() throws Exception - { - - return new OutputStream() - { - private boolean closed = false; - - private int count; - - @Override - public void close() throws IOException - { - super.close(); - closed = true; - } - - @Override - public void write(final int b) throws IOException - { - if (count++ % 1024 * 1024 == 0) - { - LargeMessageTestBase.log.debug("OutputStream received " + count + " bytes"); - } - if (closed) - { - throw new IOException("Stream was closed"); - } - } - - }; - - } - - // Private ------------------------------------------------------- - - // Inner classes ------------------------------------------------- -} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/transactions/DummyTransactionManagerLocator.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/transactions/DummyTransactionManagerLocator.java new file mode 100644 index 0000000000..1841cf85c3 --- /dev/null +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/transactions/DummyTransactionManagerLocator.java @@ -0,0 +1,94 @@ +/** + * 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.activemq.tests.util.transactions; + +import javax.transaction.HeuristicMixedException; +import javax.transaction.HeuristicRollbackException; +import javax.transaction.InvalidTransactionException; +import javax.transaction.NotSupportedException; +import javax.transaction.RollbackException; +import javax.transaction.SystemException; +import javax.transaction.Transaction; +import javax.transaction.TransactionManager; + +import org.apache.activemq.service.extensions.transactions.TransactionManagerLocator; + +/** + * @author Andy Taylor + */ +public class DummyTransactionManagerLocator implements TransactionManagerLocator,TransactionManager +{ + @Override + public void begin() throws NotSupportedException, SystemException + { + + } + + @Override + public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, RollbackException, SecurityException, SystemException + { + + } + + @Override + public int getStatus() throws SystemException + { + return 0; + } + + @Override + public Transaction getTransaction() throws SystemException + { + return null; + } + + @Override + public void resume(Transaction transaction) throws IllegalStateException, InvalidTransactionException, SystemException + { + + } + + @Override + public void rollback() throws IllegalStateException, SecurityException, SystemException + { + + } + + @Override + public void setRollbackOnly() throws IllegalStateException, SystemException + { + + } + + @Override + public void setTransactionTimeout(int i) throws SystemException + { + + } + + @Override + public Transaction suspend() throws SystemException + { + return null; + } + + @Override + public TransactionManager getTransactionManager() + { + return this; + } +} diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/transactions/TransactionManagerLocatorTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/transactions/TransactionManagerLocatorTest.java new file mode 100644 index 0000000000..9e91b1ae6b --- /dev/null +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/transactions/TransactionManagerLocatorTest.java @@ -0,0 +1,35 @@ +/** + * 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.activemq.tests.util.transactions; + +import org.apache.activemq.service.extensions.ServiceUtils; +import org.junit.Assert; +import org.junit.Test; + +/** + * * + * @author Andy Taylor + */ +public class TransactionManagerLocatorTest extends Assert +{ + @Test + public void getTM() + { + assertNotNull(ServiceUtils.getTransactionManager()); + assertEquals(ServiceUtils.getTransactionManager().getClass(), DummyTransactionManagerLocator.class); + } +} diff --git a/tests/integration-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator b/tests/integration-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator index e9ef6bf146..209f66f801 100644 --- a/tests/integration-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator +++ b/tests/integration-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator @@ -1 +1 @@ -org.apache.activemq.tests.extras.jms.bridge.TransactionManagerLocatorImpl +org.apache.activemq.tests.util.transactions.DummyTransactionManagerLocator From 11dadb5a2a22a0287f99ca836cbb60125f443896 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Fri, 6 Mar 2015 23:15:07 -0500 Subject: [PATCH 2/4] Fixing Logger errors on the testsuite Fixing the classpath so some tests would find the LogManager configured Fixing the dependency on the AssertionLoggerHandler so all the tests could also see it without further errors --- activemq-commons/pom.xml | 5 ++++ .../utils}/AssertionLoggerHandler.java | 30 +++++-------------- .../activemq-amqp-protocol/pom.xml | 14 +++++++++ .../activemq-proton-plug/pom.xml | 16 ++++++++++ .../WrongRoleFileConfigurationParserTest.java | 2 +- .../src/test/resources/logging.properties | 2 +- activemq-service-extensions/pom.xml | 16 ++++++++++ activemq-web/pom.xml | 16 ++++++++++ tests/config/logging.properties | 2 +- tests/config/logging.properties.trace | 2 +- tests/extra-tests/pom.xml | 7 +++++ tests/integration-tests/pom.xml | 10 +++++++ .../tests/integration/client/PagingTest.java | 2 +- .../server/AddressFullLoggingTest.java | 2 +- .../server/FileLockTimeoutTest.java | 2 +- .../server/SimpleStartStopTest.java | 2 +- tests/joram-tests/pom.xml | 9 ++++++ tests/performance-tests/pom.xml | 9 ++++++ tests/soak-tests/pom.xml | 9 ++++++ tests/stress-tests/pom.xml | 9 ++++++ tests/timing-tests/pom.xml | 9 ++++++ tests/unit-tests/pom.xml | 9 ++++++ 22 files changed, 154 insertions(+), 30 deletions(-) rename {activemq-server/src/test/java/org/apache/activemq/tests/logging => activemq-commons/src/main/java/org/apache/activemq/utils}/AssertionLoggerHandler.java (80%) diff --git a/activemq-commons/pom.xml b/activemq-commons/pom.xml index 2d1d7542e8..1296b078df 100644 --- a/activemq-commons/pom.xml +++ b/activemq-commons/pom.xml @@ -36,6 +36,11 @@ org.jboss.logging jboss-logging-processor + + org.jboss.logmanager + jboss-logmanager + compile + org.jboss.logging jboss-logging diff --git a/activemq-server/src/test/java/org/apache/activemq/tests/logging/AssertionLoggerHandler.java b/activemq-commons/src/main/java/org/apache/activemq/utils/AssertionLoggerHandler.java similarity index 80% rename from activemq-server/src/test/java/org/apache/activemq/tests/logging/AssertionLoggerHandler.java rename to activemq-commons/src/main/java/org/apache/activemq/utils/AssertionLoggerHandler.java index 8188495d1c..109617cf47 100644 --- a/activemq-server/src/test/java/org/apache/activemq/tests/logging/AssertionLoggerHandler.java +++ b/activemq-commons/src/main/java/org/apache/activemq/utils/AssertionLoggerHandler.java @@ -14,18 +14,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.tests.logging; +package org.apache.activemq.utils; -import java.util.Arrays; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import org.jboss.logmanager.ExtHandler; import org.jboss.logmanager.ExtLogRecord; -import org.junit.Assert; /** + * This class contains a tool where programs could intercept for LogMessage given an interval of time between {@link #startCapture()} + * and {@link #stopCapture()} + *

+ * Be careful with this use as this is intended for testing only (such as testcases) * + * * @author Emmanuel Hugonnet (c) 2013 Red Hat, inc. */ public class AssertionLoggerHandler extends ExtHandler @@ -62,7 +65,8 @@ public class AssertionLoggerHandler extends ExtHandler /** * is there any record matching Level? - * @param level + * + * @param level * @return */ public static boolean hasLevel(Level level) @@ -122,24 +126,6 @@ public class AssertionLoggerHandler extends ExtHandler return false; } - public static void assertMessageWasLoggedWithLevel(String expectedMessage, Level expectedLevel) - { - if (!messages.containsKey(expectedMessage)) - { - throw new AssertionError((Arrays.toString(messages.keySet().toArray()))); - } - Assert.assertEquals(expectedLevel, messages.get(expectedMessage).getLevel()); - } - - public static void assertMessageWasLoggedWithLevel(String assertionMessage, String expectedMessage, Level expectedLevel) - { - if (!messages.containsKey(expectedMessage)) - { - throw new AssertionError(assertionMessage); - } - Assert.assertEquals(assertionMessage, expectedLevel, messages.get(expectedMessage).getLevel()); - } - public static final void clear() { messages.clear(); diff --git a/activemq-protocols/activemq-amqp-protocol/pom.xml b/activemq-protocols/activemq-amqp-protocol/pom.xml index 6f6d68b42c..11993b8f14 100644 --- a/activemq-protocols/activemq-amqp-protocol/pom.xml +++ b/activemq-protocols/activemq-amqp-protocol/pom.xml @@ -48,6 +48,20 @@ + + + org.jboss.logmanager + jboss-logmanager + test + + + + + org.apache.activemq + activemq-commons + ${project.version} + + org.jboss.logging jboss-logging diff --git a/activemq-protocols/activemq-proton-plug/pom.xml b/activemq-protocols/activemq-proton-plug/pom.xml index e2411269a1..cc545b2d73 100644 --- a/activemq-protocols/activemq-proton-plug/pom.xml +++ b/activemq-protocols/activemq-proton-plug/pom.xml @@ -48,6 +48,22 @@ + + + + org.jboss.logmanager + jboss-logmanager + test + + + + + org.apache.activemq + activemq-commons + ${project.version} + test + + org.jboss.logging jboss-logging diff --git a/activemq-server/src/test/java/org/apache/activemq/core/config/impl/WrongRoleFileConfigurationParserTest.java b/activemq-server/src/test/java/org/apache/activemq/core/config/impl/WrongRoleFileConfigurationParserTest.java index 0773d3f8ac..b95ec5c4ad 100644 --- a/activemq-server/src/test/java/org/apache/activemq/core/config/impl/WrongRoleFileConfigurationParserTest.java +++ b/activemq-server/src/test/java/org/apache/activemq/core/config/impl/WrongRoleFileConfigurationParserTest.java @@ -20,7 +20,7 @@ import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import org.apache.activemq.core.deployers.impl.FileConfigurationParser; -import org.apache.activemq.tests.logging.AssertionLoggerHandler; +import org.apache.activemq.utils.AssertionLoggerHandler; import org.apache.activemq.tests.util.UnitTestCase; import org.junit.AfterClass; import org.junit.BeforeClass; diff --git a/activemq-server/src/test/resources/logging.properties b/activemq-server/src/test/resources/logging.properties index 4b42bc41a6..1ac02cc777 100644 --- a/activemq-server/src/test/resources/logging.properties +++ b/activemq-server/src/test/resources/logging.properties @@ -45,7 +45,7 @@ handler.FILE.formatter=PATTERN # Console handler configuration -handler.TEST=org.apache.activemq.tests.logging.AssertionLoggerHandler +handler.TEST=org.apache.activemq.utils.AssertionLoggerHandler handler.TEST.level=TRACE handler.TEST.formatter=PATTERN diff --git a/activemq-service-extensions/pom.xml b/activemq-service-extensions/pom.xml index 8fd86d0b04..da50e32234 100644 --- a/activemq-service-extensions/pom.xml +++ b/activemq-service-extensions/pom.xml @@ -55,6 +55,22 @@ junit test + + + + org.jboss.logmanager + jboss-logmanager + test + + + + + org.apache.activemq + activemq-commons + ${project.version} + + + diff --git a/activemq-web/pom.xml b/activemq-web/pom.xml index 9b99cf9719..53b3166a1d 100644 --- a/activemq-web/pom.xml +++ b/activemq-web/pom.xml @@ -56,6 +56,22 @@ jboss-logmanager test + + + + org.jboss.logmanager + jboss-logmanager + test + + + + + org.apache.activemq + activemq-commons + ${project.version} + + + diff --git a/tests/config/logging.properties b/tests/config/logging.properties index fb5d487adb..3062239331 100644 --- a/tests/config/logging.properties +++ b/tests/config/logging.properties @@ -51,7 +51,7 @@ handler.FILE.fileName=target/activemq.log handler.FILE.formatter=PATTERN # Console handler configuration -handler.TEST=org.apache.activemq.tests.logging.AssertionLoggerHandler +handler.TEST=org.apache.activemq.utils.AssertionLoggerHandler handler.TEST.level=TRACE handler.TEST.formatter=PATTERN diff --git a/tests/config/logging.properties.trace b/tests/config/logging.properties.trace index bc3b050cb3..c6c948d802 100644 --- a/tests/config/logging.properties.trace +++ b/tests/config/logging.properties.trace @@ -53,7 +53,7 @@ handler.FILE.fileName=target/activemq.log handler.FILE.formatter=PATTERN # Console handler configuration -handler.TEST=org.apache.activemq.tests.logging.AssertionLoggerHandler +handler.TEST=org.apache.activemq.utils.AssertionLoggerHandler handler.TEST.level=TRACE handler.TEST.formatter=PATTERN diff --git a/tests/extra-tests/pom.xml b/tests/extra-tests/pom.xml index 3329bf31c4..b439ae86ad 100644 --- a/tests/extra-tests/pom.xml +++ b/tests/extra-tests/pom.xml @@ -169,6 +169,13 @@ junit + + + org.apache.activemq + activemq-commons + ${project.version} + test + diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml index 3c32bfe978..93b8f9715f 100644 --- a/tests/integration-tests/pom.xml +++ b/tests/integration-tests/pom.xml @@ -223,6 +223,16 @@ 1.0.1 test + + + + org.apache.activemq + activemq-commons + ${project.version} + test + + + diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/PagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/PagingTest.java index 0e4751d8e0..4e53b9189f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/PagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/PagingTest.java @@ -73,7 +73,7 @@ import org.apache.activemq.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.core.settings.impl.AddressSettings; import org.apache.activemq.tests.integration.IntegrationTestLogger; -import org.apache.activemq.tests.logging.AssertionLoggerHandler; +import org.apache.activemq.utils.AssertionLoggerHandler; import org.apache.activemq.tests.util.ServiceTestBase; import org.apache.activemq.tests.util.UnitTestCase; import org.junit.Assert; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/AddressFullLoggingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/AddressFullLoggingTest.java index b887a07834..7d73029cb0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/AddressFullLoggingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/AddressFullLoggingTest.java @@ -33,7 +33,7 @@ import org.apache.activemq.api.core.client.ServerLocator; import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.core.settings.impl.AddressSettings; -import org.apache.activemq.tests.logging.AssertionLoggerHandler; +import org.apache.activemq.utils.AssertionLoggerHandler; import org.apache.activemq.tests.util.ServiceTestBase; import org.junit.AfterClass; import org.junit.Assert; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/FileLockTimeoutTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/FileLockTimeoutTest.java index 588feb61fe..1f295d30a5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/FileLockTimeoutTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/FileLockTimeoutTest.java @@ -27,7 +27,7 @@ import org.apache.activemq.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.JournalType; import org.apache.activemq.tests.integration.IntegrationTestLogger; -import org.apache.activemq.tests.logging.AssertionLoggerHandler; +import org.apache.activemq.utils.AssertionLoggerHandler; import org.apache.activemq.tests.util.ServiceTestBase; import org.junit.AfterClass; import org.junit.Assert; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/SimpleStartStopTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/SimpleStartStopTest.java index 265cb166f2..b5386c56c4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/SimpleStartStopTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/server/SimpleStartStopTest.java @@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.core.persistence.impl.journal.JournalRecordIds; import org.apache.activemq.core.server.ActiveMQServer; -import org.apache.activemq.tests.logging.AssertionLoggerHandler; +import org.apache.activemq.utils.AssertionLoggerHandler; import org.apache.activemq.tests.util.ServiceTestBase; import org.jboss.logmanager.Level; import org.junit.Test; diff --git a/tests/joram-tests/pom.xml b/tests/joram-tests/pom.xml index 81c0fd330a..05d7e65651 100644 --- a/tests/joram-tests/pom.xml +++ b/tests/joram-tests/pom.xml @@ -79,6 +79,15 @@ org.apache.geronimo.specs geronimo-jms_2.0_spec + + + + org.apache.activemq + activemq-commons + ${project.version} + test + + diff --git a/tests/performance-tests/pom.xml b/tests/performance-tests/pom.xml index 3e6dc27402..5e3c3f00e1 100644 --- a/tests/performance-tests/pom.xml +++ b/tests/performance-tests/pom.xml @@ -101,6 +101,15 @@ org.apache.geronimo.specs geronimo-jms_2.0_spec + + + + org.apache.activemq + activemq-commons + ${project.version} + test + + diff --git a/tests/soak-tests/pom.xml b/tests/soak-tests/pom.xml index a789581203..4e9d351d44 100644 --- a/tests/soak-tests/pom.xml +++ b/tests/soak-tests/pom.xml @@ -112,6 +112,15 @@ org.apache.geronimo.specs geronimo-jms_2.0_spec + + + + org.apache.activemq + activemq-commons + ${project.version} + test + + diff --git a/tests/stress-tests/pom.xml b/tests/stress-tests/pom.xml index b51dbbf7fd..fb71b42227 100644 --- a/tests/stress-tests/pom.xml +++ b/tests/stress-tests/pom.xml @@ -112,6 +112,15 @@ org.apache.geronimo.specs geronimo-jms_2.0_spec + + + + org.apache.activemq + activemq-commons + ${project.version} + test + + diff --git a/tests/timing-tests/pom.xml b/tests/timing-tests/pom.xml index 7a1def1729..7d95726e17 100644 --- a/tests/timing-tests/pom.xml +++ b/tests/timing-tests/pom.xml @@ -90,6 +90,15 @@ org.apache.geronimo.specs geronimo-jms_2.0_spec + + + + org.apache.activemq + activemq-commons + ${project.version} + test + + diff --git a/tests/unit-tests/pom.xml b/tests/unit-tests/pom.xml index 87a4fb2a09..39927ef631 100644 --- a/tests/unit-tests/pom.xml +++ b/tests/unit-tests/pom.xml @@ -94,6 +94,15 @@ org.jboss.logmanager jboss-logmanager + + + + org.apache.activemq + activemq-commons + ${project.version} + test + + From 02a2e8d14a1a1ca3804ad82114a00bf1ed859c85 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Fri, 6 Mar 2015 23:55:16 -0500 Subject: [PATCH 3/4] fixing source distribution to exclude extra-tests and data --- .../activemq/src/main/assembly/source-assembly.xml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/distribution/activemq/src/main/assembly/source-assembly.xml b/distribution/activemq/src/main/assembly/source-assembly.xml index 21f3cba8be..a55157e486 100644 --- a/distribution/activemq/src/main/assembly/source-assembly.xml +++ b/distribution/activemq/src/main/assembly/source-assembly.xml @@ -37,13 +37,10 @@ - tests/integration-tests/ - tests/jms-tests/ - tests/byteman-tests/ - tests/concurrent-tests/ - tests/performance-tests/ - tests/soak-tests/ - tests/stress-tests/ + tests/extra-tests/ + + + data/ From 440ae2e14648e22b297eeba68503e1115735aec6 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Sat, 7 Mar 2015 00:14:20 -0500 Subject: [PATCH 4/4] Fixing checkstyle on XATest This test wasn't compiled by the default profile for that reason I missed this. --- .../activemq/tests/extras/jms/xa/XATest.java | 192 +++++++++--------- 1 file changed, 94 insertions(+), 98 deletions(-) diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/xa/XATest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/xa/XATest.java index 4847e348d6..d036b76f30 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/xa/XATest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/xa/XATest.java @@ -36,7 +36,6 @@ import javax.transaction.xa.Xid; import com.arjuna.ats.arjuna.coordinator.TransactionReaper; import com.arjuna.ats.arjuna.coordinator.TxControl; import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple; - import org.apache.activemq.api.jms.ActiveMQJMSClient; import org.apache.activemq.core.client.impl.ClientSessionInternal; import org.apache.activemq.tests.extras.ExtrasTestLogger; @@ -48,14 +47,11 @@ import org.junit.Before; import org.junit.Test; /** - * * A XATestBase * * @author Tim Fox * @author Clebert Suconic * @version $Revision: 1.1 $ - * - * */ public class XATest extends JMSTestBase { @@ -70,7 +66,7 @@ public class XATest extends JMSTestBase protected Transaction suspendedTx; protected XAConnectionFactory xacf; - + protected Queue queue1; // Constructors -------------------------------------------------- @@ -84,7 +80,7 @@ public class XATest extends JMSTestBase super.setUp(); xacf = ActiveMQJMSClient.createConnectionFactory("tcp://localhost:61616", "test"); - + queue1 = createQueue("queue1"); TxControl.enable(); @@ -176,10 +172,10 @@ public class XATest extends JMSTestBase conn2.start(); Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer cons = sessReceiver.createConsumer(queue1); - TextMessage m2 = (TextMessage)cons.receive(1000); + TextMessage m2 = (TextMessage) cons.receive(1000); Assert.assertNotNull(m2); Assert.assertEquals("XATest1", m2.getText()); - m2 = (TextMessage)cons.receive(1000); + m2 = (TextMessage) cons.receive(1000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); } @@ -238,10 +234,10 @@ public class XATest extends JMSTestBase conn2.start(); Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer cons = sessReceiver.createConsumer(queue1); - TextMessage m2 = (TextMessage)cons.receive(5000); + TextMessage m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest1", m2.getText()); - m2 = (TextMessage)cons.receive(5000); + m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); } @@ -419,12 +415,12 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); - TextMessage m2 = (TextMessage)cons.receive(5000); + TextMessage m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest1", m2.getText()); - m2 = (TextMessage)cons.receive(5000); + m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); @@ -497,12 +493,12 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); - TextMessage m2 = (TextMessage)cons.receive(5000); + TextMessage m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest1", m2.getText()); - m2 = (TextMessage)cons.receive(5000); + m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); @@ -576,10 +572,10 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); - TextMessage m2 = (TextMessage)cons.receive(5000); + TextMessage m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest1", m2.getText()); - m2 = (TextMessage)cons.receive(5000); + m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); @@ -596,10 +592,10 @@ public class XATest extends JMSTestBase tx.enlistResource(res); tx.enlistResource(res2); - TextMessage m3 = (TextMessage)cons.receive(5000); + TextMessage m3 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m3); Assert.assertEquals("XATest1", m3.getText()); - m3 = (TextMessage)cons.receive(5000); + m3 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m3); Assert.assertEquals("XATest2", m3.getText()); @@ -657,10 +653,10 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); - TextMessage m2 = (TextMessage)cons.receive(5000); + TextMessage m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest1", m2.getText()); - m2 = (TextMessage)cons.receive(5000); + m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); @@ -677,10 +673,10 @@ public class XATest extends JMSTestBase tx.enlistResource(res); tx.enlistResource(res2); - TextMessage m3 = (TextMessage)cons.receive(5000); + TextMessage m3 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m3); Assert.assertEquals("XATest1", m3.getText()); - m3 = (TextMessage)cons.receive(5000); + m3 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m3); Assert.assertEquals("XATest2", m3.getText()); @@ -739,10 +735,10 @@ public class XATest extends JMSTestBase conn2.start(); Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer cons = sessReceiver.createConsumer(queue1); - TextMessage m2 = (TextMessage)cons.receive(5000); + TextMessage m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest1", m2.getText()); - m2 = (TextMessage)cons.receive(5000); + m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); } @@ -790,11 +786,11 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); - TextMessage m2 = (TextMessage)cons.receive(5000); + TextMessage m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest1", m2.getText()); - m2 = (TextMessage)cons.receive(5000); + m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); @@ -859,12 +855,12 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); - TextMessage m2 = (TextMessage)cons.receive(5000); + TextMessage m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest1", m2.getText()); - m2 = (TextMessage)cons.receive(5000); + m2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m2); Assert.assertEquals("XATest2", m2.getText()); @@ -880,12 +876,12 @@ public class XATest extends JMSTestBase tx = tm.getTransaction(); tx.enlistResource(res); - TextMessage m3 = (TextMessage)cons.receive(5000); + TextMessage m3 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m3); Assert.assertEquals("XATest1", m3.getText()); - m3 = (TextMessage)cons.receive(5000); + m3 = (TextMessage) cons.receive(5000); Assert.assertNotNull(m3); Assert.assertEquals("XATest2", m3.getText()); @@ -947,7 +943,7 @@ public class XATest extends JMSTestBase // Receive the messages, one on each consumer MessageConsumer cons1 = sess1.createConsumer(queue1); - TextMessage r1 = (TextMessage)cons1.receive(5000); + TextMessage r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish1", r1.getText()); @@ -955,7 +951,7 @@ public class XATest extends JMSTestBase cons1.close(); MessageConsumer cons2 = sess2.createConsumer(queue1); - TextMessage r2 = (TextMessage)cons2.receive(5000); + TextMessage r2 = (TextMessage) cons2.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("jellyfish2", r2.getText()); @@ -970,7 +966,7 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); conn2.start(); - TextMessage r3 = (TextMessage)cons.receive(100); + TextMessage r3 = (TextMessage) cons.receive(100); Assert.assertNull(r3); } @@ -1012,9 +1008,9 @@ public class XATest extends JMSTestBase // Create 2 sessions and enlist them XASession sess1 = conn.createXASession(); - ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource(); + ClientSessionInternal res1 = (ClientSessionInternal) sess1.getXAResource(); XASession sess2 = conn.createXASession(); - ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource(); + ClientSessionInternal res2 = (ClientSessionInternal) sess2.getXAResource(); res1.setForceNotSameRM(true); res2.setForceNotSameRM(true); @@ -1024,7 +1020,7 @@ public class XATest extends JMSTestBase // Receive the messages, one on each consumer MessageConsumer cons1 = sess1.createConsumer(queue1); - TextMessage r1 = (TextMessage)cons1.receive(5000); + TextMessage r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish1", r1.getText()); @@ -1032,7 +1028,7 @@ public class XATest extends JMSTestBase cons1.close(); MessageConsumer cons2 = sess2.createConsumer(queue1); - TextMessage r2 = (TextMessage)cons2.receive(5000); + TextMessage r2 = (TextMessage) cons2.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("jellyfish2", r2.getText()); @@ -1047,7 +1043,7 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); conn2.start(); - TextMessage r3 = (TextMessage)cons.receive(100); + TextMessage r3 = (TextMessage) cons.receive(100); Assert.assertNull(r3); } @@ -1095,9 +1091,9 @@ public class XATest extends JMSTestBase // Create 2 sessions and enlist them XASession sess1 = conn.createXASession(); - ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource(); + ClientSessionInternal res1 = (ClientSessionInternal) sess1.getXAResource(); XASession sess2 = conn.createXASession(); - ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource(); + ClientSessionInternal res2 = (ClientSessionInternal) sess2.getXAResource(); Transaction tx = tm.getTransaction(); tx.enlistResource(res1); @@ -1105,12 +1101,12 @@ public class XATest extends JMSTestBase // Receive the messages, two on each consumer MessageConsumer cons1 = sess1.createConsumer(queue1); - TextMessage r1 = (TextMessage)cons1.receive(5000); + TextMessage r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish1", r1.getText()); - r1 = (TextMessage)cons1.receive(5000); + r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish2", r1.getText()); @@ -1118,12 +1114,12 @@ public class XATest extends JMSTestBase cons1.close(); MessageConsumer cons2 = sess2.createConsumer(queue1); - TextMessage r2 = (TextMessage)cons2.receive(5000); + TextMessage r2 = (TextMessage) cons2.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("jellyfish3", r2.getText()); - r2 = (TextMessage)cons2.receive(5000); + r2 = (TextMessage) cons2.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("jellyfish4", r2.getText()); @@ -1147,7 +1143,7 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); conn2.start(); - TextMessage r = (TextMessage)cons.receive(5000); + TextMessage r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); boolean session1First = false; @@ -1167,19 +1163,19 @@ public class XATest extends JMSTestBase if (session1First) { - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish2", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish3", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); @@ -1188,26 +1184,26 @@ public class XATest extends JMSTestBase } else { - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish4", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish1", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish2", r.getText()); } - r = (TextMessage)cons.receive(100); + r = (TextMessage) cons.receive(100); Assert.assertNull(r); @@ -1254,9 +1250,9 @@ public class XATest extends JMSTestBase // Create 2 sessions and enlist them XASession sess1 = conn.createXASession(); - ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource(); + ClientSessionInternal res1 = (ClientSessionInternal) sess1.getXAResource(); XASession sess2 = conn.createXASession(); - ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource(); + ClientSessionInternal res2 = (ClientSessionInternal) sess2.getXAResource(); res1.setForceNotSameRM(true); res2.setForceNotSameRM(true); @@ -1266,12 +1262,12 @@ public class XATest extends JMSTestBase // Receive the messages, two on each consumer MessageConsumer cons1 = sess1.createConsumer(queue1); - TextMessage r1 = (TextMessage)cons1.receive(5000); + TextMessage r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish1", r1.getText()); - r1 = (TextMessage)cons1.receive(5000); + r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish2", r1.getText()); @@ -1282,12 +1278,12 @@ public class XATest extends JMSTestBase Thread.sleep(500); MessageConsumer cons2 = sess2.createConsumer(queue1); - TextMessage r2 = (TextMessage)cons2.receive(5000); + TextMessage r2 = (TextMessage) cons2.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("jellyfish3", r2.getText()); - r2 = (TextMessage)cons2.receive(5000); + r2 = (TextMessage) cons2.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("jellyfish4", r2.getText()); @@ -1311,7 +1307,7 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); conn2.start(); - TextMessage r = (TextMessage)cons.receive(5000); + TextMessage r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); boolean session1First = false; @@ -1331,19 +1327,19 @@ public class XATest extends JMSTestBase if (session1First) { - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish2", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish3", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); @@ -1352,26 +1348,26 @@ public class XATest extends JMSTestBase } else { - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish4", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish1", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish2", r.getText()); } - r = (TextMessage)cons.receive(100); + r = (TextMessage) cons.receive(100); Assert.assertNull(r); } @@ -1424,27 +1420,27 @@ public class XATest extends JMSTestBase tx.enlistResource(res2); MessageConsumer cons1 = sess1.createConsumer(queue1); - TextMessage r1 = (TextMessage)cons1.receive(5000); + TextMessage r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish1", r1.getText()); - r1 = (TextMessage)cons1.receive(5000); + r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish2", r1.getText()); - r1 = (TextMessage)cons1.receive(5000); + r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish3", r1.getText()); - r1 = (TextMessage)cons1.receive(5000); + r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish4", r1.getText()); - r1 = (TextMessage)cons1.receive(100); + r1 = (TextMessage) cons1.receive(100); Assert.assertNull(r1); @@ -1476,31 +1472,31 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); conn2.start(); - TextMessage r = (TextMessage)cons.receive(5000); + TextMessage r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish1", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish2", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish3", r.getText()); - r = (TextMessage)cons.receive(5000); + r = (TextMessage) cons.receive(5000); Assert.assertNotNull(r); Assert.assertEquals("jellyfish4", r.getText()); - r = (TextMessage)cons.receive(100); + r = (TextMessage) cons.receive(100); Assert.assertNull(r); } @@ -1565,11 +1561,11 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); conn2.start(); - TextMessage r1 = (TextMessage)cons.receive(5000); + TextMessage r1 = (TextMessage) cons.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("echidna1", r1.getText()); - TextMessage r2 = (TextMessage)cons.receive(5000); + TextMessage r2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("echidna2", r2.getText()); @@ -1606,9 +1602,9 @@ public class XATest extends JMSTestBase // Create 2 sessions and enlist them XASession sess1 = conn.createXASession(); - ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource(); + ClientSessionInternal res1 = (ClientSessionInternal) sess1.getXAResource(); XASession sess2 = conn.createXASession(); - ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource(); + ClientSessionInternal res2 = (ClientSessionInternal) sess2.getXAResource(); res1.setForceNotSameRM(true); res2.setForceNotSameRM(true); @@ -1637,11 +1633,11 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); conn2.start(); - TextMessage r1 = (TextMessage)cons.receive(5000); + TextMessage r1 = (TextMessage) cons.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("echidna1", r1.getText()); - TextMessage r2 = (TextMessage)cons.receive(5000); + TextMessage r2 = (TextMessage) cons.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("echidna2", r2.getText()); @@ -1708,7 +1704,7 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); conn2.start(); - TextMessage r1 = (TextMessage)cons.receive(100); + TextMessage r1 = (TextMessage) cons.receive(100); Assert.assertNull(r1); } @@ -1742,9 +1738,9 @@ public class XATest extends JMSTestBase // Create 2 sessions and enlist them XASession sess1 = conn.createXASession(); - ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource(); + ClientSessionInternal res1 = (ClientSessionInternal) sess1.getXAResource(); XASession sess2 = conn.createXASession(); - ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource(); + ClientSessionInternal res2 = (ClientSessionInternal) sess2.getXAResource(); res1.setForceNotSameRM(true); res2.setForceNotSameRM(true); @@ -1773,7 +1769,7 @@ public class XATest extends JMSTestBase MessageConsumer cons = sess.createConsumer(queue1); conn2.start(); - TextMessage r1 = (TextMessage)cons.receive(100); + TextMessage r1 = (TextMessage) cons.receive(100); Assert.assertNull(r1); } finally @@ -1823,7 +1819,7 @@ public class XATest extends JMSTestBase // Receive one message in one tx - TextMessage r1 = (TextMessage)cons1.receive(5000); + TextMessage r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish1", r1.getText()); @@ -1838,7 +1834,7 @@ public class XATest extends JMSTestBase tx2.enlistResource(res1); // Receive 2nd message in a different tx - TextMessage r2 = (TextMessage)cons1.receive(5000); + TextMessage r2 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("jellyfish2", r2.getText()); @@ -1853,7 +1849,7 @@ public class XATest extends JMSTestBase Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE); conn2.start(); MessageConsumer cons = sess.createConsumer(queue1); - TextMessage r3 = (TextMessage)cons.receive(100); + TextMessage r3 = (TextMessage) cons.receive(100); Assert.assertNull(r3); // now resume the first tx and then commit it @@ -1908,7 +1904,7 @@ public class XATest extends JMSTestBase // Receive one message in one tx - TextMessage r1 = (TextMessage)cons1.receive(5000); + TextMessage r1 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("jellyfish1", r1.getText()); @@ -1923,7 +1919,7 @@ public class XATest extends JMSTestBase tx2.enlistResource(res1); // Receive 2nd message in a different tx - TextMessage r2 = (TextMessage)cons1.receive(5000); + TextMessage r2 = (TextMessage) cons1.receive(5000); Assert.assertNotNull(r2); Assert.assertEquals("jellyfish2", r2.getText()); @@ -1941,11 +1937,11 @@ public class XATest extends JMSTestBase conn2.start(); MessageConsumer cons = sess.createConsumer(queue1); - TextMessage r3 = (TextMessage)cons.receive(5000); + TextMessage r3 = (TextMessage) cons.receive(5000); Assert.assertNotNull(r3); Assert.assertEquals("jellyfish2", r3.getText()); - r3 = (TextMessage)cons.receive(100); + r3 = (TextMessage) cons.receive(100); Assert.assertNull(r3); // rollback the other tx @@ -1953,10 +1949,10 @@ public class XATest extends JMSTestBase tm.rollback(); // Verify the first message is now available - r3 = (TextMessage)cons.receive(5000); + r3 = (TextMessage) cons.receive(5000); Assert.assertNotNull(r3); Assert.assertEquals("jellyfish1", r3.getText()); - r3 = (TextMessage)cons.receive(100); + r3 = (TextMessage) cons.receive(100); Assert.assertNull(r3); } @@ -2024,10 +2020,10 @@ public class XATest extends JMSTestBase Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE); conn2.start(); MessageConsumer cons = sess.createConsumer(queue1); - TextMessage r1 = (TextMessage)cons.receive(5000); + TextMessage r1 = (TextMessage) cons.receive(5000); Assert.assertNotNull(r1); Assert.assertEquals("kangaroo2", r1.getText()); - TextMessage r2 = (TextMessage)cons.receive(100); + TextMessage r2 = (TextMessage) cons.receive(100); Assert.assertNull(r2); // now resume the first tx and then commit it @@ -2036,7 +2032,7 @@ public class XATest extends JMSTestBase tm.commit(); // verify that the first text message is received - TextMessage r3 = (TextMessage)cons.receive(5000); + TextMessage r3 = (TextMessage) cons.receive(5000); Assert.assertNotNull(r3); Assert.assertEquals("kangaroo1", r3.getText());