Repository: qpid-jms Updated Branches: refs/heads/master 4a6bbc4ee -> 008943630
Test and fix a minir issue with create of QueueReceiver Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/00894363 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/00894363 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/00894363 Branch: refs/heads/master Commit: 008943630e902858187d0135038b643598ecd91b Parents: 4a6bbc4 Author: Timothy Bish <[email protected]> Authored: Mon Feb 2 11:08:46 2015 -0500 Committer: Timothy Bish <[email protected]> Committed: Mon Feb 2 11:08:55 2015 -0500 ---------------------------------------------------------------------- .../java/org/apache/qpid/jms/JmsSession.java | 2 +- .../qpid/jms/consumer/JmsQueueReceiverTest.java | 80 ++++++++++++++++++++ .../jms/consumer/JmsTopicSubscriberTest.java | 80 ++++++++++++++++++++ 3 files changed, 161 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/00894363/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java index 3d8618c..28bd08b 100644 --- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java +++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsSession.java @@ -309,7 +309,7 @@ public class JmsSession implements Session, QueueSession, TopicSession, JmsMessa checkClosed(); checkDestination(queue); JmsDestination dest = JmsMessageTransformation.transformDestination(connection, queue); - JmsQueueReceiver result = new JmsQueueReceiver(getNextConsumerId(), this, dest, ""); + JmsQueueReceiver result = new JmsQueueReceiver(getNextConsumerId(), this, dest, null); result.init(); return result; } http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/00894363/qpid-jms-client/src/test/java/org/apache/qpid/jms/consumer/JmsQueueReceiverTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/consumer/JmsQueueReceiverTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/consumer/JmsQueueReceiverTest.java new file mode 100644 index 0000000..e5d6a4f --- /dev/null +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/consumer/JmsQueueReceiverTest.java @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.qpid.jms.consumer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.Queue; +import javax.jms.QueueReceiver; +import javax.jms.QueueSession; +import javax.jms.Session; + +import org.apache.qpid.jms.JmsConnectionTestSupport; +import org.junit.Before; +import org.junit.Test; + +/** + * Test the basic contract of the QueueReceiver + */ +public class JmsQueueReceiverTest extends JmsConnectionTestSupport { + + protected QueueSession session; + protected Queue queue; + protected QueueReceiver receiver; + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + queueConnection = createQueueConnectionToMockProvider(); + session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); + queue = session.createQueue(_testName.getMethodName()); + receiver = session.createReceiver(queue); + } + + @Test(timeout = 30000) + public void testMultipleCloseCalls() throws Exception { + receiver.close(); + receiver.close(); + } + + @Test(timeout = 30000) + public void testGetQueue() throws Exception { + assertEquals(queue, receiver.getQueue()); + } + + @Test(timeout = 30000) + public void testGetMessageListener() throws Exception { + assertNull(receiver.getMessageListener()); + receiver.setMessageListener(new MessageListener() { + + @Override + public void onMessage(Message message) { + } + }); + assertNotNull(receiver.getMessageListener()); + } + + @Test(timeout = 30000) + public void testGetMessageSelector() throws Exception { + assertNull(receiver.getMessageSelector()); + } +} http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/00894363/qpid-jms-client/src/test/java/org/apache/qpid/jms/consumer/JmsTopicSubscriberTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/consumer/JmsTopicSubscriberTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/consumer/JmsTopicSubscriberTest.java new file mode 100644 index 0000000..259d562 --- /dev/null +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/consumer/JmsTopicSubscriberTest.java @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.qpid.jms.consumer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.Session; +import javax.jms.Topic; +import javax.jms.TopicSession; +import javax.jms.TopicSubscriber; + +import org.apache.qpid.jms.JmsConnectionTestSupport; +import org.junit.Before; +import org.junit.Test; + +/** + * Test the basic contract of the TopicSubscriber + */ +public class JmsTopicSubscriberTest extends JmsConnectionTestSupport { + + protected TopicSession session; + protected Topic topic; + protected TopicSubscriber subscriber; + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + topicConnection = createTopicConnectionToMockProvider(); + session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); + topic = session.createTopic(_testName.getMethodName()); + subscriber = session.createSubscriber(topic); + } + + @Test(timeout = 30000) + public void testMultipleCloseCalls() throws Exception { + subscriber.close(); + subscriber.close(); + } + + @Test(timeout = 30000) + public void testGetQueue() throws Exception { + assertEquals(topic, subscriber.getTopic()); + } + + @Test(timeout = 30000) + public void testGetMessageListener() throws Exception { + assertNull(subscriber.getMessageListener()); + subscriber.setMessageListener(new MessageListener() { + + @Override + public void onMessage(Message message) { + } + }); + assertNotNull(subscriber.getMessageListener()); + } + + @Test(timeout = 30000) + public void testGetMessageSelector() throws Exception { + assertNull(subscriber.getMessageSelector()); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
