You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2015/01/31 00:52:39 UTC

qpid-jms git commit: Move this test to where the other producer tests live.

Repository: qpid-jms
Updated Branches:
  refs/heads/master c136cb6fe -> bb5ddbace


Move this test to where the other producer tests live.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/bb5ddbac
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/bb5ddbac
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/bb5ddbac

Branch: refs/heads/master
Commit: bb5ddbace951197be02ef4e594b948cc6e652239
Parents: c136cb6
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Jan 30 18:47:10 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Fri Jan 30 18:47:10 2015 -0500

----------------------------------------------------------------------
 .../apache/qpid/jms/JmsMessageProducerTest.java | 127 -------------------
 .../jms/producer/JmsMessageProducerTest.java    | 109 ++++++++++++++++
 2 files changed, 109 insertions(+), 127 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bb5ddbac/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsMessageProducerTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsMessageProducerTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsMessageProducerTest.java
deleted file mode 100644
index 0b7021d..0000000
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsMessageProducerTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.jms;
-
-import static org.junit.Assert.fail;
-
-import javax.jms.InvalidDestinationException;
-import javax.jms.Message;
-
-import org.apache.qpid.jms.meta.JmsProducerId;
-import org.apache.qpid.jms.meta.JmsProducerInfo;
-import org.apache.qpid.jms.meta.JmsResource;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test basic functionality around JmsConnection
- */
-public class JmsMessageProducerTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(JmsMessageProducerTest.class);
-
-    private JmsConnection connection;
-    private  JmsSession session;
-    private JmsProducerId producerId;
-
-    @Before
-    public void setUp() throws Exception {
-        connection = Mockito.mock(JmsConnection.class);
-        session = Mockito.mock(JmsSession.class);
-        producerId = new JmsProducerId("key");
-
-        Mockito.when(session.getConnection()).thenReturn(connection);
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(InvocationOnMock invocation) throws Throwable {
-                Object[] args = invocation.getArguments();
-                LOG.debug("Handling connection createResource call");
-                if (args[0] instanceof JmsProducerInfo) {
-                    return args[0];
-                }
-
-                throw new IllegalArgumentException("Not implemented");
-            }
-        }).when(connection).createResource(Mockito.any(JmsResource.class));
-    }
-
-    @Test
-    public void testAnonymousProducerThrowsUOEWhenExplictDestinationNotProvided() throws Exception {
-        JmsMessageProducer producer = new JmsMessageProducer(producerId, session, null);
-
-        Message message = Mockito.mock(Message.class);
-        try {
-            producer.send(message);
-            fail("Expected exception not thrown");
-        } catch (UnsupportedOperationException uoe) {
-            // expected
-        }
-
-        try {
-            producer.send(message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
-            fail("Expected exception not thrown");
-        } catch (UnsupportedOperationException uoe) {
-            // expected
-        }
-    }
-
-    @Test
-    public void testExplicitProducerThrowsUOEWhenExplictDestinationIsProvided() throws Exception {
-        JmsDestination dest = new JmsQueue("explicitDestination");
-        JmsMessageProducer producer = new JmsMessageProducer(producerId, session, dest);
-
-        Message message = Mockito.mock(Message.class);
-        try {
-            producer.send(dest, message);
-            fail("Expected exception not thrown");
-        } catch (UnsupportedOperationException uoe) {
-            // expected
-        }
-
-        try {
-            producer.send(dest, message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
-            fail("Expected exception not thrown");
-        } catch (UnsupportedOperationException uoe) {
-            // expected
-        }
-    }
-
-    @Test
-    public void testAnonymousDestinationProducerThrowsIDEWhenNullDestinationIsProvided() throws Exception {
-        JmsMessageProducer producer = new JmsMessageProducer(producerId, session, null);
-
-        Message message = Mockito.mock(Message.class);
-        try {
-            producer.send(null, message);
-            fail("Expected exception not thrown");
-        } catch (InvalidDestinationException ide) {
-            // expected
-        }
-
-        try {
-            producer.send(null, message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
-            fail("Expected exception not thrown");
-        } catch (InvalidDestinationException ide) {
-            // expected
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/bb5ddbac/qpid-jms-client/src/test/java/org/apache/qpid/jms/producer/JmsMessageProducerTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/producer/JmsMessageProducerTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/producer/JmsMessageProducerTest.java
new file mode 100644
index 0000000..120c24d
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/producer/JmsMessageProducerTest.java
@@ -0,0 +1,109 @@
+/**
+ * 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.producer;
+
+import static org.junit.Assert.fail;
+
+import javax.jms.InvalidDestinationException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.apache.qpid.jms.JmsConnectionTestSupport;
+import org.apache.qpid.jms.JmsDestination;
+import org.apache.qpid.jms.JmsQueue;
+import org.apache.qpid.jms.JmsSession;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+/**
+ * Test basic functionality around JmsConnection
+ */
+public class JmsMessageProducerTest extends JmsConnectionTestSupport {
+
+    private JmsSession session;
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        connection = createConnectionToMockProvider();
+        session = (JmsSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+    }
+
+    @Test
+    public void testAnonymousProducerThrowsUOEWhenExplictDestinationNotProvided() throws Exception {
+        MessageProducer producer = session.createProducer(null);
+
+        Message message = Mockito.mock(Message.class);
+        try {
+            producer.send(message);
+            fail("Expected exception not thrown");
+        } catch (UnsupportedOperationException uoe) {
+            // expected
+        }
+
+        try {
+            producer.send(message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+            fail("Expected exception not thrown");
+        } catch (UnsupportedOperationException uoe) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testExplicitProducerThrowsUOEWhenExplictDestinationIsProvided() throws Exception {
+        JmsDestination dest = new JmsQueue("explicitDestination");
+        MessageProducer producer = session.createProducer(new JmsQueue());
+
+        Message message = Mockito.mock(Message.class);
+        try {
+            producer.send(dest, message);
+            fail("Expected exception not thrown");
+        } catch (UnsupportedOperationException uoe) {
+            // expected
+        }
+
+        try {
+            producer.send(dest, message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+            fail("Expected exception not thrown");
+        } catch (UnsupportedOperationException uoe) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testAnonymousDestinationProducerThrowsIDEWhenNullDestinationIsProvided() throws Exception {
+        MessageProducer producer = session.createProducer(null);
+
+        Message message = Mockito.mock(Message.class);
+        try {
+            producer.send(null, message);
+            fail("Expected exception not thrown");
+        } catch (InvalidDestinationException ide) {
+            // expected
+        }
+
+        try {
+            producer.send(null, message, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+            fail("Expected exception not thrown");
+        } catch (InvalidDestinationException ide) {
+            // expected
+        }
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org