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>();
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 =
testStruct(testClient);
testNestedStruct(testClient);
testMap(testClient);
+ testStringMap(testClient);
testSet(testClient);
testList(testClient);
testEnum(testClient);
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);
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
});