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.repository;
04:
05: import com.tc.config.schema.validate.ConfigurationValidator;
06:
07: import java.util.HashMap;
08: import java.util.Iterator;
09: import java.util.Map;
10:
11: /**
12: * A mock {@link ApplicationsRepository}, for use in tests.
13: */
14: public class MockApplicationsRepository implements
15: ApplicationsRepository {
16:
17: private int numRepositoryFors;
18: private String lastApplicationName;
19:
20: private int numApplicationNames;
21:
22: private Map returnedRepositories;
23:
24: public MockApplicationsRepository() {
25: this .returnedRepositories = new HashMap();
26:
27: reset();
28: }
29:
30: public void reset() {
31: this .numRepositoryFors = 0;
32: this .lastApplicationName = null;
33:
34: this .numApplicationNames = 0;
35: }
36:
37: public void addRepositoryValidator(ConfigurationValidator validator) {
38: // nothing here yet
39: }
40:
41: public MutableBeanRepository repositoryFor(String applicationName) {
42: ++this .numRepositoryFors;
43: this .lastApplicationName = applicationName;
44: return (MutableBeanRepository) this .returnedRepositories
45: .get(applicationName);
46: }
47:
48: public Iterator applicationNames() {
49: ++this .numApplicationNames;
50: return this .returnedRepositories.keySet().iterator();
51: }
52:
53: public String getLastApplicationName() {
54: return lastApplicationName;
55: }
56:
57: public int getNumApplicationNames() {
58: return numApplicationNames;
59: }
60:
61: public int getNumRepositoryFors() {
62: return numRepositoryFors;
63: }
64:
65: public void setReturnedRepositories(Map returnedRepositories) {
66: this.returnedRepositories = returnedRepositories;
67: }
68:
69: }
|