activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [27/51] [partial] https://issues.apache.org/jira/browse/OPENWIRE-1
Date Thu, 24 Jul 2014 14:23:16 GMT
http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-jms/src/test/java/org/apache/activemq/openwire/jms/OpenWireJMSStreamMessageTest.java
----------------------------------------------------------------------
diff --git a/openwire-jms/src/test/java/org/apache/activemq/openwire/jms/OpenWireJMSStreamMessageTest.java b/openwire-jms/src/test/java/org/apache/activemq/openwire/jms/OpenWireJMSStreamMessageTest.java
new file mode 100644
index 0000000..fe4cc9d
--- /dev/null
+++ b/openwire-jms/src/test/java/org/apache/activemq/openwire/jms/OpenWireJMSStreamMessageTest.java
@@ -0,0 +1,938 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.jms;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
+import javax.jms.MessageNotReadableException;
+import javax.jms.MessageNotWriteableException;
+
+import org.apache.activemq.openwire.jms.OpenWireJMSStreamMessage;
+import org.junit.Test;
+
+/**
+ * Test for the OpenWireJMSStreamMessage facade class.
+ */
+public class OpenWireJMSStreamMessageTest {
+
+    @Test
+    public void testReadBoolean() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        msg.writeBoolean(true);
+        msg.reset();
+        assertTrue(msg.readBoolean());
+        msg.reset();
+        assertTrue(msg.readString().equals("true"));
+        msg.reset();
+        try {
+            msg.readByte();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readShort();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readInt();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readLong();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readFloat();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readDouble();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+    }
+
+    @Test
+    public void testreadByte() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        byte test = (byte) 4;
+        msg.writeByte(test);
+        msg.reset();
+        assertTrue(msg.readByte() == test);
+        msg.reset();
+        assertTrue(msg.readShort() == test);
+        msg.reset();
+        assertTrue(msg.readInt() == test);
+        msg.reset();
+        assertTrue(msg.readLong() == test);
+        msg.reset();
+        assertTrue(msg.readString().equals(new Byte(test).toString()));
+        msg.reset();
+        try {
+            msg.readBoolean();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readFloat();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readDouble();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+    }
+
+    @Test
+    public void testReadShort() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        short test = (short) 4;
+        msg.writeShort(test);
+        msg.reset();
+        assertTrue(msg.readShort() == test);
+        msg.reset();
+        assertTrue(msg.readInt() == test);
+        msg.reset();
+        assertTrue(msg.readLong() == test);
+        msg.reset();
+        assertTrue(msg.readString().equals(new Short(test).toString()));
+        msg.reset();
+        try {
+            msg.readBoolean();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readByte();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readFloat();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readDouble();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+    }
+
+    @Test
+    public void testReadChar() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        char test = 'z';
+        msg.writeChar(test);
+        msg.reset();
+        assertTrue(msg.readChar() == test);
+        msg.reset();
+        assertTrue(msg.readString().equals(new Character(test).toString()));
+        msg.reset();
+        try {
+            msg.readBoolean();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readByte();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readShort();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readInt();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readLong();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readFloat();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readDouble();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+    }
+
+    @Test
+    public void testReadInt() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        int test = 4;
+        msg.writeInt(test);
+        msg.reset();
+        assertTrue(msg.readInt() == test);
+        msg.reset();
+        assertTrue(msg.readLong() == test);
+        msg.reset();
+        assertTrue(msg.readString().equals(new Integer(test).toString()));
+        msg.reset();
+        try {
+            msg.readBoolean();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readByte();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readShort();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readFloat();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readDouble();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+    }
+
+    @Test
+    public void testReadLong() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        long test = 4L;
+        msg.writeLong(test);
+        msg.reset();
+        assertTrue(msg.readLong() == test);
+        msg.reset();
+        assertTrue(msg.readString().equals(Long.valueOf(test).toString()));
+        msg.reset();
+        try {
+            msg.readBoolean();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readByte();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readShort();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readInt();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readFloat();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readDouble();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg = new OpenWireJMSStreamMessage();
+        msg.writeObject(new Long("1"));
+        // reset so it's readable now
+        msg.reset();
+        assertEquals(new Long("1"), msg.readObject());
+    }
+
+    @Test
+    public void testReadFloat() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        float test = 4.4f;
+        msg.writeFloat(test);
+        msg.reset();
+        assertTrue(msg.readFloat() == test);
+        msg.reset();
+        assertTrue(msg.readDouble() == test);
+        msg.reset();
+        assertTrue(msg.readString().equals(new Float(test).toString()));
+        msg.reset();
+        try {
+            msg.readBoolean();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readByte();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readShort();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readInt();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readLong();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+    }
+
+    @Test
+    public void testReadDouble() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        double test = 4.4d;
+        msg.writeDouble(test);
+        msg.reset();
+        assertTrue(msg.readDouble() == test);
+        msg.reset();
+        assertTrue(msg.readString().equals(new Double(test).toString()));
+        msg.reset();
+        try {
+            msg.readBoolean();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readByte();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readShort();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readInt();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readLong();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readFloat();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+        msg.reset();
+        try {
+            msg.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageFormatException mfe) {
+        }
+    }
+
+    @Test
+    public void testReadString() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        byte testByte = (byte) 2;
+        msg.writeString(new Byte(testByte).toString());
+        msg.reset();
+        assertTrue(msg.readByte() == testByte);
+        msg.clearBody();
+        short testShort = 3;
+        msg.writeString(new Short(testShort).toString());
+        msg.reset();
+        assertTrue(msg.readShort() == testShort);
+        msg.clearBody();
+        int testInt = 4;
+        msg.writeString(new Integer(testInt).toString());
+        msg.reset();
+        assertTrue(msg.readInt() == testInt);
+        msg.clearBody();
+        long testLong = 6L;
+        msg.writeString(new Long(testLong).toString());
+        msg.reset();
+        assertTrue(msg.readLong() == testLong);
+        msg.clearBody();
+        float testFloat = 6.6f;
+        msg.writeString(new Float(testFloat).toString());
+        msg.reset();
+        assertTrue(msg.readFloat() == testFloat);
+        msg.clearBody();
+        double testDouble = 7.7d;
+        msg.writeString(new Double(testDouble).toString());
+        msg.reset();
+        assertTrue(msg.readDouble() == testDouble);
+        msg.clearBody();
+        msg.writeString("true");
+        msg.reset();
+        assertTrue(msg.readBoolean());
+        msg.clearBody();
+        msg.writeString("a");
+        msg.reset();
+        try {
+            msg.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageFormatException e) {
+        }
+        msg.clearBody();
+        msg.writeString("777");
+        msg.reset();
+        try {
+            msg.readBytes(new byte[3]);
+            fail("Should have thrown exception");
+        } catch (MessageFormatException e) {
+        }
+    }
+
+    @Test
+    public void testReadBigString() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        try {
+            // Test with a 1Meg String
+            StringBuffer bigSB = new StringBuffer(1024 * 1024);
+            for (int i = 0; i < 1024 * 1024; i++) {
+                bigSB.append('a' + i % 26);
+            }
+            String bigString = bigSB.toString();
+
+            msg.writeString(bigString);
+            msg.reset();
+            assertEquals(bigString, msg.readString());
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    @Test
+    public void testReadBytes() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        try {
+            byte[] test = new byte[50];
+            for (int i = 0; i < test.length; i++) {
+                test[i] = (byte) i;
+            }
+            msg.writeBytes(test);
+            msg.reset();
+            byte[] valid = new byte[test.length];
+            msg.readBytes(valid);
+            for (int i = 0; i < valid.length; i++) {
+                assertTrue(valid[i] == test[i]);
+            }
+            msg.reset();
+            try {
+                msg.readByte();
+                fail("Should have thrown exception");
+            } catch (MessageFormatException mfe) {
+            }
+            msg.reset();
+            try {
+                msg.readShort();
+                fail("Should have thrown exception");
+            } catch (MessageFormatException mfe) {
+            }
+            msg.reset();
+            try {
+                msg.readInt();
+                fail("Should have thrown exception");
+            } catch (MessageFormatException mfe) {
+            }
+            msg.reset();
+            try {
+                msg.readLong();
+                fail("Should have thrown exception");
+            } catch (MessageFormatException mfe) {
+            }
+            msg.reset();
+            try {
+                msg.readFloat();
+                fail("Should have thrown exception");
+            } catch (MessageFormatException mfe) {
+            }
+            msg.reset();
+            try {
+                msg.readChar();
+                fail("Should have thrown exception");
+            } catch (MessageFormatException mfe) {
+            }
+            msg.reset();
+            try {
+                msg.readString();
+                fail("Should have thrown exception");
+            } catch (MessageFormatException mfe) {
+            }
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    @Test
+    public void testReadObject() throws Exception {
+        OpenWireJMSStreamMessage msg = new OpenWireJMSStreamMessage();
+        try {
+            byte testByte = (byte) 2;
+            msg.writeByte(testByte);
+            msg.reset();
+            assertTrue(((Byte) msg.readObject()).byteValue() == testByte);
+            msg.clearBody();
+
+            short testShort = 3;
+            msg.writeShort(testShort);
+            msg.reset();
+            assertTrue(((Short) msg.readObject()).shortValue() == testShort);
+            msg.clearBody();
+
+            int testInt = 4;
+            msg.writeInt(testInt);
+            msg.reset();
+            assertTrue(((Integer) msg.readObject()).intValue() == testInt);
+            msg.clearBody();
+
+            long testLong = 6L;
+            msg.writeLong(testLong);
+            msg.reset();
+            assertTrue(((Long) msg.readObject()).longValue() == testLong);
+            msg.clearBody();
+
+            float testFloat = 6.6f;
+            msg.writeFloat(testFloat);
+            msg.reset();
+            assertTrue(((Float) msg.readObject()).floatValue() == testFloat);
+            msg.clearBody();
+
+            double testDouble = 7.7d;
+            msg.writeDouble(testDouble);
+            msg.reset();
+            assertTrue(((Double) msg.readObject()).doubleValue() == testDouble);
+            msg.clearBody();
+
+            char testChar = 'z';
+            msg.writeChar(testChar);
+            msg.reset();
+            assertTrue(((Character) msg.readObject()).charValue() == 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();
+            assertTrue(valid.length == data.length);
+            for (int i = 0; i < valid.length; i++) {
+                assertTrue(valid[i] == data[i]);
+            }
+            msg.clearBody();
+            msg.writeBoolean(true);
+            msg.reset();
+            assertTrue(((Boolean) msg.readObject()).booleanValue());
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    @Test
+    public void testClearBody() throws JMSException {
+        OpenWireJMSStreamMessage streamMessage = new OpenWireJMSStreamMessage();
+        try {
+            streamMessage.writeObject(new Long(2));
+            streamMessage.clearBody();
+            assertFalse(streamMessage.isReadOnlyBody());
+            streamMessage.writeObject(new Long(2));
+            streamMessage.readObject();
+            fail("should throw exception");
+        } catch (MessageNotReadableException mnwe) {
+        } catch (MessageNotWriteableException mnwe) {
+            fail("should be writeable");
+        }
+    }
+
+    @Test
+    public void testReset() throws JMSException {
+        OpenWireJMSStreamMessage streamMessage = new OpenWireJMSStreamMessage();
+        try {
+            streamMessage.writeDouble(24.5);
+            streamMessage.writeLong(311);
+        } catch (MessageNotWriteableException mnwe) {
+            fail("should be writeable");
+        }
+        streamMessage.reset();
+        try {
+            assertTrue(streamMessage.isReadOnlyBody());
+            assertEquals(streamMessage.readDouble(), 24.5, 0);
+            assertEquals(streamMessage.readLong(), 311);
+        } catch (MessageNotReadableException mnre) {
+            fail("should be readable");
+        }
+        try {
+            streamMessage.writeInt(33);
+            fail("should throw exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+    }
+
+    @Test
+    public void testReadOnlyBody() throws JMSException {
+        OpenWireJMSStreamMessage message = new OpenWireJMSStreamMessage();
+        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.writeFloat((float) 1.5);
+            message.writeInt(1);
+            message.writeLong(1);
+            message.writeObject("stringobj");
+            message.writeShort((short) 1);
+            message.writeString("string");
+        } catch (MessageNotWriteableException mnwe) {
+            fail("Should be writeable");
+        }
+        message.reset();
+        try {
+            message.readBoolean();
+            message.readByte();
+            assertEquals(1, message.readBytes(new byte[10]));
+            assertEquals(-1, message.readBytes(new byte[10]));
+            assertEquals(2, message.readBytes(new byte[10]));
+            assertEquals(-1, message.readBytes(new byte[10]));
+            message.readChar();
+            message.readDouble();
+            message.readFloat();
+            message.readInt();
+            message.readLong();
+            message.readString();
+            message.readShort();
+            message.readString();
+        } catch (MessageNotReadableException mnwe) {
+            fail("Should be readable");
+        }
+        try {
+            message.writeBoolean(true);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeByte((byte) 1);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeBytes(new byte[3], 0, 2);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeChar('a');
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeDouble(1.5);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeFloat((float) 1.5);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeInt(1);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeLong(1);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeObject("stringobj");
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeShort((short) 1);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeString("string");
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+    }
+
+    @Test
+    public void testWriteOnlyBody() throws JMSException {
+        OpenWireJMSStreamMessage message = new OpenWireJMSStreamMessage();
+        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.writeFloat((float) 1.5);
+            message.writeInt(1);
+            message.writeLong(1);
+            message.writeObject("stringobj");
+            message.writeShort((short) 1);
+            message.writeString("string");
+        } catch (MessageNotWriteableException mnwe) {
+            fail("Should be writeable");
+        }
+        try {
+            message.readBoolean();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException mnwe) {
+        }
+        try {
+            message.readByte();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readBytes(new byte[2]);
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readDouble();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readFloat();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readInt();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readLong();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readString();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readShort();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readString();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+    }
+
+    @Test
+    public void testWriteObject() throws Exception {
+        try {
+            OpenWireJMSStreamMessage message = new OpenWireJMSStreamMessage();
+            message.clearBody();
+            message.writeObject("test");
+            message.writeObject(new Character('a'));
+            message.writeObject(new Boolean(false));
+            message.writeObject(new Byte((byte) 2));
+            message.writeObject(new Short((short) 2));
+            message.writeObject(new Integer(2));
+            message.writeObject(new Long(2l));
+            message.writeObject(new Float(2.0f));
+            message.writeObject(new Double(2.0d));
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+        try {
+            OpenWireJMSStreamMessage message = new OpenWireJMSStreamMessage();
+            message.clearBody();
+            message.writeObject(new Object());
+            fail("should throw an exception");
+        } catch (MessageFormatException e) {
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-jms/src/test/java/org/apache/activemq/openwire/jms/OpenWireJMSTextMessageTest.java
----------------------------------------------------------------------
diff --git a/openwire-jms/src/test/java/org/apache/activemq/openwire/jms/OpenWireJMSTextMessageTest.java b/openwire-jms/src/test/java/org/apache/activemq/openwire/jms/OpenWireJMSTextMessageTest.java
new file mode 100644
index 0000000..c299f8c
--- /dev/null
+++ b/openwire-jms/src/test/java/org/apache/activemq/openwire/jms/OpenWireJMSTextMessageTest.java
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.jms;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.DataOutputStream;
+
+import javax.jms.JMSException;
+import javax.jms.MessageNotReadableException;
+import javax.jms.MessageNotWriteableException;
+
+import org.apache.activemq.openwire.commands.OpenWireMessage;
+import org.apache.activemq.openwire.jms.OpenWireJMSTextMessage;
+import org.apache.activemq.openwire.utils.OpenWireMarshallingSupport;
+import org.fusesource.hawtbuf.ByteArrayOutputStream;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class OpenWireJMSTextMessageTest {
+
+    @Test
+    public void testReadOnlyBody() throws JMSException {
+        OpenWireJMSTextMessage textMessage = new OpenWireJMSTextMessage();
+        textMessage.setText("test");
+        textMessage.setReadOnlyBody(true);
+        try {
+            textMessage.getText();
+        } catch (MessageNotReadableException e) {
+            fail("should be readable");
+        }
+        try {
+            textMessage.setText("test");
+            fail("should throw exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+    }
+
+    @Test
+    public void testWriteOnlyBody() throws JMSException { // should always be readable
+        OpenWireJMSTextMessage textMessage = new OpenWireJMSTextMessage();
+        textMessage.setReadOnlyBody(false);
+        try {
+            textMessage.setText("test");
+            textMessage.getText();
+        } catch (MessageNotReadableException e) {
+            fail("should be readable");
+        }
+        textMessage.setReadOnlyBody(true);
+        try {
+            textMessage.getText();
+            textMessage.setText("test");
+            fail("should throw exception");
+        } catch (MessageNotReadableException e) {
+            fail("should be readable");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+    }
+
+    @Test
+    public void testShortText() throws Exception {
+        String shortText = "Content";
+        OpenWireJMSTextMessage shortMessage = new OpenWireJMSTextMessage();
+        setContent(shortMessage.getOpenWireMessage(), shortText);
+        assertTrue(shortMessage.getText().equals(shortText));
+
+        String longText = "Very very very very veeeeeeery loooooooooooooooooooooooooooooooooong text";
+        OpenWireJMSTextMessage longMessage = new OpenWireJMSTextMessage();
+        setContent(longMessage.getOpenWireMessage(), longText);
+        assertTrue(longMessage.getText().equals(longText));
+    }
+
+    protected void setContent(OpenWireMessage message, String text) throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        DataOutputStream dataOut = new DataOutputStream(baos);
+        OpenWireMarshallingSupport.writeUTF8(dataOut, text);
+        dataOut.close();
+        message.setContent(baos.toBuffer());
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-jms/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/openwire-jms/src/test/resources/log4j.properties b/openwire-jms/src/test/resources/log4j.properties
new file mode 100644
index 0000000..0588275
--- /dev/null
+++ b/openwire-jms/src/test/resources/log4j.properties
@@ -0,0 +1,41 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out, stdout
+
+log4j.logger.org.apache.activemq.openwire=DEBUG
+
+# Tune the ActiveMQ and it's OpenWire transport as needed for debugging.
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.broker=DEBUG
+log4j.logger.org.apache.activemq.transport.openwire=TRACE
+log4j.logger.org.apache.activemq.transport.openwire.FRAMES=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/activemq-test.log
+log4j.appender.out.append=true

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/.gitignore
----------------------------------------------------------------------
diff --git a/openwire-legacy/.gitignore b/openwire-legacy/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/openwire-legacy/.gitignore
@@ -0,0 +1 @@
+/target

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/pom.xml
----------------------------------------------------------------------
diff --git a/openwire-legacy/pom.xml b/openwire-legacy/pom.xml
new file mode 100644
index 0000000..8d61ac9
--- /dev/null
+++ b/openwire-legacy/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.activemq</groupId>
+    <artifactId>openwire-protocol</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>openwire-legacy</artifactId>
+  <name>openwire-legacy</name>
+  <description>An OpenWire extension library that contains the legacy OpenWire Codecs</description>
+  <packaging>jar</packaging>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <!-- =================================== -->
+    <!-- Required Dependencies               -->
+    <!-- =================================== -->
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>openwire-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.fusesource.hawtbuf</groupId>
+      <artifactId>hawtbuf</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BaseCommandMarshaller.java
----------------------------------------------------------------------
diff --git a/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BaseCommandMarshaller.java b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BaseCommandMarshaller.java
new file mode 100644
index 0000000..bf85755
--- /dev/null
+++ b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BaseCommandMarshaller.java
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.codec.v2;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.codec.BaseDataStreamMarshaller;
+import org.apache.activemq.openwire.codec.BooleanStream;
+import org.apache.activemq.openwire.codec.OpenWireFormat;
+import org.apache.activemq.openwire.commands.BaseCommand;
+
+public abstract class BaseCommandMarshaller extends BaseDataStreamMarshaller {
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
+        super.tightUnmarshal(wireFormat, o, dataIn, bs);
+
+        BaseCommand info = (BaseCommand) o;
+        info.setCommandId(dataIn.readInt());
+        info.setResponseRequired(bs.readBoolean());
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
+        BaseCommand info = (BaseCommand) o;
+
+        int rc = super.tightMarshal1(wireFormat, o, bs);
+        bs.writeBoolean(info.isResponseRequired());
+
+        return rc + 4;
+    }
+
+    /**
+     * Write a object instance to data output stream
+     *
+     * @param o
+     *        the instance to be marshaled
+     * @param dataOut
+     *        the output stream
+     * @throws IOException
+     *         thrown if an error occurs
+     */
+    @Override
+    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
+        super.tightMarshal2(wireFormat, o, dataOut, bs);
+
+        BaseCommand info = (BaseCommand) o;
+        dataOut.writeInt(info.getCommandId());
+        bs.readBoolean();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
+        super.looseUnmarshal(wireFormat, o, dataIn);
+
+        BaseCommand info = (BaseCommand) o;
+        info.setCommandId(dataIn.readInt());
+        info.setResponseRequired(dataIn.readBoolean());
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
+        BaseCommand info = (BaseCommand) o;
+
+        super.looseMarshal(wireFormat, o, dataOut);
+        dataOut.writeInt(info.getCommandId());
+        dataOut.writeBoolean(info.isResponseRequired());
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BrokerIdMarshaller.java
----------------------------------------------------------------------
diff --git a/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BrokerIdMarshaller.java b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BrokerIdMarshaller.java
new file mode 100644
index 0000000..4d865c6
--- /dev/null
+++ b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BrokerIdMarshaller.java
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.codec.v2;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.codec.BaseDataStreamMarshaller;
+import org.apache.activemq.openwire.codec.BooleanStream;
+import org.apache.activemq.openwire.codec.OpenWireFormat;
+import org.apache.activemq.openwire.commands.BrokerId;
+import org.apache.activemq.openwire.commands.DataStructure;
+
+public class BrokerIdMarshaller extends BaseDataStreamMarshaller {
+
+    /**
+     * Return the type of Data Structure we marshal
+     *
+     * @return short representation of the type data structure
+     */
+    @Override
+    public byte getDataStructureType() {
+        return BrokerId.DATA_STRUCTURE_TYPE;
+    }
+
+    /**
+     * @return a new object instance
+     */
+    @Override
+    public DataStructure createObject() {
+        return new BrokerId();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
+        super.tightUnmarshal(wireFormat, o, dataIn, bs);
+
+        BrokerId info = (BrokerId) o;
+        info.setValue(tightUnmarshalString(dataIn, bs));
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
+        BrokerId info = (BrokerId) o;
+
+        int rc = super.tightMarshal1(wireFormat, o, bs);
+        rc += tightMarshalString1(info.getValue(), bs);
+
+        return rc + 0;
+    }
+
+    /**
+     * Write a object instance to data output stream
+     *
+     * @param o
+     *        the instance to be marshaled
+     * @param dataOut
+     *        the output stream
+     * @throws IOException
+     *         thrown if an error occurs
+     */
+    @Override
+    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
+        super.tightMarshal2(wireFormat, o, dataOut, bs);
+
+        BrokerId info = (BrokerId) o;
+        tightMarshalString2(info.getValue(), dataOut, bs);
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
+        super.looseUnmarshal(wireFormat, o, dataIn);
+
+        BrokerId info = (BrokerId) o;
+        info.setValue(looseUnmarshalString(dataIn));
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
+        BrokerId info = (BrokerId) o;
+
+        super.looseMarshal(wireFormat, o, dataOut);
+        looseMarshalString(info.getValue(), dataOut);
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BrokerInfoMarshaller.java
----------------------------------------------------------------------
diff --git a/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BrokerInfoMarshaller.java b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BrokerInfoMarshaller.java
new file mode 100644
index 0000000..2e4fcb5
--- /dev/null
+++ b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/BrokerInfoMarshaller.java
@@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.codec.v2;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.codec.BooleanStream;
+import org.apache.activemq.openwire.codec.OpenWireFormat;
+import org.apache.activemq.openwire.commands.BrokerId;
+import org.apache.activemq.openwire.commands.BrokerInfo;
+import org.apache.activemq.openwire.commands.DataStructure;
+
+public class BrokerInfoMarshaller extends BaseCommandMarshaller {
+
+    /**
+     * Return the type of Data Structure we marshal
+     *
+     * @return short representation of the type data structure
+     */
+    @Override
+    public byte getDataStructureType() {
+        return BrokerInfo.DATA_STRUCTURE_TYPE;
+    }
+
+    /**
+     * @return a new object instance
+     */
+    @Override
+    public DataStructure createObject() {
+        return new BrokerInfo();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
+        super.tightUnmarshal(wireFormat, o, dataIn, bs);
+
+        BrokerInfo info = (BrokerInfo) o;
+        info.setBrokerId((BrokerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
+        info.setBrokerURL(tightUnmarshalString(dataIn, bs));
+
+        if (bs.readBoolean()) {
+            short size = dataIn.readShort();
+            BrokerInfo value[] = new BrokerInfo[size];
+            for (int i = 0; i < size; i++) {
+                value[i] = (BrokerInfo) tightUnmarsalNestedObject(wireFormat, dataIn, bs);
+            }
+            info.setPeerBrokerInfos(value);
+        } else {
+            info.setPeerBrokerInfos(null);
+        }
+        info.setBrokerName(tightUnmarshalString(dataIn, bs));
+        info.setSlaveBroker(bs.readBoolean());
+        info.setMasterBroker(bs.readBoolean());
+        info.setFaultTolerantConfiguration(bs.readBoolean());
+        info.setDuplexConnection(bs.readBoolean());
+        info.setNetworkConnection(bs.readBoolean());
+        info.setConnectionId(tightUnmarshalLong(wireFormat, dataIn, bs));
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
+        BrokerInfo info = (BrokerInfo) o;
+
+        int rc = super.tightMarshal1(wireFormat, o, bs);
+        rc += tightMarshalCachedObject1(wireFormat, info.getBrokerId(), bs);
+        rc += tightMarshalString1(info.getBrokerURL(), bs);
+        rc += tightMarshalObjectArray1(wireFormat, info.getPeerBrokerInfos(), bs);
+        rc += tightMarshalString1(info.getBrokerName(), bs);
+        bs.writeBoolean(info.isSlaveBroker());
+        bs.writeBoolean(info.isMasterBroker());
+        bs.writeBoolean(info.isFaultTolerantConfiguration());
+        bs.writeBoolean(info.isDuplexConnection());
+        bs.writeBoolean(info.isNetworkConnection());
+        rc += tightMarshalLong1(wireFormat, info.getConnectionId(), bs);
+
+        return rc + 0;
+    }
+
+    /**
+     * Write a object instance to data output stream
+     *
+     * @param o
+     *        the instance to be marshaled
+     * @param dataOut
+     *        the output stream
+     * @throws IOException
+     *         thrown if an error occurs
+     */
+    @Override
+    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
+        super.tightMarshal2(wireFormat, o, dataOut, bs);
+
+        BrokerInfo info = (BrokerInfo) o;
+        tightMarshalCachedObject2(wireFormat, info.getBrokerId(), dataOut, bs);
+        tightMarshalString2(info.getBrokerURL(), dataOut, bs);
+        tightMarshalObjectArray2(wireFormat, info.getPeerBrokerInfos(), dataOut, bs);
+        tightMarshalString2(info.getBrokerName(), dataOut, bs);
+        bs.readBoolean();
+        bs.readBoolean();
+        bs.readBoolean();
+        bs.readBoolean();
+        bs.readBoolean();
+        tightMarshalLong2(wireFormat, info.getConnectionId(), dataOut, bs);
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
+        super.looseUnmarshal(wireFormat, o, dataIn);
+
+        BrokerInfo info = (BrokerInfo) o;
+        info.setBrokerId((BrokerId) looseUnmarsalCachedObject(wireFormat, dataIn));
+        info.setBrokerURL(looseUnmarshalString(dataIn));
+
+        if (dataIn.readBoolean()) {
+            short size = dataIn.readShort();
+            BrokerInfo value[] = new BrokerInfo[size];
+            for (int i = 0; i < size; i++) {
+                value[i] = (BrokerInfo) looseUnmarsalNestedObject(wireFormat, dataIn);
+            }
+            info.setPeerBrokerInfos(value);
+        } else {
+            info.setPeerBrokerInfos(null);
+        }
+        info.setBrokerName(looseUnmarshalString(dataIn));
+        info.setSlaveBroker(dataIn.readBoolean());
+        info.setMasterBroker(dataIn.readBoolean());
+        info.setFaultTolerantConfiguration(dataIn.readBoolean());
+        info.setDuplexConnection(dataIn.readBoolean());
+        info.setNetworkConnection(dataIn.readBoolean());
+        info.setConnectionId(looseUnmarshalLong(wireFormat, dataIn));
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
+        BrokerInfo info = (BrokerInfo) o;
+
+        super.looseMarshal(wireFormat, o, dataOut);
+        looseMarshalCachedObject(wireFormat, info.getBrokerId(), dataOut);
+        looseMarshalString(info.getBrokerURL(), dataOut);
+        looseMarshalObjectArray(wireFormat, info.getPeerBrokerInfos(), dataOut);
+        looseMarshalString(info.getBrokerName(), dataOut);
+        dataOut.writeBoolean(info.isSlaveBroker());
+        dataOut.writeBoolean(info.isMasterBroker());
+        dataOut.writeBoolean(info.isFaultTolerantConfiguration());
+        dataOut.writeBoolean(info.isDuplexConnection());
+        dataOut.writeBoolean(info.isNetworkConnection());
+        looseMarshalLong(wireFormat, info.getConnectionId(), dataOut);
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionControlMarshaller.java
----------------------------------------------------------------------
diff --git a/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionControlMarshaller.java b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionControlMarshaller.java
new file mode 100644
index 0000000..b100047
--- /dev/null
+++ b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionControlMarshaller.java
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.codec.v2;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.codec.BooleanStream;
+import org.apache.activemq.openwire.codec.OpenWireFormat;
+import org.apache.activemq.openwire.commands.ConnectionControl;
+import org.apache.activemq.openwire.commands.DataStructure;
+
+public class ConnectionControlMarshaller extends BaseCommandMarshaller {
+
+    /**
+     * Return the type of Data Structure we marshal
+     * @return short representation of the type data structure
+     */
+    @Override
+    public byte getDataStructureType() {
+        return ConnectionControl.DATA_STRUCTURE_TYPE;
+    }
+
+    /**
+     * @return a new object instance
+     */
+    @Override
+    public DataStructure createObject() {
+        return new ConnectionControl();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o the object to un-marshal
+     * @param dataIn the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
+        super.tightUnmarshal(wireFormat, o, dataIn, bs);
+
+        ConnectionControl info = (ConnectionControl)o;
+        info.setClose(bs.readBoolean());
+        info.setExit(bs.readBoolean());
+        info.setFaultTolerant(bs.readBoolean());
+        info.setResume(bs.readBoolean());
+        info.setSuspend(bs.readBoolean());
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
+        ConnectionControl info = (ConnectionControl)o;
+
+        int rc = super.tightMarshal1(wireFormat, o, bs);
+        bs.writeBoolean(info.isClose());
+        bs.writeBoolean(info.isExit());
+        bs.writeBoolean(info.isFaultTolerant());
+        bs.writeBoolean(info.isResume());
+        bs.writeBoolean(info.isSuspend());
+
+        return rc + 0;
+    }
+
+    /**
+     * Write a object instance to data output stream
+     *
+     * @param o the instance to be marshaled
+     * @param dataOut the output stream
+     * @throws IOException thrown if an error occurs
+     */
+    @Override
+    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
+        super.tightMarshal2(wireFormat, o, dataOut, bs);
+
+        bs.readBoolean();
+        bs.readBoolean();
+        bs.readBoolean();
+        bs.readBoolean();
+        bs.readBoolean();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o the object to un-marshal
+     * @param dataIn the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
+        super.looseUnmarshal(wireFormat, o, dataIn);
+
+        ConnectionControl info = (ConnectionControl)o;
+        info.setClose(dataIn.readBoolean());
+        info.setExit(dataIn.readBoolean());
+        info.setFaultTolerant(dataIn.readBoolean());
+        info.setResume(dataIn.readBoolean());
+        info.setSuspend(dataIn.readBoolean());
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
+        ConnectionControl info = (ConnectionControl)o;
+
+        super.looseMarshal(wireFormat, o, dataOut);
+        dataOut.writeBoolean(info.isClose());
+        dataOut.writeBoolean(info.isExit());
+        dataOut.writeBoolean(info.isFaultTolerant());
+        dataOut.writeBoolean(info.isResume());
+        dataOut.writeBoolean(info.isSuspend());
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionErrorMarshaller.java
----------------------------------------------------------------------
diff --git a/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionErrorMarshaller.java b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionErrorMarshaller.java
new file mode 100644
index 0000000..15286a3
--- /dev/null
+++ b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionErrorMarshaller.java
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.codec.v2;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.codec.BooleanStream;
+import org.apache.activemq.openwire.codec.OpenWireFormat;
+import org.apache.activemq.openwire.commands.ConnectionError;
+import org.apache.activemq.openwire.commands.ConnectionId;
+import org.apache.activemq.openwire.commands.DataStructure;
+
+public class ConnectionErrorMarshaller extends BaseCommandMarshaller {
+
+    /**
+     * Return the type of Data Structure we marshal
+     *
+     * @return short representation of the type data structure
+     */
+    @Override
+    public byte getDataStructureType() {
+        return ConnectionError.DATA_STRUCTURE_TYPE;
+    }
+
+    /**
+     * @return a new object instance
+     */
+    @Override
+    public DataStructure createObject() {
+        return new ConnectionError();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
+        super.tightUnmarshal(wireFormat, o, dataIn, bs);
+
+        ConnectionError info = (ConnectionError) o;
+        info.setException(tightUnmarsalThrowable(wireFormat, dataIn, bs));
+        info.setConnectionId((ConnectionId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
+        ConnectionError info = (ConnectionError) o;
+
+        int rc = super.tightMarshal1(wireFormat, o, bs);
+        rc += tightMarshalThrowable1(wireFormat, info.getException(), bs);
+        rc += tightMarshalNestedObject1(wireFormat, info.getConnectionId(), bs);
+
+        return rc + 0;
+    }
+
+    /**
+     * Write a object instance to data output stream
+     *
+     * @param o
+     *        the instance to be marshaled
+     * @param dataOut
+     *        the output stream
+     * @throws IOException
+     *         thrown if an error occurs
+     */
+    @Override
+    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
+        super.tightMarshal2(wireFormat, o, dataOut, bs);
+
+        ConnectionError info = (ConnectionError) o;
+        tightMarshalThrowable2(wireFormat, info.getException(), dataOut, bs);
+        tightMarshalNestedObject2(wireFormat, info.getConnectionId(), dataOut, bs);
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
+        super.looseUnmarshal(wireFormat, o, dataIn);
+
+        ConnectionError info = (ConnectionError) o;
+        info.setException(looseUnmarsalThrowable(wireFormat, dataIn));
+        info.setConnectionId((ConnectionId) looseUnmarsalNestedObject(wireFormat, dataIn));
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
+        ConnectionError info = (ConnectionError) o;
+
+        super.looseMarshal(wireFormat, o, dataOut);
+        looseMarshalThrowable(wireFormat, info.getException(), dataOut);
+        looseMarshalNestedObject(wireFormat, info.getConnectionId(), dataOut);
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionIdMarshaller.java
----------------------------------------------------------------------
diff --git a/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionIdMarshaller.java b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionIdMarshaller.java
new file mode 100644
index 0000000..ff430d1
--- /dev/null
+++ b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionIdMarshaller.java
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.codec.v2;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.codec.BaseDataStreamMarshaller;
+import org.apache.activemq.openwire.codec.BooleanStream;
+import org.apache.activemq.openwire.codec.OpenWireFormat;
+import org.apache.activemq.openwire.commands.ConnectionId;
+import org.apache.activemq.openwire.commands.DataStructure;
+
+public class ConnectionIdMarshaller extends BaseDataStreamMarshaller {
+
+    /**
+     * Return the type of Data Structure we marshal
+     *
+     * @return short representation of the type data structure
+     */
+    @Override
+    public byte getDataStructureType() {
+        return ConnectionId.DATA_STRUCTURE_TYPE;
+    }
+
+    /**
+     * @return a new object instance
+     */
+    @Override
+    public DataStructure createObject() {
+        return new ConnectionId();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
+        super.tightUnmarshal(wireFormat, o, dataIn, bs);
+
+        ConnectionId info = (ConnectionId) o;
+        info.setValue(tightUnmarshalString(dataIn, bs));
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
+        ConnectionId info = (ConnectionId) o;
+
+        int rc = super.tightMarshal1(wireFormat, o, bs);
+        rc += tightMarshalString1(info.getValue(), bs);
+
+        return rc + 0;
+    }
+
+    /**
+     * Write a object instance to data output stream
+     *
+     * @param o
+     *        the instance to be marshaled
+     * @param dataOut
+     *        the output stream
+     * @throws IOException
+     *         thrown if an error occurs
+     */
+    @Override
+    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
+        super.tightMarshal2(wireFormat, o, dataOut, bs);
+
+        ConnectionId info = (ConnectionId) o;
+        tightMarshalString2(info.getValue(), dataOut, bs);
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
+        super.looseUnmarshal(wireFormat, o, dataIn);
+
+        ConnectionId info = (ConnectionId) o;
+        info.setValue(looseUnmarshalString(dataIn));
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
+        ConnectionId info = (ConnectionId) o;
+
+        super.looseMarshal(wireFormat, o, dataOut);
+        looseMarshalString(info.getValue(), dataOut);
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionInfoMarshaller.java
----------------------------------------------------------------------
diff --git a/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionInfoMarshaller.java b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionInfoMarshaller.java
new file mode 100644
index 0000000..154c123
--- /dev/null
+++ b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConnectionInfoMarshaller.java
@@ -0,0 +1,174 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.codec.v2;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.codec.BooleanStream;
+import org.apache.activemq.openwire.codec.OpenWireFormat;
+import org.apache.activemq.openwire.commands.BrokerId;
+import org.apache.activemq.openwire.commands.ConnectionId;
+import org.apache.activemq.openwire.commands.ConnectionInfo;
+import org.apache.activemq.openwire.commands.DataStructure;
+
+public class ConnectionInfoMarshaller extends BaseCommandMarshaller {
+
+    /**
+     * Return the type of Data Structure we marshal
+     * @return short representation of the type data structure
+     */
+    @Override
+    public byte getDataStructureType() {
+        return ConnectionInfo.DATA_STRUCTURE_TYPE;
+    }
+
+    /**
+     * @return a new object instance
+     */
+    @Override
+    public DataStructure createObject() {
+        return new ConnectionInfo();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o the object to un-marshal
+     * @param dataIn the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
+        super.tightUnmarshal(wireFormat, o, dataIn, bs);
+
+        ConnectionInfo info = (ConnectionInfo)o;
+        info.setConnectionId((ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
+        info.setClientId(tightUnmarshalString(dataIn, bs));
+        info.setPassword(tightUnmarshalString(dataIn, bs));
+        info.setUserName(tightUnmarshalString(dataIn, bs));
+
+        if (bs.readBoolean()) {
+            short size = dataIn.readShort();
+            BrokerId value[] = new BrokerId[size];
+            for( int i=0; i < size; i++ ) {
+                value[i] = (BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);
+            }
+            info.setBrokerPath(value);
+        }
+        else {
+            info.setBrokerPath(null);
+        }
+        info.setBrokerMasterConnector(bs.readBoolean());
+        info.setManageable(bs.readBoolean());
+        info.setClientMaster(bs.readBoolean());
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
+        ConnectionInfo info = (ConnectionInfo)o;
+
+        int rc = super.tightMarshal1(wireFormat, o, bs);
+        rc += tightMarshalCachedObject1(wireFormat, info.getConnectionId(), bs);
+        rc += tightMarshalString1(info.getClientId(), bs);
+        rc += tightMarshalString1(info.getPassword(), bs);
+        rc += tightMarshalString1(info.getUserName(), bs);
+        rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
+        bs.writeBoolean(info.isBrokerMasterConnector());
+        bs.writeBoolean(info.isManageable());
+        bs.writeBoolean(info.isClientMaster());
+
+        return rc + 0;
+    }
+
+    /**
+     * Write a object instance to data output stream
+     *
+     * @param o the instance to be marshaled
+     * @param dataOut the output stream
+     * @throws IOException thrown if an error occurs
+     */
+    @Override
+    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
+        super.tightMarshal2(wireFormat, o, dataOut, bs);
+
+        ConnectionInfo info = (ConnectionInfo)o;
+        tightMarshalCachedObject2(wireFormat, info.getConnectionId(), dataOut, bs);
+        tightMarshalString2(info.getClientId(), dataOut, bs);
+        tightMarshalString2(info.getPassword(), dataOut, bs);
+        tightMarshalString2(info.getUserName(), dataOut, bs);
+        tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
+        bs.readBoolean();
+        bs.readBoolean();
+        bs.readBoolean();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o the object to un-marshal
+     * @param dataIn the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
+        super.looseUnmarshal(wireFormat, o, dataIn);
+
+        ConnectionInfo info = (ConnectionInfo)o;
+        info.setConnectionId((ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn));
+        info.setClientId(looseUnmarshalString(dataIn));
+        info.setPassword(looseUnmarshalString(dataIn));
+        info.setUserName(looseUnmarshalString(dataIn));
+
+        if (dataIn.readBoolean()) {
+            short size = dataIn.readShort();
+            BrokerId value[] = new BrokerId[size];
+            for( int i=0; i < size; i++ ) {
+                value[i] = (BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);
+            }
+            info.setBrokerPath(value);
+        }
+        else {
+            info.setBrokerPath(null);
+        }
+        info.setBrokerMasterConnector(dataIn.readBoolean());
+        info.setManageable(dataIn.readBoolean());
+        info.setClientMaster(dataIn.readBoolean());
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
+        ConnectionInfo info = (ConnectionInfo)o;
+
+        super.looseMarshal(wireFormat, o, dataOut);
+        looseMarshalCachedObject(wireFormat, info.getConnectionId(), dataOut);
+        looseMarshalString(info.getClientId(), dataOut);
+        looseMarshalString(info.getPassword(), dataOut);
+        looseMarshalString(info.getUserName(), dataOut);
+        looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
+        dataOut.writeBoolean(info.isBrokerMasterConnector());
+        dataOut.writeBoolean(info.isManageable());
+        dataOut.writeBoolean(info.isClientMaster());
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-openwire/blob/7ae454fa/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConsumerControlMarshaller.java
----------------------------------------------------------------------
diff --git a/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConsumerControlMarshaller.java b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConsumerControlMarshaller.java
new file mode 100644
index 0000000..51fa18f
--- /dev/null
+++ b/openwire-legacy/src/main/java/org/apache/activemq/openwire/codec/v2/ConsumerControlMarshaller.java
@@ -0,0 +1,148 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire.codec.v2;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.activemq.openwire.codec.BooleanStream;
+import org.apache.activemq.openwire.codec.OpenWireFormat;
+import org.apache.activemq.openwire.commands.ConsumerControl;
+import org.apache.activemq.openwire.commands.ConsumerId;
+import org.apache.activemq.openwire.commands.DataStructure;
+
+public class ConsumerControlMarshaller extends BaseCommandMarshaller {
+
+    /**
+     * Return the type of Data Structure we marshal
+     *
+     * @return short representation of the type data structure
+     */
+    @Override
+    public byte getDataStructureType() {
+        return ConsumerControl.DATA_STRUCTURE_TYPE;
+    }
+
+    /**
+     * @return a new object instance
+     */
+    @Override
+    public DataStructure createObject() {
+        return new ConsumerControl();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
+        super.tightUnmarshal(wireFormat, o, dataIn, bs);
+
+        ConsumerControl info = (ConsumerControl) o;
+        info.setClose(bs.readBoolean());
+        info.setConsumerId((ConsumerId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
+        info.setPrefetch(dataIn.readInt());
+        info.setFlush(bs.readBoolean());
+        info.setStart(bs.readBoolean());
+        info.setStop(bs.readBoolean());
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
+        ConsumerControl info = (ConsumerControl) o;
+
+        int rc = super.tightMarshal1(wireFormat, o, bs);
+        bs.writeBoolean(info.isClose());
+        rc += tightMarshalNestedObject1(wireFormat, info.getConsumerId(), bs);
+        bs.writeBoolean(info.isFlush());
+        bs.writeBoolean(info.isStart());
+        bs.writeBoolean(info.isStop());
+
+        return rc + 4;
+    }
+
+    /**
+     * Write a object instance to data output stream
+     *
+     * @param o
+     *        the instance to be marshaled
+     * @param dataOut
+     *        the output stream
+     * @throws IOException
+     *         thrown if an error occurs
+     */
+    @Override
+    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
+        super.tightMarshal2(wireFormat, o, dataOut, bs);
+
+        ConsumerControl info = (ConsumerControl) o;
+        bs.readBoolean();
+        tightMarshalNestedObject2(wireFormat, info.getConsumerId(), dataOut, bs);
+        dataOut.writeInt(info.getPrefetch());
+        bs.readBoolean();
+        bs.readBoolean();
+        bs.readBoolean();
+    }
+
+    /**
+     * Un-marshal an object instance from the data input stream
+     *
+     * @param o
+     *        the object to un-marshal
+     * @param dataIn
+     *        the data input stream to build the object from
+     * @throws IOException
+     */
+    @Override
+    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
+        super.looseUnmarshal(wireFormat, o, dataIn);
+
+        ConsumerControl info = (ConsumerControl) o;
+        info.setClose(dataIn.readBoolean());
+        info.setConsumerId((ConsumerId) looseUnmarsalNestedObject(wireFormat, dataIn));
+        info.setPrefetch(dataIn.readInt());
+        info.setFlush(dataIn.readBoolean());
+        info.setStart(dataIn.readBoolean());
+        info.setStop(dataIn.readBoolean());
+    }
+
+    /**
+     * Write the booleans that this object uses to a BooleanStream
+     */
+    @Override
+    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
+        ConsumerControl info = (ConsumerControl) o;
+
+        super.looseMarshal(wireFormat, o, dataOut);
+        dataOut.writeBoolean(info.isClose());
+        looseMarshalNestedObject(wireFormat, info.getConsumerId(), dataOut);
+        dataOut.writeInt(info.getPrefetch());
+        dataOut.writeBoolean(info.isFlush());
+        dataOut.writeBoolean(info.isStart());
+        dataOut.writeBoolean(info.isStop());
+    }
+}


Mime
View raw message