01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tctest;
06:
07: import com.tc.object.config.ConfigVisitor;
08: import com.tc.object.config.DSOClientConfigHelper;
09: import com.tc.object.config.TransparencyClassSpec;
10: import com.tc.simulator.app.ApplicationConfig;
11: import com.tc.simulator.listener.ListenerProvider;
12: import com.tc.util.Assert;
13: import com.tctest.runner.AbstractTransparentApp;
14:
15: public class DistributedWaitTestApp extends AbstractTransparentApp {
16:
17: private static final long WAIT_TIME = 15 * 1000;
18: private Object myRoot = new Object();
19:
20: public DistributedWaitTestApp(String appId, ApplicationConfig cfg,
21: ListenerProvider listenerProvider) {
22: super (appId, cfg, listenerProvider);
23: }
24:
25: public void run() {
26: synchronized (myRoot) {
27: try {
28: long start = System.currentTimeMillis();
29: myRoot.wait(WAIT_TIME);
30: long end = System.currentTimeMillis();
31: Assert.assertEquals((double) WAIT_TIME,
32: (double) (end - start), 3 * 1000.0);
33: } catch (InterruptedException e) {
34: throw new RuntimeException(e);
35: }
36: }
37: }
38:
39: public static void visitL1DSOConfig(ConfigVisitor visitor,
40: DSOClientConfigHelper config) {
41: String testClass = DistributedWaitTestApp.class.getName();
42: TransparencyClassSpec spec = config.getOrCreateSpec(testClass);
43:
44: String methodExpression = "* " + testClass + "*.*(..)";
45: config.addWriteAutolock(methodExpression);
46: spec.addRoot("myRoot", "myRoot");
47:
48: }
49: }
|