01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.config;
05:
06: import com.tc.config.schema.builder.DSOApplicationConfigBuilder;
07: import com.tc.util.concurrent.NoExceptionLinkedQueue;
08:
09: import junit.framework.TestCase;
10:
11: public class ConfigVisitorTest extends TestCase {
12: public void testDSOApplicationConfigVisitor() throws Throwable {
13:
14: ConfigVisitor visitor = new ConfigVisitor();
15: TestDSOApplicationConfig cfg = new TestDSOApplicationConfig();
16: visitor.visitDSOApplicationConfig(cfg, Target.class);
17: Object[] args = (Object[]) Target.visitCalls.poll(0);
18: assertNotNull(args);
19: assertSame(visitor, args[0]);
20: assertSame(cfg, args[1]);
21:
22: visitor.visitDSOApplicationConfig(cfg, Target.class);
23: assertNull(Target.visitCalls.poll(0));
24: }
25:
26: private static final class TestDSOApplicationConfig implements
27: DSOApplicationConfig {
28: public void addRoot(String rootName, String rootFieldName) {
29: return;
30: }
31:
32: public void writeTo(DSOApplicationConfigBuilder builder) {
33: return;
34: }
35:
36: public void addIncludePattern(String classPattern) {
37: return;
38: }
39:
40: public void addWriteAutolock(String methodPattern) {
41: return;
42: }
43:
44: public void addReadAutolock(String methodPattern) {
45: return;
46: }
47:
48: public void addIncludePattern(String classname, boolean b) {
49: return;
50: }
51: }
52:
53: private static final class Target {
54: public static NoExceptionLinkedQueue visitCalls = new NoExceptionLinkedQueue();
55:
56: public static void visitDSOApplicationConfig(
57: ConfigVisitor visitor, DSOApplicationConfig config) {
58: visitCalls.put(new Object[] { visitor, config });
59: }
60: }
61:
62: }
|