1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PathSettings.java,v $
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 ************************************************************************/
33 import com
.sun
.star
.beans
.NamedValue
;
34 import com
.sun
.star
.beans
.Property
;
35 import com
.sun
.star
.beans
.PropertyVetoException
;
36 import com
.sun
.star
.beans
.XPropertySet
;
37 import com
.sun
.star
.beans
.XPropertySetInfo
;
38 import com
.sun
.star
.lang
.IllegalArgumentException
;
39 import com
.sun
.star
.lang
.WrappedTargetException
;
40 import com
.sun
.star
.uno
.UnoRuntime
;
41 import java
.io
.PrintWriter
;
42 import java
.util
.HashSet
;
46 import lib
.StatusException
;
48 import lib
.TestEnvironment
;
49 import lib
.TestParameters
;
52 import com
.sun
.star
.lang
.XMultiServiceFactory
;
53 import com
.sun
.star
.uno
.XInterface
;
56 * Test for object which is represented by service
57 * <code>com.sun.star.comp.framework.PathSettings</code>. <p>
59 * Object implements the following interfaces :
61 * <li> <code>com::sun::star::beans::XFastPropertySet</code></li>
62 * <li> <code>com::sun::star::util::PathSettings</code></li>
63 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
64 * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li>
67 * @see com.sun.star.beans.XFastPropertySet
68 * @see com.sun.star.util.PathSettings
69 * @see com.sun.star.beans.XPropertySet
70 * @see com.sun.star.beans.XMultiPropertySet
71 * @see ifc.beans._XFastPropertySet
72 * @see ifc.util._PathSettings
73 * @see ifc.beans._XPropertySet
74 * @see ifc.beans._XMultiPropertySet
76 public class PathSettings
extends TestCase
{
78 private static NamedValue
[] m_Properties
;
79 private static XPropertySet xPS
;
82 * restores the old values of the path settings
83 * @param tParam the test parameter
84 * @param log the log writer
86 protected void cleanup(TestParameters tParam
, PrintWriter log
) {
87 log
.println("restore old values of path settings...");
89 for (int i
=0; i
< m_Properties
.length
; i
++){
92 xPS
.setPropertyValue(m_Properties
[i
].Name
, m_Properties
[i
].Value
);
94 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
95 } catch (PropertyVetoException e
){
96 } catch (IllegalArgumentException e
){
97 } catch (WrappedTargetException e
){
102 * Creating a Testenvironment for the interfaces to be tested.
103 * Creates an instance of the service
104 * <code>com.sun.star.comp.framework.PathSettings</code>.
106 protected TestEnvironment createTestEnvironment
107 (TestParameters Param
, PrintWriter log
) {
108 XInterface oObj
= null;
109 Object oInterface
= null ;
111 //now get the OButtonControl
113 oInterface
= ((XMultiServiceFactory
)Param
.getMSF()).createInstance
114 ("com.sun.star.comp.framework.PathSettings") ;
115 } catch (com
.sun
.star
.uno
.Exception e
) {
116 log
.println("Couldn't get service");
117 e
.printStackTrace(log
);
118 throw new StatusException("Couldn't get GridControl", e
);
121 if (oInterface
== null) {
122 log
.println("Service wasn't created") ;
123 throw new StatusException(Status
.failed("Service wasn't created")) ;
126 oObj
= (XInterface
) oInterface
;
127 log
.println("ImplName: "+utils
.getImplName(oObj
));
129 log
.println( "creating a new environment for object" );
130 TestEnvironment tEnv
= new TestEnvironment( oObj
);
132 Set exclProps
= new HashSet();
133 exclProps
.add("UIConfig");
134 tEnv
.addObjRelation("XFastPropertySet.ExcludeProps", exclProps
);
135 tEnv
.addObjRelation("XMultiPropertySet.ExcludeProps", exclProps
);
137 saveAllPropertyValues(oObj
);
140 } // finish method getTestEnvironment
142 private void saveAllPropertyValues(XInterface oObj
){
144 xPS
= (XPropertySet
) UnoRuntime
.queryInterface(
145 XPropertySet
.class, oObj
);
147 XPropertySetInfo xPSI
= xPS
.getPropertySetInfo();
149 Property
[] allProperties
= xPSI
.getProperties();
150 m_Properties
= new NamedValue
[allProperties
.length
];
152 for (int i
=0; i
< allProperties
.length
; i
++){
154 m_Properties
[i
] = new NamedValue(allProperties
[i
].Name
,
155 xPS
.getPropertyValue(allProperties
[i
].Name
));
157 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
158 } catch (WrappedTargetException e
){