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.mailet.base.test;
21  
22  import org.apache.mailet.MailetConfig;
23  import org.apache.mailet.MailetContext;
24  
25  import java.util.Iterator;
26  import java.util.Properties;
27  
28  /**
29   * MailetConfig over Properties
30   */
31  public class FakeMailetConfig extends Properties implements MailetConfig {
32  
33      public String mailetName;
34      public MailetContext mc;
35  
36      public FakeMailetConfig() {
37          this("A Mailet", new FakeMailContext());
38      }
39      
40      public FakeMailetConfig(String mailetName, MailetContext mc) {
41          super();
42          this.mailetName = mailetName;
43          this.mc = mc;
44      }
45  
46      public FakeMailetConfig(String mailetName, MailetContext mc, Properties arg0) {
47          super(arg0);
48          this.mailetName = mailetName;
49          this.mc = mc;
50      }
51  
52      public String getInitParameter(String name) {
53          return getProperty(name);
54      }
55  
56      public Iterator getInitParameterNames() {
57          return keySet().iterator();
58      }
59  
60      public MailetContext getMailetContext() {
61          return mc;
62      }
63  
64      public String getMailetName() {
65          return mailetName;
66      }
67  
68      // Override setProperty to work like it should in this MockMailetConfig
69      public Object setProperty(String key, String value) {
70          String oldValue = getProperty(key);
71          String newValue = value;
72  
73          if (oldValue != null) {
74              newValue = oldValue + "," + value;
75          }
76          return super.setProperty(key, newValue);
77      }
78  }