THRIFT-1238 Thrift JS client cannot read map of structures(TestCase)
Patch: Henrique Mendonca
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1147301 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/java/test/org/apache/thrift/server/ServerTestBase.java b/lib/java/test/org/apache/thrift/server/ServerTestBase.java
index 13a8be6..b9974c4 100644
--- a/lib/java/test/org/apache/thrift/server/ServerTestBase.java
+++ b/lib/java/test/org/apache/thrift/server/ServerTestBase.java
@@ -185,13 +185,10 @@
Insanity crazy = new Insanity();
crazy.userMap = new HashMap<Numberz, Long>();
- crazy.xtructs = new ArrayList<Xtruct>();
-
crazy.userMap.put(Numberz.EIGHT, (long)8);
- crazy.xtructs.add(goodbye);
-
- Insanity looney = new Insanity();
crazy.userMap.put(Numberz.FIVE, (long)5);
+ crazy.xtructs = new ArrayList<Xtruct>();
+ crazy.xtructs.add(goodbye);
crazy.xtructs.add(hello);
HashMap<Numberz,Insanity> first_map = new HashMap<Numberz, Insanity>();
@@ -200,6 +197,7 @@
first_map.put(Numberz.TWO, crazy);
first_map.put(Numberz.THREE, crazy);
+ Insanity looney = new Insanity();
second_map.put(Numberz.SIX, looney);
Map<Long,Map<Numberz,Insanity>> insane =
@@ -389,6 +387,7 @@
testStruct(testClient);
testNestedStruct(testClient);
testMap(testClient);
+ testStringMap(testClient);
testSet(testClient);
testList(testClient);
testEnum(testClient);
@@ -429,6 +428,16 @@
assertEquals(mapout, mapin);
}
+ private void testStringMap(ThriftTest.Client testClient) throws TException {
+ Map<String,String> mapout = new HashMap<String,String>();
+ mapout.put("a", "123");
+ mapout.put(" x y ", " with spaces ");
+ mapout.put("same", "same");
+ mapout.put("0", "numeric key");
+ Map<String,String> mapin = testClient.testStringMap(mapout);
+ assertEquals(mapout, mapin);
+ }
+
private void testNestedMap(ThriftTest.Client testClient) throws TException {
Map<Integer,Map<Integer,Integer>> mm =
testClient.testMapMap(1);
diff --git a/lib/js/test/build.xml b/lib/js/test/build.xml
index bd2faf2..32316a1 100644
--- a/lib/js/test/build.xml
+++ b/lib/js/test/build.xml
@@ -59,7 +59,10 @@
<condition>
<not>
<resourcecount count="2">
- <fileset id="fs" dir="${thrift.java.dir}/build" includes="libthrift*.jar"/>
+ <fileset id="fs" dir="${thrift.java.dir}/build">
+ <include name="libthrift*.jar" />
+ <exclude name="libthrift*javadoc.jar" />
+ </fileset>
</resourcecount>
</not>
</condition>
diff --git a/lib/js/test/test.html b/lib/js/test/test.html
index bd124af..5039edb 100644
--- a/lib/js/test/test.html
+++ b/lib/js/test/test.html
@@ -215,9 +215,47 @@
module("Insanity");
test("testInsanity", function() {
- var insanity;
- var res = client.testInsanity(insanity);
- ok(res);
+ var insanity = {
+ "1":{
+ "3":{
+ "userMap":{ "8":8, "5":5 },
+ "xtructs":[{
+ "string_thing":"Goodbye4",
+ "byte_thing":4,
+ "i32_thing":4,
+ "i64_thing":4
+ },
+ {
+ "string_thing":"Hello2",
+ "byte_thing":2,
+ "i32_thing":2,
+ "i64_thing":2
+ }
+ ]
+ },
+ "2":{
+ "userMap":{ "8":8, "5":5 },
+ "xtructs":[{
+ "string_thing":"Goodbye4",
+ "byte_thing":4,
+ "i32_thing":4,
+ "i64_thing":4
+ },
+ {
+ "string_thing":"Hello2",
+ "byte_thing":2,
+ "i32_thing":2,
+ "i64_thing":2
+ }
+ ]
+ }
+ },
+ "2":{ "6":{ "userMap":null, "xtructs":null } }
+ };
+ var res = client.testInsanity("");
+ ok(res, JSON.stringify(res));
+ ok(insanity, JSON.stringify(insanity));
+ equals(JSON.stringify(res), JSON.stringify(insanity)) //TODO: read and compare maps recursively
});