KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > repository > MockApplicationsRepository


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.repository;
5
6 import com.tc.config.schema.validate.ConfigurationValidator;
7
8 import java.util.HashMap JavaDoc;
9 import java.util.Iterator JavaDoc;
10 import java.util.Map JavaDoc;
11
12 /**
13  * A mock {@link ApplicationsRepository}, for use in tests.
14  */

15 public class MockApplicationsRepository implements ApplicationsRepository {
16
17   private int numRepositoryFors;
18   private String JavaDoc lastApplicationName;
19
20   private int numApplicationNames;
21
22   private Map JavaDoc returnedRepositories;
23
24   public MockApplicationsRepository() {
25     this.returnedRepositories = new HashMap JavaDoc();
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 JavaDoc applicationName) {
42     ++this.numRepositoryFors;
43     this.lastApplicationName = applicationName;
44     return (MutableBeanRepository) this.returnedRepositories.get(applicationName);
45   }
46
47   public Iterator JavaDoc applicationNames() {
48     ++this.numApplicationNames;
49     return this.returnedRepositories.keySet().iterator();
50   }
51
52   public String JavaDoc getLastApplicationName() {
53     return lastApplicationName;
54   }
55
56   public int getNumApplicationNames() {
57     return numApplicationNames;
58   }
59
60   public int getNumRepositoryFors() {
61     return numRepositoryFors;
62   }
63
64   public void setReturnedRepositories(Map JavaDoc returnedRepositories) {
65     this.returnedRepositories = returnedRepositories;
66   }
67
68 }
69
Popular Tags