You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2009/06/18 14:42:29 UTC

svn commit: r786040 [5/6] - in /activemq/sandbox/activemq-flow: activemq-all/src/test/java/org/apache/activemq/legacy/ activemq-all/src/test/java/org/apache/activemq/legacy/broker/ activemq-all/src/test/java/org/apache/activemq/legacy/broker/advisory/ ...

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,92 @@
+/**
+ * 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.legacy.test2;
+
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision: 1.3 $
+ */
+public class JmsTopicSendReceiveTest extends JmsSendReceiveTestSupport {
+    private static final Log LOG = LogFactory.getLog(JmsTopicSendReceiveTest.class);
+
+    protected Connection connection;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        connectionFactory = createConnectionFactory();
+        connection = createConnection();
+        if (durable) {
+            connection.setClientID(getClass().getName());
+        }
+
+        LOG.info("Created connection: " + connection);
+
+        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        LOG.info("Created session: " + session);
+        producer = session.createProducer(null);
+        producer.setDeliveryMode(deliveryMode);
+
+        LOG.info("Created producer: " + producer + " delivery mode = " + (deliveryMode == DeliveryMode.PERSISTENT ? "PERSISTENT" : "NON_PERSISTENT"));
+
+        if (topic) {
+            consumerDestination = session.createTopic(getConsumerSubject());
+            producerDestination = session.createTopic(getProducerSubject());
+        } else {
+            consumerDestination = session.createQueue(getConsumerSubject());
+            producerDestination = session.createQueue(getProducerSubject());
+        }
+
+        LOG.info("Created  consumer destination: " + consumerDestination + " of type: " + consumerDestination.getClass());
+        LOG.info("Created  producer destination: " + producerDestination + " of type: " + producerDestination.getClass());
+        consumer = createConsumer();
+        consumer.setMessageListener(this);
+        connection.start();
+
+        // log.info("Created connection: " + connection);
+    }
+
+    protected MessageConsumer createConsumer() throws JMSException {
+        if (durable) {
+            LOG.info("Creating durable consumer");
+            return session.createDurableSubscriber((Topic)consumerDestination, getName());
+        }
+        return session.createConsumer(consumerDestination);
+    }
+
+    protected void tearDown() throws Exception {
+        LOG.info("Dumping stats...");
+        // connectionFactory.getStats().reset();
+
+        LOG.info("Closing down connection");
+
+        /** TODO we should be able to shut down properly */
+        session.close();
+        connection.close();
+    }
+
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsTest.java Thu Jun 18 12:42:23 2009
@@ -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.activemq.legacy.test2;
+
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+/**
+ * @version
+ */
+public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTestSupport {
+
+    private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
+        .getLog(JmsTopicSendReceiveWithTwoConnectionsTest.class);
+
+    protected Connection sendConnection;
+    protected Connection receiveConnection;
+    protected Session receiveSession;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        connectionFactory = createConnectionFactory();
+
+        sendConnection = createSendConnection();
+        sendConnection.start();
+
+        receiveConnection = createReceiveConnection();
+        receiveConnection.start();
+
+        LOG.info("Created sendConnection: " + sendConnection);
+        LOG.info("Created receiveConnection: " + receiveConnection);
+
+        session = sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        receiveSession = receiveConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        LOG.info("Created sendSession: " + session);
+        LOG.info("Created receiveSession: " + receiveSession);
+
+        producer = session.createProducer(null);
+        producer.setDeliveryMode(deliveryMode);
+
+        LOG.info("Created producer: " + producer + " delivery mode = "
+                 + (deliveryMode == DeliveryMode.PERSISTENT ? "PERSISTENT" : "NON_PERSISTENT"));
+
+        if (topic) {
+            consumerDestination = session.createTopic(getConsumerSubject());
+            producerDestination = session.createTopic(getProducerSubject());
+        } else {
+            consumerDestination = session.createQueue(getConsumerSubject());
+            producerDestination = session.createQueue(getProducerSubject());
+        }
+
+        LOG.info("Created  consumer destination: " + consumerDestination + " of type: "
+                 + consumerDestination.getClass());
+        LOG.info("Created  producer destination: " + producerDestination + " of type: "
+                 + producerDestination.getClass());
+
+        consumer = createConsumer(receiveSession, consumerDestination);
+        consumer.setMessageListener(this);
+
+        LOG.info("Started connections");
+    }
+
+    protected Connection createReceiveConnection() throws Exception {
+        return createConnection();
+    }
+
+    protected Connection createSendConnection() throws Exception {
+        return createConnection();
+    }
+
+    protected MessageConsumer createConsumer(Session session, Destination dest) throws JMSException {
+        return session.createConsumer(dest);
+    }
+
+    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
+        return new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+    }
+
+    protected void tearDown() throws Exception {
+        session.close();
+        receiveSession.close();
+        sendConnection.close();
+        receiveConnection.close();
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,31 @@
+/**
+ * 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.legacy.test2;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+/**
+ * 
+ * @version $Revision$
+ */
+public class JmsTopicSendReceiveWithTwoConnectionsWithJMXTest extends
+    JmsTopicSendReceiveWithTwoConnectionsTest {
+
+    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
+        return new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false&broker.useJmx=true");
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendReceiveWithTwoConnectionsWithJMXTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendSameMessageTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendSameMessageTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendSameMessageTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendSameMessageTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,49 @@
+/**
+ * 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.legacy.test2;
+
+import javax.jms.TextMessage;
+
+
+/**
+ * @version $Revision: 1.3 $
+ */
+public class JmsTopicSendSameMessageTest extends JmsTopicSendReceiveWithTwoConnectionsTest {
+
+    private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
+        .getLog(JmsTopicSendSameMessageTest.class);
+
+    public void testSendReceive() throws Exception {
+        messages.clear();
+
+        TextMessage message = session.createTextMessage();
+
+        for (int i = 0; i < data.length; i++) {
+            message.setText(data[i]);
+            message.setStringProperty("stringProperty", data[i]);
+            message.setIntProperty("intProperty", i);
+
+            if (verbose) {
+                LOG.info("About to send a message: " + message + " with text: " + data[i]);
+            }
+
+            producer.send(producerDestination, message);
+        }
+
+        assertMessagesAreReceived();
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendSameMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/JmsTopicSendSameMessageTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/TestSupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/TestSupport.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/TestSupport.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/TestSupport.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,142 @@
+/**
+ * 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.legacy.test2;
+
+import java.io.File;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.TextMessage;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTopic;
+
+/**
+ * Useful base class for unit test cases
+ * 
+ * @version $Revision: 1.5 $
+ */
+public class TestSupport extends TestCase {
+
+    protected ActiveMQConnectionFactory connectionFactory;
+    protected boolean topic = true;
+
+    public TestSupport() {
+        super();
+    }
+
+    public TestSupport(String name) {
+        super(name);
+    }
+
+    protected ActiveMQMessage createMessage() {
+        return new ActiveMQMessage();
+    }
+
+    protected Destination createDestination(String subject) {
+        if (topic) {
+            return new ActiveMQTopic(subject);
+        } else {
+            return new ActiveMQQueue(subject);
+        }
+    }
+
+    protected Destination createDestination() {
+        return createDestination(getDestinationString());
+    }
+
+    /**
+     * Returns the name of the destination used in this test case
+     */
+    protected String getDestinationString() {
+        return getClass().getName() + "." + getName();
+    }
+
+    /**
+     * @param messsage
+     * @param firstSet
+     * @param secondSet
+     */
+    protected void assertTextMessagesEqual(String messsage, Message[] firstSet, Message[] secondSet)
+        throws JMSException {
+        assertEquals("Message count does not match: " + messsage, firstSet.length, secondSet.length);
+        for (int i = 0; i < secondSet.length; i++) {
+            TextMessage m1 = (TextMessage)firstSet[i];
+            TextMessage m2 = (TextMessage)secondSet[i];
+            assertFalse("Message " + (i + 1) + " did not match : " + messsage + ": expected {" + m1
+                        + "}, but was {" + m2 + "}", m1 == null ^ m2 == null);
+            assertEquals("Message " + (i + 1) + " did not match: " + messsage + ": expected {" + m1
+                         + "}, but was {" + m2 + "}", m1.getText(), m2.getText());
+        }
+    }
+
+    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
+        return new ActiveMQConnectionFactory("vm://localhost?broker=jaxb:classpath:non-persistent-activemq.xml");
+    }
+
+    /**
+     * Factory method to create a new connection
+     */
+    protected Connection createConnection() throws Exception {
+        return getConnectionFactory().createConnection();
+    }
+
+    public ActiveMQConnectionFactory getConnectionFactory() throws Exception {
+        if (connectionFactory == null) {
+            connectionFactory = createConnectionFactory();
+            assertTrue("Should have created a connection factory!", connectionFactory != null);
+        }
+        return connectionFactory;
+    }
+
+    protected String getConsumerSubject() {
+        return getSubject();
+    }
+
+    protected String getProducerSubject() {
+        return getSubject();
+    }
+
+    protected String getSubject() {
+        return getName();
+    }
+
+    public static void recursiveDelete(File f) {
+        if (f.isDirectory()) {
+            File[] files = f.listFiles();
+            for (int i = 0; i < files.length; i++) {
+                recursiveDelete(files[i]);
+            }
+        }
+        f.delete();
+    }
+
+    public static void removeMessageStore() {
+        if (System.getProperty("activemq.store.dir") != null) {
+            recursiveDelete(new File(System.getProperty("activemq.store.dir")));
+        }
+        if (System.getProperty("derby.system.home") != null) {
+            recursiveDelete(new File(System.getProperty("derby.system.home")));
+        }
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/TestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test2/TestSupport.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/CreateConsumerButDontStartConnectionWarningTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/CreateConsumerButDontStartConnectionWarningTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/CreateConsumerButDontStartConnectionWarningTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/CreateConsumerButDontStartConnectionWarningTest.java Thu Jun 18 12:42:23 2009
@@ -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.activemq.legacy.test3;
+
+import javax.jms.JMSException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class CreateConsumerButDontStartConnectionWarningTest extends JmsQueueSendReceiveTest {
+    private static final transient Log LOG = LogFactory.getLog(CreateConsumerButDontStartConnectionWarningTest.class);
+
+    @Override
+    protected void startConnection() throws JMSException {
+        // don't start the connection
+    }
+
+    @Override
+    protected void assertMessagesAreReceived() throws JMSException {
+        try {
+            Thread.sleep(1000);
+        } catch (InterruptedException e) {
+            LOG.warn("Caught: " + e, e);
+        }
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/CreateConsumerButDontStartConnectionWarningTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsDurableTopicTransactionTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsDurableTopicTransactionTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsDurableTopicTransactionTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsDurableTopicTransactionTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.legacy.test3;
+
+import javax.jms.DeliveryMode;
+
+
+/**
+ * @version $Revision: 1.2 $
+ */
+public class JmsDurableTopicTransactionTest extends JmsTopicTransactionTest {
+
+    /**
+     * @see JmsTransactionTestSupport#getJmsResourceProvider()
+     */
+    protected JmsResourceProvider getJmsResourceProvider() {
+        JmsResourceProvider provider = new JmsResourceProvider();
+        provider.setTopic(true);
+        provider.setDeliveryMode(DeliveryMode.PERSISTENT);
+        provider.setClientID(getClass().getName());
+        provider.setDurableName(getName());
+        return provider;
+    }
+
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsDurableTopicTransactionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsDurableTopicTransactionTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueCompositeSendReceiveTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueCompositeSendReceiveTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueCompositeSendReceiveTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueCompositeSendReceiveTest.java Thu Jun 18 12:42:23 2009
@@ -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.activemq.legacy.test3;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.Topic;
+
+
+
+/**
+ * @version $Revision: 1.3 $
+ */
+public class JmsQueueCompositeSendReceiveTest extends JmsTopicSendReceiveTest {
+    private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
+            .getLog(JmsQueueCompositeSendReceiveTest.class);
+    
+    /**
+     * Sets a test to have a queue destination and non-persistent delivery mode.
+     *
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        topic = false;
+        deliveryMode = DeliveryMode.NON_PERSISTENT;
+        super.setUp();
+    }
+
+    /**
+     * Returns the consumer subject.
+     *
+     * @return String - consumer subject
+     * @see org.apache.activemq.legacy.test3.TestSupport#getConsumerSubject()
+     */
+    protected String getConsumerSubject() {
+        return "FOO.BAR.HUMBUG";
+    }
+
+    /**
+     * Returns the producer subject.
+     *
+     * @return String - producer subject
+     * @see org.apache.activemq.legacy.test3.TestSupport#getProducerSubject()
+     */
+    protected String getProducerSubject() {
+        return "FOO.BAR.HUMBUG,FOO.BAR.HUMBUG2";
+    }
+   
+    /**
+     * Test if all the messages sent are being received.
+     *
+     * @throws Exception
+     */
+    public void testSendReceive() throws Exception {
+        super.testSendReceive();
+        messages.clear();
+        Destination consumerDestination = consumeSession.createQueue("FOO.BAR.HUMBUG2");
+        LOG.info("Created  consumer destination: " + consumerDestination + " of type: " + consumerDestination.getClass());
+        MessageConsumer consumer = null;
+        if (durable) {
+            LOG.info("Creating durable consumer");
+            consumer = consumeSession.createDurableSubscriber((Topic) consumerDestination, getName());
+        } else {
+            consumer = consumeSession.createConsumer(consumerDestination);
+        }
+        consumer.setMessageListener(this);
+
+        assertMessagesAreReceived();
+        LOG.info("" + data.length + " messages(s) received, closing down connections");
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueCompositeSendReceiveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueCompositeSendReceiveTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueRequestReplyTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueRequestReplyTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueRequestReplyTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueRequestReplyTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,34 @@
+/**
+ * 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.legacy.test3;
+
+
+/**
+ * @version $Revision: 1.2 $
+ */
+public class JmsQueueRequestReplyTest extends JmsTopicRequestReplyTest {
+
+    /**
+     * Set up the test with a queue.
+     * 
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        topic = false;
+        super.setUp();
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueRequestReplyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueRequestReplyTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,34 @@
+/**
+ * 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.legacy.test3;
+
+
+/**
+ * @version $Revision: 1.2 $
+ */
+public class JmsQueueSendReceiveTest extends JmsTopicSendReceiveTest {
+
+    /**
+     * Set up the test with a queue.
+     * 
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        topic = false;
+        super.setUp();
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java Thu Jun 18 12:42:23 2009
@@ -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.activemq.legacy.test3;
+
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.legacy.broker.BrokerService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision$
+ */
+public class JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest extends JmsQueueSendReceiveTwoConnectionsTest {
+    private static final Log LOG = LogFactory.getLog(JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.class);
+
+    private Queue<Exception> errors = new ConcurrentLinkedQueue<Exception>();
+    private int delayBeforeStartingBroker = 1000;
+    private BrokerService broker;
+
+    public void startBroker() {
+        // Initialize the broker
+        LOG.info("Lets wait: " + delayBeforeStartingBroker + " millis  before creating the broker");
+        try {
+            Thread.sleep(delayBeforeStartingBroker);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+
+        LOG.info("Now starting the broker");
+        try {
+            broker = new BrokerService();
+            broker.setPersistent(false);
+            broker.addConnector("tcp://localhost:61616");
+            broker.start();
+        } catch (Exception e) {
+            LOG.info("Caught: " + e);
+            errors.add(e);
+        }
+    }
+
+    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
+        return new ActiveMQConnectionFactory("failover:(tcp://localhost:61616)?maxReconnectAttempts=10&useExponentialBackOff=false&initialReconnectDelay=200");
+    }
+
+    protected void setUp() throws Exception {
+        // now lets asynchronously start a broker
+        Thread thread = new Thread() {
+            public void run() {
+                startBroker();
+            }
+        };
+        thread.start();
+
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        if (broker != null) {
+            broker.stop();
+        }
+        if (!errors.isEmpty()) {
+            Exception e = errors.remove();
+            throw e;
+        }
+    }
+
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsStartBeforeBrokerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,36 @@
+/**
+ * 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.legacy.test3;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision: 1.2 $
+ */
+public class JmsQueueSendReceiveTwoConnectionsTest extends JmsTopicSendReceiveWithTwoConnectionsTest {
+
+    /**
+     * Set up the test with a queue and using two connections.
+     * 
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        topic = false;
+        super.setUp();
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveTwoConnectionsTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveUsingTwoSessionsTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveUsingTwoSessionsTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveUsingTwoSessionsTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveUsingTwoSessionsTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,34 @@
+/**
+ * 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.legacy.test3;
+
+
+/**
+ * @version $Revision: 1.2 $
+ */
+public class JmsQueueSendReceiveUsingTwoSessionsTest extends JmsQueueSendReceiveTest {
+
+    /**
+     * Set up the test using two sessions.
+     * 
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        useSeparateSession = true;
+        super.setUp();
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveUsingTwoSessionsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueSendReceiveUsingTwoSessionsTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTopicCompositeSendReceiveTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTopicCompositeSendReceiveTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTopicCompositeSendReceiveTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTopicCompositeSendReceiveTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,87 @@
+/**
+ * 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.legacy.test3;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.Topic;
+
+
+
+/**
+ * @version $Revision: 1.3 $
+ */
+public class JmsQueueTopicCompositeSendReceiveTest extends JmsTopicSendReceiveTest {
+    private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
+            .getLog(JmsQueueTopicCompositeSendReceiveTest.class);
+    Destination consumerDestination2;
+    MessageConsumer consumer2;
+
+    /**
+     * Sets a test to have a queue destination and non-persistent delivery mode.
+     *
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        deliveryMode = DeliveryMode.NON_PERSISTENT;
+        topic = false;
+        super.setUp();
+        consumerDestination2 = consumeSession.createTopic("FOO.BAR.HUMBUG2");
+        LOG.info("Created  consumer destination: " + consumerDestination2 + " of type: " + consumerDestination2.getClass());
+        if (durable) {
+            LOG.info("Creating durable consumer");
+            consumer2 = consumeSession.createDurableSubscriber((Topic) consumerDestination2, getName());
+        } else {
+            consumer2 = consumeSession.createConsumer(consumerDestination2);
+        }
+
+    }
+
+    /**
+     * Returns the consumer subject.
+     *
+     * @return String - consumer subject
+     * @see org.apache.activemq.legacy.test3.TestSupport#getConsumerSubject()
+     */
+    protected String getConsumerSubject() {
+        return "FOO.BAR.HUMBUG";
+    }
+
+    /**
+     * Returns the producer subject.
+     *
+     * @return String - producer subject
+     * @see org.apache.activemq.legacy.test3.TestSupport#getProducerSubject()
+     */
+    protected String getProducerSubject() {
+        return "queue://FOO.BAR.HUMBUG,topic://FOO.BAR.HUMBUG2";
+    }
+
+    /**
+     * Test if all the messages sent are being received.
+     *
+     * @throws Exception
+     */
+    public void testSendReceive() throws Exception {
+        super.testSendReceive();
+        messages.clear();
+        consumer2.setMessageListener(this);
+        assertMessagesAreReceived();
+        LOG.info("" + data.length + " messages(s) received, closing down connections");
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTopicCompositeSendReceiveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTopicCompositeSendReceiveTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTransactionTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTransactionTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTransactionTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTransactionTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,204 @@
+/**
+ * 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.legacy.test3;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision: 1.2 $
+ */
+public class JmsQueueTransactionTest extends JmsTransactionTestSupport {
+    private static final Log LOG = LogFactory.getLog(JmsQueueTransactionTest.class);
+
+    /**
+     * @see org.apache.activemq.legacy.test3.JmsTransactionTestSupport#getJmsResourceProvider()
+     */
+    protected JmsResourceProvider getJmsResourceProvider() {
+        JmsResourceProvider p = new JmsResourceProvider();
+        p.setTopic(false);
+        return p;
+    }
+
+    /**
+     * Tests if the the connection gets reset, the messages will still be
+     * received.
+     * 
+     * @throws Exception
+     */
+    public void testReceiveTwoThenCloseConnection() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")};
+
+        // lets consume any outstanding messages from previous test runs
+        beginTx();
+        while (consumer.receive(1000) != null) {
+        }
+        commitTx();
+
+        beginTx();
+        producer.send(outbound[0]);
+        producer.send(outbound[1]);
+        commitTx();
+
+        LOG.info("Sent 0: " + outbound[0]);
+        LOG.info("Sent 1: " + outbound[1]);
+
+        ArrayList<Message> messages = new ArrayList<Message>();
+        beginTx();
+        Message message = consumer.receive(2000);
+        assertEquals(outbound[0], message);
+
+        message = consumer.receive(2000);
+        assertNotNull(message);
+        assertEquals(outbound[1], message);
+
+        // Close and reopen connection.
+        reconnect();
+
+        // Consume again.. the previous message should
+        // get redelivered.
+        beginTx();
+        message = consumer.receive(2000);
+        assertNotNull("Should have re-received the first message again!", message);
+        messages.add(message);
+        assertEquals(outbound[0], message);
+
+        message = consumer.receive(5000);
+        assertNotNull("Should have re-received the second message again!", message);
+        messages.add(message);
+        assertEquals(outbound[1], message);
+        commitTx();
+
+        Message inbound[] = new Message[messages.size()];
+        messages.toArray(inbound);
+
+        assertTextMessagesEqual("Rollback did not work", outbound, inbound);
+    }
+
+    /**
+     * Tests sending and receiving messages with two sessions(one for producing
+     * and another for consuming).
+     * 
+     * @throws Exception
+     */
+    public void testSendReceiveInSeperateSessionTest() throws Exception {
+        session.close();
+        int batchCount = 10;
+
+        for (int i = 0; i < batchCount; i++) {
+            // Session that sends messages
+            {
+                Session session = resourceProvider.createSession(connection);
+                this.session = session;
+                MessageProducer producer = resourceProvider.createProducer(session, destination);
+                // consumer = resourceProvider.createConsumer(session,
+                // destination);
+                beginTx();
+                producer.send(session.createTextMessage("Test Message: " + i));
+                commitTx();
+                session.close();
+            }
+
+            // Session that consumes messages
+            {
+                Session session = resourceProvider.createSession(connection);
+                this.session = session;
+                MessageConsumer consumer = resourceProvider.createConsumer(session, destination);
+
+                beginTx();
+                TextMessage message = (TextMessage)consumer.receive(1000 * 5);
+                assertNotNull("Received only " + i + " messages in batch ", message);
+                assertEquals("Test Message: " + i, message.getText());
+
+                commitTx();
+                session.close();
+            }
+        }
+    }
+
+    /**
+     * Tests the queue browser. Browses the messages then the consumer tries to
+     * receive them. The messages should still be in the queue even when it was
+     * browsed.
+     * 
+     * @throws Exception
+     */
+    public void testReceiveBrowseReceive() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message"), session.createTextMessage("Third Message")};
+
+        // lets consume any outstanding messages from previous test runs
+        beginTx();
+        while (consumer.receive(1000) != null) {
+        }
+        commitTx();
+
+        beginTx();
+        producer.send(outbound[0]);
+        producer.send(outbound[1]);
+        producer.send(outbound[2]);
+        commitTx();
+
+        // Get the first.
+        beginTx();
+        assertEquals(outbound[0], consumer.receive(1000));
+        consumer.close();
+        commitTx();
+        
+        beginTx();
+        QueueBrowser browser = session.createBrowser((Queue)destination);
+        Enumeration enumeration = browser.getEnumeration();
+
+        // browse the second
+        assertTrue("should have received the second message", enumeration.hasMoreElements());
+        assertEquals(outbound[1], (Message)enumeration.nextElement());
+
+        // browse the third.
+        assertTrue("Should have received the third message", enumeration.hasMoreElements());
+        assertEquals(outbound[2], (Message)enumeration.nextElement());
+
+        // There should be no more.
+        boolean tooMany = false;
+        while (enumeration.hasMoreElements()) {
+            LOG.info("Got extra message: " + ((TextMessage)enumeration.nextElement()).getText());
+            tooMany = true;
+        }
+        assertFalse(tooMany);
+        browser.close();
+
+        // Re-open the consumer.
+        consumer = resourceProvider.createConsumer(session, destination);
+        // Receive the second.
+        assertEquals(outbound[1], consumer.receive(1000));
+        // Receive the third.
+        assertEquals(outbound[2], consumer.receive(1000));
+        consumer.close();
+
+        commitTx();
+    }
+
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTransactionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueTransactionTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueWildcardSendReceiveTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueWildcardSendReceiveTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueWildcardSendReceiveTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueWildcardSendReceiveTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,173 @@
+/**
+ * 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.legacy.test3;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.command.ActiveMQDestination;
+
+/**
+ * @version $Revision: 1.4 $
+ */
+public class JmsQueueWildcardSendReceiveTest extends JmsTopicSendReceiveTest {
+
+    private String destination1String = "TEST.ONE.ONE";
+    private String destination2String = "TEST.ONE.ONE.ONE";
+    private String destination3String = "TEST.ONE.TWO";
+    private String destination4String = "TEST.TWO.ONE";
+
+    /**
+     * Sets a test to have a queue destination and non-persistent delivery mode.
+     * 
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        topic = false;
+        deliveryMode = DeliveryMode.NON_PERSISTENT;
+        super.setUp();
+    }
+
+    /**
+     * Returns the consumer subject.
+     * 
+     * @return String - consumer subject
+     * @see org.apache.activemq.legacy.test3.TestSupport#getConsumerSubject()
+     */
+    protected String getConsumerSubject() {
+        return "FOO.>";
+    }
+
+    /**
+     * Returns the producer subject.
+     * 
+     * @return String - producer subject
+     * @see org.apache.activemq.legacy.test3.TestSupport#getProducerSubject()
+     */
+    protected String getProducerSubject() {
+        return "FOO.BAR.HUMBUG";
+    }
+
+    public void testReceiveWildcardQueueEndAsterisk() throws Exception {
+        connection.start();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        ActiveMQDestination destination1 = (ActiveMQDestination)session.createQueue(destination1String);
+        ActiveMQDestination destination3 = (ActiveMQDestination)session.createQueue(destination3String);
+
+        Message m = null;
+        MessageConsumer consumer = null;
+        String text = null;
+
+        sendMessage(session, destination1, destination1String);
+        sendMessage(session, destination3, destination3String);
+        ActiveMQDestination destination6 = (ActiveMQDestination)session.createQueue("TEST.ONE.*");
+        consumer = session.createConsumer(destination6);
+        m = consumer.receive(1000);
+        assertNotNull(m);
+        text = ((TextMessage)m).getText();
+        if (!(text.equals(destination1String) || text.equals(destination3String))) {
+            fail("unexpected message:" + text);
+        }
+        m = consumer.receive(1000);
+        assertNotNull(m);
+        text = ((TextMessage)m).getText();
+        if (!(text.equals(destination1String) || text.equals(destination3String))) {
+            fail("unexpected message:" + text);
+        }
+        assertNull(consumer.receiveNoWait());
+    }
+
+    public void testReceiveWildcardQueueEndGreaterThan() throws Exception {
+        connection.start();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        ActiveMQDestination destination1 = (ActiveMQDestination)session.createQueue(destination1String);
+        ActiveMQDestination destination2 = (ActiveMQDestination)session.createQueue(destination2String);
+        ActiveMQDestination destination3 = (ActiveMQDestination)session.createQueue(destination3String);
+
+        Message m = null;
+        MessageConsumer consumer = null;
+        String text = null;
+
+        sendMessage(session, destination1, destination1String);
+        sendMessage(session, destination2, destination2String);
+        sendMessage(session, destination3, destination3String);
+        ActiveMQDestination destination7 = (ActiveMQDestination)session.createQueue("TEST.ONE.>");
+        consumer = session.createConsumer(destination7);
+        m = consumer.receive(1000);
+        assertNotNull(m);
+        text = ((TextMessage)m).getText();
+        if (!(text.equals(destination1String) || text.equals(destination2String) || text.equals(destination3String))) {
+            fail("unexpected message:" + text);
+        }
+        m = consumer.receive(1000);
+        assertNotNull(m);
+        if (!(text.equals(destination1String) || text.equals(destination2String) || text.equals(destination3String))) {
+            fail("unexpected message:" + text);
+        }
+        m = consumer.receive(1000);
+        assertNotNull(m);
+        if (!(text.equals(destination1String) || text.equals(destination2String) || text.equals(destination3String))) {
+            fail("unexpected message:" + text);
+        }
+        assertNull(consumer.receiveNoWait());
+    }
+
+    public void testReceiveWildcardQueueMidAsterisk() throws Exception {
+        connection.start();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        ActiveMQDestination destination1 = (ActiveMQDestination)session.createQueue(destination1String);
+        ActiveMQDestination destination4 = (ActiveMQDestination)session.createQueue(destination4String);
+
+        Message m = null;
+        MessageConsumer consumer = null;
+        String text = null;
+
+        sendMessage(session, destination1, destination1String);
+        sendMessage(session, destination4, destination4String);
+        ActiveMQDestination destination8 = (ActiveMQDestination)session.createQueue("TEST.*.ONE");
+        consumer = session.createConsumer(destination8);
+        m = consumer.receive(1000);
+        assertNotNull(m);
+        text = ((TextMessage)m).getText();
+        if (!(text.equals(destination1String) || text.equals(destination4String))) {
+            fail("unexpected message:" + text);
+        }
+        m = consumer.receive(1000);
+        assertNotNull(m);
+        text = ((TextMessage)m).getText();
+        if (!(text.equals(destination1String) || text.equals(destination4String))) {
+            fail("unexpected message:" + text);
+        }
+        assertNull(consumer.receiveNoWait());
+
+    }
+
+    private void sendMessage(Session session, Destination destination, String text) throws JMSException {
+        MessageProducer producer = session.createProducer(destination);
+        producer.send(session.createTextMessage(text));
+        producer.close();
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueWildcardSendReceiveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsQueueWildcardSendReceiveTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsResourceProvider.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsResourceProvider.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsResourceProvider.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsResourceProvider.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,258 @@
+/**
+ * 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.legacy.test3;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionConsumer;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ServerSessionPool;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+/**
+ * @version $Revision: 1.4 $
+ */
+public class JmsResourceProvider {
+
+    private String serverUri = "vm://localhost?broker.persistent=false";
+    private boolean transacted;
+    private int ackMode = Session.AUTO_ACKNOWLEDGE;
+    private boolean isTopic;
+    private int deliveryMode = DeliveryMode.PERSISTENT;
+    private String durableName = "DummyName";
+    private String clientID = getClass().getName();
+
+    /**
+     * Creates a connection factory.
+     * 
+     * @see org.apache.activemq.legacy.test3.JmsResourceProvider#createConnectionFactory()
+     */
+    public ConnectionFactory createConnectionFactory() throws Exception {
+        return new ActiveMQConnectionFactory(serverUri);
+    }
+
+    /**
+     * Creates a connection.
+     * 
+     * @see org.apache.activemq.legacy.test3.JmsResourceProvider#createConnection(javax.jms.ConnectionFactory)
+     */
+    public Connection createConnection(ConnectionFactory cf) throws JMSException {
+        Connection connection = cf.createConnection();
+        if (getClientID() != null) {
+            connection.setClientID(getClientID());
+        }
+        return connection;
+    }
+
+    /**
+     * @see org.apache.activemq.legacy.test3.JmsResourceProvider#createSession(javax.jms.Connection)
+     */
+    public Session createSession(Connection conn) throws JMSException {
+        return conn.createSession(transacted, ackMode);
+    }
+
+    /**
+     * @see org.apache.activemq.legacy.test3.JmsResourceProvider#createConsumer(javax.jms.Session,
+     *      javax.jms.Destination)
+     */
+    public MessageConsumer createConsumer(Session session, Destination destination) throws JMSException {
+        if (isDurableSubscriber()) {
+            return session.createDurableSubscriber((Topic)destination, durableName);
+        }
+        return session.createConsumer(destination);
+    }
+
+    /**
+     * Creates a connection for a consumer.
+     * 
+     * @param ssp - ServerSessionPool
+     * @return ConnectionConsumer
+     */
+    public ConnectionConsumer createConnectionConsumer(Connection connection, Destination destination, ServerSessionPool ssp) throws JMSException {
+        return connection.createConnectionConsumer(destination, null, ssp, 1);
+    }
+
+    /**
+     * Creates a producer.
+     * 
+     * @see org.apache.activemq.legacy.test3.JmsResourceProvider#createProducer(javax.jms.Session,
+     *      javax.jms.Destination)
+     */
+    public MessageProducer createProducer(Session session, Destination destination) throws JMSException {
+        MessageProducer producer = session.createProducer(destination);
+        producer.setDeliveryMode(deliveryMode);
+        return producer;
+    }
+
+    /**
+     * Creates a destination, which can either a topic or a queue.
+     * 
+     * @see org.apache.activemq.legacy.test3.JmsResourceProvider#createDestination(javax.jms.Session,
+     *      java.lang.String)
+     */
+    public Destination createDestination(Session session, String name) throws JMSException {
+        if (isTopic) {
+            return session.createTopic("TOPIC." + name);
+        } else {
+            return session.createQueue("QUEUE." + name);
+        }
+    }
+
+    /**
+     * Returns true if the subscriber is durable.
+     * 
+     * @return isDurableSubscriber
+     */
+    public boolean isDurableSubscriber() {
+        return isTopic && durableName != null;
+    }
+
+    /**
+     * Returns the acknowledgement mode.
+     * 
+     * @return Returns the ackMode.
+     */
+    public int getAckMode() {
+        return ackMode;
+    }
+
+    /**
+     * Sets the acnknowledgement mode.
+     * 
+     * @param ackMode The ackMode to set.
+     */
+    public void setAckMode(int ackMode) {
+        this.ackMode = ackMode;
+    }
+
+    /**
+     * Returns true if the destination is a topic, false if the destination is a
+     * queue.
+     * 
+     * @return Returns the isTopic.
+     */
+    public boolean isTopic() {
+        return isTopic;
+    }
+
+    /**
+     * @param isTopic The isTopic to set.
+     */
+    public void setTopic(boolean isTopic) {
+        this.isTopic = isTopic;
+    }
+
+    /**
+     * Returns the server URI.
+     * 
+     * @return Returns the serverUri.
+     */
+    public String getServerUri() {
+        return serverUri;
+    }
+
+    /**
+     * Sets the server URI.
+     * 
+     * @param serverUri - the server URI to set.
+     */
+    public void setServerUri(String serverUri) {
+        this.serverUri = serverUri;
+    }
+
+    /**
+     * Return true if the session is transacted.
+     * 
+     * @return Returns the transacted.
+     */
+    public boolean isTransacted() {
+        return transacted;
+    }
+
+    /**
+     * Sets the session to be transacted.
+     * 
+     * @param transacted
+     */
+    public void setTransacted(boolean transacted) {
+        this.transacted = transacted;
+        if (transacted) {
+            setAckMode(Session.SESSION_TRANSACTED);
+        }
+    }
+
+    /**
+     * Returns the delivery mode.
+     * 
+     * @return deliveryMode
+     */
+    public int getDeliveryMode() {
+        return deliveryMode;
+    }
+
+    /**
+     * Sets the delivery mode.
+     * 
+     * @param deliveryMode
+     */
+    public void setDeliveryMode(int deliveryMode) {
+        this.deliveryMode = deliveryMode;
+    }
+
+    /**
+     * Returns the client id.
+     * 
+     * @return clientID
+     */
+    public String getClientID() {
+        return clientID;
+    }
+
+    /**
+     * Sets the client id.
+     * 
+     * @param clientID
+     */
+    public void setClientID(String clientID) {
+        this.clientID = clientID;
+    }
+
+    /**
+     * Returns the durable name of the provider.
+     * 
+     * @return durableName
+     */
+    public String getDurableName() {
+        return durableName;
+    }
+
+    /**
+     * Sets the durable name of the provider.
+     * 
+     * @param durableName
+     */
+    public void setDurableName(String durableName) {
+        this.durableName = durableName;
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsResourceProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsResourceProvider.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsSendReceiveTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsSendReceiveTestSupport.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsSendReceiveTestSupport.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsSendReceiveTestSupport.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,254 @@
+/**
+ * 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.legacy.test3;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import junit.framework.AssertionFailedError;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision: 1.2 $
+ */
+public abstract class JmsSendReceiveTestSupport extends TestSupport implements MessageListener {
+    private static final Log LOG = LogFactory.getLog(JmsSendReceiveTestSupport.class);
+
+    protected int messageCount = 100;
+    protected String[] data;
+    protected Session session;
+    protected Session consumeSession;
+    protected MessageConsumer consumer;
+    protected MessageProducer producer;
+    protected Destination consumerDestination;
+    protected Destination producerDestination;
+    protected List<Message> messages = createConcurrentList();
+    protected boolean topic = true;
+    protected boolean durable;
+    protected int deliveryMode = DeliveryMode.PERSISTENT;
+    protected final Object lock = new Object();
+    protected boolean verbose;
+    protected boolean useSeparateSession;
+    protected boolean largeMessages;
+    protected int largeMessageLoopSize = 4 * 1024;
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        String temp = System.getProperty("messageCount");
+
+        if (temp != null) {
+            int i = Integer.parseInt(temp);
+            if (i > 0) {
+                messageCount = i;
+            }
+        }
+
+        LOG.info("Message count for test case is: " + messageCount);
+        data = new String[messageCount];
+        for (int i = 0; i < messageCount; i++) {
+            data[i] = createMessageText(i);
+        }
+    }
+
+    protected String createMessageText(int i) {
+        if (largeMessages) {
+            return createMessageBodyText();
+        } else {
+            return "Text for message: " + i + " at " + new Date();
+        }
+    }
+
+    protected String createMessageBodyText() {
+        StringBuffer buffer = new StringBuffer();
+        for (int i = 0; i < largeMessageLoopSize; i++) {
+            buffer.append("0123456789");
+        }
+        return buffer.toString();
+    }
+
+    /**
+     * Test if all the messages sent are being received.
+     * 
+     * @throws Exception
+     */
+    public void testSendReceive() throws Exception {
+
+        Thread.sleep(1000);
+        messages.clear();
+
+        for (int i = 0; i < data.length; i++) {
+            Message message = createMessage(i);
+            configureMessage(message);
+            if (verbose) {
+                LOG.info("About to send a message: " + message + " with text: " + data[i]);
+            }
+            sendMessage(i, message);
+        }
+
+        assertMessagesAreReceived();
+        LOG.info("" + data.length + " messages(s) received, closing down connections");
+    }
+    
+    protected void sendMessage(int index, Message message) throws Exception {
+    	producer.send(producerDestination, message);
+    }
+
+    protected Message createMessage(int index) throws JMSException {
+        Message message = session.createTextMessage(data[index]);
+        return message;
+    }
+
+    /**
+     * A hook to allow the message to be configured such as adding extra headers
+     * 
+     * @throws JMSException
+     */
+    protected void configureMessage(Message message) throws JMSException {
+    }
+
+    /**
+     * Waits to receive the messages and performs the test if all messages have
+     * been received and are in sequential order.
+     * 
+     * @throws JMSException
+     */
+    protected void assertMessagesAreReceived() throws JMSException {
+        waitForMessagesToBeDelivered();
+        assertMessagesReceivedAreValid(messages);
+    }
+
+    /**
+     * Tests if the messages have all been received and are in sequential order.
+     * 
+     * @param receivedMessages
+     * @throws JMSException
+     */
+    protected void assertMessagesReceivedAreValid(List<Message> receivedMessages) throws JMSException {
+        List<Object> copyOfMessages = Arrays.asList(receivedMessages.toArray());
+        int counter = 0;
+
+        if (data.length != copyOfMessages.size()) {
+            for (Iterator<Object> iter = copyOfMessages.iterator(); iter.hasNext();) {
+                Object message = iter.next();
+                LOG.info("<== " + counter++ + " = " + message);
+            }
+        }
+
+        assertEquals("Not enough messages received", data.length, receivedMessages.size());
+
+        for (int i = 0; i < data.length; i++) {
+            Message received = receivedMessages.get(i);
+            try {
+                assertMessageValid(i, received);
+            } catch (AssertionFailedError e) {
+                for (int j = 0; j < data.length; j++) {
+                    Message m = receivedMessages.get(j);
+                    System.out.println(j+" => "+m.getJMSMessageID());
+                }
+                throw e;
+            }
+        }
+    }
+
+    protected void assertMessageValid(int index, Message message) throws JMSException {
+        TextMessage textMessage = (TextMessage)message;
+        String text = textMessage.getText();
+
+        if (verbose) {
+            LOG.info("Received Text: " + text);
+        }
+
+        assertEquals("Message: " + index, data[index], text);
+    }
+
+    /**
+     * Waits for the messages to be delivered or when the wait time has been
+     * reached.
+     */
+    protected void waitForMessagesToBeDelivered() {
+        long maxWaitTime = 60000;
+        long waitTime = maxWaitTime;
+        long start = (maxWaitTime <= 0) ? 0 : System.currentTimeMillis();
+
+        synchronized (lock) {
+            while (messages.size() < data.length && waitTime >= 0) {
+                try {
+                    lock.wait(200);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+
+                waitTime = maxWaitTime - (System.currentTimeMillis() - start);
+            }
+        }
+    }
+
+    /**
+     * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
+     */
+    public synchronized void onMessage(Message message) {
+        consumeMessage(message, messages);
+    }
+
+    /**
+     * Consumes a received message.
+     * 
+     * @param message - a newly received message.
+     * @param messageList - list containing the received messages.
+     */
+    protected void consumeMessage(Message message, List<Message> messageList) {
+        if (verbose) {
+            LOG.info("Received message: " + message);
+        }
+
+        messageList.add(message);
+
+        if (messageList.size() >= data.length) {
+            synchronized (lock) {
+                lock.notifyAll();
+            }
+        }
+    }
+
+    /**
+     * Creates a synchronized list.
+     * 
+     * @return a synchronized view of the specified list.
+     */
+    protected List<Message> createConcurrentList() {
+        return Collections.synchronizedList(new ArrayList<Message>());
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsSendReceiveTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsSendReceiveTestSupport.java
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsTopicCompositeSendReceiveTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsTopicCompositeSendReceiveTest.java?rev=786040&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsTopicCompositeSendReceiveTest.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsTopicCompositeSendReceiveTest.java Thu Jun 18 12:42:23 2009
@@ -0,0 +1,87 @@
+/**
+ * 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.legacy.test3;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.Topic;
+
+
+
+/**
+ * @version $Revision: 1.3 $
+ */
+public class JmsTopicCompositeSendReceiveTest extends JmsTopicSendReceiveTest {
+    private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
+            .getLog(JmsTopicCompositeSendReceiveTest.class);
+    
+    Destination consumerDestination2;
+    MessageConsumer consumer2;
+
+    /**
+     * Sets a test to have a queue destination and non-persistent delivery mode.
+     *
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        deliveryMode = DeliveryMode.NON_PERSISTENT;
+        super.setUp();
+        consumerDestination2 = consumeSession.createTopic("FOO.BAR.HUMBUG2");
+        LOG.info("Created  consumer destination: " + consumerDestination2 + " of type: " + consumerDestination2.getClass());
+        if (durable) {
+            LOG.info("Creating durable consumer");
+            consumer2 = consumeSession.createDurableSubscriber((Topic) consumerDestination2, getName());
+        } else {
+            consumer2 = consumeSession.createConsumer(consumerDestination2);
+        }
+
+    }
+
+    /**
+     * Returns the consumer subject.
+     *
+     * @return String - consumer subject
+     * @see org.apache.activemq.legacy.test3.TestSupport#getConsumerSubject()
+     */
+    protected String getConsumerSubject() {
+        return "FOO.BAR.HUMBUG";
+    }
+
+    /**
+     * Returns the producer subject.
+     *
+     * @return String - producer subject
+     * @see org.apache.activemq.legacy.test3.TestSupport#getProducerSubject()
+     */
+    protected String getProducerSubject() {
+        return "FOO.BAR.HUMBUG,FOO.BAR.HUMBUG2";
+    }
+
+    /**
+     * Test if all the messages sent are being received.
+     *
+     * @throws Exception
+     */
+    public void testSendReceive() throws Exception {
+        super.testSendReceive();
+        messages.clear();
+        consumer2.setMessageListener(this);
+        assertMessagesAreReceived();
+        LOG.info("" + data.length + " messages(s) received, closing down connections");
+    }
+}

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsTopicCompositeSendReceiveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/sandbox/activemq-flow/activemq-client/src/test/java/org/apache/activemq/legacy/test3/JmsTopicCompositeSendReceiveTest.java
------------------------------------------------------------------------------
    svn:executable = *