merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _proxyset / SystemProxySettings.java
blob6830318e83e984f944df8236b6ea6759eb0e5395
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SystemProxySettings.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._proxyset;
33 import java.io.PrintWriter;
34 import java.util.Hashtable;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
40 import com.sun.star.lang.XMultiServiceFactory;
41 import com.sun.star.uno.XInterface;
43 /**
44 * Test for object which is represented by service
45 * <code>com.sun.star.system.SystemProxySettings</code>. <p>
46 * Object implements the following interfaces :
47 * <ul>
48 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
49 * <li> <code>com::sun::star::system::XProxySettings</code></li>
50 * <li> <code>com::sun::star::lang::XTypeProvider</code></li>
51 * </ul> <p>
53 * This object test <b> is NOT </b> designed to be run in several
54 * threads concurently.
56 * @see com.sun.star.lang.XServiceInfo
57 * @see com.sun.star.system.XProxySettings
58 * @see com.sun.star.lang.XTypeProvider
59 * @see ifc.lang._XServiceInfo
60 * @see ifc.system._XProxySettings
61 * @see ifc.lang._XTypeProvider
63 public class SystemProxySettings extends TestCase {
65 /**
66 * Creating a Testenvironment for the interfaces to be tested.
67 * Creates an instance of
68 * <code>com.sun.star.system.SystemProxySettings</code>,for testing.
70 * Object relations created :
71 * <ul>
72 * <li> <code>'XProxySettings.proxySettings'</code> for
73 * {@link ifc.system._XProxySettings} : </li>
74 * <p>It passes a Hashtable with expected proxy settings as object
75 * relation "XProxySettings.proxySettings", to verify results. The expected
76 * settings are taken from parameters. The following parameters are recognized:
77 * <ul>
78 * <li>test.proxy.soffice52.ftpProxyAddress</li>
79 * <li>test.proxy.soffice52.ftpProxyPort</li>
80 * <li>test.proxy.soffice52.gopherProxyAddress</li>
81 * <li>test.proxy.soffice52.gopherProxyPort</li>
82 * <li>test.proxy.soffice52.httpProxyAddress</li>
83 * <li>test.proxy.soffice52.httpProxyPort</li>
84 * <li>test.proxy.soffice52.httpsProxyAddress</li>
85 * <li>test.proxy.soffice52.httpsProxyPort</li>
86 * <li>test.proxy.soffice52.socksProxyAddress</li>
87 * <li>test.proxy.soffice52.socksProxyPort</li>
88 * <li>test.proxy.soffice52.proxyBypassAddress</li>
89 * <li>test.proxy.soffice52.proxyEnabled</li>
90 * </ul>.
91 * </ul>
93 protected TestEnvironment createTestEnvironment
94 (TestParameters tParam, PrintWriter log) {
95 XInterface oObj = null;
96 Object oInterface = null;
98 try {
99 XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF();
100 oInterface = xMSF.createInstance
101 ( "com.sun.star.system.SystemProxySettings" );
103 catch( com.sun.star.uno.Exception e ) {
104 log.println("Service not available" );
107 oObj = (XInterface) oInterface;
109 log.println( " creating a new environment for object" );
110 TestEnvironment tEnv = new TestEnvironment( oObj );
112 // extracting parameters to proxy settings
113 Hashtable proxySettings = new Hashtable(12);
115 String prefix = "test.proxy.system.";
117 final String[] names = {
118 "ftpProxyAddress",
119 "ftpProxyPort",
120 "gopherProxyAddress",
121 "gopherProxyPort",
122 "httpProxyAddress",
123 "httpProxyPort",
124 "httpsProxyAddress",
125 "httpsProxyPort",
126 "socksProxyAddress",
127 "socksProxyPort",
128 "proxyBypassAddress",
129 "proxyEnabled"
132 for (int i = 0; i < names.length; i++) {
133 String name = prefix + names[i];
134 String value = (String) tParam.get(name);
136 if (value == null) {
137 value = "";
140 proxySettings.put(names[i], value);
143 tEnv.addObjRelation("XProxySettings.proxySettings", proxySettings);
145 return tEnv;