public void WriteBytes(byte[] value, int offset, int length) { InitializeWriting(); try { this.dataOut.Write(PrimitiveMap.BYTE_ARRAY_TYPE); this.dataOut.Write((int) length); this.dataOut.Write(value, offset, length); } catch(IOException e) { NMSExceptionSupport.Create(e); } }
public void TestReadObject() { ActiveMQStreamMessage msg = new ActiveMQStreamMessage(); byte testByte = (byte)2; msg.WriteByte(testByte); msg.Reset(); Assert.IsTrue((byte)msg.ReadObject() == testByte); msg.ClearBody(); short testShort = 3; msg.WriteInt16(testShort); msg.Reset(); Assert.IsTrue((short)msg.ReadObject() == testShort); msg.ClearBody(); int testInt = 4; msg.WriteInt32(testInt); msg.Reset(); Assert.IsTrue((int)msg.ReadObject() == testInt); msg.ClearBody(); long testLong = 6L; msg.WriteInt64(testLong); msg.Reset(); Assert.IsTrue((long)msg.ReadObject() == testLong); msg.ClearBody(); float testFloat = 6.6f; msg.WriteSingle(testFloat); msg.Reset(); Assert.IsTrue((float)msg.ReadObject() == testFloat); msg.ClearBody(); double testDouble = 7.7d; msg.WriteDouble(testDouble); msg.Reset(); Assert.IsTrue((double)msg.ReadObject() == testDouble); msg.ClearBody(); char testChar = 'z'; msg.WriteChar(testChar); msg.Reset(); Assert.IsTrue((char)msg.ReadObject() == testChar); msg.ClearBody(); byte[] data = new byte[50]; for(int i = 0; i < data.Length; i++) { data[i] = (byte)i; } msg.WriteBytes(data); msg.Reset(); byte[] valid = (byte[])msg.ReadObject(); Assert.IsTrue(valid.Length == data.Length); for(int i = 0; i < valid.Length; i++) { Assert.IsTrue(valid[i] == data[i]); } msg.ClearBody(); msg.WriteBoolean(true); msg.Reset(); Assert.IsTrue((bool)msg.ReadObject()); }