PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-29/SWIG/Examples/test-suite/java/director_protected_runme.java

#
Java | 85 lines | 68 code | 17 blank | 0 comment | 7 complexity | e1bae96118c82746f1f4cac8c6195af4 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. import director_protected.*;
  2. import java.lang.reflect.*;
  3. public class director_protected_runme {
  4. static {
  5. try {
  6. System.loadLibrary("director_protected");
  7. } catch (UnsatisfiedLinkError e) {
  8. 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);
  9. System.exit(1);
  10. }
  11. }
  12. public static void main(String argv[]) {
  13. Bar b = new Bar();
  14. Foo f = b.create();
  15. director_protected_FooBar fb = new director_protected_FooBar();
  16. director_protected_FooBar2 fb2 = new director_protected_FooBar2();
  17. {
  18. String s = fb.used();
  19. if (!s.equals("Foo::pang();Bar::pong();Foo::pong();director_protected_FooBar::ping();"))
  20. throw new RuntimeException( "bad director_protected_FooBar::used" );
  21. }
  22. {
  23. String s = fb2.used();
  24. if (!s.equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();"))
  25. throw new RuntimeException( "bad director_protected_FooBar2::used" );
  26. }
  27. {
  28. String s = b.pong();
  29. if (!s.equals("Bar::pong();Foo::pong();Bar::ping();"))
  30. throw new RuntimeException( "bad Bar::pong" );
  31. }
  32. {
  33. String s = f.pong();
  34. if (!s.equals("Bar::pong();Foo::pong();Bar::ping();"))
  35. throw new RuntimeException(" bad Foo::pong" );
  36. }
  37. {
  38. String s3 = fb.pong();
  39. if (!s3.equals("Bar::pong();Foo::pong();director_protected_FooBar::ping();"))
  40. throw new RuntimeException(" bad director_protected_FooBar::pong" );
  41. }
  42. try {
  43. Method method = b.getClass().getDeclaredMethod("ping", (java.lang.Class[])null);
  44. if ( !Modifier.isProtected(method.getModifiers()) )
  45. throw new RuntimeException("Bar::ping should be protected" );
  46. method = f.getClass().getDeclaredMethod("ping", (java.lang.Class[])null);
  47. if ( !Modifier.isProtected(method.getModifiers()) )
  48. throw new RuntimeException("Foo::ping should be protected" );
  49. } catch (NoSuchMethodException n) {
  50. throw new RuntimeException("NoSuchmethodException caught. Test failed.");
  51. } catch (SecurityException s) {
  52. throw new RuntimeException("SecurityException caught. Test failed.");
  53. }
  54. }
  55. }
  56. class director_protected_FooBar extends Bar {
  57. public String ping() {
  58. return "director_protected_FooBar::ping();";
  59. }
  60. }
  61. class director_protected_FooBar2 extends Bar {
  62. public String ping() {
  63. return "director_protected_FooBar2::ping();";
  64. }
  65. public String pang() {
  66. return "director_protected_FooBar2::pang();";
  67. }
  68. }