You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2014/12/16 22:01:32 UTC
svn commit: r1646075 - in
/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src:
main/csharp/OpenWire/BaseDataStreamMarshaller.cs
test/csharp/OpenWire/BaseDataStreamMarshallerTest.cs
Author: tabish
Date: Tue Dec 16 21:01:31 2014
New Revision: 1646075
URL: http://svn.apache.org/r1646075
Log:
https://issues.apache.org/jira/browse/AMQNET-495
Read compacted long values as unsigned.
Added:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BaseDataStreamMarshallerTest.cs (with props)
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/BaseDataStreamMarshaller.cs
Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/BaseDataStreamMarshaller.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/BaseDataStreamMarshaller.cs?rev=1646075&r1=1646074&r2=1646075&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/BaseDataStreamMarshaller.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/BaseDataStreamMarshaller.cs Tue Dec 16 21:01:31 2014
@@ -28,7 +28,6 @@ namespace Apache.NMS.ActiveMQ.OpenWire
/// </summary>
public abstract class BaseDataStreamMarshaller
{
-
private static readonly String[] HEX_TABLE = new String[]{
"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f",
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f",
@@ -55,6 +54,7 @@ namespace Apache.NMS.ActiveMQ.OpenWire
{
return 0;
}
+
public virtual void TightMarshal2(
OpenWireFormat wireFormat,
Object o,
@@ -70,8 +70,7 @@ namespace Apache.NMS.ActiveMQ.OpenWire
BooleanStream bs)
{
}
-
-
+
protected virtual DataStructure TightUnmarshalNestedObject(
OpenWireFormat wireFormat,
BinaryReader dataIn,
@@ -262,6 +261,7 @@ namespace Apache.NMS.ActiveMQ.OpenWire
}
}
}
+
public virtual long TightUnmarshalLong(OpenWireFormat wireFormat, BinaryReader dataIn, BooleanStream bs)
{
if (bs.ReadBoolean())
@@ -272,14 +272,14 @@ namespace Apache.NMS.ActiveMQ.OpenWire
}
else
{
- return dataIn.ReadInt32();
+ return dataIn.ReadUInt32();
}
}
else
{
if (bs.ReadBoolean())
{
- return dataIn.ReadInt16();
+ return dataIn.ReadUInt16();
}
else
{
@@ -287,6 +287,7 @@ namespace Apache.NMS.ActiveMQ.OpenWire
}
}
}
+
protected virtual int TightMarshalObjectArray1(
OpenWireFormat wireFormat,
DataStructure[] objects,
@@ -326,7 +327,6 @@ namespace Apache.NMS.ActiveMQ.OpenWire
}
}
-
protected virtual BrokerError TightUnmarshalBrokerError(
OpenWireFormat wireFormat,
BinaryReader dataIn,
@@ -422,7 +422,6 @@ namespace Apache.NMS.ActiveMQ.OpenWire
}
}
-
public virtual void LooseMarshal(
OpenWireFormat wireFormat,
Object o,
@@ -437,7 +436,6 @@ namespace Apache.NMS.ActiveMQ.OpenWire
{
}
-
protected virtual DataStructure LooseUnmarshalNestedObject(
OpenWireFormat wireFormat,
BinaryReader dataIn)
@@ -457,48 +455,17 @@ namespace Apache.NMS.ActiveMQ.OpenWire
OpenWireFormat wireFormat,
BinaryReader dataIn)
{
- /*
- if (wireFormat.isCacheEnabled()) {
- if (bs.ReadBoolean()) {
- short index = dataIndataIn.ReadInt16()Int16();
- DataStructure value = wireFormat.UnmarshalNestedObject(dataIn, bs);
- wireFormat.setInUnmarshallCache(index, value);
- return value;
- } else {
- short index = dataIn.ReadInt16();
- return wireFormat.getFromUnmarshallCache(index);
- }
- } else {
- return wireFormat.UnmarshalNestedObject(dataIn, bs);
- }
- */
return wireFormat.LooseUnmarshalNestedObject(dataIn);
}
-
-
+
protected virtual void LooseMarshalCachedObject(
OpenWireFormat wireFormat,
DataStructure o,
BinaryWriter dataOut)
{
- /*
- if (wireFormat.isCacheEnabled()) {
- Short index = wireFormat.getMarshallCacheIndex(o);
- if (bs.ReadBoolean()) {
- dataOut.Write(index.shortValue(), dataOut);
- wireFormat.Marshal2NestedObject(o, dataOut, bs);
- } else {
- dataOut.Write(index.shortValue(), dataOut);
- }
- } else {
- wireFormat.Marshal2NestedObject(o, dataOut, bs);
- }
- */
wireFormat.LooseMarshalNestedObject(o, dataOut);
}
-
-
-
+
protected virtual String LooseUnmarshalString(BinaryReader dataIn)
{
if (dataIn.ReadBoolean())
@@ -510,8 +477,7 @@ namespace Apache.NMS.ActiveMQ.OpenWire
return null;
}
}
-
-
+
public static void LooseMarshalString(String value, BinaryWriter dataOut)
{
dataOut.Write(value != null);
@@ -655,8 +621,6 @@ namespace Apache.NMS.ActiveMQ.OpenWire
return new String(text);
}
-
-
/// <summary>
/// Converts the object to a String
/// </summary>
@@ -664,6 +628,7 @@ namespace Apache.NMS.ActiveMQ.OpenWire
{
return ToString(id.ProducerId) + ":" + id.ProducerSequenceId;
}
+
/// <summary>
/// Converts the object to a String
/// </summary>
@@ -672,7 +637,6 @@ namespace Apache.NMS.ActiveMQ.OpenWire
return id.ConnectionId + ":" + id.SessionId + ":" + id.Value;
}
-
/// <summary>
/// Converts the given transaction ID into a String
/// </summary>
@@ -703,7 +667,6 @@ namespace Apache.NMS.ActiveMQ.OpenWire
}
return buffer.ToString();
}
-
}
}
Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BaseDataStreamMarshallerTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BaseDataStreamMarshallerTest.cs?rev=1646075&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BaseDataStreamMarshallerTest.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BaseDataStreamMarshallerTest.cs Tue Dec 16 21:01:31 2014
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+using Apache.NMS.ActiveMQ.OpenWire;
+using Apache.NMS.ActiveMQ.Commands;
+using Apache.NMS.Util;
+using NUnit.Framework;
+
+namespace Apache.NMS.ActiveMQ.Test
+{
+ [TestFixture]
+ public class BaseDataStreamMarshalerTest
+ {
+ OpenWireFormat wireFormat;
+ TestDataStreamMarshaller testMarshaller;
+
+ [SetUp]
+ public void SetUp()
+ {
+ wireFormat = new OpenWireFormat();
+ testMarshaller = new TestDataStreamMarshaller();
+ }
+
+ [Test]
+ public void TestCompactedLongToIntegerTightUnmarshal()
+ {
+ long inputValue = 2147483667;
+
+ BooleanStream stream = new BooleanStream();
+ stream.WriteBoolean(true);
+ stream.WriteBoolean(false);
+
+ stream.Clear();
+
+ MemoryStream buffer = new MemoryStream();
+ BinaryWriter ds = new EndianBinaryWriter(buffer);
+
+ ds.Write((int) inputValue);
+
+ MemoryStream ins = new MemoryStream(buffer.ToArray());
+ BinaryReader dis = new EndianBinaryReader(ins);
+
+ long outputValue = testMarshaller.TightUnmarshalLong(wireFormat, dis, stream);
+ Assert.AreEqual(inputValue, outputValue);
+ }
+
+ [Test]
+ public void TestCompactedLongToShortTightUnmarshal()
+ {
+ long inputValue = 33000;
+
+ BooleanStream stream = new BooleanStream();
+ stream.WriteBoolean(false);
+ stream.WriteBoolean(true);
+
+ stream.Clear();
+
+ MemoryStream buffer = new MemoryStream();
+ BinaryWriter ds = new EndianBinaryWriter(buffer);
+
+ ds.Write((short) inputValue);
+
+ MemoryStream ins = new MemoryStream(buffer.ToArray());
+ BinaryReader dis = new EndianBinaryReader(ins);
+
+ long outputValue = testMarshaller.TightUnmarshalLong(wireFormat, dis, stream);
+ Assert.AreEqual(inputValue, outputValue);
+ }
+
+ private class TestDataStreamMarshaller : BaseDataStreamMarshaller
+ {
+ public override DataStructure CreateObject()
+ {
+ return null;
+ }
+
+ public override byte GetDataStructureType()
+ {
+ return 0;
+ }
+ }
+ }
+}
+
Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BaseDataStreamMarshallerTest.cs
------------------------------------------------------------------------------
svn:eol-style = native