KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > dynamic > MockConfigItem


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.dynamic;
5
6 /**
7  * A mock {@link ConfigItem}, for use in tests.
8  */

9 public class MockConfigItem implements ConfigItem {
10
11   private int numGetObjects;
12   private Object JavaDoc returnedObject;
13
14   private int numAddListeners;
15   private int numRemoveListeners;
16   private ConfigItemListener lastListener;
17
18   public MockConfigItem() {
19     this(null);
20   }
21
22   public MockConfigItem(Object JavaDoc value) {
23     this.returnedObject = value;
24
25     reset();
26   }
27
28   public void reset() {
29     this.numGetObjects = 0;
30     this.numAddListeners = 0;
31     this.numRemoveListeners = 0;
32     this.lastListener = null;
33   }
34
35   public Object JavaDoc getObject() {
36     ++this.numGetObjects;
37     return this.returnedObject;
38   }
39
40   public void addListener(ConfigItemListener changeListener) {
41     ++this.numAddListeners;
42     this.lastListener = changeListener;
43   }
44
45   public void removeListener(ConfigItemListener changeListener) {
46     ++this.numRemoveListeners;
47     this.lastListener = changeListener;
48   }
49
50   public ConfigItemListener getLastListener() {
51     return lastListener;
52   }
53
54   public int getNumGetObjects() {
55     return numGetObjects;
56   }
57
58   public int getNumAddListeners() {
59     return numAddListeners;
60   }
61
62   public int getNumRemoveListeners() {
63     return numRemoveListeners;
64   }
65
66   public void setReturnedObject(Object JavaDoc returnedObject) {
67     this.returnedObject = returnedObject;
68   }
69
70 }
71
Popular Tags