KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > config > ConfigVisitorTest


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

4 package com.tc.object.config;
5
6 import com.tc.config.schema.builder.DSOApplicationConfigBuilder;
7 import com.tc.util.concurrent.NoExceptionLinkedQueue;
8
9 import junit.framework.TestCase;
10
11 public class ConfigVisitorTest extends TestCase {
12   public void testDSOApplicationConfigVisitor() throws Throwable JavaDoc {
13
14     ConfigVisitor visitor = new ConfigVisitor();
15     TestDSOApplicationConfig cfg = new TestDSOApplicationConfig();
16     visitor.visitDSOApplicationConfig(cfg, Target.class);
17     Object JavaDoc[] args = (Object JavaDoc[]) 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 DSOApplicationConfig {
27     public void addRoot(String JavaDoc rootName, String JavaDoc rootFieldName) {
28       return;
29     }
30
31     public void writeTo(DSOApplicationConfigBuilder builder) {
32       return;
33     }
34
35     public void addIncludePattern(String JavaDoc classPattern) {
36       return;
37     }
38
39     public void addWriteAutolock(String JavaDoc methodPattern) {
40       return;
41     }
42     
43     public void addReadAutolock(String JavaDoc methodPattern) {
44       return;
45     }
46
47     public void addIncludePattern(String JavaDoc classname, boolean b) {
48       return;
49     }
50   }
51   
52   private static final class Target {
53     public static NoExceptionLinkedQueue visitCalls = new NoExceptionLinkedQueue();
54     public static void visitDSOApplicationConfig(ConfigVisitor visitor, DSOApplicationConfig config) {
55       visitCalls.put(new Object JavaDoc[] {visitor, config});
56     }
57   }
58   
59 }
60
Popular Tags