KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > DistributedWaitTestApp


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

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 JavaDoc myRoot = new Object JavaDoc();
19
20   public DistributedWaitTestApp(String JavaDoc 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 JavaDoc e) {
32         throw new RuntimeException JavaDoc(e);
33       }
34     }
35   }
36
37   public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) {
38     String JavaDoc testClass = DistributedWaitTestApp.class.getName();
39     TransparencyClassSpec spec = config.getOrCreateSpec(testClass);
40
41     String JavaDoc methodExpression = "* " + testClass + "*.*(..)";
42     config.addWriteAutolock(methodExpression);
43     spec.addRoot("myRoot", "myRoot");
44
45   }
46 }
47
Popular Tags