/trunk/Examples/test-suite/java/director_basic_runme.java
Java | 72 lines | 55 code | 17 blank | 0 comment | 11 complexity | 1a0545aef183d53e9f4d057ceb753b0b MD5 | raw file
1 2import director_basic.*; 3 4public class director_basic_runme { 5 6 static { 7 try { 8 System.loadLibrary("director_basic"); 9 } catch (UnsatisfiedLinkError e) { 10 System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); 11 System.exit(1); 12 } 13 } 14 15 public static void main(String argv[]) { 16 17 director_basic_MyFoo a = new director_basic_MyFoo(); 18 19 if (!a.ping().equals("director_basic_MyFoo::ping()")) { 20 throw new RuntimeException ( "a.ping()" ); 21 } 22 23 if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) { 24 throw new RuntimeException ( "a.pong()" ); 25 } 26 27 Foo b = new Foo(); 28 29 if (!b.ping().equals("Foo::ping()")) { 30 throw new RuntimeException ( "b.ping()" ); 31 } 32 33 if (!b.pong().equals("Foo::pong();Foo::ping()")) { 34 throw new RuntimeException ( "b.pong()" ); 35 } 36 37 A1 a1 = new A1(1, false); 38 a1.delete(); 39 40 { 41 MyOverriddenClass my = new MyOverriddenClass(); 42 43 my.expectNull = true; 44 if (MyClass.call_pmethod(my, null) != null) 45 throw new RuntimeException("null pointer marshalling problem"); 46 47 Bar myBar = new Bar(); 48 my.expectNull = false; 49 Bar myNewBar = MyClass.call_pmethod(my, myBar); 50 if (myNewBar == null) 51 throw new RuntimeException("non-null pointer marshalling problem"); 52 myNewBar.setX(10); 53 } 54 } 55} 56 57class director_basic_MyFoo extends Foo { 58 public String ping() { 59 return "director_basic_MyFoo::ping()"; 60 } 61} 62 63class MyOverriddenClass extends MyClass { 64 public boolean expectNull = false; 65 public boolean nonNullReceived = false; 66 public Bar pmethod(Bar b) { 67 if ( expectNull && (b != null) ) 68 throw new RuntimeException("null not received as expected"); 69 return b; 70 } 71} 72