mirror of https://github.com/apache/activemq.git
added full test for MapMessage together with fixing a bug with long marshalling types and headers
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@380666 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
76494afa3f
commit
7130f43c8f
|
@ -39,22 +39,26 @@ namespace OpenWire.Client.Commands
|
|||
get {
|
||||
if (body == null)
|
||||
{
|
||||
body = PrimitiveMap.Unmarshal(Content);
|
||||
}
|
||||
body = PrimitiveMap.Unmarshal(Content);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
public void BeforeMarshall(OpenWireFormat wireFormat)
|
||||
public override void BeforeMarshall(OpenWireFormat wireFormat)
|
||||
{
|
||||
base.BeforeMarshall(wireFormat);
|
||||
|
||||
if (body == null) {
|
||||
if (body == null)
|
||||
{
|
||||
Content = null;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
Content = body.Marshal();
|
||||
}
|
||||
|
||||
Console.WriteLine("BeforeMarshalling, content is: " + Content);
|
||||
|
||||
base.BeforeMarshall(wireFormat);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ namespace OpenWire.Client.Commands
|
|||
return true;
|
||||
}
|
||||
|
||||
public void BeforeMarshall(OpenWireFormat wireFormat)
|
||||
public virtual void BeforeMarshall(OpenWireFormat wireFormat)
|
||||
{
|
||||
MarshalledProperties = null;
|
||||
if (properties != null)
|
||||
|
@ -286,23 +286,23 @@ namespace OpenWire.Client.Commands
|
|||
}
|
||||
}
|
||||
|
||||
public void AfterMarshall(OpenWireFormat wireFormat)
|
||||
public virtual void AfterMarshall(OpenWireFormat wireFormat)
|
||||
{
|
||||
}
|
||||
|
||||
public void BeforeUnmarshall(OpenWireFormat wireFormat)
|
||||
public virtual void BeforeUnmarshall(OpenWireFormat wireFormat)
|
||||
{
|
||||
}
|
||||
|
||||
public void AfterUnmarshall(OpenWireFormat wireFormat)
|
||||
public virtual void AfterUnmarshall(OpenWireFormat wireFormat)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetMarshalledForm(OpenWireFormat wireFormat, byte[] data)
|
||||
public virtual void SetMarshalledForm(OpenWireFormat wireFormat, byte[] data)
|
||||
{
|
||||
}
|
||||
|
||||
public byte[] GetMarshalledForm(OpenWireFormat wireFormat)
|
||||
public virtual byte[] GetMarshalledForm(OpenWireFormat wireFormat)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -331,6 +331,12 @@ namespace OpenWire.Client.Core
|
|||
dataOut.Write(SwitchEndian(value));
|
||||
}
|
||||
|
||||
public static void WriteLong(long value, BinaryWriter dataOut)
|
||||
{
|
||||
dataOut.Write(SwitchEndian(value));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Switches from one endian to the other
|
||||
/// </summary>
|
||||
|
@ -361,11 +367,6 @@ namespace OpenWire.Client.Core
|
|||
return answer;
|
||||
}
|
||||
|
||||
public static void WriteLong(long value, BinaryWriter dataOut)
|
||||
{
|
||||
dataOut.Write(IPAddress.HostToNetworkOrder(value));
|
||||
}
|
||||
|
||||
public virtual int Marshal1Long(OpenWireFormat wireFormat, long o, BooleanStream bs)
|
||||
{
|
||||
if (o == 0L)
|
||||
|
|
|
@ -104,14 +104,14 @@ namespace OpenWire.Client
|
|||
Assert.AreEqual(custom3, message.Properties["custom3"], "custom3");
|
||||
Assert.AreEqual(custom4, message.Properties["custom4"], "custom4");
|
||||
// TODO
|
||||
//Assert.AreEqual(custom5, message.Properties["custom5"], "custom5");
|
||||
Assert.AreEqual(custom5, message.Properties["custom5"], "custom5");
|
||||
Assert.AreEqual(custom6, message.Properties["custom6"], "custom6");
|
||||
|
||||
Assert.AreEqual(custom1, message.Properties.GetBool("custom1"), "custom1");
|
||||
Assert.AreEqual(custom2, message.Properties.GetByte("custom2"), "custom2");
|
||||
Assert.AreEqual(custom3, message.Properties.GetShort("custom3"), "custom3");
|
||||
Assert.AreEqual(custom4, message.Properties.GetInt("custom4"), "custom4");
|
||||
//Assert.AreEqual(custom5, message.Properties.GetLong("custom5"), "custom5");
|
||||
Assert.AreEqual(custom5, message.Properties.GetLong("custom5"), "custom5");
|
||||
Assert.AreEqual(custom6, message.Properties.GetChar("custom6"), "custom6");
|
||||
|
||||
// lets now look at some standard JMS headers
|
||||
|
|
|
@ -43,23 +43,53 @@ namespace OpenWire.Client
|
|||
|
||||
protected override IMessage CreateMessage(ISession session)
|
||||
{
|
||||
IMapMessage request = session.CreateMapMessage();
|
||||
return request;
|
||||
IMapMessage message = session.CreateMapMessage();
|
||||
|
||||
message.Body["a"] = a;
|
||||
message.Body["b"] = b;
|
||||
message.Body["c"] = c;
|
||||
message.Body["d"] = d;
|
||||
message.Body["e"] = e;
|
||||
message.Body["f"] = f;
|
||||
message.Body["g"] = g;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
protected override void AssertValidMessage(IMessage message)
|
||||
{
|
||||
Assert.IsTrue(message is IMapMessage, "Did not receive a MapMessage!");
|
||||
|
||||
Console.WriteLine("Received MapMessage: " + message);
|
||||
|
||||
IMapMessage mapMessage = (IMapMessage) message;
|
||||
|
||||
/*
|
||||
String text = mapMessage.Text;
|
||||
Assert.AreEqual(expected, text, "the message text");
|
||||
*/
|
||||
Console.WriteLine("Received MapMessage: " + message);
|
||||
Console.WriteLine("Received Count: " + mapMessage.Body.Count);
|
||||
|
||||
Assert.AreEqual(ToHex(f), ToHex(mapMessage.Body.GetLong("f")), "map entry: f as hex");
|
||||
|
||||
// use generic API to access entries
|
||||
Assert.AreEqual(a, mapMessage.Body["a"], "generic map entry: a");
|
||||
Assert.AreEqual(b, mapMessage.Body["b"], "generic map entry: b");
|
||||
Assert.AreEqual(c, mapMessage.Body["c"], "generic map entry: c");
|
||||
Assert.AreEqual(d, mapMessage.Body["d"], "generic map entry: d");
|
||||
Assert.AreEqual(e, mapMessage.Body["e"], "generic map entry: e");
|
||||
Assert.AreEqual(f, mapMessage.Body["f"], "generic map entry: f");
|
||||
Assert.AreEqual(g, mapMessage.Body["g"], "generic map entry: g");
|
||||
|
||||
// use type safe APIs
|
||||
Assert.AreEqual(a, mapMessage.Body.GetBool("a"), "map entry: a");
|
||||
Assert.AreEqual(b, mapMessage.Body.GetByte("b"), "map entry: b");
|
||||
Assert.AreEqual(c, mapMessage.Body.GetChar("c"), "map entry: c");
|
||||
Assert.AreEqual(d, mapMessage.Body.GetShort("d"), "map entry: d");
|
||||
Assert.AreEqual(e, mapMessage.Body.GetInt("e"), "map entry: e");
|
||||
Assert.AreEqual(f, mapMessage.Body.GetLong("f"), "map entry: f");
|
||||
Assert.AreEqual(g, mapMessage.Body.GetString("g"), "map entry: g");
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected string ToHex(long value)
|
||||
{
|
||||
return String.Format("{0:x}", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue