qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1748053 - in /qpid/java/trunk: client/src/main/java/org/apache/qpid/client/ common/src/main/java/org/apache/qpid/transport/ common/src/main/java/org/apache/qpid/transport/network/io/ systests/src/test/java/org/apache/qpid/client/connection/
Date Sun, 12 Jun 2016 21:27:54 GMT
Author: kwall
Date: Sun Jun 12 21:27:54 2016
New Revision: 1748053

URL: http://svn.apache.org/viewvc?rev=1748053&view=rev
Log:
QPID-7297: [Java Client] Allow an existing socket to be used for 0-10 connections too

Added:
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/connection/
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/connection/ExistingSocketTest.java
Modified:
    qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
    qpid/java/trunk/client/src/main/java/org/apache/qpid/client/BrokerDetails.java
    qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java
    qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java?rev=1748053&r1=1748052&r2=1748053&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
(original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
Sun Jun 12 21:27:54 2016
@@ -120,7 +120,6 @@ public class AMQConnectionDelegate_8_0 i
                 EnumSet.of(AMQState.CONNECTION_OPEN, AMQState.CONNECTION_CLOSED);
 
         ConnectionSettings settings = brokerDetail.buildConnectionSettings();
-        settings.setProtocol(brokerDetail.getTransport());
 
         //Check connection-level ssl override setting
         String connectionSslOption = _conn.getConnectionURL().getOption(ConnectionURL.OPTIONS_SSL);

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/BrokerDetails.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/BrokerDetails.java?rev=1748053&r1=1748052&r2=1748053&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/BrokerDetails.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/BrokerDetails.java Sun Jun
12 21:27:54 2016
@@ -461,6 +461,7 @@ public class BrokerDetails implements Se
 
         conSettings.setHost(getHost());
         conSettings.setPort(getPort());
+        conSettings.setTransport(getTransport());
 
         // ------------ sasl options ---------------
         if (getProperty(BrokerDetails.OPTIONS_SASL_MECHS) != null)

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java?rev=1748053&r1=1748052&r2=1748053&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java
(original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/ConnectionSettings.java
Sun Jun 12 21:27:54 2016
@@ -76,7 +76,7 @@ public class ConnectionSettings
 
     private static final SecureRandom RANDOM = new SecureRandom();
 
-    private String protocol = "tcp";
+    private String _transport = "tcp";
     private String host = "localhost";
     private String vhost;
     private String username;
@@ -194,14 +194,14 @@ public class ConnectionSettings
         return this.heartbeatTimeoutFactor;
     }
 
-    public String getProtocol()
+    public String getTransport()
     {
-        return protocol;
+        return _transport;
     }
 
-    public void setProtocol(String protocol)
+    public void setTransport(String transport)
     {
-        this.protocol = protocol;
+        _transport = transport;
     }
 
     public String getHost()

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java?rev=1748053&r1=1748052&r2=1748053&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java
(original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java
Sun Jun 12 21:27:54 2016
@@ -64,11 +64,11 @@ public class IoNetworkTransport
     {
 
         final Socket socket;
-        if("tcp".equalsIgnoreCase(settings.getProtocol()))
+        if("tcp".equalsIgnoreCase(settings.getTransport()))
         {
             socket = connectTcp(settings);
         }
-        else if("socket".equalsIgnoreCase(settings.getProtocol()))
+        else if("socket".equalsIgnoreCase(settings.getTransport()))
         {
             socket = _registeredSockets.remove(settings.getHost());
             if(socket == null)
@@ -78,7 +78,7 @@ public class IoNetworkTransport
         }
         else
         {
-            throw new TransportException("Unknown transport '"+settings.getProtocol()+"'");
+            throw new TransportException("Unknown transport '" + settings.getTransport()
+ "'");
         }
 
         int sendBufferSize = settings.getWriteBufferSize();

Added: qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/connection/ExistingSocketTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/connection/ExistingSocketTest.java?rev=1748053&view=auto
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/connection/ExistingSocketTest.java
(added)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/connection/ExistingSocketTest.java
Sun Jun 12 21:27:54 2016
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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.client.connection;
+
+import java.net.Socket;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+
+import org.apache.qpid.client.AMQConnectionURL;
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.transport.network.io.IoNetworkTransport;
+
+public class ExistingSocketTest extends QpidBrokerTestCase
+{
+    public static final String SOCKET_NAME = "mysock";
+
+    public void testExistingSocket_SuccessfulConnection() throws Exception
+    {
+        // Suppress negotiation
+        setTestClientSystemProperty(ClientProperties.AMQP_VERSION, getBrokerProtocol().getProtocolVersion());
+
+        try(Socket sock = new Socket("localhost", getDefaultAmqpPort()))
+        {
+
+            IoNetworkTransport.registerOpenSocket(SOCKET_NAME, sock);
+
+            String url = String.format("amqp://guest:guest@/test?brokerlist='socket://%s'",
SOCKET_NAME);
+
+            Connection conn = getConnection(new AMQConnectionURL(url));
+            conn.createSession(true, javax.jms.Session.SESSION_TRANSACTED);
+            conn.close();
+        }
+    }
+
+    public void testExistingSocket_UnknownSocket() throws Exception
+    {
+        final Object unknownSockName = "unknownSock";
+
+        String url = String.format("amqp://guest:guest@/test?brokerlist='socket://%s'", unknownSockName);
+
+        try
+        {
+            getConnection(new AMQConnectionURL(url));
+        }
+        catch (JMSException e)
+        {
+            String expected = String.format("Error creating connection: No socket registered
with id 'unknownSock'",
+                                            unknownSockName);
+            assertEquals(expected, e.getMessage());
+        }
+    }
+}



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


Mime
View raw message