1 5 package com.tctest; 6 7 import com.tc.object.config.ConfigVisitor; 8 import com.tc.object.config.DSOClientConfigHelper; 9 import com.tc.object.config.TransparencyClassSpec; 10 import com.tc.simulator.app.ApplicationConfig; 11 import com.tc.simulator.listener.ListenerProvider; 12 import com.tctest.runner.AbstractTransparentApp; 13 import com.tc.util.Assert; 14 15 public class DistributedWaitTestApp extends AbstractTransparentApp { 16 17 private static final long WAIT_TIME = 30 * 1000; 18 private Object myRoot = new Object (); 19 20 public DistributedWaitTestApp(String appId, ApplicationConfig cfg, ListenerProvider listenerProvider) { 21 super(appId, cfg, listenerProvider); 22 } 23 24 public void run() { 25 synchronized (myRoot) { 26 try { 27 long start = System.currentTimeMillis(); 28 myRoot.wait(WAIT_TIME); 29 long end = System.currentTimeMillis(); 30 Assert.assertEquals((double) WAIT_TIME, (double) (end - start), 500.0); 31 } catch (InterruptedException e) { 32 throw new RuntimeException (e); 33 } 34 } 35 } 36 37 public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) { 38 String testClass = DistributedWaitTestApp.class.getName(); 39 TransparencyClassSpec spec = config.getOrCreateSpec(testClass); 40 41 String methodExpression = "* " + testClass + "*.*(..)"; 42 config.addWriteAutolock(methodExpression); 43 spec.addRoot("myRoot", "myRoot"); 44 45 } 46 } 47 | Popular Tags |