@@ -106,18 +106,21 @@ exports['Java - Call Static Method'] = nodeunit.testCase({
106106 test . done ( ) ;
107107 } ,
108108
109- "callStaticMethod exception thrown from method" : function ( test ) {
109+ "callStaticMethod exception thrown from method (sync) " : function ( test ) {
110110 var ex = java . newInstanceSync ( "java.lang.Exception" , "my exception" ) ;
111- java . callStaticMethod ( "Test" , "staticMethodThrows" , ex , function ( err , result ) {
111+ var result ;
112+ try {
113+ result = java . callStaticMethodSync ( "Test" , "staticMethodThrows" , ex ) ;
114+ } catch ( err ) {
112115 test . ok ( err ) ;
113116 test . equals ( 'my exception' , err . cause . getMessageSync ( ) ) ;
114117 test . ok ( err . toString ( ) . match ( / m y e x c e p t i o n / ) ) ;
115118 test . ok ( ! result ) ;
116119 test . done ( ) ;
117- } ) ;
120+ }
118121 } ,
119122
120- "callStaticMethodSync exception thrown from method" : function ( test ) {
123+ "staticMethodThrows exception thrown from method (sync) " : function ( test ) {
121124 var ex = java . newInstanceSync ( "java.lang.Exception" , "my exception" ) ;
122125 try {
123126 java . callStaticMethodSync ( "Test" , "staticMethodThrows" , ex ) ;
@@ -128,7 +131,38 @@ exports['Java - Call Static Method'] = nodeunit.testCase({
128131 test . done ( ) ;
129132 } ,
130133
131- "callMethodSync exception thrown from method" : function ( test ) {
134+ "staticMethodThrows exception thrown from method" : function ( test ) {
135+ var ex = java . newInstanceSync ( "java.lang.Exception" , "my exception" ) ;
136+ java . callStaticMethod ( "Test" , "staticMethodThrows" , ex , function ( err , result ) {
137+ test . ok ( err ) ;
138+ test . equals ( 'my exception' , err . cause . getMessageSync ( ) ) ;
139+ test . ok ( err . toString ( ) . match ( / m y e x c e p t i o n / ) ) ;
140+ test . ok ( ! result ) ;
141+ test . done ( ) ;
142+ } ) ;
143+ } ,
144+
145+ "staticMethodThrowsNewException exception thrown from method (sync)" : function ( test ) {
146+ try {
147+ java . callStaticMethodSync ( "Test" , "staticMethodThrowsNewException" ) ;
148+ test . fail ( "should throw" ) ;
149+ } catch ( err ) {
150+ test . ok ( err . toString ( ) . match ( / m y e x c e p t i o n / ) ) ;
151+ }
152+ test . done ( ) ;
153+ } ,
154+
155+ "staticMethodThrowsNewException exception thrown from method" : function ( test ) {
156+ java . callStaticMethod ( "Test" , "staticMethodThrowsNewException" , function ( err , result ) {
157+ test . ok ( err ) ;
158+ test . equals ( 'my exception' , err . cause . getMessageSync ( ) ) ;
159+ test . ok ( err . toString ( ) . match ( / m y e x c e p t i o n / ) ) ;
160+ test . ok ( ! result ) ;
161+ test . done ( ) ;
162+ } ) ;
163+ } ,
164+
165+ "methodThrows exception thrown from method (sync)" : function ( test ) {
132166 var ex = java . newInstanceSync ( "java.lang.Exception" , "my exception" ) ;
133167 var myTest = java . newInstanceSync ( "Test" ) ;
134168 try {
@@ -140,6 +174,34 @@ exports['Java - Call Static Method'] = nodeunit.testCase({
140174 test . done ( ) ;
141175 } ,
142176
177+ "methodThrows exception thrown from method" : function ( test ) {
178+ var ex = java . newInstanceSync ( "java.lang.Exception" , "my exception" ) ;
179+ var myTest = java . newInstanceSync ( "Test" ) ;
180+ return myTest . methodThrows ( ex , function ( err ) {
181+ test . ok ( err . toString ( ) . match ( / m y e x c e p t i o n / ) ) ;
182+ test . done ( ) ;
183+ } ) ;
184+ } ,
185+
186+ "methodThrowsNewException exception thrown from method (sync)" : function ( test ) {
187+ var myTest = java . newInstanceSync ( "Test" ) ;
188+ try {
189+ myTest . methodThrowsNewExceptionSync ( ) ;
190+ test . fail ( "should throw" ) ;
191+ } catch ( err ) {
192+ test . ok ( err . toString ( ) . match ( / m y e x c e p t i o n / ) ) ;
193+ }
194+ test . done ( ) ;
195+ } ,
196+
197+ "methodThrowsNewException exception thrown from method" : function ( test ) {
198+ var myTest = java . newInstanceSync ( "Test" ) ;
199+ return myTest . methodThrowsNewException ( function ( err ) {
200+ test . ok ( err . toString ( ) . match ( / m y e x c e p t i o n / ) ) ;
201+ test . done ( ) ;
202+ } ) ;
203+ } ,
204+
143205 "char array" : function ( test ) {
144206 var charArray = java . newArray ( "char" , "hello world\n" . split ( '' ) ) ;
145207 java . callStaticMethod ( "Test" , "staticMethodCharArrayToString" , charArray , function ( err , result ) {
0 commit comments