1 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 lastEnsureClass; 23 private RuntimeException exceptionOnEnsureRepositoryProvides; 24 25 private int numItemCreateds; 26 private ConfigItem lastItemCreated; 27 28 private int numHasDefaultFors; 29 private String lastHasDefaultForXPath; 30 private boolean returnedHasDefaultFor; 31 32 private int numBeans; 33 private XmlObject returnedBean; 34 35 private int numIsOptionals; 36 private String lastIsOptionalXPath; 37 private boolean returnedIsOptional; 38 39 private int numDefaultFors; 40 private String 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 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 getLastEnsureClass() { 95 return lastEnsureClass; 96 } 97 98 public boolean hasDefaultFor(String xpath) { 99 ++this.numHasDefaultFors; 100 this.lastHasDefaultForXPath = xpath; 101 return this.returnedHasDefaultFor; 102 } 103 104 public XmlObject defaultFor(String xpath) { 105 ++this.numDefaultFors; 106 this.lastDefaultForXPath = xpath; 107 return this.returnedDefaultFor; 108 } 109 110 public Object syncLockForBean() { 111 return this; 112 } 113 114 public boolean isOptional(String 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 xpath) { 131 return null; 132 } 133 134 public StringConfigItem stringItem(String xpath) { 135 return null; 136 } 137 138 public StringArrayConfigItem stringArrayItem(String xpath) { 139 return null; 140 } 141 142 public FileConfigItem fileItem(String xpath) { 143 return null; 144 } 145 146 public BooleanConfigItem booleanItem(String xpath) { 147 return null; 148 } 149 150 public BooleanConfigItem booleanItem(String xpath, boolean defaultValue) { 151 return null; 152 } 153 154 public FileConfigItem substitutedFileItem(String 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 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 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 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 xpath) { 216 return null; 217 } 218 219 } 220 | Popular Tags |