qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject svn commit: r1661929 - in /qpid/trunk/qpid/java: broker-core/src/main/java/org/apache/qpid/server/model/adapter/ broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ broker-plugins/management-jmx/src/test/java/org/apache/qpid/...
Date Tue, 24 Feb 2015 12:57:42 GMT
Author: orudyy
Date: Tue Feb 24 12:57:42 2015
New Revision: 1661929

URL: http://svn.apache.org/r1661929
Log:
QPID-6410: [Java Broker] Disambiguate connection adapter name by adding a connection ID to
the name

Modified:
    qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
    qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java
    qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBeanTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
    qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/ConnectionRestTest.java

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java?rev=1661929&r1=1661928&r2=1661929&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
Tue Feb 24 12:57:42 2015
@@ -78,7 +78,7 @@ public final class ConnectionAdapter ext
     {
         Map<String,Object> attributes = new HashMap<String, Object>();
         attributes.put(ID, UUID.randomUUID());
-        attributes.put(NAME, _connection.getRemoteAddressString().replaceAll("/", ""));
+        attributes.put(NAME, "[" + _connection.getConnectionId() + "] " + _connection.getRemoteAddressString().replaceAll("/",
""));
         attributes.put(DURABLE, false);
         return attributes;
     }

Modified: qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java?rev=1661929&r1=1661928&r2=1661929&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBean.java
Tue Feb 24 12:57:42 2015
@@ -100,7 +100,7 @@ public class ConnectionMBean extends Abs
 
     public String getObjectInstanceName()
     {
-        return ObjectName.quote(getRemoteAddress());
+        return ObjectName.quote(getConfiguredObject().getName());
     }
 
     @Override

Modified: qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBeanTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBeanTest.java?rev=1661929&r1=1661928&r2=1661929&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBeanTest.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ConnectionMBeanTest.java
Tue Feb 24 12:57:42 2015
@@ -159,9 +159,9 @@ public class ConnectionMBeanTest extends
 
     public void testGetObjectInstanceName()
     {
-        String remoteAddress = "testRemoteAddress";
-        String quotedRemoteAddress = "\"testRemoteAddress\"";
-        when(_mockConnection.getAttribute(Connection.REMOTE_ADDRESS)).thenReturn(remoteAddress);
+        String name = "[1] 127.0.0.1:5555";
+        String quotedRemoteAddress = "\"" + name +"\"";
+        when(_mockConnection.getName()).thenReturn(name);
         String objectInstanceName = _connectionMBean.getObjectInstanceName();
         assertEquals(quotedRemoteAddress, objectInstanceName);
     }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java?rev=1661929&r1=1661928&r2=1661929&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
Tue Feb 24 12:57:42 2015
@@ -31,10 +31,12 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.security.GeneralSecurityException;
 import java.security.KeyStore;
 import java.util.Collections;
@@ -575,4 +577,20 @@ public class RestTestHelper
         }
     }
 
+    public String encode(String value, String encoding) throws UnsupportedEncodingException
+    {
+        return URLEncoder.encode(value, encoding).replace("+", "%20");
+    }
+
+    public String encodeAsUTF(String value)
+    {
+        try
+        {
+            return encode(value, "UTF8");
+        }
+        catch(UnsupportedEncodingException e)
+        {
+            throw new RuntimeException("Unsupported encoding UTF8", e);
+        }
+    }
 }

Modified: qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/ConnectionRestTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/ConnectionRestTest.java?rev=1661929&r1=1661928&r2=1661929&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/ConnectionRestTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/ConnectionRestTest.java
Tue Feb 24 12:57:42 2015
@@ -21,7 +21,6 @@
 package org.apache.qpid.systest.rest;
 
 import java.io.IOException;
-import java.net.URLDecoder;
 import java.util.List;
 import java.util.Map;
 
@@ -112,7 +111,7 @@ public class ConnectionRestTest extends
         String connectionName = getConnectionName();
 
         Map<String, Object> connectionDetails = getRestTestHelper().getJsonAsSingletonList("connection/test/test/"
-                + URLDecoder.decode(connectionName, "UTF-8"));
+                + getRestTestHelper().encodeAsUTF(connectionName));
         assertConnection(connectionDetails);
     }
 
@@ -124,7 +123,7 @@ public class ConnectionRestTest extends
         List<Map<String, Object>> connections = getRestTestHelper().getJsonAsList("connection/test/test");
         assertEquals("Unexpected number of connections before deletion", 1, connections.size());
 
-        String connectionUrl = "connection/test/test/" + URLDecoder.decode(connectionName,
"UTF-8");
+        String connectionUrl = "connection/test/test/" + getRestTestHelper().encodeAsUTF(connectionName);
         getRestTestHelper().submitRequest(connectionUrl, "DELETE", HttpServletResponse.SC_OK);
 
         connections = getRestTestHelper().getJsonAsList("connection/test/test");
@@ -161,7 +160,7 @@ public class ConnectionRestTest extends
         String connectionName = getConnectionName();
 
         List<Map<String, Object>> sessions = getRestTestHelper().getJsonAsList("session/test/test/"
-                + URLDecoder.decode(connectionName, "UTF-8"));
+                + getRestTestHelper().encodeAsUTF(connectionName));
         assertEquals("Unexpected number of sessions", 1, sessions.size());
         assertSession(sessions.get(0), (AMQSession<?, ?>) _session);
     }
@@ -172,7 +171,7 @@ public class ConnectionRestTest extends
         String connectionName = getConnectionName();
 
         List<Map<String, Object>> sessions = getRestTestHelper().getJsonAsList("session/test/test/"
-                + URLDecoder.decode(connectionName, "UTF-8") + "/" + ((AMQSession<?, ?>)
_session).getChannelId());
+                + getRestTestHelper().encodeAsUTF(connectionName) + "/" + ((AMQSession<?,
?>) _session).getChannelId());
         assertEquals("Unexpected number of sessions", 1, sessions.size());
         assertSession(sessions.get(0), (AMQSession<?, ?>) _session);
     }
@@ -187,7 +186,8 @@ public class ConnectionRestTest extends
         String connectionName = getConnectionName();
 
         List<Map<String, Object>> sessions = getRestTestHelper().getJsonAsList("session/test/test/"
-                                                                               + URLDecoder.decode(connectionName,
"UTF-8") + "/" + ((AMQSession<?, ?>) _session).getChannelId());
+                                                                               + getRestTestHelper().encodeAsUTF(connectionName)
+                                                                               + "/" + ((AMQSession<?,
?>) _session).getChannelId());
         assertEquals("Unexpected number of sessions", 1, sessions.size());
 
         final Map<String, Object> sessionData = sessions.get(0);



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


Mime
View raw message