You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2011/07/15 22:16:44 UTC
svn commit: r1147301 - in /thrift/trunk/lib:
java/test/org/apache/thrift/server/ServerTestBase.java js/test/build.xml
js/test/test.html
Author: roger
Date: Fri Jul 15 20:16:43 2011
New Revision: 1147301
URL: http://svn.apache.org/viewvc?rev=1147301&view=rev
Log:
THRIFT-1238 Thrift JS client cannot read map of structures(TestCase)
Patch: Henrique Mendonca
Modified:
thrift/trunk/lib/java/test/org/apache/thrift/server/ServerTestBase.java
thrift/trunk/lib/js/test/build.xml
thrift/trunk/lib/js/test/test.html
Modified: thrift/trunk/lib/java/test/org/apache/thrift/server/ServerTestBase.java
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/java/test/org/apache/thrift/server/ServerTestBase.java?rev=1147301&r1=1147300&r2=1147301&view=diff
==============================================================================
--- thrift/trunk/lib/java/test/org/apache/thrift/server/ServerTestBase.java (original)
+++ thrift/trunk/lib/java/test/org/apache/thrift/server/ServerTestBase.java Fri Jul 15 20:16:43 2011
@@ -185,13 +185,10 @@ public abstract class ServerTestBase ext
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 ext
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 ext
testStruct(testClient);
testNestedStruct(testClient);
testMap(testClient);
+ testStringMap(testClient);
testSet(testClient);
testList(testClient);
testEnum(testClient);
@@ -429,6 +428,16 @@ public abstract class ServerTestBase ext
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);
Modified: thrift/trunk/lib/js/test/build.xml
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/build.xml?rev=1147301&r1=1147300&r2=1147301&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/build.xml (original)
+++ thrift/trunk/lib/js/test/build.xml Fri Jul 15 20:16:43 2011
@@ -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>
Modified: thrift/trunk/lib/js/test/test.html
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/test.html?rev=1147301&r1=1147300&r2=1147301&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/test.html (original)
+++ thrift/trunk/lib/js/test/test.html Fri Jul 15 20:16:43 2011
@@ -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
});