public void TestClearBody() { ActiveMQMapMessage mapMessage = new ActiveMQMapMessage(); mapMessage.Body.SetString("String", "String"); mapMessage.ClearBody(); Assert.IsFalse(mapMessage.ReadOnlyBody); mapMessage.OnSend(); mapMessage.Content = mapMessage.Content; Assert.IsNull(mapMessage.Body.GetString("String")); mapMessage.ClearBody(); mapMessage.Body.SetString("String", "String"); mapMessage = (ActiveMQMapMessage)mapMessage.Clone(); mapMessage.Body.GetString("String"); }
public void TestGetBoolean() { ActiveMQMapMessage msg = new ActiveMQMapMessage(); msg.Body.SetBool(name, true); msg.ReadOnlyBody = true; Assert.IsTrue(msg.Body.GetBool(name)); msg.ClearBody(); msg.Body.SetString(name, "True"); msg = (ActiveMQMapMessage)msg.Clone(); Assert.IsTrue(msg.Body.GetBool(name)); }
public void TestGetObject() { ActiveMQMapMessage msg = new ActiveMQMapMessage(); Boolean booleanValue = true; Byte byteValue = Byte.Parse("1"); byte[] bytesValue = new byte[3]; Char charValue = (Char)'a'; Double doubleValue = Double.Parse("1.5", CultureInfo.InvariantCulture); Single floatValue = Single.Parse("1.5", CultureInfo.InvariantCulture); Int32 intValue = Int32.Parse("1"); Int64 longValue = Int64.Parse("1"); Int16 shortValue = Int16.Parse("1"); String stringValue = "string"; try { msg.Body["boolean"] = booleanValue; msg.Body["byte"] = byteValue; msg.Body["bytes"] = bytesValue; msg.Body["char"] = charValue; msg.Body["double"] = doubleValue; msg.Body["float"] = floatValue; msg.Body["int"] = intValue; msg.Body["long"] = longValue; msg.Body["short"] = shortValue; msg.Body["string"] = stringValue; } catch (MessageFormatException) { Assert.Fail("object formats should be correct"); } msg = (ActiveMQMapMessage)msg.Clone(); Assert.IsTrue(msg.Body["boolean"] is Boolean); Assert.AreEqual(msg.Body["boolean"], booleanValue); Assert.AreEqual(msg.Body.GetBool("boolean"), booleanValue); Assert.IsTrue(msg.Body["byte"] is Byte); Assert.AreEqual(msg.Body["byte"], byteValue); Assert.AreEqual(msg.Body.GetByte("byte"), byteValue); Assert.IsTrue(msg.Body["bytes"] is byte[]); Assert.AreEqual(((byte[])msg.Body["bytes"]).Length, bytesValue.Length); Assert.AreEqual((msg.Body["bytes"] as byte[]).Length, bytesValue.Length); Assert.IsTrue(msg.Body["char"] is Char); Assert.AreEqual(msg.Body["char"], charValue); Assert.AreEqual(msg.Body.GetChar("char"), charValue); Assert.IsTrue(msg.Body["double"] is Double); Assert.AreEqual(msg.Body["double"], doubleValue); Assert.AreEqual(msg.Body.GetDouble("double"), doubleValue, 0); Assert.IsTrue(msg.Body["float"] is Single); Assert.AreEqual(msg.Body["float"], floatValue); Assert.AreEqual(msg.Body.GetFloat("float"), floatValue, 0); Assert.IsTrue(msg.Body["int"] is Int32); Assert.AreEqual(msg.Body["int"], intValue); Assert.AreEqual(msg.Body.GetInt("int"), intValue); Assert.IsTrue(msg.Body["long"] is Int64); Assert.AreEqual(msg.Body["long"], longValue); Assert.AreEqual(msg.Body.GetLong("long"), longValue); Assert.IsTrue(msg.Body["short"] is Int16); Assert.AreEqual(msg.Body["short"], shortValue); Assert.AreEqual(msg.Body.GetShort("short"), shortValue); Assert.IsTrue(msg.Body["string"] is String); Assert.AreEqual(msg.Body["string"], stringValue); Assert.AreEqual(msg.Body.GetString("string"), stringValue); msg.ClearBody(); try { msg.Body["object"] = new Object(); Assert.Fail("should have thrown exception"); } catch (MessageFormatException) { } }