PageRenderTime 19ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 74 lines | 60 code | 14 blank | 0 comment | 15 complexity | 8a1204437e0252d108743c16a6a3fcab MD5 | raw file
 1import allprotected.*;
 2
 3public class allprotected_runme {
 4  static {
 5    try {
 6      System.loadLibrary("allprotected");
 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
13  public static void main(String argv[]) 
14  {
15    MyProtectedBase mpb = new MyProtectedBase("MyProtectedBase");
16    mpb.accessProtected();
17  }
18}
19
20class MyProtectedBase extends ProtectedBase
21{
22  MyProtectedBase(String name) {
23    super(name);
24  }
25  void accessProtected() {
26    String s = virtualMethod();
27    if (!s.equals("ProtectedBase"))
28      throw new RuntimeException("Failed");
29
30    Klass k = instanceMethod(new Klass("xyz"));
31    if (!k.getName().equals("xyz")) 
32      throw new RuntimeException("Failed");
33
34    k = instanceOverloaded(new Klass("xyz"));
35    if (!k.getName().equals("xyz")) 
36      throw new RuntimeException("Failed");
37
38    k = instanceOverloaded(new Klass("xyz"), "abc");
39    if (!k.getName().equals("abc")) 
40      throw new RuntimeException("Failed");
41
42    k = ProtectedBase.staticMethod(new Klass("abc"));
43    if (!k.getName().equals("abc")) 
44      throw new RuntimeException("Failed");
45
46    k = ProtectedBase.staticOverloaded(new Klass("xyz"));
47    if (!k.getName().equals("xyz")) 
48      throw new RuntimeException("Failed");
49
50    k = ProtectedBase.staticOverloaded(new Klass("xyz"), "abc");
51    if (!k.getName().equals("abc")) 
52      throw new RuntimeException("Failed");
53
54    setInstanceMemberVariable(30);
55    int i = getInstanceMemberVariable();
56    if (i != 30)
57      throw new RuntimeException("Failed");
58
59    setStaticMemberVariable(40);
60    i = getStaticMemberVariable();
61    if (i != 40)
62      throw new RuntimeException("Failed");
63
64    i = staticConstMemberVariable;
65    if (i != 20)
66      throw new RuntimeException("Failed");
67
68    setAnEnum(ProtectedBase.AnEnum.EnumVal1);
69    ProtectedBase.AnEnum ae = getAnEnum();
70    if (ae != ProtectedBase.AnEnum.EnumVal1)
71      throw new RuntimeException("Failed");
72  }
73}
74