You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2013/02/25 23:29:05 UTC

svn commit: r1449939 - /qpid/proton/trunk/tests/java/org/apache/qpid/proton/InteropTest.java

Author: aconway
Date: Mon Feb 25 22:29:05 2013
New Revision: 1449939

URL: http://svn.apache.org/r1449939
Log:
PROTON-215: Fix bug in JNI map decoding discovered by new tests.

JNIData.getJavaMap() was alwayws returning an empty map.

Modified:
    qpid/proton/trunk/tests/java/org/apache/qpid/proton/InteropTest.java

Modified: qpid/proton/trunk/tests/java/org/apache/qpid/proton/InteropTest.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/java/org/apache/qpid/proton/InteropTest.java?rev=1449939&r1=1449938&r2=1449939&view=diff
==============================================================================
--- qpid/proton/trunk/tests/java/org/apache/qpid/proton/InteropTest.java (original)
+++ qpid/proton/trunk/tests/java/org/apache/qpid/proton/InteropTest.java Mon Feb 25 22:29:05 2013
@@ -21,6 +21,7 @@ package org.apache.qpid.proton;
 import org.apache.qpid.proton.TestDecoder;
 import org.apache.qpid.proton.ProtonFactoryLoader;
 import org.apache.qpid.proton.amqp.Binary;
+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;
@@ -30,12 +31,18 @@ import org.apache.qpid.proton.message.Me
 import org.apache.qpid.proton.message.MessageFactory;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertArrayEquals;
 import org.junit.Test;
 import java.lang.System;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.util.Vector;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
 
 public class InteropTest {
 
@@ -92,9 +99,64 @@ public class InteropTest {
 
     @Test
     public void test_strings() throws IOException {
-	// FIXME aconway 2013-02-18:
+	TestDecoder d = createDecoder(getBytes("strings"));
+	assertEquals(new Binary("abc\0defg".getBytes("UTF-8")), d.readBinary());
+	assertEquals("abcdefg", d.readString());
+	assertEquals(Symbol.valueOf("abcdefg"), d.readSymbol());
+	assertEquals(new Binary(new byte[0]), d.readBinary());
+	assertEquals("", d.readString());
+	assertEquals(Symbol.valueOf(""), d.readSymbol());
     }
 
-    // FIXMEo aconway 2013-02-15: add tests for all fragments generated by
+    @Test
+    public void test_described() throws IOException {
+	// FIXME aconway 2013-02-18: TODO
+    }
+
+    @Test
+    public void test_described_array() throws IOException {
+	// FIXME aconway 2013-02-18: TODO
+    }
+
+    @Test
+    public void test_arrays() throws IOException {
+        TestDecoder d = createDecoder(getBytes("arrays"));
+
+	Vector<Integer> ints = new Vector<Integer>();
+	for (int i = 0; i < 100; ++i) ints.add(new Integer(i));
+	assertArrayEquals(ints.toArray(), d.readArray());
+
+	String strings[] = { "a", "b", "c" };
+	assertArrayEquals(strings, d.readArray());
+
+	// FIXME aconway 2013-02-18: NPE: bug in decoder?
+        // assertArrayEquals(new Integer[0], d.readArray());
+    }
+
+    @Test
+    public void test_lists() throws IOException {
+        TestDecoder d = createDecoder(getBytes("lists"));
+	List<Object> l = new ArrayList<Object>() {{
+	    add(new Integer(32));
+	    add("foo");
+	    add(new Boolean(true));
+	}};
+	assertEquals(l, d.readList());
+	l.clear();
+	assertEquals(l, d.readList());
+    }
+
+    @Test
+    public void test_maps() throws IOException {
+        TestDecoder d = createDecoder(getBytes("maps"));
+	Map map = new HashMap() {{
+	    put("one", 1);
+	    put("two", 2);
+	    put("three", 3);
+	}};
+	assertEquals(map, d.readMap());
+	// FIXME aconway 2013-02-18: todo
+    }
+    // FIXME aconway 2013-02-15: add tests for all fragments generated by
     // interop-generate
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org