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/02/14 01:39:31 UTC
qpid-jms git commit: Some tests and cleanup of AmqpProvider.
Repository: qpid-jms
Updated Branches:
refs/heads/master 398a62a73 -> 79b9004e0
Some tests and cleanup of AmqpProvider.
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/79b9004e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/79b9004e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/79b9004e
Branch: refs/heads/master
Commit: 79b9004e0eee01792cdf72af2dd594e7d72825fb
Parents: 398a62a
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Feb 13 19:39:26 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Fri Feb 13 19:39:26 2015 -0500
----------------------------------------------------------------------
.../qpid/jms/provider/amqp/AmqpProvider.java | 4 +-
.../jms/provider/amqp/AmqpProviderTest.java | 86 ++++++++++++++++++++
2 files changed, 88 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/79b9004e/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java
index 5332e0a..610682a 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpProvider.java
@@ -171,7 +171,7 @@ public class AmqpProvider implements Provider, TransportListener {
// If we are not connected then there is nothing we can do now
// just signal success.
- if (!transport.isConnected()) {
+ if (transport == null || !transport.isConnected()) {
request.onSuccess();
}
@@ -182,7 +182,7 @@ public class AmqpProvider implements Provider, TransportListener {
request.onSuccess();
}
} catch (Exception e) {
- LOG.debug("Caught exception while closing proton connection");
+ LOG.debug("Caught exception while closing proton connection: {}", e.getMessage());
}
}
});
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/79b9004e/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderTest.java
new file mode 100644
index 0000000..6e93f21
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/AmqpProviderTest.java
@@ -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.qpid.jms.provider.amqp;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.qpid.jms.test.QpidJmsTestCase;
+import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test some basic functionality of the AmqpProvider
+ */
+public class AmqpProviderTest extends QpidJmsTestCase {
+
+ private TestAmqpPeer testPeer;
+ private URI peerURI;
+ private AmqpProvider provider;
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ testPeer = new TestAmqpPeer();
+ peerURI = new URI("amqp://localhost:" + testPeer.getServerPort());
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ if (provider != null) {
+ provider.close();
+ provider = null;
+ }
+
+ if (testPeer != null) {
+ testPeer.close();
+ testPeer = null;
+ }
+ }
+
+ @Test(timeout=10000)
+ public void testCreate() {
+ provider = new AmqpProvider(peerURI);
+ assertFalse(provider.isPresettleConsumers());
+ }
+
+ @Test(timeout=10000)
+ public void testConnectThrowsWhenNoPeer() throws Exception {
+ provider = new AmqpProvider(peerURI);
+ testPeer.close();
+ try {
+ provider.connect();
+ fail("Should have failed to connect.");
+ } catch (Exception ex) {
+ }
+ }
+
+ @Test(timeout=10000)
+ public void testToString() throws IOException {
+ provider = new AmqpProvider(peerURI);
+ provider.connect();
+ assertTrue(provider.toString().contains("localhost"));
+ assertTrue(provider.toString().contains(String.valueOf(peerURI.getPort())));
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org