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 DistributedWaitCrashTestApp extends AbstractTransparentApp {
16:
17: private static final long WAIT_TIME = 15 * 1000;
18: private Object myRoot = new Object();
19:
20: public DistributedWaitCrashTestApp(String appId,
21: ApplicationConfig cfg, ListenerProvider listenerProvider) {
22: super (appId, cfg, listenerProvider);
23: }
24:
25: public void run() {
26: int wokeupCount = 0;
27: for (int i = 0; i < 4; i++) {
28: synchronized (myRoot) {
29: try {
30: myRoot.wait(WAIT_TIME);
31: System.out.println("woke up count: "
32: + wokeupCount++);
33: } catch (InterruptedException e) {
34: throw new RuntimeException(e);
35: }
36: }
37: }
38: Assert.assertEquals(4, wokeupCount);
39: }
40:
41: public static void visitL1DSOConfig(ConfigVisitor visitor,
42: DSOClientConfigHelper config) {
43: String testClass = DistributedWaitCrashTestApp.class.getName();
44: TransparencyClassSpec spec = config.getOrCreateSpec(testClass);
45:
46: String methodExpression = "* " + testClass + "*.*(..)";
47: config.addWriteAutolock(methodExpression);
48: spec.addRoot("myRoot", "myRoot");
49:
50: }
51: }
|