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/30 17:10:43 UTC

svn commit: r1152486 - in /thrift/trunk/lib/js/test: build.xml test.html test.js

Author: roger
Date: Sat Jul 30 15:10:42 2011
New Revision: 1152486

URL: http://svn.apache.org/viewvc?rev=1152486&view=rev
Log:
THRIFT-1247 JavaScript unit test with phantomjs
update: unit test depends on init, move testcases from test.html to test.js

Added:
    thrift/trunk/lib/js/test/test.js   (with props)
Modified:
    thrift/trunk/lib/js/test/build.xml
    thrift/trunk/lib/js/test/test.html   (contents, props changed)

Modified: thrift/trunk/lib/js/test/build.xml
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/build.xml?rev=1152486&r1=1152485&r2=1152486&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/build.xml (original)
+++ thrift/trunk/lib/js/test/build.xml Sat Jul 30 15:10:42 2011
@@ -119,7 +119,7 @@
     </exec>
   </target>
 
-  <target name="unittest" description="do unit tests with headless browser phantomjs" depends="phantomjs, jstest" if="phantomjs.present">
+  <target name="unittest" description="do unit tests with headless browser phantomjs" depends="init, phantomjs, jstest" if="phantomjs.present">
     <parallel>
       <exec executable="Xvfb" spawn="true" failonerror="false">
         <arg line=":99" />

Modified: thrift/trunk/lib/js/test/test.html
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/test.html?rev=1152486&r1=1152485&r2=1152486&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/test.html (original)
+++ thrift/trunk/lib/js/test/test.html Sat Jul 30 15:10:42 2011
@@ -29,384 +29,12 @@
   <!-- jQuery -->
   <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.js" charset="utf-8"></script>
   
-  <!-- json2  -->
-  <script type="text/javascript" src="json2.js" charset="utf-8"></script>
-
   <!-- QUnit Test framework-->
   <script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js" charset="utf-8"></script>
   <link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" />
