KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > DuplicateRootNameTestApp


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest;
5
6 import com.tc.object.config.ConfigVisitor;
7 import com.tc.object.config.DSOClientConfigHelper;
8 import com.tc.object.config.TransparencyClassSpec;
9 import com.tc.simulator.app.ApplicationConfig;
10 import com.tc.simulator.listener.ListenerProvider;
11 import com.tctest.runner.AbstractTransparentApp;
12
13 public class DuplicateRootNameTestApp extends AbstractTransparentApp {
14   private Integer JavaDoc intObjRoot; // testing duplicate root name, so this varilable is not being used.
15
private Long JavaDoc longObjRoot; // testing duplicate root name, so this varilable is not being used.
16

17   private int intRoot; // testing duplicate root name, so this varilable is not being used.
18
private long longRoot; // testing duplicate root name, so this varilable is not being used.
19

20   private static Integer JavaDoc staticIntObjRoot; // testing duplicate root name, so this varilable is not being used.
21
private static Long JavaDoc staticLongObjRoot; // testing duplicate root name, so this varilable is not being used.
22

23   private static int staticIntRoot; // testing duplicate root name, so this varilable is not being used.
24
private static long staticLongRoot; // testing duplicate root name, so this varilable is not being used.
25

26   public DuplicateRootNameTestApp(String JavaDoc appId, ApplicationConfig cfg, ListenerProvider listenerProvider) {
27     super(appId, cfg, listenerProvider);
28   }
29
30   public void run() {
31     intObjRoot = new Integer JavaDoc(10);
32     try {
33       longObjRoot = new Long JavaDoc(100);
34       System.out.println(intObjRoot); // Putting this println to get rid of the eclipse warnings.
35
System.out.println(longObjRoot); // Putting this println to get rid of the eclipse warnings.
36
throw new AssertionError JavaDoc("Should have thrown a ClassCastException due to duplicate root name");
37     } catch (ClassCastException JavaDoc e) {
38       // Expected.
39
}
40
41     intRoot = 10;
42     try {
43       longRoot = 100L;
44       System.out.println(intRoot); // Putting this println to get rid of the eclipse warnings.
45
System.out.println(longRoot); // Putting this println to get rid of the eclipse warnings.
46
throw new AssertionError JavaDoc("Should have thrown a ClassCastException due to duplicate root name");
47     } catch (ClassCastException JavaDoc e) {
48       // Expected.
49
}
50
51     staticIntObjRoot = new Integer JavaDoc(10);
52     try {
53       staticLongObjRoot = new Long JavaDoc(100);
54       System.out.println(staticIntObjRoot); // Putting this println to get rid of the eclipse warnings.
55
System.out.println(staticLongObjRoot); // Putting this println to get rid of the eclipse warnings.
56
throw new AssertionError JavaDoc("Should have thrown a ClassCastException due to duplicate root name");
57     } catch (ClassCastException JavaDoc e) {
58       // Expected.
59
}
60
61     staticIntRoot = 10;
62     try {
63       staticLongRoot = 100;
64       System.out.println(staticIntRoot); // Putting this println to get rid of the eclipse warnings.
65
System.out.println(staticLongRoot); // Putting this println to get rid of the eclipse warnings.
66
throw new AssertionError JavaDoc("Should have thrown a ClassCastException due to duplicate root name");
67     } catch (ClassCastException JavaDoc e) {
68       // Expected.
69
}
70   }
71
72   public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) {
73     String JavaDoc testClass = DuplicateRootNameTestApp.class.getName();
74
75     TransparencyClassSpec spec = config.getOrCreateSpec(testClass);
76
77     String JavaDoc methodExpression = "* " + testClass + "*.*(..)";
78     config.addWriteAutolock(methodExpression);
79     spec.addRoot("intObjRoot", "objRoot");
80     spec.addRoot("longObjRoot", "objRoot");
81     spec.addRoot("intRoot", "primitiveRoot", true);
82     spec.addRoot("longRoot", "primitiveRoot", true);
83     spec.addRoot("staticIntObjRoot", "staticRoot");
84     spec.addRoot("staticLongObjRoot", "staticRoot");
85     spec.addRoot("staticIntRoot", "staticPrimitiveRoot", true);
86     spec.addRoot("staticLongRoot", "staticPrimitiveRoot", true);
87   }
88
89 }
90
Popular Tags