Inheritance: ActiveMQMessage, IBytesMessage
Exemplo n.º 1
0
	    public void TestReadBoolean() 
		{
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            msg.WriteBoolean(true);
            msg.Reset();
            Assert.IsTrue(msg.ReadBoolean());
	    }
Exemplo n.º 2
0
	    public void TestReadByte()
		{
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            msg.WriteByte( (byte)2 );
            msg.Reset();
            Assert.IsTrue( msg.ReadByte() == 2 );
	    }
Exemplo n.º 3
0
	    public void TestGetBodyLength() 
		{
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
	        int len = 10;

            for(int i = 0; i < len; i++)
			{
                msg.WriteInt64(5L);
            }

            msg.Reset();
            Assert.IsTrue(msg.BodyLength == (len * 8));
	    }
        public void ProcessMessage_WhenMessageIsNotATextMessage_ThenErrorMessageIsSent()
        {
            const string Queue = "SomeQueue";
            var amqMessage = new ActiveMQBytesMessage
                                 {
                                     NMSTimestamp = DateTime.Now,
                                     Destination = new ActiveMQQueue(Queue)
                                 };

            this.testee.ProcessMessage(amqMessage, this.errorMessageProducer);

            this.ErrorMessageShouldBeSent(
                amqMessage, 
                exceptionMessage => exceptionMessage.StartsWith("System.InvalidCastException"), 
                "queue://" + Queue);
        }
 public void TestClearBody()
 {
     ActiveMQBytesMessage bytesMessage = new ActiveMQBytesMessage();
     try {
         bytesMessage.WriteInt32(1);
         bytesMessage.ClearBody();
         Assert.IsFalse(bytesMessage.ReadOnlyBody);
         bytesMessage.WriteInt32(1);
         bytesMessage.ReadInt32();
     }
     catch(MessageNotReadableException)
     {
     }
     catch(MessageNotWriteableException)
     {
         Assert.IsTrue(false);
     }
 }
Exemplo n.º 6
0
		public void TestCommand()
		{
			ActiveMQBytesMessage message = new ActiveMQBytesMessage();
			
			// Test that a BytesMessage is created in WriteOnly mode.
			try
			{
				byte[] content = message.Content;
				content.SetValue(0, 0);
				Assert.Fail("Should have thrown an exception");
			}
			catch
			{
			}
			
			Assert.IsTrue( !message.ReadOnlyBody );
			Assert.IsTrue( !message.ReadOnlyProperties );
			
			message.Reset();
			
			Assert.IsNull( message.Content );
			Assert.IsTrue( message.ReadOnlyBody );
		}
Exemplo n.º 7
0
 public LengthTrackerStream(Stream sink, ActiveMQBytesMessage parent) : base()
 {
     this.sink = sink;
     this.parent = parent;
 }
 protected override IBytesMessage DoCreateBytesMessage()
 {
     ActiveMQBytesMessage message = new ActiveMQBytesMessage();
     message.Connection = this.connection;
     return message;
 }
Exemplo n.º 9
0
 public void TestClearBody()
 {
     ActiveMQBytesMessage message = new ActiveMQBytesMessage();
     message.ClearBody();
     Assert.IsFalse(message.ReadOnlyBody);
 }
Exemplo n.º 10
0
	    public void TestReadChar() {
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            msg.WriteChar('a');
            msg.Reset();
            Assert.IsTrue(msg.ReadChar() == 'a');
	    }
 public LengthTrackerStream(Stream sink, ActiveMQBytesMessage parent) : base()
 {
     this.sink   = sink;
     this.parent = parent;
 }
Exemplo n.º 12
0
 public IBytesMessage CreateBytesMessage(byte[] body)
 {
     ActiveMQBytesMessage answer = new ActiveMQBytesMessage();
     answer.Content = body;
     return ConfigureMessage(answer) as IBytesMessage;
 }
Exemplo n.º 13
0
	    public void TestReadShort() {
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            msg.WriteInt16((short) 3000);
            msg.Reset();
            Assert.IsTrue(msg.ReadInt16() == 3000);
	    }
Exemplo n.º 14
0
	    public void TestReadFloat() {
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            msg.WriteSingle(3.3f);
            msg.Reset();
            Assert.IsTrue(msg.ReadSingle() == 3.3f);
	    }
