01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest;
05:
06: import com.tc.object.config.ConfigVisitor;
07: import com.tc.object.config.DSOClientConfigHelper;
08: import com.tc.object.config.TransparencyClassSpec;
09: 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 intObjRoot; // testing duplicate root name, so this varilable is not being used.
15: private Long 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 staticIntObjRoot; // testing duplicate root name, so this varilable is not being used.
21: private static Long 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 appId,
27: ApplicationConfig cfg, ListenerProvider listenerProvider) {
28: super (appId, cfg, listenerProvider);
29: }
30:
31: public void run() {
32: intObjRoot = new Integer(10);
33: try {
34: longObjRoot = new Long(100);
35: System.out.println(intObjRoot); // Putting this println to get rid of the eclipse warnings.
36: System.out.println(longObjRoot); // Putting this println to get rid of the eclipse warnings.
37: throw new AssertionError(
38: "Should have thrown a ClassCastException due to duplicate root name");
39: } catch (ClassCastException e) {
40: // Expected.
41: }
42:
43: intRoot = 10;
44: try {
45: longRoot = 100L;
46: System.out.println(intRoot); // Putting this println to get rid of the eclipse warnings.
47: System.out.println(longRoot); // Putting this println to get rid of the eclipse warnings.
48: throw new AssertionError(
49: "Should have thrown a ClassCastException due to duplicate root name");
50: } catch (ClassCastException e) {
51: // Expected.
52: }
53:
54: staticIntObjRoot = new Integer(10);
55: try {
56: staticLongObjRoot = new Long(100);
57: System.out.println(staticIntObjRoot); // Putting this println to get rid of the eclipse warnings.
58: System.out.println(staticLongObjRoot); // Putting this println to get rid of the eclipse warnings.
59: throw new AssertionError(
60: "Should have thrown a ClassCastException due to duplicate root name");
61: } catch (ClassCastException e) {
62: // Expected.
63: }
64:
65: staticIntRoot = 10;
66: try {
67: staticLongRoot = 100;
68: System.out.println(staticIntRoot); // Putting this println to get rid of the eclipse warnings.
69: System.out.println(staticLongRoot); // Putting this println to get rid of the eclipse warnings.
70: throw new AssertionError(
71: "Should have thrown a ClassCastException due to duplicate root name");
72: } catch (ClassCastException e) {
73: // Expected.
74: }
75: }
76:
77: public static void visitL1DSOConfig(ConfigVisitor visitor,
78: DSOClientConfigHelper config) {
79: String testClass = DuplicateRootNameTestApp.class.getName();
80:
81: TransparencyClassSpec spec = config.getOrCreateSpec(testClass);
82:
83: String methodExpression = "* " + testClass + "*.*(..)";
84: config.addWriteAutolock(methodExpression);
85: spec.addRoot("intObjRoot", "objRoot");
86: spec.addRoot("longObjRoot", "objRoot");
87: spec.addRoot("intRoot", "primitiveRoot", true);
88: spec.addRoot("longRoot", "primitiveRoot", true);
89: spec.addRoot("staticIntObjRoot", "staticRoot");
90: spec.addRoot("staticLongObjRoot", "staticRoot");
91: spec.addRoot("staticIntRoot", "staticPrimitiveRoot", true);
92: spec.addRoot("staticLongRoot", "staticPrimitiveRoot", true);
93: }
94:
95: }
|