diff options
author | Roger Meier <roger@apache.org> | 2011-07-15 20:16:43 +0000 |
---|---|---|
committer | Roger Meier <roger@apache.org> | 2011-07-15 20:16:43 +0000 |
commit | a35944bfe2fabda4816e4396f92280ee9fcf789d (patch) | |
tree | ab77845ce350afbb7880ab930a71980c4d82a6fd | |
parent | cdbf36c6082a3931e41d5d1fb8ba8b5cb3eade23 (diff) | |
download | thrift-a35944bfe2fabda4816e4396f92280ee9fcf789d.tar.gz |
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
-rw-r--r-- | lib/java/test/org/apache/thrift/server/ServerTestBase.java | 19 | ||||
-rw-r--r-- | lib/js/test/build.xml | 5 | ||||
-rw-r--r-- | lib/js/test/test.html | 44 |
3 files changed, 59 insertions, 9 deletions
diff --git a/lib/java/test/org/apache/thrift/server/ServerTestBase.java b/lib/java/test/org/apache/thrift/server/ServerTestBase.java index 13a8be696..b9974c4a4 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 @@ public abstract class ServerTestBase extends TestCase { 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 @@ public abstract class ServerTestBase extends TestCase { 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 @@ public abstract class ServerTestBase extends TestCase { testStruct(testClient); testNestedStruct(testClient); testMap(testClient); + testStringMap(testClient); testSet(testClient); testList(testClient); testEnum(testClient); @@ -429,6 +428,16 @@ public abstract class ServerTestBase extends TestCase { 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 bd2faf25a..32316a167 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 bd124afa7..5039edb47 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 }); |