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.AbstractErrorCatchingTransparentApp;
14:
15: /**
16: * Test for DEV-865
17: *
18: * @author hhuynh
19: */
20: public class CloneExceptionTestApp extends
21: AbstractErrorCatchingTransparentApp {
22: private MyStuff root = new MyStuff();
23:
24: public CloneExceptionTestApp(String appId, ApplicationConfig cfg,
25: ListenerProvider listenerProvider) {
26: super (appId, cfg, listenerProvider);
27: }
28:
29: protected void runTest() throws Throwable {
30: synchronized (root) {
31: try {
32: MyStuff cloned = (MyStuff) root.clone();
33: } catch (RuntimeException e) {
34: System.err
35: .println("Expecting CloneNotSupportedException, got "
36: + e.getCause());
37: Assert
38: .assertTrue(e.getCause() instanceof CloneNotSupportedException);
39: }
40: }
41: }
42:
43: public static void visitL1DSOConfig(ConfigVisitor visitor,
44: DSOClientConfigHelper config) {
45: String testClass = CloneExceptionTestApp.class.getName();
46: TransparencyClassSpec spec = config.getOrCreateSpec(testClass);
47: config.addIncludePattern(MyStuff.class.getName());
48: config.addWriteAutolock("* " + MyStuff.class.getName()
49: + "*.*(..)");
50:
51: config.addWriteAutolock("* " + testClass + "*.runTest(..)");
52:
53: spec.addRoot("root", "root");
54: }
55:
56: private static class MyStuff {
57: protected Object clone() {
58: try {
59: return super .clone();
60: } catch (CloneNotSupportedException e) {
61: throw new RuntimeException(e);
62: }
63: }
64: }
65:
66: }
|