blob: 95a4ca107b97b5e6252ea7a0bbd77e405696ee9f [file] [log] [blame]
Felix Meschbergera0903df2009-01-19 10:40:28 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.apache.felix.cm;
20
21
22import java.io.IOException;
23import java.util.Collections;
24import java.util.Dictionary;
25import java.util.Enumeration;
26import java.util.HashMap;
27import java.util.Map;
28
29
30public class MockPersistenceManager implements PersistenceManager
31{
32
33 private final Map configs = new HashMap();
34
35
36 public void delete( String pid )
37 {
38 configs.remove( pid );
39 }
40
41
42 public boolean exists( String pid )
43 {
44 return configs.containsKey( pid );
45 }
46
47
48 public Enumeration getDictionaries()
49 {
50 return Collections.enumeration( configs.values() );
51 }
52
53
54 public Dictionary load( String pid ) throws IOException
55 {
56 Dictionary config = ( Dictionary ) configs.get( pid );
57 if ( config != null )
58 {
59 return config;
60 }
61
62 throw new IOException( "No such configuration: " + pid );
63 }
64
65
66 public void store( String pid, Dictionary properties )
67 {
68 configs.put( pid, properties );
69 }
70
71}