View Javadoc

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  
21  package org.apache.james.remotemanager;
22  
23  import org.apache.avalon.framework.configuration.DefaultConfiguration;
24  import org.apache.james.test.util.Util;
25  
26  public class RemoteManagerTestConfiguration extends DefaultConfiguration {
27  
28      private int m_remoteManagerListenerPort;
29      private Integer m_connectionLimit = null;
30      private String m_loginName = "testLogin";
31      private String m_loginPassword = "testPassword";
32  
33      public RemoteManagerTestConfiguration(int smtpListenerPort) {
34          super("smptserver");
35  
36          m_remoteManagerListenerPort = smtpListenerPort;
37      }
38  
39      public void setConnectionLimit(int iConnectionLimit) {
40          m_connectionLimit = new Integer(iConnectionLimit);
41      }
42  
43      public String getLoginName() {
44          return m_loginName;
45      }
46  
47      public void setLoginName(String loginName) {
48          m_loginName = loginName;
49      }
50  
51      public String getLoginPassword() {
52          return m_loginPassword;
53      }
54  
55      public void setLoginPassword(String loginPassword) {
56          m_loginPassword = loginPassword;
57      }
58  
59      public void init() {
60  
61          setAttribute("enabled", true);
62  
63          addChild(Util.getValuedConfiguration("port", "" + m_remoteManagerListenerPort));
64          if (m_connectionLimit != null) addChild(Util.getValuedConfiguration("connectionLimit", "" + m_connectionLimit.intValue()));
65  
66          DefaultConfiguration handlerConfig = new DefaultConfiguration("handler");
67          handlerConfig.addChild(Util.getValuedConfiguration("helloName", "myMailServer"));
68          handlerConfig.addChild(Util.getValuedConfiguration("connectiontimeout", "360000"));
69  
70          DefaultConfiguration adminAccounts = new DefaultConfiguration("administrator_accounts");
71          
72          DefaultConfiguration account = new DefaultConfiguration("account");
73          
74          account.setAttribute("login", m_loginName);
75          account.setAttribute("password", m_loginPassword);
76  
77          adminAccounts.addChild(account);
78          handlerConfig.addChild(adminAccounts);
79          
80          // handlerConfig.addChild(Util.getValuedConfiguration("prompt", ">"));
81  
82          handlerConfig.addChild(Util.createRemoteManagerHandlerChainConfiguration());
83          addChild(handlerConfig);
84      }
85  
86  }