1 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 intObjRoot; private Long longObjRoot; 17 private int intRoot; private long longRoot; 20 private static Integer staticIntObjRoot; private static Long staticLongObjRoot; 23 private static int staticIntRoot; private static long staticLongRoot; 26 public DuplicateRootNameTestApp(String appId, ApplicationConfig cfg, ListenerProvider listenerProvider) { 27 super(appId, cfg, listenerProvider); 28 } 29 30 public void run() { 31 intObjRoot = new Integer (10); 32 try { 33 longObjRoot = new Long (100); 34 System.out.println(intObjRoot); System.out.println(longObjRoot); throw new AssertionError ("Should have thrown a ClassCastException due to duplicate root name"); 37 } catch (ClassCastException e) { 38 } 40 41 intRoot = 10; 42 try { 43 longRoot = 100L; 44 System.out.println(intRoot); System.out.println(longRoot); throw new AssertionError ("Should have thrown a ClassCastException due to duplicate root name"); 47 } catch (ClassCastException e) { 48 } 50 51 staticIntObjRoot = new Integer (10); 52 try { 53 staticLongObjRoot = new Long (100); 54 System.out.println(staticIntObjRoot); System.out.println(staticLongObjRoot); throw new AssertionError ("Should have thrown a ClassCastException due to duplicate root name"); 57 } catch (ClassCastException e) { 58 } 60 61 staticIntRoot = 10; 62 try { 63 staticLongRoot = 100; 64 System.out.println(staticIntRoot); System.out.println(staticLongRoot); throw new AssertionError ("Should have thrown a ClassCastException due to duplicate root name"); 67 } catch (ClassCastException e) { 68 } 70 } 71 72 public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) { 73 String testClass = DuplicateRootNameTestApp.class.getName(); 74 75 TransparencyClassSpec spec = config.getOrCreateSpec(testClass); 76 77 String 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 |