activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r705547 - in /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire: DataFileGeneratorTestSupport.java v1/MessageTestSupport.java v2/MessageTestSupport.java
Date Fri, 17 Oct 2008 10:22:24 GMT
Author: dejanb
Date: Fri Oct 17 03:22:24 2008
New Revision: 705547

URL: http://svn.apache.org/viewvc?rev=705547&view=rev
Log:
fix for AMQ-1981

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/DataFileGeneratorTestSupport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/MessageTestSupport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v2/MessageTestSupport.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/DataFileGeneratorTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/DataFileGeneratorTestSupport.java?rev=705547&r1=705546&r2=705547&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/DataFileGeneratorTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/DataFileGeneratorTestSupport.java
Fri Oct 17 03:22:24 2008
@@ -31,10 +31,12 @@
 import java.lang.reflect.Method;
 import java.net.URI;
 import java.net.URL;
+import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQMessage;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTextMessage;
 import org.apache.activemq.command.BrokerId;
@@ -103,9 +105,9 @@
         DataInputStream dis = new DataInputStream(in);
         Object actual = openWireformat.unmarshal(dis);
 
-        LOG.info("Parsed: " + actual);
 
         assertBeansEqual("", new HashSet<Object>(), expected, actual);
+        LOG.info("Parsed: " + actual);
     }
 
     protected void assertBeansEqual(String message, Set<Object> comparedObjects, Object
expected, Object actual) throws Exception {
@@ -151,6 +153,8 @@
                 assertByteSequencesEqual(message, (ByteSequence)expectedValue, actualValue);
             } else if (expectedValue instanceof DataStructure) {
                 assertBeansEqual(message + name, comparedObjects, expectedValue, actualValue);
+            } else if (expectedValue instanceof Enumeration) {
+            	assertEnumerationEqual(message + name, comparedObjects, (Enumeration)expectedValue,
(Enumeration)actualValue);
             } else {
                 assertEquals(message, expectedValue, actualValue);
             }
@@ -164,6 +168,14 @@
             assertPropertyValuesEqual(message + ". element: " + i, comparedObjects, expected[i],
actual[i]);
         }
     }
+    
+    protected void assertEnumerationEqual(String message, Set<Object> comparedObjects,
Enumeration expected, Enumeration actual) throws Exception {
+        while (expected.hasMoreElements()) {
+        	Object expectedElem = expected.nextElement();
+        	Object actualElem = actual.nextElement();
+        	assertPropertyValuesEqual(message + ". element: " + expectedElem, comparedObjects,
expectedElem, actualElem);
+        }
+    }
 
     protected void assertPrimitiveArrayEqual(String message, Set<Object> comparedObjects,
Object expected, Object actual) throws ArrayIndexOutOfBoundsException, IllegalArgumentException,
         Exception {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/MessageTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/MessageTestSupport.java?rev=705547&r1=705546&r2=705547&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/MessageTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v1/MessageTestSupport.java
Fri Oct 17 03:22:24 2008
@@ -16,8 +16,15 @@
  */
 package org.apache.activemq.openwire.v1;
 
+import java.io.DataOutputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.activemq.command.BrokerId;
 import org.apache.activemq.command.Message;
+import org.apache.activemq.util.ByteArrayOutputStream;
+import org.apache.activemq.util.MarshallingSupport;
 
 /**
  * Test case for the OpenWire marshalling for Message NOTE!: This file is auto
@@ -49,13 +56,21 @@
         info.setType("Type:10");
 
         {
-            byte data[] = "Content:11".getBytes();
-            info.setContent(new org.apache.activemq.util.ByteSequence(data, 0, data.length));
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            DataOutputStream dataOut = new DataOutputStream(baos);
+            MarshallingSupport.writeUTF8(dataOut, "Content:11");
+            dataOut.close();
+            info.setContent(baos.toByteSequence());
         }
 
         {
-            byte data[] = "MarshalledProperties:12".getBytes();
-            info.setMarshalledProperties(new org.apache.activemq.util.ByteSequence(data,
0, data.length));
+        	Map map = new HashMap();
+        	map.put("MarshalledProperties", 12);
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            DataOutputStream os = new DataOutputStream(baos);
+            MarshallingSupport.marshalPrimitiveMap(map, os);
+            os.close();
+            info.setMarshalledProperties(baos.toByteSequence());
         }
 
         info.setDataStructure(createDataStructure("DataStructure:13"));

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v2/MessageTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v2/MessageTestSupport.java?rev=705547&r1=705546&r2=705547&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v2/MessageTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/v2/MessageTestSupport.java
Fri Oct 17 03:22:24 2008
@@ -16,8 +16,14 @@
  */
 package org.apache.activemq.openwire.v2;
 
+import java.io.DataOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.activemq.command.BrokerId;
 import org.apache.activemq.command.Message;
+import org.apache.activemq.util.ByteArrayOutputStream;
+import org.apache.activemq.util.MarshallingSupport;
 
 /**
  * Test case for the OpenWire marshalling for Message NOTE!: This file is auto
@@ -49,12 +55,20 @@
         info.setTimestamp(2);
         info.setType("Type:10");
         {
-            byte data[] = "Content:11".getBytes();
-            info.setContent(new org.apache.activemq.util.ByteSequence(data, 0, data.length));
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            DataOutputStream dataOut = new DataOutputStream(baos);
+            MarshallingSupport.writeUTF8(dataOut, "Content:11");
+            dataOut.close();
+            info.setContent(baos.toByteSequence());
         }
         {
-            byte data[] = "MarshalledProperties:12".getBytes();
-            info.setMarshalledProperties(new org.apache.activemq.util.ByteSequence(data,
0, data.length));
+        	Map map = new HashMap();
+        	map.put("MarshalledProperties", 12);
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            DataOutputStream os = new DataOutputStream(baos);
+            MarshallingSupport.marshalPrimitiveMap(map, os);
+            os.close();
+            info.setMarshalledProperties(baos.toByteSequence());
         }
         info.setDataStructure(createDataStructure("DataStructure:13"));
         info.setTargetConsumerId(createConsumerId("TargetConsumerId:14"));



Mime
View raw message