-
-  <script type="text/javascript" charset="utf-8">
-  //<![CDATA[
-  $(document).ready(function(){
-    var transport = new Thrift.Transport("/service");
-    var protocol  = new Thrift.Protocol(transport);
-    var client    = new ThriftTest.ThriftTestClient(protocol);
-
-    // all Languages in UTF-8
-    var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig,
  Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (ny
 norsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
-
-
-    module("Base Types");
-
-    test("Void", function() {
-      equals(client.testVoid(), undefined);
-    });
-    test("String", function() {
-      equals(client.testString(stringTest), stringTest);
-
-      var specialCharacters = 'quote: \" backslash:' +
-            ' forwardslash-escaped: \/ ' +
-            ' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
-            ' now-all-of-them-together: "\\\/\b\n\r\t' +
-            ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><';
-      equals(client.testString(specialCharacters),specialCharacters);
-    });
-    test("Double", function() {
-      equals(client.testDouble(3.14), 3.14);
-    });
-    test("Byte", function() {
-      equals(client.testByte(0x01), 0x01);
-    });
-    test("I32", function() {
-      equals(client.testI32(Math.pow(2,30)), Math.pow(2,30));
-    });
-    test("I64", function() {
-      equals(client.testI64(Math.pow(2,60)), Math.pow(2,60));
-    });
-
-
-    module("Structured Types");
-
-    test("Struct", function() {
-      var structTestInput = new ThriftTest.Xtruct()
-      structTestInput.string_thing = 'worked'
-      structTestInput.byte_thing = 0x01
-      structTestInput.i32_thing = Math.pow(2,30)
-      structTestInput.i64_thing = Math.pow(2,60)
-
-      var structTestOutput = client.testStruct(structTestInput);
-
-      equals(structTestOutput.string_thing, structTestInput.string_thing);
-      equals(structTestOutput.byte_thing, structTestInput.byte_thing);
-      equals(structTestOutput.i32_thing, structTestInput.i32_thing);
-      equals(structTestOutput.i64_thing, structTestInput.i64_thing);
-      
-      equals(JSON.stringify(structTestOutput), JSON.stringify(structTestInput))
-    });
-    
-    test("Nest", function() {
-      var xtrTestInput = new ThriftTest.Xtruct()
-      xtrTestInput.string_thing = 'worked'
-      xtrTestInput.byte_thing = 0x01
-      xtrTestInput.i32_thing = Math.pow(2,30)
-      xtrTestInput.i64_thing = Math.pow(2,60)
-      
-      var nestTestInput = new ThriftTest.Xtruct2()
-      nestTestInput.byte_thing = 0x02
-      nestTestInput.struct_thing = xtrTestInput
-      nestTestInput.i32_thing = Math.pow(2,15)
-      
-      var nestTestOutput = client.testNest(nestTestInput);
-      
-      equals(nestTestOutput.byte_thing, nestTestInput.byte_thing);
-      equals(nestTestOutput.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
-      equals(nestTestOutput.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
-      equals(nestTestOutput.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
-      equals(nestTestOutput.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
-      equals(nestTestOutput.i32_thing, nestTestInput.i32_thing);
-      
-      equals(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput))
-    });
-
-    test("Map", function() {
-      var mapTestInput = {7:77, 8:88, 9:99};
-
-      var mapTestOutput = client.testMap(mapTestInput)
-
-      for (var key in mapTestOutput) {
-        equals(mapTestOutput[key], mapTestInput[key]);
-      }
-    });
-
-    test("StringMap", function() {
-      var mapTestInput = {
-        "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
-        "longValue":stringTest, stringTest:"long key"
-      };
-
-      var mapTestOutput = client.testStringMap(mapTestInput)
-
-      for (var key in mapTestOutput) {
-        equals(mapTestOutput[key], mapTestInput[key]);
-      }
-    });
-
-    test("Set", function() {
-      var setTestInput = new Array(1,2,3)
-      ok(client.testSet(setTestInput), setTestInput);
-    });
-    
-    test("List", function() {
-      var listTestInput = new Array(1,2,3)
-      ok(client.testList(listTestInput), listTestInput);
-    });
-    
-    test("Enum", function() {
-      equals(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
-    });
-    
-    test("TypeDef", function() {
-      equals(client.testTypedef(69), 69);
-    });
-
-    module("deeper!");
-    
-    test("MapMap", function() {
-      var mapMapTestExpectedResult = {
-        "4":{"1":1,"2":2,"3":3,"4":4},
-        "-4":{"-4":-4, "-3":-3, "-2":-2, "-1":-1}
-      };
-
-      var mapMapTestOutput = client.testMapMap(1);
-
-
-      for (var key in mapMapTestOutput) {
-        for (var key2 in mapMapTestOutput[key]) {
-          equals(mapMapTestOutput[key][key2], mapMapTestExpectedResult[key][key2]);
-        }
-      }
-      
-      equals(JSON.stringify(mapMapTestOutput), JSON.stringify(mapMapTestExpectedResult))
-    });
-
-
-    module("Exception");
-
-    test("Xception", function() {
-      expect(2);
-      try{
-        client.testException("Xception");
-      }catch(e){
-        equals(e.errorCode, 1001);
-        equals(e.message, "Xception");
-      }
-    });
-
-    test("no Exception", function() {
-      try{
-        client.testException("no Exception");
-      }catch(e){
-        ok(false);
-      }
-    });
-
-    test("unexpected Application Exception", function() {
-      expect(1);
-      try{
-        client.testException("ApplicationException");
-      } catch(e) {
-        ok(true); //@HACK: ignore faulty java server response for exceptions
-        //equals(e.message, "ApplicationException");
-      }
-    });
-
-
-    module("Insanity");
-
-    test("testInsanity", function() {
-      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
-    });
-
-
-    //////////////////////////////////
-    //Run same tests asynchronously
-    jQuery.ajaxSetup({ timeout: 0 });
-    $(document).ajaxError( function() { QUnit.start(); } );
-
-    module("Async Manual");
-
-    test("testI32", function() {
-      expect( 2 );
-      QUnit.stop();
-
-      var transport = new Thrift.Transport();
-      var protocol  = new Thrift.Protocol(transport);
-      var client    = new ThriftTest.ThriftTestClient(protocol);
-
-      var jqxhr = jQuery.ajax({
-        url: "/service",
-        data: client.send_testI32(Math.pow(-2,31)),
-        type: "POST",
-        cache: false,
-        dataType: "text",
-        success: function(res){
-          transport.setRecvBuffer( res );
-          equals(client.recv_testI32(), Math.pow(-2,31));
-        },
-        error: function() { ok(false); },
-        complete: function() {
-          ok(true);
-          QUnit.start();
-        }
-      });
-    });
-
-
-    test("testI64", function() {
-      expect( 2 );
-      QUnit.stop();
-
-      var transport = new Thrift.Transport();
-      var protocol  = new Thrift.Protocol(transport);
-      var client    = new ThriftTest.ThriftTestClient(protocol);
-
-      jQuery.ajax({
-        url: "/service",
-        data: client.send_testI64(Math.pow(-2,61)),
-        type: "POST",
-        cache: false,
-        dataType: "text",
-        success: function(res){
-          transport.setRecvBuffer( res );
-          equals(client.recv_testI64(), Math.pow(-2,61));
-        },
-        error: function() { ok(false); },
-        complete: function() {
-          ok(true);
-          QUnit.start();
-        }
-      });
-    });
-
-
-
-    module("Async");
-
-    test("Double", function() {
-      expect( 1 );
-
-      QUnit.stop();
-      client.testDouble(3.14159265, function(result) {
-        equals(result, 3.14159265);
-        QUnit.start();
-      });
-    });
-
-    test("Byte", function() {
-      expect( 1 );
-
-      QUnit.stop();
-      client.testByte(0x01, function(result) {
-        equals(result, 0x01);
-        QUnit.start();
-      });
-    });
-
-    test("I32", function() {
-      expect( 3 );
-
-      QUnit.stop();
-      client.testI32(Math.pow(2,30), function(result) {
-        equals(result, Math.pow(2,30));
-        QUnit.start();
-      });
-
-      QUnit.stop();
-      var jqxhr = client.testI32(Math.pow(-2,31), function(result) {
-        equals(result, Math.pow(-2,31));
-      });
-
-      jqxhr.success(function(result) {
-        equals(result, Math.pow(-2,31));
-        QUnit.start();
-      });
-    });
-
-    test("I64", function() {
-      expect( 4 );
-
-      QUnit.stop();
-      client.testI64(Math.pow(2,60), function(result) {
-        equals(result, Math.pow(2,60));
-        QUnit.start();
-      });
-
-      QUnit.stop();
-      client.testI64(Math.pow(-2,61), function(result) {
-        equals(result, Math.pow(-2,61));
-      })
-      .error( function(e) {  ok(false); } )
-      .success(function(result) {
-        equals(result, Math.pow(-2,61));
-      })
-      .complete(function() {
-        ok(true);
-        QUnit.start();
-      });
-    });
-
-    test("Xception", function() {
-      expect( 2 );
-
-      QUnit.stop();
-
-      var dfd = client.testException("Xception", function(result) {
-        ok(false);
-        QUnit.start();
-      })
-      .error(function(e){
-        equals(e.errorCode, 1001);
-        equals(e.message, "Xception");
-        QUnit.start();
-      });
-    });
-
-
-  });
-  //]]>
-  </script>
-
+  
+  <!-- the Test Suite-->
+  <script type="text/javascript" src="test.js" charset="utf-8"></script>
 </head>
 <body>
   <h1 id="qunit-header">Thrift Javascript Bindings: Unit Test (<a href="https://svn.apache.org/repos/asf/thrift/trunk/test/ThriftTest.thrift">ThriftTest.thrift</a>)</h1>

Propchange: thrift/trunk/lib/js/test/test.html
------------------------------------------------------------------------------
    svn:executable = *

Added: thrift/trunk/lib/js/test/test.js
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/test.js?rev=1152486&view=auto
==============================================================================
--- thrift/trunk/lib/js/test/test.js (added)
+++ thrift/trunk/lib/js/test/test.js Sat Jul 30 15:10:42 2011
@@ -0,0 +1,386 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ 
+ 
+/*
+ * JavaScript test suite
+ */
+
+var transport = new Thrift.Transport("/service");
+var protocol  = new Thrift.Protocol(transport);
+var client    = new ThriftTest.ThriftTestClient(protocol);
+
+// all Languages in UTF-8
+var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Gal
 ego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynors
 k)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
+
+
+module("Base Types");
+
+  test("Void", function() {
+    equals(client.testVoid(), undefined);
+  });
+  test("String", function() {
+    equals(client.testString(stringTest), stringTest);
+
+    var specialCharacters = 'quote: \" backslash:' +
+          ' forwardslash-escaped: \/ ' +
+          ' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
+          ' now-all-of-them-together: "\\\/\b\n\r\t' +
+          ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><';
+    equals(client.testString(specialCharacters),specialCharacters);
+  });
+  test("Double", function() {
+    equals(client.testDouble(3.14), 3.14);
+  });
+  test("Byte", function() {
+    equals(client.testByte(0x01), 0x01);
+  });
+  test("I32", function() {
+    equals(client.testI32(Math.pow(2,30)), Math.pow(2,30));
+  });
+  test("I64", function() {
+    equals(client.testI64(Math.pow(2,60)), Math.pow(2,60));
+  });
+
+
+module("Structured Types");
+
+  test("Struct", function() {
+    var structTestInput = new ThriftTest.Xtruct()
+    structTestInput.string_thing = 'worked'
+    structTestInput.byte_thing = 0x01
+    structTestInput.i32_thing = Math.pow(2,30)
+    structTestInput.i64_thing = Math.pow(2,60)
+
+    var structTestOutput = client.testStruct(structTestInput);
+
+    equals(structTestOutput.string_thing, structTestInput.string_thing);
+    equals(structTestOutput.byte_thing, structTestInput.byte_thing);
+    equals(structTestOutput.i32_thing, structTestInput.i32_thing);
+    equals(structTestOutput.i64_thing, structTestInput.i64_thing);
+    
+    equals(JSON.stringify(structTestOutput), JSON.stringify(structTestInput))
+  });
+
+  test("Nest", function() {
+    var xtrTestInput = new ThriftTest.Xtruct()
+    xtrTestInput.string_thing = 'worked'
+    xtrTestInput.byte_thing = 0x01
+    xtrTestInput.i32_thing = Math.pow(2,30)
+    xtrTestInput.i64_thing = Math.pow(2,60)
+    
+    var nestTestInput = new ThriftTest.Xtruct2()
+    nestTestInput.byte_thing = 0x02
+    nestTestInput.struct_thing = xtrTestInput
+    nestTestInput.i32_thing = Math.pow(2,15)
+    
+    var nestTestOutput = client.testNest(nestTestInput);
+    
+    equals(nestTestOutput.byte_thing, nestTestInput.byte_thing);
+    equals(nestTestOutput.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
+    equals(nestTestOutput.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
+    equals(nestTestOutput.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
+    equals(nestTestOutput.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
+    equals(nestTestOutput.i32_thing, nestTestInput.i32_thing);
+    
+    equals(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput))
+  });
+
+  test("Map", function() {
+    var mapTestInput = {7:77, 8:88, 9:99};
+
+    var mapTestOutput = client.testMap(mapTestInput)
+
+    for (var key in mapTestOutput) {
+      equals(mapTestOutput[key], mapTestInput[key]);
+    }
+  });
+
+  test("StringMap", function() {
+    var mapTestInput = {
+      "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
+      "longValue":stringTest, stringTest:"long key"
+    };
+
+    var mapTestOutput = client.testStringMap(mapTestInput)
+
+    for (var key in mapTestOutput) {
+      equals(mapTestOutput[key], mapTestInput[key]);
+    }
+  });
+
+  test("Set", function() {
+    var setTestInput = new Array(1,2,3)
+    ok(client.testSet(setTestInput), setTestInput);
+  });
+
+  test("List", function() {
+    var listTestInput = new Array(1,2,3)
+    ok(client.testList(listTestInput), listTestInput);
+  });
+
+  test("Enum", function() {
+    equals(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
+  });
+
+  test("TypeDef", function() {
+    equals(client.testTypedef(69), 69);
+  });
+
+
+module("deeper!");
+
+  test("MapMap", function() {
+    var mapMapTestExpectedResult = {
+      "4":{"1":1,"2":2,"3":3,"4":4},
+      "-4":{"-4":-4, "-3":-3, "-2":-2, "-1":-1}
+    };
+
+    var mapMapTestOutput = client.testMapMap(1);
+
+
+    for (var key in mapMapTestOutput) {
+      for (var key2 in mapMapTestOutput[key]) {
+        equals(mapMapTestOutput[key][key2], mapMapTestExpectedResult[key][key2]);
+      }
+    }
+    
+    equals(JSON.stringify(mapMapTestOutput), JSON.stringify(mapMapTestExpectedResult))
+  });
+
+
+module("Exception");
+
+  test("Xception", function() {
+    expect(2);
+    try{
+      client.testException("Xception");
+    }catch(e){
+      equals(e.errorCode, 1001);
+      equals(e.message, "Xception");
+    }
+  });
+
+  test("no Exception", function() {
+    try{
+      client.testException("no Exception");
+    }catch(e){
+      ok(false);
+    }
+  });
+
+  test("unexpected Application Exception", function() {
+    expect(1);
+    try{
+      client.testException("ApplicationException");
+    } catch(e) {
+      ok(true); //@HACK: ignore faulty java server response for exceptions
+      //equals(e.message, "ApplicationException");
+    }
+  });
+
+
+module("Insanity");
+
+  test("testInsanity", function() {
+    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
+  });
+
+
+//////////////////////////////////
+//Run same tests asynchronously
+jQuery.ajaxSetup({ timeout: 0 });
+$(document).ajaxError( function() { QUnit.start(); } );
+
+module("Async Manual");
+
+  test("testI32", function() {
+    expect( 2 );
+    QUnit.stop();
+
+    var transport = new Thrift.Transport();
+    var protocol  = new Thrift.Protocol(transport);
+    var client    = new ThriftTest.ThriftTestClient(protocol);
+
+    var jqxhr = jQuery.ajax({
+      url: "/service",
+      data: client.send_testI32(Math.pow(-2,31)),
+      type: "POST",
+      cache: false,
+      dataType: "text",
+      success: function(res){
+        transport.setRecvBuffer( res );
+        equals(client.recv_testI32(), Math.pow(-2,31));
+      },
+      error: function() { ok(false); },
+      complete: function() {
+        ok(true);
+        QUnit.start();
+      }
+    });
+  });
+
+
+  test("testI64", function() {
+    expect( 2 );
+    QUnit.stop();
+
+    var transport = new Thrift.Transport();
+    var protocol  = new Thrift.Protocol(transport);
+    var client    = new ThriftTest.ThriftTestClient(protocol);
+
+    jQuery.ajax({
+      url: "/service",
+      data: client.send_testI64(Math.pow(-2,61)),
+      type: "POST",
+      cache: false,
+      dataType: "text",
+      success: function(res){
+        transport.setRecvBuffer( res );
+        equals(client.recv_testI64(), Math.pow(-2,61));
+      },
+      error: function() { ok(false); },
+      complete: function() {
+        ok(true);
+        QUnit.start();
+      }
+    });
+  });
+
+
+module("Async");
+
+  test("Double", function() {
+    expect( 1 );
+
+    QUnit.stop();
+    client.testDouble(3.14159265, function(result) {
+      equals(result, 3.14159265);
+      QUnit.start();
+    });
+  });
+
+  test("Byte", function() {
+    expect( 1 );
+
+    QUnit.stop();
+    client.testByte(0x01, function(result) {
+      equals(result, 0x01);
+      QUnit.start();
+    });
+  });
+
+  test("I32", function() {
+    expect( 3 );
+
+    QUnit.stop();
+    client.testI32(Math.pow(2,30), function(result) {
+      equals(result, Math.pow(2,30));
+      QUnit.start();
+    });
+
+    QUnit.stop();
+    var jqxhr = client.testI32(Math.pow(-2,31), function(result) {
+      equals(result, Math.pow(-2,31));
+    });
+
+    jqxhr.success(function(result) {
+      equals(result, Math.pow(-2,31));
+      QUnit.start();
+    });
+  });
+
+  test("I64", function() {
+    expect( 4 );
+
+    QUnit.stop();
+    client.testI64(Math.pow(2,60), function(result) {
+      equals(result, Math.pow(2,60));
+      QUnit.start();
+    });
+
+    QUnit.stop();
+    client.testI64(Math.pow(-2,61), function(result) {
+      equals(result, Math.pow(-2,61));
+    })
+    .error( function(e) {  ok(false); } )
+    .success(function(result) {
+      equals(result, Math.pow(-2,61));
+    })
+    .complete(function() {
+      ok(true);
+      QUnit.start();
+    });
+  });
+
+  test("Xception", function() {
+    expect( 2 );
+
+    QUnit.stop();
+
+    var dfd = client.testException("Xception", function(result) {
+      ok(false);
+      QUnit.start();
+    })
+    .error(function(e){
+      equals(e.errorCode, 1001);
+      equals(e.message, "Xception");
+      QUnit.start();
+    });
+  });

Propchange: thrift/trunk/lib/js/test/test.js
------------------------------------------------------------------------------
    svn:executable = *