KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > context > MockConfigContext


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.config.schema.context;
5
6 import org.apache.xmlbeans.XmlObject;
7
8 import com.tc.config.schema.IllegalConfigurationChangeHandler;
9 import com.tc.config.schema.dynamic.BooleanConfigItem;
10 import com.tc.config.schema.dynamic.ConfigItem;
11 import com.tc.config.schema.dynamic.FileConfigItem;
12 import com.tc.config.schema.dynamic.IntConfigItem;
13 import com.tc.config.schema.dynamic.StringArrayConfigItem;
14 import com.tc.config.schema.dynamic.StringConfigItem;
15
16 public class MockConfigContext implements ConfigContext {
17
18   private int numIllegalConfigurationChangeHandlers;
19   private IllegalConfigurationChangeHandler returnedIllegalConfigurationChangeHandler;
20
21   private int numEnsureRepositoryProvides;
22   private Class JavaDoc lastEnsureClass;
23   private RuntimeException JavaDoc exceptionOnEnsureRepositoryProvides;
24
25   private int numItemCreateds;
26   private ConfigItem lastItemCreated;
27
28   private int numHasDefaultFors;
29   private String JavaDoc lastHasDefaultForXPath;
30   private boolean returnedHasDefaultFor;
31
32   private int numBeans;
33   private XmlObject returnedBean;
34
35   private int numIsOptionals;
36   private String JavaDoc lastIsOptionalXPath;
37   private boolean returnedIsOptional;
38
39   private int numDefaultFors;
40   private String JavaDoc lastDefaultForXPath;
41   private XmlObject returnedDefaultFor;
42
43   public MockConfigContext() {
44     this.returnedIllegalConfigurationChangeHandler = null;
45     this.exceptionOnEnsureRepositoryProvides = null;
46     this.returnedBean = null;
47     this.returnedHasDefaultFor = false;
48     this.returnedIsOptional = false;
49     this.returnedDefaultFor = null;
50
51     reset();
52   }
53
54   public void reset() {
55     this.numIllegalConfigurationChangeHandlers = 0;
56
57     this.numEnsureRepositoryProvides = 0;
58     this.lastEnsureClass = null;
59
60     this.numItemCreateds = 0;
61     this.lastItemCreated = null;
62
63     this.numHasDefaultFors = 0;
64     this.lastHasDefaultForXPath = null;
65
66     this.numIsOptionals = 0;
67     this.lastIsOptionalXPath = null;
68
69     this.numDefaultFors = 0;
70     this.lastDefaultForXPath = null;
71
72     this.numBeans = 0;
73   }
74
75   public IllegalConfigurationChangeHandler illegalConfigurationChangeHandler() {
76     ++this.numIllegalConfigurationChangeHandlers;
77     return this.returnedIllegalConfigurationChangeHandler;
78   }
79
80   public void ensureRepositoryProvides(Class JavaDoc theClass) {
81     ++this.numEnsureRepositoryProvides;
82     this.lastEnsureClass = theClass;
83     if (this.exceptionOnEnsureRepositoryProvides != null) throw this.exceptionOnEnsureRepositoryProvides;
84   }
85
86   public int getNumBeans() {
87     return numBeans;
88   }
89
90   public int getNumEnsureRepositoryProvides() {
91     return numEnsureRepositoryProvides;
92   }
93
94   public Class JavaDoc getLastEnsureClass() {
95     return lastEnsureClass;
96   }
97
98   public boolean hasDefaultFor(String JavaDoc xpath) {
99     ++this.numHasDefaultFors;
100     this.lastHasDefaultForXPath = xpath;
101     return this.returnedHasDefaultFor;
102   }
103
104   public XmlObject defaultFor(String JavaDoc xpath) {
105     ++this.numDefaultFors;
106     this.lastDefaultForXPath = xpath;
107     return this.returnedDefaultFor;
108   }
109   
110   public Object JavaDoc syncLockForBean() {
111     return this;
112   }
113
114   public boolean isOptional(String JavaDoc xpath) {
115     ++this.numIsOptionals;
116     this.lastIsOptionalXPath = xpath;
117     return this.returnedIsOptional;
118   }
119
120   public XmlObject bean() {
121     ++this.numBeans;
122     return this.returnedBean;
123   }
124
125   public void itemCreated(ConfigItem item) {
126     ++this.numItemCreateds;
127     this.lastItemCreated = item;
128   }
129
130   public IntConfigItem intItem(String JavaDoc xpath) {
131     return null;
132   }
133
134   public StringConfigItem stringItem(String JavaDoc xpath) {
135     return null;
136   }
137
138   public StringArrayConfigItem stringArrayItem(String JavaDoc xpath) {
139     return null;
140   }
141
142   public FileConfigItem fileItem(String JavaDoc xpath) {
143     return null;
144   }
145
146   public BooleanConfigItem booleanItem(String JavaDoc xpath) {
147     return null;
148   }
149
150   public BooleanConfigItem booleanItem(String JavaDoc xpath, boolean defaultValue) {
151     return null;
152   }
153
154   public FileConfigItem substitutedFileItem(String JavaDoc xpath) {
155     return null;
156   }
157
158   public ConfigItem getLastItemCreated() {
159     return lastItemCreated;
160   }
161
162   public int getNumItemCreateds() {
163     return numItemCreateds;
164   }
165
166   public String JavaDoc getLastHasDefaultForXPath() {
167     return lastHasDefaultForXPath;
168   }
169
170   public int getNumHasDefaultFors() {
171     return numHasDefaultFors;
172   }
173
174   public void setReturnedHasDefaultFor(boolean returnedHasDefaultFor) {
175     this.returnedHasDefaultFor = returnedHasDefaultFor;
176   }
177
178   public void setReturnedBean(XmlObject returnedBean) {
179     this.returnedBean = returnedBean;
180   }
181
182   public String JavaDoc getLastIsOptionalXPath() {
183     return lastIsOptionalXPath;
184   }
185
186   public int getNumIsOptionals() {
187     return numIsOptionals;
188   }
189
190   public void setReturnedIsOptional(boolean returnedIsOptional) {
191     this.returnedIsOptional = returnedIsOptional;
192   }
193
194   public String JavaDoc getLastDefaultForXPath() {
195     return lastDefaultForXPath;
196   }
197
198   public int getNumDefaultFors() {
199     return numDefaultFors;
200   }
201
202   public void setReturnedDefaultFor(XmlObject returnedDefaultFor) {
203     this.returnedDefaultFor = returnedDefaultFor;
204   }
205
206   public int getNumIllegalConfigurationChangeHandlers() {
207     return numIllegalConfigurationChangeHandlers;
208   }
209
210   public void setReturnedIllegalConfigurationChangeHandler(
211                                                            IllegalConfigurationChangeHandler returnedIllegalConfigurationChangeHandler) {
212     this.returnedIllegalConfigurationChangeHandler = returnedIllegalConfigurationChangeHandler;
213   }
214
215   public FileConfigItem configRelativeSubstitutedFileItem(String JavaDoc xpath) {
216     return null;
217   }
218
219 }
220
Popular Tags