mirror of https://github.com/apache/activemq.git
fix for AMQ-1981
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@705547 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fdee6e81e2
commit
4842547a5b
|
@ -31,10 +31,12 @@ import java.lang.reflect.Array;
|
|||
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 @@ public abstract class DataFileGeneratorTestSupport extends TestSupport {
|
|||
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 @@ public abstract class DataFileGeneratorTestSupport extends TestSupport {
|
|||
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 @@ public abstract class DataFileGeneratorTestSupport extends TestSupport {
|
|||
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 {
|
||||
|
|
|
@ -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 @@ public abstract class MessageTestSupport extends BaseCommandTestSupport {
|
|||
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"));
|
||||
|
|
|
@ -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 @@ public abstract class MessageTestSupport extends BaseCommandTestSupport {
|
|||
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"));
|
||||
|
|
Loading…
Reference in New Issue