Exemplo n.º 15
0
	    public void TestReadLong() {
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            msg.WriteInt64(3000);
            msg.Reset();
            Assert.IsTrue(msg.ReadInt64() == 3000);
	    }
        public void TestBytesMessageTransformation()
        {
            ActiveMQBytesMessage message = new ActiveMQBytesMessage();

            Assert.AreSame(message, transformer.TransformMessage<ActiveMQMessage>(message));
        }
Exemplo n.º 17
0
	    public void TestWriteOnlyBody() 
		{
	        ActiveMQBytesMessage message = new ActiveMQBytesMessage();
	        message.ClearBody();
	        
			try
			{
	            message.WriteBoolean(true);
	            message.WriteByte((byte) 1);
	            message.WriteBytes(new byte[1]);
	            message.WriteBytes(new byte[3], 0, 2);
	            message.WriteChar('a');
	            message.WriteDouble(1.5);
	            message.WriteSingle((float) 1.5);
	            message.WriteInt32(1);
	            message.WriteInt64(1);
	            message.WriteObject("stringobj");
	            message.WriteInt16((short) 1);
	            message.WriteString("utfstring");
	        }
			catch(MessageNotWriteableException)
			{
	            Assert.Fail("Should be writeable");
	        }
			
	        try
			{
	            message.ReadBoolean();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadByte();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadBytes(new byte[1]);
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadBytes(new byte[2], 2);
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadChar();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadDouble();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try 
			{
	            message.ReadSingle();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadInt32();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadInt64();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadString();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try
			{
	            message.ReadInt16();
	            Assert.Fail("Should have thrown exception");
	        }
			catch(MessageNotReadableException)
			{
	        }
	        
			try 
			{
	            message.ReadString();
	            Assert.Fail("Should have thrown exception");
	        } 
			catch(MessageNotReadableException) 
			{
	        }
	    }		
Exemplo n.º 18
0
	    public void TestReset() {

			ActiveMQBytesMessage message = new ActiveMQBytesMessage();
	        
			try 
			{
	            message.WriteDouble(24.5);
	            message.WriteInt64(311);
	        } 
			catch(MessageNotWriteableException)
			{
	            Assert.Fail("should be writeable");
	        }
	        
			message.Reset();
	        
			try {
	            Assert.IsTrue(message.ReadOnlyBody);
	            Assert.AreEqual(message.ReadDouble(), 24.5, 0);
	            Assert.AreEqual(message.ReadInt64(), 311);
	        } 
			catch(MessageNotReadableException) 
			{
	            Assert.Fail("should be readable");
	        }
	        
			try
			{
	            message.WriteInt32(33);
	            Assert.Fail("should throw exception");
	        }
			catch(MessageNotWriteableException)
			{
	        }
	    }
Exemplo n.º 19
0
	    public void TestWriteObject()
		{
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
			
	        try
			{
	            msg.WriteObject("fred");
	            msg.WriteObject((Boolean) true);
	            msg.WriteObject((Char) 'q');
	            msg.WriteObject((Byte) ((byte) 1));
	            msg.WriteObject((Int16) ((short) 3));
	            msg.WriteObject((Int32) 3 );
	            msg.WriteObject((Int64) 300L);
	            msg.WriteObject((Single) 3.3f );
	            msg.WriteObject((Double) 3.3 );
	            msg.WriteObject((Object) new byte[3]);
	        } 
			catch(MessageFormatException) 
			{
	            Assert.Fail("objectified primitives should be allowed");
	        }
			
	        try 
			{
	            msg.WriteObject(new Object());
	            Assert.Fail("only objectified primitives are allowed");
	        } 
			catch(MessageFormatException ) 
			{
	        }
	    }
Exemplo n.º 20
0
	    public void TestReadBytesbyteArray() 
		{
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            byte[] data = new byte[50];
            for(int i = 0; i < data.Length; i++) 
			{
                data[i] = (byte) i;
            }
            msg.WriteBytes(data);
            msg.Reset();
            byte[] test = new byte[data.Length];
            msg.ReadBytes(test);
            for(int i = 0; i < test.Length; i++) 
			{
                Assert.IsTrue(test[i] == i);
            }
	    }
Exemplo n.º 21
0
	    public void TestReadString() {
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            string str = "this is a test";
            msg.WriteString(str);
            msg.Reset();
            Assert.IsTrue(msg.ReadString() == str);
	    }
Exemplo n.º 22
0
	    public void TestReadDouble() {
	        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
            msg.WriteDouble(3.3d);
            msg.Reset();
            Assert.IsTrue(msg.ReadDouble() == 3.3d);
	    }