PageRenderTime 104ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/java/director_basic_runme.java

#
Java | 72 lines | 55 code | 17 blank | 0 comment | 11 complexity | 1a0545aef183d53e9f4d057ceb753b0b MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. import director_basic.*;
  2. public class director_basic_runme {
  3. static {
  4. try {
  5. System.loadLibrary("director_basic");
  6. } catch (UnsatisfiedLinkError e) {
  7. 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);
  8. System.exit(1);
  9. }
  10. }
  11. public static void main(String argv[]) {
  12. director_basic_MyFoo a = new director_basic_MyFoo();
  13. if (!a.ping().equals("director_basic_MyFoo::ping()")) {
  14. throw new RuntimeException ( "a.ping()" );
  15. }
  16. if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) {
  17. throw new RuntimeException ( "a.pong()" );
  18. }
  19. Foo b = new Foo();
  20. if (!b.ping().equals("Foo::ping()")) {
  21. throw new RuntimeException ( "b.ping()" );
  22. }
  23. if (!b.pong().equals("Foo::pong();Foo::ping()")) {
  24. throw new RuntimeException ( "b.pong()" );
  25. }
  26. A1 a1 = new A1(1, false);
  27. a1.delete();
  28. {
  29. MyOverriddenClass my = new MyOverriddenClass();
  30. my.expectNull = true;
  31. if (MyClass.call_pmethod(my, null) != null)
  32. throw new RuntimeException("null pointer marshalling problem");
  33. Bar myBar = new Bar();
  34. my.expectNull = false;
  35. Bar myNewBar = MyClass.call_pmethod(my, myBar);
  36. if (myNewBar == null)
  37. throw new RuntimeException("non-null pointer marshalling problem");
  38. myNewBar.setX(10);
  39. }
  40. }
  41. }
  42. class director_basic_MyFoo extends Foo {
  43. public String ping() {
  44. return "director_basic_MyFoo::ping()";
  45. }
  46. }
  47. class MyOverriddenClass extends MyClass {
  48. public boolean expectNull = false;
  49. public boolean nonNullReceived = false;
  50. public Bar pmethod(Bar b) {
  51. if ( expectNull && (b != null) )
  52. throw new RuntimeException("null not received as expected");
  53. return b;
  54. }
  55. }