summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles E. Rolke <chug@apache.org>2014-04-23 19:14:09 +0000
committerCharles E. Rolke <chug@apache.org>2014-04-23 19:14:09 +0000
commit75f9e37431ec7d7ca112012e322133db76808df4 (patch)
tree64236fa55dc72da7239d055127b1dd403fec5d64
parent8a89bd87f49681333c9e0b0ffdffad9b49de5a1d (diff)
downloadqpid-python-75f9e37431ec7d7ca112012e322133db76808df4.tar.gz
QPID-5716: Messaging C++ .NET binding fails to return GetContentObject data
Changes function signature to: object = message.GetContentObject() Adds self tests using SetContentObject and GetContentObject. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1589496 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/bindings/qpid/dotnet/src/Message.cpp4
-rw-r--r--qpid/cpp/bindings/qpid/dotnet/src/Message.h2
-rw-r--r--qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.connection.cs13
-rw-r--r--qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.message.cs94
4 files changed, 96 insertions, 17 deletions
diff --git a/qpid/cpp/bindings/qpid/dotnet/src/Message.cpp b/qpid/cpp/bindings/qpid/dotnet/src/Message.cpp
index 24755a7fe3..c62bf9446f 100644
--- a/qpid/cpp/bindings/qpid/dotnet/src/Message.cpp
+++ b/qpid/cpp/bindings/qpid/dotnet/src/Message.cpp
@@ -565,7 +565,7 @@ namespace Messaging {
}
- void Message::GetContentObject(System::Object ^ managedObject)
+ System::Object ^ Message::GetContentObject()
{
msclr::lock lk(privateLock);
ThrowIfDisposed();
@@ -576,7 +576,7 @@ namespace Messaging {
{
::qpid::types::Variant nativeObject = nativeObjPtr->getContentObject();
- managedObject = TypeTranslator::NativeToManagedObject(nativeObject);
+ return TypeTranslator::NativeToManagedObject(nativeObject);
}
catch (const ::qpid::types::Exception & error)
{
diff --git a/qpid/cpp/bindings/qpid/dotnet/src/Message.h b/qpid/cpp/bindings/qpid/dotnet/src/Message.h
index 2b64ef90f3..c706d11ce5 100644
--- a/qpid/cpp/bindings/qpid/dotnet/src/Message.h
+++ b/qpid/cpp/bindings/qpid/dotnet/src/Message.h
@@ -455,7 +455,7 @@ namespace Messaging {
void GetContent(cli::array<System::Byte> ^ arr);
// get content as object
- void GetContentObject(System::Object ^ object);
+ System::Object ^ GetContentObject();
//
// ContentSize
diff --git a/qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.connection.cs b/qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.connection.cs
index dd368b5e5e..c93f1d63f7 100644
--- a/qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.connection.cs
+++ b/qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.connection.cs
@@ -54,9 +54,7 @@ namespace Org.Apache.Qpid.Messaging.UnitTest
public void ConnectionCreate_2()
{
Dictionary<string, object> options = new Dictionary<string, object>();
- options["id"] = 987654321;
- options["name"] = "Widget";
- options["percent"] = 0.99;
+ options["reconnect"] = true;
Connection myConn = new Connection("url", options);
Assert.IsFalse(myConn.IsOpen);
@@ -73,12 +71,10 @@ namespace Org.Apache.Qpid.Messaging.UnitTest
public void ConnectionSetOption()
{
Dictionary<string, object> options = new Dictionary<string, object>();
- options["id"] = 987654321;
- options["name"] = "Widget";
- options["percent"] = 0.99;
+ options["reconnect"] = true;
Connection myConn = new Connection("url", options);
- myConn.SetOption("name", "purple");
+ myConn.SetOption("reconnect", false);
Assert.IsFalse(myConn.IsOpen);
}
@@ -87,9 +83,6 @@ namespace Org.Apache.Qpid.Messaging.UnitTest
public void ConnectionClose()
{
Dictionary<string, object> options = new Dictionary<string, object>();
- options["id"] = 987654321;
- options["name"] = "Widget";
- options["percent"] = 0.99;
Connection myConn = new Connection("url", options);
myConn.Close();
diff --git a/qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.message.cs b/qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.message.cs
index ac834047ad..3912278148 100644
--- a/qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.message.cs
+++ b/qpid/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.message.cs
@@ -240,8 +240,8 @@ namespace Org.Apache.Qpid.Messaging.UnitTest
StringAssert.IsMatch("System.Boolean", rxContent["mybool"].GetType().ToString());
bool rxbool = (bool)rxContent["mybool"];
- StringAssert.IsMatch("System.SByte", rxContent["mybyte"].GetType().ToString());
- sbyte rxbyte = (sbyte)rxContent["mybyte"];
+ StringAssert.IsMatch("System.Byte", rxContent["mybyte"].GetType().ToString());
+ byte rxbyte = (byte)rxContent["mybyte"];
StringAssert.IsMatch("System.UInt16", rxContent["myUInt16"].GetType().ToString());
UInt16 rxUInt16 = (UInt16)rxContent["myUInt16"];
@@ -252,7 +252,7 @@ namespace Org.Apache.Qpid.Messaging.UnitTest
StringAssert.IsMatch("System.UInt64", rxContent["myUInt64"].GetType().ToString());
UInt64 rxUInt64 = (UInt64)rxContent["myUInt64"];
- StringAssert.IsMatch("System.Int32", rxContent["mychar"].GetType().ToString());
+ StringAssert.IsMatch("System.SByte", rxContent["mychar"].GetType().ToString());
char rxchar = System.Convert.ToChar(rxContent["mychar"]);
StringAssert.IsMatch("System.Int16", rxContent["myInt16"].GetType().ToString());
@@ -288,7 +288,93 @@ namespace Org.Apache.Qpid.Messaging.UnitTest
Assert.AreEqual(11, rxInt64);
Assert.AreEqual((Single)12.12, rxSingle);
Assert.AreEqual((Double)13.13, rxDouble);
- StringAssert.IsMatch("00010203-0405-0607-0809-0a0b0c0d0e0f", rxGuid.ToString());
+ StringAssert.IsMatch("03020100-0504-0706-0809-0a0b0c0d0e0f", rxGuid.ToString());
+ }
+
+ [Test]
+ public void MessageContentAsObject()
+ {
+ // Only processes primitive data types
+
+ // Create the message
+ Message message = new Message();
+ Object gotThis = new Object();
+
+
+ // add one of each supported amqp data type
+ bool mybool = true;
+ message.SetContentObject(mybool);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.Boolean", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(mybool));
+
+ byte mybyte = 4;
+ message.SetContentObject(mybyte);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.Byte", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(mybyte));
+
+ UInt16 myUInt16 = 5;
+ message.SetContentObject(myUInt16);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.UInt16", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(myUInt16));
+
+ UInt32 myUInt32 = 6;
+ message.SetContentObject(myUInt32);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.UInt32", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(myUInt32));
+
+ UInt64 myUInt64 = 7;
+ message.SetContentObject(myUInt64);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.UInt64", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(myUInt64));
+
+ char mychar = 'h';
+ message.SetContentObject(mychar);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.SByte", gotThis.GetType().ToString());
+ char result;
+ result = Convert.ToChar(gotThis);
+ Assert.IsTrue(result.Equals(mychar));
+
+ Int16 myInt16 = 9;
+ message.SetContentObject(myInt16);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.Int16", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(myInt16));
+
+ Int32 myInt32 = 10;
+ message.SetContentObject(myInt32);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.Int32", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(myInt32));
+
+ Int64 myInt64 = 11;
+ message.SetContentObject(myInt64);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.Int64", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(myInt64));
+
+ Single mySingle = (Single)12.12;
+ message.SetContentObject(mySingle);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.Single", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(mySingle));
+
+ Double myDouble = 13.13;
+ message.SetContentObject(myDouble);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.Double", gotThis.GetType().ToString());
+ Assert.IsTrue(gotThis.Equals(myDouble));
+
+ Guid myGuid = new Guid("000102030405060708090a0b0c0d0e0f");
+ message.SetContentObject(myGuid);
+ gotThis = message.GetContentObject();
+ StringAssert.IsMatch("System.Guid", gotThis.GetType().ToString());
+ StringAssert.IsMatch("03020100-0504-0706-0809-0a0b0c0d0e0f", gotThis.ToString());
}
}
}