1-
21var java = require ( "../testHelpers" ) . java ;
32
43var nodeunit = require ( "nodeunit" ) ;
@@ -22,6 +21,9 @@ exports['Java - Call Static Method'] = nodeunit.testCase({
2221
2322 "callStaticMethod with args" : function ( test ) {
2423 java . callStaticMethod ( "Test" , "staticMethod" , 42 , function ( err , result ) {
24+ if ( err ) {
25+ return test . done ( err ) ;
26+ }
2527 test . ok ( result ) ;
2628 test . equal ( result , 43 ) ;
2729 test . done ( ) ;
@@ -111,7 +113,7 @@ exports['Java - Call Static Method'] = nodeunit.testCase({
111113 try {
112114 java . callStaticMethodSync ( "Test" , "staticMethodThrows" , ex ) ;
113115 test . fail ( "should throw" ) ;
114- } catch ( err ) {
116+ } catch ( err ) {
115117 test . ok ( err . toString ( ) . match ( / m y e x c e p t i o n / ) ) ;
116118 }
117119 test . done ( ) ;
@@ -123,7 +125,7 @@ exports['Java - Call Static Method'] = nodeunit.testCase({
123125 try {
124126 myTest . methodThrowsSync ( ex ) ;
125127 test . fail ( "should throw" ) ;
126- } catch ( err ) {
128+ } catch ( err ) {
127129 test . ok ( err . toString ( ) . match ( / m y e x c e p t i o n / ) ) ;
128130 }
129131 test . done ( ) ;
@@ -132,9 +134,35 @@ exports['Java - Call Static Method'] = nodeunit.testCase({
132134 "char array" : function ( test ) {
133135 var charArray = java . newArray ( "char" , "hello world\n" . split ( '' ) ) ;
134136 java . callStaticMethod ( "Test" , "staticMethodCharArrayToString" , charArray , function ( err , result ) {
137+ if ( err ) {
138+ return test . done ( err ) ;
139+ }
135140 test . ok ( result ) ;
136141 test . equal ( result , "hello world\n" ) ;
137142 test . done ( ) ;
138143 } ) ;
144+ } ,
145+
146+ "java.lang.Long calls (java Long)" : function ( test ) {
147+ var javaLong = java . newInstanceSync ( "java.lang.Long" , 5 ) ;
148+ java . callStaticMethod ( "Test" , "staticMethodLongToString" , javaLong , function ( err , result ) {
149+ if ( err ) {
150+ return test . done ( err ) ;
151+ }
152+ test . ok ( result ) ;
153+ test . equal ( result , "5" ) ;
154+ test . done ( ) ;
155+ } ) ;
156+ } ,
157+
158+ "Call method that returns a long" : function ( test ) {
159+ java . callStaticMethod ( "Test" , "staticMethodReturnLong" , function ( err , result ) {
160+ if ( err ) {
161+ return test . done ( err ) ;
162+ }
163+ test . ok ( result ) ;
164+ test . equal ( result . toStringSync ( ) , "9223372036854775807" ) ;
165+ test . done ( ) ;
166+ } ) ;
139167 }
140168} ) ;
0 commit comments