You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cs...@apache.org on 2017/12/06 13:41:58 UTC
activemq git commit: AMQ-6871 - By default only send generic platform
details
Repository: activemq
Updated Branches:
refs/heads/master 9d98ee253 -> 5fa0bbd51
AMQ-6871 - By default only send generic platform details
The default behavior by the OpenWire client will be to send generic
platform details to the server with a new flag to send more specific
information.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/5fa0bbd5
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/5fa0bbd5
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/5fa0bbd5
Branch: refs/heads/master
Commit: 5fa0bbd5156f29d97dcf48fd9fdb6a0488a8df1a
Parents: 9d98ee2
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Authored: Wed Nov 29 12:43:20 2017 -0500
Committer: Christopher L. Shannon (cshannon) <ch...@gmail.com>
Committed: Wed Dec 6 08:41:51 2017 -0500
----------------------------------------------------------------------
.../activemq/ActiveMQConnectionMetaData.java | 1 +
.../openwire/OpenWireFormatFactory.java | 17 +++-
.../openwire/WireFormatInfoPropertiesTest.java | 101 ++++++++++---------
3 files changed, 69 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/5fa0bbd5/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionMetaData.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionMetaData.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionMetaData.java
index ff6c38f..38c9761 100644
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionMetaData.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionMetaData.java
@@ -33,6 +33,7 @@ public final class ActiveMQConnectionMetaData implements ConnectionMetaData {
public static final int PROVIDER_MAJOR_VERSION;
public static final int PROVIDER_MINOR_VERSION;
public static final String PROVIDER_NAME = "ActiveMQ";
+ public static final String DEFAULT_PLATFORM_DETAILS = "Java";
public static final String PLATFORM_DETAILS;
public static final ActiveMQConnectionMetaData INSTANCE = new ActiveMQConnectionMetaData();
http://git-wip-us.apache.org/repos/asf/activemq/blob/5fa0bbd5/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormatFactory.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormatFactory.java b/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormatFactory.java
index ba6d643..2614ad7 100644
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormatFactory.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormatFactory.java
@@ -22,7 +22,7 @@ import org.apache.activemq.wireformat.WireFormat;
import org.apache.activemq.wireformat.WireFormatFactory;
/**
- *
+ *
*/
public class OpenWireFormatFactory implements WireFormatFactory {
@@ -44,8 +44,10 @@ public class OpenWireFormatFactory implements WireFormatFactory {
private String host=null;
private String providerName = ActiveMQConnectionMetaData.PROVIDER_NAME;
private String providerVersion = ActiveMQConnectionMetaData.PROVIDER_VERSION;
- private String platformDetails = ActiveMQConnectionMetaData.PLATFORM_DETAILS;
+ private String platformDetails = ActiveMQConnectionMetaData.DEFAULT_PLATFORM_DETAILS;
+ private boolean includePlatformDetails = false;
+ @Override
public WireFormat createWireFormat() {
WireFormatInfo info = new WireFormatInfo();
info.setVersion(version);
@@ -65,6 +67,9 @@ public class OpenWireFormatFactory implements WireFormatFactory {
}
info.setProviderName(providerName);
info.setProviderVersion(providerVersion);
+ if (includePlatformDetails) {
+ platformDetails = ActiveMQConnectionMetaData.PLATFORM_DETAILS;
+ }
info.setPlatformDetails(platformDetails);
} catch (Exception e) {
IllegalStateException ise = new IllegalStateException("Could not configure WireFormatInfo");
@@ -190,4 +195,12 @@ public class OpenWireFormatFactory implements WireFormatFactory {
public void setPlatformDetails(String platformDetails) {
this.platformDetails = platformDetails;
}
+
+ public boolean isIncludePlatformDetails() {
+ return includePlatformDetails;
+ }
+
+ public void setIncludePlatformDetails(boolean includePlatformDetails) {
+ this.includePlatformDetails = includePlatformDetails;
+ }
}
http://git-wip-us.apache.org/repos/asf/activemq/blob/5fa0bbd5/activemq-unit-tests/src/test/java/org/apache/activemq/openwire/WireFormatInfoPropertiesTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/openwire/WireFormatInfoPropertiesTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/openwire/WireFormatInfoPropertiesTest.java
index 5c0608d..2eedd65 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/openwire/WireFormatInfoPropertiesTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/openwire/WireFormatInfoPropertiesTest.java
@@ -25,7 +25,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.URI;
-import java.util.concurrent.atomic.AtomicReference;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
@@ -33,7 +32,8 @@ import org.apache.activemq.ActiveMQConnectionMetaData;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.command.WireFormatInfo;
-import org.apache.activemq.transport.DefaultTransportListener;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,36 +42,60 @@ public class WireFormatInfoPropertiesTest {
static final Logger LOG = LoggerFactory.getLogger(WireFormatInfoPropertiesTest.class);
- protected BrokerService master;
- protected String brokerUri;
+ private BrokerService service;
+ private String brokerUri;
+ private TransportConnector connector;
+
+ @Before
+ public void before() throws Exception {
+ service = new BrokerService();
+ connector = service.addConnector("tcp://localhost:0");
+ brokerUri = connector.getPublishableConnectString();
+ service.setPersistent(false);
+ service.setUseJmx(false);
+ service.setBrokerName("Master");
+ service.start();
+ service.waitUntilStarted();
+ }
+
+ @After
+ public void after() throws Exception {
+ if (service != null) {
+ service.stop();
+ service.waitUntilStopped();
+ }
+ }
@Test
- public void testClientProperties() throws Exception{
- BrokerService service = createBrokerService();
- try {
- ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(new URI(brokerUri));
- ActiveMQConnection conn = (ActiveMQConnection)factory.createConnection();
- final AtomicReference<WireFormatInfo> clientWf = new AtomicReference<WireFormatInfo>();
- conn.addTransportListener(new DefaultTransportListener() {
- @Override
- public void onCommand(Object command) {
- if (command instanceof WireFormatInfo) {
- clientWf.set((WireFormatInfo)command);
- }
- }
- });
- conn.start();
- if (clientWf.get() == null) {
- fail("Wire format info is null");
- }
- assertTrue(clientWf.get().getProperties().containsKey("ProviderName"));
- assertTrue(clientWf.get().getProperties().containsKey("ProviderVersion"));
- assertTrue(clientWf.get().getProperties().containsKey("PlatformDetails"));
- assertTrue(clientWf.get().getProviderName().equals(ActiveMQConnectionMetaData.PROVIDER_NAME));
- assertTrue(clientWf.get().getPlatformDetails().equals(ActiveMQConnectionMetaData.PLATFORM_DETAILS));
- } finally {
- stopBroker(service);
+ public void testClientPropertiesWithDefaultPlatformDetails() throws Exception{
+ WireFormatInfo clientWf = testClientProperties(brokerUri);
+ assertTrue(clientWf.getPlatformDetails().equals(ActiveMQConnectionMetaData.DEFAULT_PLATFORM_DETAILS));
+ }
+
+ @Test
+ public void testClientPropertiesWithPlatformDetails() throws Exception{
+ WireFormatInfo clientWf = testClientProperties(brokerUri + "?wireFormat.includePlatformDetails=true");
+ assertTrue(clientWf.getPlatformDetails().equals(ActiveMQConnectionMetaData.PLATFORM_DETAILS));
+ }
+
+ private WireFormatInfo testClientProperties(String brokerUri) throws Exception {
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(new URI(brokerUri));
+ ActiveMQConnection conn = (ActiveMQConnection)factory.createConnection();
+ conn.start();
+
+ assertTrue(connector.getConnections().size() == 1);
+ final WireFormatInfo clientWf = connector.getConnections().get(0).getRemoteWireFormatInfo();
+ if (clientWf == null) {
+ fail("Wire format info is null");
}
+
+ //verify properties that the client sends to the broker
+ assertTrue(clientWf.getProperties().containsKey("ProviderName"));
+ assertTrue(clientWf.getProperties().containsKey("ProviderVersion"));
+ assertTrue(clientWf.getProperties().containsKey("PlatformDetails"));
+ assertTrue(clientWf.getProviderName().equals(ActiveMQConnectionMetaData.PROVIDER_NAME));
+
+ return clientWf;
}
@Test
@@ -100,23 +124,4 @@ public class WireFormatInfoPropertiesTest {
assertTrue(result.getPlatformDetails().equals(orig.getPlatformDetails()));
}
- private BrokerService createBrokerService() throws Exception {
- BrokerService service = new BrokerService();
- TransportConnector connector = service.addConnector("tcp://localhost:0");
- brokerUri = connector.getPublishableConnectString();
- service.setPersistent(false);
- service.setUseJmx(false);
- service.setBrokerName("Master");
- service.start();
- service.waitUntilStarted();
- return service;
- }
-
- private void stopBroker(BrokerService service) throws Exception {
- if (service != null) {
- service.stop();
- service.waitUntilStopped();
- }
- }
-
}