KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > test > mock > mailet > MockMailetConfig


1 /****************************************************************
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  ****************************************************************/

19
20 package org.apache.james.test.mock.mailet;
21
22 import org.apache.mailet.MailetConfig;
23 import org.apache.mailet.MailetContext;
24
25 import java.util.Iterator JavaDoc;
26 import java.util.Properties JavaDoc;
27
28 /**
29  * MailetConfig over Properties
30  */

31 public class MockMailetConfig extends Properties JavaDoc implements MailetConfig {
32
33     private String JavaDoc mailetName;
34     private MailetContext mc;
35
36     
37     public MockMailetConfig(String JavaDoc mailetName, MailetContext mc) {
38         super();
39         this.mailetName = mailetName;
40         this.mc = mc;
41     }
42
43     public MockMailetConfig(String JavaDoc mailetName, MailetContext mc, Properties JavaDoc arg0) {
44         super(arg0);
45         this.mailetName = mailetName;
46         this.mc = mc;
47     }
48
49     public String JavaDoc getInitParameter(String JavaDoc name) {
50         return getProperty(name);
51     }
52
53     public Iterator JavaDoc getInitParameterNames() {
54         return keySet().iterator();
55     }
56
57     public MailetContext getMailetContext() {
58         return mc;
59     }
60
61     public String JavaDoc getMailetName() {
62         return mailetName;
63     }
64
65     // Override setProperty to work like it should in this MockMailetConfig
66
public Object JavaDoc setProperty(String JavaDoc key, String JavaDoc value) {
67         String JavaDoc oldValue = getProperty(key);
68         String JavaDoc newValue = value;
69
70         if (oldValue != null) {
71             newValue = oldValue + "," + value;
72         }
73         return super.setProperty(key, newValue);
74     }
75 }
76
Popular Tags