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.tc.util.Assert; 12 import com.tctest.runner.AbstractTransparentApp; 13 14 import java.util.HashMap ; 15 import java.util.Map ; 16 17 20 public class ClassInMapTestApp extends AbstractTransparentApp { 21 22 private final Map map = new HashMap (); 23 24 public ClassInMapTestApp(String appId, ApplicationConfig cfg, ListenerProvider listenerProvider) { 25 super(appId, cfg, listenerProvider); 26 if (getParticipantCount() != 2) { throw new IllegalArgumentException ("invalid number of participants"); } 27 } 28 29 public void run() { 30 try { 31 run0(); 32 } catch (Throwable t) { 33 notifyError(t); 34 } 35 } 36 37 private void run0() throws Exception { 38 synchronized (map) { 39 if (map.isEmpty()) { 40 map.put(this.getClass(), "value"); 41 map.put("key", Object .class); 42 43 while (!map.isEmpty()) { 45 map.wait(120000); 46 } 47 } else { 48 Assert.assertEquals("value", map.get(this.getClass())); 49 Assert.assertEquals(Object .class, map.get("key")); 50 map.remove(this.getClass()); 51 map.remove("key"); 52 map.notifyAll(); 53 } 54 } 55 } 56 57 public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) { 58 String testClass = ClassInMapTestApp.class.getName(); 59 TransparencyClassSpec spec = config.getOrCreateSpec(testClass); 60 61 String methodExpression = "* " + testClass + "*.*(..)"; 62 config.addWriteAutolock(methodExpression); 63 spec.addRoot("map", "map"); 64 } 65 66 } 67 | Popular Tags |