https://issues.apache.org/jira/browse/AMQCPP-607
Add basic provider information to the WireFormatInfo
(cherry picked from commit fe3b221630daf3bfb2e8c99569acfdba86c76246)
diff --git a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.cpp b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.cpp
index 1faea34..cb2aef8 100644
--- a/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.cpp
+++ b/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormatFactory.cpp
@@ -18,6 +18,8 @@
#include <activemq/wireformat/openwire/OpenWireFormatFactory.h>
#include <activemq/wireformat/openwire/OpenWireFormat.h>
+#include <activemq/core/ActiveMQConnectionMetaData.h>
+
#include <decaf/lang/Boolean.h>
#include <decaf/lang/Integer.h>
#include <decaf/lang/Long.h>
@@ -26,6 +28,7 @@
using namespace std;
using namespace activemq;
using namespace activemq::util;
+using namespace activemq::core;
using namespace activemq::commands;
using namespace activemq::transport;
using namespace activemq::exceptions;
@@ -39,6 +42,8 @@
try {
+ ActiveMQConnectionMetaData meta;
+
Pointer<WireFormatInfo> info(new WireFormatInfo());
// Configure the version to use
@@ -62,6 +67,10 @@
info->setMaxInactivityDurationInitalDelay(
Long::parseLong(properties.getProperty("wireFormat.MaxInactivityDurationInitalDelay", "10000")));
+ info->getProperties().setString("ProviderName", meta.getCMSProviderName());
+ info->getProperties().setString("ProviderVersion", meta.getProviderVersion());
+ info->getProperties().setString("PlatformDetails", "C++");
+
// Create the Openwire Format Object
Pointer<OpenWireFormat> wireFormat(new OpenWireFormat(properties));
diff --git a/activemq-cpp/src/test/activemq/wireformat/openwire/OpenWireFormatTest.cpp b/activemq-cpp/src/test/activemq/wireformat/openwire/OpenWireFormatTest.cpp
index 2981ee9..4921bc3 100644
--- a/activemq-cpp/src/test/activemq/wireformat/openwire/OpenWireFormatTest.cpp
+++ b/activemq-cpp/src/test/activemq/wireformat/openwire/OpenWireFormatTest.cpp
@@ -18,11 +18,15 @@
#include "OpenWireFormatTest.h"
#include <decaf/util/Properties.h>
+#include <activemq/wireformat/openwire/OpenWireFormatFactory.h>
#include <activemq/wireformat/openwire/OpenWireFormat.h>
+#include <activemq/core/ActiveMQConnectionMetaData.h>
+
using namespace std;
using namespace activemq;
using namespace activemq::util;
+using namespace activemq::core;
using namespace decaf::io;
using namespace decaf::lang;
using namespace decaf::util;
@@ -31,8 +35,18 @@
using namespace activemq::wireformat::openwire;
////////////////////////////////////////////////////////////////////////////////
-void OpenWireFormatTest::test()
-{
+void OpenWireFormatTest::testProviderInfoInWireFormat() {
+ ActiveMQConnectionMetaData meta;
+
+ OpenWireFormatFactory factory;
Properties properties;
- //OpenWireFormat myWireFormat( properties );
+
+ Pointer<OpenWireFormat> myWireFormat =
+ factory.createWireFormat(properties).dynamicCast<OpenWireFormat>();
+
+ CPPUNIT_ASSERT_EQUAL(meta.getCMSProviderName(),
+ myWireFormat->getPreferedWireFormatInfo()->getProperties().getString("ProviderName"));
+ CPPUNIT_ASSERT_EQUAL(meta.getProviderVersion(),
+ myWireFormat->getPreferedWireFormatInfo()->getProperties().getString("ProviderVersion"));
+ CPPUNIT_ASSERT(!myWireFormat->getPreferedWireFormatInfo()->getProperties().getString("PlatformDetails").empty());
}
diff --git a/activemq-cpp/src/test/activemq/wireformat/openwire/OpenWireFormatTest.h b/activemq-cpp/src/test/activemq/wireformat/openwire/OpenWireFormatTest.h
index ae53970..1d2ef98 100644
--- a/activemq-cpp/src/test/activemq/wireformat/openwire/OpenWireFormatTest.h
+++ b/activemq-cpp/src/test/activemq/wireformat/openwire/OpenWireFormatTest.h
@@ -28,7 +28,7 @@
class OpenWireFormatTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE( OpenWireFormatTest );
- CPPUNIT_TEST( test );
+ CPPUNIT_TEST( testProviderInfoInWireFormat );
CPPUNIT_TEST_SUITE_END();
public:
@@ -36,7 +36,7 @@
OpenWireFormatTest() {}
virtual ~OpenWireFormatTest() {}
- virtual void test();
+ virtual void testProviderInfoInWireFormat();
};