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: */package com.tc.config.schema.dynamic;
04:
05: /**
06: * A mock {@link ConfigItem}, for use in tests.
07: */
08: public class MockConfigItem implements ConfigItem {
09:
10: private int numGetObjects;
11: private Object returnedObject;
12:
13: private int numAddListeners;
14: private int numRemoveListeners;
15: private ConfigItemListener lastListener;
16:
17: public MockConfigItem() {
18: this (null);
19: }
20:
21: public MockConfigItem(Object value) {
22: this .returnedObject = value;
23:
24: reset();
25: }
26:
27: public void reset() {
28: this .numGetObjects = 0;
29: this .numAddListeners = 0;
30: this .numRemoveListeners = 0;
31: this .lastListener = null;
32: }
33:
34: public Object getObject() {
35: ++this .numGetObjects;
36: return this .returnedObject;
37: }
38:
39: public void addListener(ConfigItemListener changeListener) {
40: ++this .numAddListeners;
41: this .lastListener = changeListener;
42: }
43:
44: public void removeListener(ConfigItemListener changeListener) {
45: ++this .numRemoveListeners;
46: this .lastListener = changeListener;
47: }
48:
49: public ConfigItemListener getLastListener() {
50: return lastListener;
51: }
52:
53: public int getNumGetObjects() {
54: return numGetObjects;
55: }
56:
57: public int getNumAddListeners() {
58: return numAddListeners;
59: }
60:
61: public int getNumRemoveListeners() {
62: return numRemoveListeners;
63: }
64:
65: public void setReturnedObject(Object returnedObject) {
66: this.returnedObject = returnedObject;
67: }
68:
69: }
|