PROTON-1329: remove the TestDecoder class
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/TestDecoder.java b/proton-j/src/main/java/org/apache/qpid/proton/TestDecoder.java
deleted file mode 100644
index 50d53f7..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/TestDecoder.java
+++ /dev/null
@@ -1,96 +0,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.
- */
-package org.apache.qpid.proton;
-
-import org.apache.qpid.proton.TestDecoder;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Decimal128;
-import org.apache.qpid.proton.amqp.Decimal32;
-import org.apache.qpid.proton.amqp.Decimal64;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedByte;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.proton.amqp.UnsignedShort;
-import org.apache.qpid.proton.codec.AMQPDefinedTypes;
-
-import org.apache.qpid.proton.codec.DecoderImpl;
-import org.apache.qpid.proton.codec.EncoderImpl;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-
-/**
- * TestDecoder is a stripped-down decoder used by interop tests to decode AMQP
- * data. The native version wraps a DecoderImpl, while the JNI version wraps a
- * Data object.
- */
-
-public class TestDecoder {
- private DecoderImpl decoder;
- private EncoderImpl encoder;
- private ByteBuffer buffer;
-
- TestDecoder(byte[] data) {
- decoder = new DecoderImpl();
- encoder = new EncoderImpl(decoder);
- AMQPDefinedTypes.registerAllTypes(decoder, encoder);
- buffer = ByteBuffer.allocate(data.length);
- buffer.put(data);
- buffer.rewind();
- decoder.setByteBuffer(buffer);
- }
-
- public Boolean readBoolean() { return decoder.readBoolean(); }
- public Byte readByte() { return decoder.readByte(); }
- public Short readShort() { return decoder.readShort(); }
- public Integer readInteger() { return decoder.readInteger(); }
- public Long readLong() { return decoder.readLong(); }
- public UnsignedByte readUnsignedByte() { return decoder.readUnsignedByte(); }
- public UnsignedShort readUnsignedShort() { return decoder.readUnsignedShort(); }
- public UnsignedInteger readUnsignedInteger() { return decoder.readUnsignedInteger(); }
- public UnsignedLong readUnsignedLong() { return decoder.readUnsignedLong(); }
- public Character readCharacter() { return decoder.readCharacter(); }
- public Float readFloat() { return decoder.readFloat(); }
- public Double readDouble() { return decoder.readDouble(); }
- public UUID readUUID() { return decoder.readUUID(); }
- public Decimal32 readDecimal32() { return decoder.readDecimal32(); }
- public Decimal64 readDecimal64() { return decoder.readDecimal64(); }
- public Decimal128 readDecimal128() { return decoder.readDecimal128(); }
- public Date readTimestamp() { return decoder.readTimestamp(); }
- public Binary readBinary() { return decoder.readBinary(); }
- public Symbol readSymbol() { return decoder.readSymbol(); }
- public String readString() { return decoder.readString(); }
- public List readList() { return decoder.readList(); }
- public Map readMap() { return decoder.readMap(); }
- public Object[] readArray() { return decoder.readArray(); }
- public boolean[] readBooleanArray() { return decoder.readBooleanArray(); }
- public byte[] readByteArray() { return decoder.readByteArray(); }
- public short[] readShortArray() { return decoder.readShortArray(); }
- public int[] readIntegerArray() { return decoder.readIntegerArray(); }
- public long[] readLongArray() { return decoder.readLongArray(); }
- public float[] readFloatArray() { return decoder.readFloatArray(); }
- public double[] readDoubleArray() { return decoder.readDoubleArray(); }
- public char[] readCharacterArray() { return decoder.readCharacterArray(); }
- public Object readObject() { return decoder.readObject(); }
-}
diff --git a/tests/java/org/apache/qpid/proton/InteropTest.java b/tests/java/org/apache/qpid/proton/InteropTest.java
index c875092..e9b8c58 100644
--- a/tests/java/org/apache/qpid/proton/InteropTest.java
+++ b/tests/java/org/apache/qpid/proton/InteropTest.java
@@ -18,17 +18,21 @@
*/
package org.apache.qpid.proton;
-import org.apache.qpid.proton.TestDecoder;
import org.apache.qpid.proton.amqp.Binary;
import org.apache.qpid.proton.amqp.DescribedType;
import org.apache.qpid.proton.amqp.Symbol;
import org.apache.qpid.proton.amqp.messaging.AmqpValue;
+import org.apache.qpid.proton.codec.AMQPDefinedTypes;
+import org.apache.qpid.proton.codec.Decoder;
+import org.apache.qpid.proton.codec.DecoderImpl;
+import org.apache.qpid.proton.codec.EncoderImpl;
import org.apache.qpid.proton.message.Message;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
import java.lang.System;
+import java.nio.ByteBuffer;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -72,10 +76,16 @@
return m;
}
- TestDecoder createDecoder(byte[] data)
+ Decoder createDecoder(byte[] data)
{
- TestDecoder td = new TestDecoder(data);
- return td;
+ DecoderImpl decoder = new DecoderImpl();
+ AMQPDefinedTypes.registerAllTypes(decoder, new EncoderImpl(decoder));
+ ByteBuffer buffer = ByteBuffer.allocate(data.length);
+ buffer.put(data);
+ buffer.rewind();
+ decoder.setByteBuffer(buffer);
+
+ return decoder;
}
@Test
@@ -90,7 +100,7 @@
@Test
public void testPrimitives() throws IOException
{
- TestDecoder d = createDecoder(getBytes("primitives"));
+ Decoder d = createDecoder(getBytes("primitives"));
assertEquals(true, d.readBoolean());
assertEquals(false, d.readBoolean());
assertEquals(d.readUnsignedByte().intValue(), 42);
@@ -107,7 +117,7 @@
@Test
public void testStrings() throws IOException
{
- TestDecoder d = createDecoder(getBytes("strings"));
+ Decoder d = createDecoder(getBytes("strings"));
assertEquals(new Binary("abc\0defg".getBytes("UTF-8")), d.readBinary());
assertEquals("abcdefg", d.readString());
assertEquals(Symbol.valueOf("abcdefg"), d.readSymbol());
@@ -119,7 +129,7 @@
@Test
public void testDescribed() throws IOException
{
- TestDecoder d = createDecoder(getBytes("described"));
+ Decoder d = createDecoder(getBytes("described"));
DescribedType dt = (DescribedType) (d.readObject());
assertEquals(Symbol.valueOf("foo-descriptor"), dt.getDescriptor());
assertEquals("foo-value", dt.getDescribed());
@@ -132,7 +142,7 @@
@Test
public void testDescribedArray() throws IOException
{
- TestDecoder d = createDecoder(getBytes("described_array"));
+ Decoder d = createDecoder(getBytes("described_array"));
DescribedType a[] = (DescribedType[]) (d.readArray());
for (int i = 0; i < 10; ++i)
{
@@ -144,7 +154,7 @@
@Test
public void testArrays() throws IOException
{
- TestDecoder d = createDecoder(getBytes("arrays"));
+ Decoder d = createDecoder(getBytes("arrays"));
// int array
Vector<Integer> ints = new Vector<Integer>();
@@ -164,7 +174,7 @@
@Test
public void testLists() throws IOException
{
- TestDecoder d = createDecoder(getBytes("lists"));
+ Decoder d = createDecoder(getBytes("lists"));
List<Object> l = new ArrayList<Object>()
{
{
@@ -182,7 +192,7 @@
@Test
public void testMaps() throws IOException
{
- TestDecoder d = createDecoder(getBytes("maps"));
+ Decoder d = createDecoder(getBytes("maps"));
Map map = new HashMap()
{
{