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 2009/11/20 17:26:34 UTC

svn commit: r882632 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Commands/MessageCompressionTest.cs

Author: tabish
Date: Fri Nov 20 16:26:34 2009
New Revision: 882632

URL: http://svn.apache.org/viewvc?rev=882632&view=rev
Log:
Fix the test case such that a TextMessage is sent using a CompressionPolicy that yeilds no compression.  Sending a TextMessage in compressed form using .NET compression results in the broker rejecting the message because it can't read the contained string.  This at least provides a test for the use of a custom compression policy.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Commands/MessageCompressionTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Commands/MessageCompressionTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Commands/MessageCompressionTest.cs?rev=882632&r1=882631&r2=882632&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Commands/MessageCompressionTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Commands/MessageCompressionTest.cs Fri Nov 20 16:26:34 2009
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.IO;
 using System.Text;
 using Apache.NMS;
 using Apache.NMS.Util;
@@ -58,12 +59,36 @@
         protected float m = 2.1F;
         protected double n = 2.3;
         
+		/// <summary>
+		/// Test that we can set our own compression policy.  Also works around the fact
+		/// that sending a compressed Text Message to the broker using the default .NET
+		/// compression will cause a BrokerException to be fired.
+		/// </summary>
+		class NoCompressionPolicy : ICompressionPolicy
+		{
+			public Stream CreateCompressionStream(Stream data)
+			{
+				return data;
+			}
+			
+        	public Stream CreateDecompressionStream(Stream data)
+			{
+				return data;
+			}		
+			
+			public Object Clone()
+			{
+				return this.MemberwiseClone();
+			}
+		}
+		
         [Test]
         public void TestTextMessageCompression()
         {
             using(Connection connection = CreateConnection(TEST_CLIENT_ID) as Connection)
             {
                 connection.UseCompression = true;
+				connection.CompressionPolicy = new NoCompressionPolicy();
                 connection.Start();
 
                 Assert.IsTrue(connection.UseCompression);
@@ -79,7 +104,7 @@
 
                     producer.Send(message);
 
-                    message = consumer.Receive(TimeSpan.FromMilliseconds(4000)) as ITextMessage;
+                    message = consumer.Receive(TimeSpan.FromMilliseconds(6000)) as ITextMessage;
                     
                     Assert.IsNotNull(message);
                     Assert.IsTrue(((ActiveMQMessage) message).Compressed);