1 /************************************************************************
2 * Copyright (c) 2000-2006 The Apache Software Foundation. *
3 * All rights reserved. *
4 * ------------------------------------------------------------------- *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you *
6 * may not use this file except in compliance with the License. You *
7 * may obtain a copy of the License at: *
8 * *
9 * http://www.apache.org/licenses/LICENSE-2.0 *
10 * *
11 * Unless required by applicable law or agreed to in writing, software *
12 * distributed under the License is distributed on an "AS IS" BASIS, *
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
14 * implied. See the License for the specific language governing *
15 * permissions and limitations under the License. *
16 ***********************************************************************/
17
18
19 package org.apache.james.remotemanager;
20
21 import org.apache.avalon.framework.configuration.DefaultConfiguration;
22 import org.apache.james.test.util.Util;
23
24 public class RemoteManagerTestConfiguration extends DefaultConfiguration {
25
26 private int m_remoteManagerListenerPort;
27 private Integer m_connectionLimit = null;
28 private String m_loginName = "testLogin";
29 private String m_loginPassword = "testPassword";
30
31 public RemoteManagerTestConfiguration(int smtpListenerPort) {
32 super("smptserver");
33
34 m_remoteManagerListenerPort = smtpListenerPort;
35 }
36
37 public void setConnectionLimit(int iConnectionLimit) {
38 m_connectionLimit = new Integer(iConnectionLimit);
39 }
40
41 public String getLoginName() {
42 return m_loginName;
43 }
44
45 public void setLoginName(String loginName) {
46 m_loginName = loginName;
47 }
48
49 public String getLoginPassword() {
50 return m_loginPassword;
51 }
52
53 public void setLoginPassword(String loginPassword) {
54 m_loginPassword = loginPassword;
55 }
56
57 public void init() {
58
59 setAttribute("enabled", true);
60
61 addChild(Util.getValuedConfiguration("port", "" + m_remoteManagerListenerPort));
62 if (m_connectionLimit != null) addChild(Util.getValuedConfiguration("connectionLimit", "" + m_connectionLimit.intValue()));
63
64 DefaultConfiguration handlerConfig = new DefaultConfiguration("handler");
65 handlerConfig.addChild(Util.getValuedConfiguration("helloName", "myMailServer"));
66 handlerConfig.addChild(Util.getValuedConfiguration("connectiontimeout", "360000"));
67
68 DefaultConfiguration adminAccounts = new DefaultConfiguration("administrator_accounts");
69
70 DefaultConfiguration account = new DefaultConfiguration("account");
71
72 account.setAttribute("login", m_loginName);
73 account.setAttribute("password", m_loginPassword);
74
75 adminAccounts.addChild(account);
76 handlerConfig.addChild(adminAccounts);
77
78
79
80 handlerConfig.addChild(Util.createRemoteManagerHandlerChainConfiguration());
81 addChild(handlerConfig);
82 }
83
84 }