2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import com
.sun
.star
.beans
.NamedValue
;
22 import com
.sun
.star
.beans
.Property
;
23 import com
.sun
.star
.beans
.PropertyVetoException
;
24 import com
.sun
.star
.beans
.XPropertySet
;
25 import com
.sun
.star
.beans
.XPropertySetInfo
;
26 import com
.sun
.star
.lang
.IllegalArgumentException
;
27 import com
.sun
.star
.lang
.WrappedTargetException
;
28 import com
.sun
.star
.uno
.UnoRuntime
;
29 import java
.io
.PrintWriter
;
30 import java
.util
.HashSet
;
34 import lib
.TestEnvironment
;
35 import lib
.TestParameters
;
38 import com
.sun
.star
.uno
.XInterface
;
41 * Test for object which is represented by service
42 * <code>com.sun.star.comp.framework.PathSettings</code>. <p>
44 * Object implements the following interfaces :
46 * <li> <code>com::sun::star::beans::XFastPropertySet</code></li>
47 * <li> <code>com::sun::star::util::PathSettings</code></li>
48 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
49 * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li>
52 * @see com.sun.star.beans.XFastPropertySet
53 * @see com.sun.star.util.PathSettings
54 * @see com.sun.star.beans.XPropertySet
55 * @see com.sun.star.beans.XMultiPropertySet
56 * @see ifc.beans._XFastPropertySet
57 * @see ifc.util._PathSettings
58 * @see ifc.beans._XPropertySet
59 * @see ifc.beans._XMultiPropertySet
61 public class PathSettings
extends TestCase
{
63 private static NamedValue
[] m_Properties
;
64 private static XPropertySet xPS
;
67 * restores the old values of the path settings
68 * @param tParam the test parameter
69 * @param log the log writer
72 protected void cleanup(TestParameters tParam
, PrintWriter log
) {
73 log
.println("restore old values of path settings...");
75 for (int i
=0; i
< m_Properties
.length
; i
++){
78 xPS
.setPropertyValue(m_Properties
[i
].Name
, m_Properties
[i
].Value
);
80 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
81 } catch (PropertyVetoException e
){
82 } catch (IllegalArgumentException e
){
83 } catch (WrappedTargetException e
){
88 * Creating a TestEnvironment for the interfaces to be tested.
89 * Creates an instance of the service
90 * <code>com.sun.star.comp.framework.PathSettings</code>.
93 protected TestEnvironment createTestEnvironment
94 (TestParameters Param
, PrintWriter log
) throws Exception
{
95 XInterface oObj
= null;
96 //now get the OButtonControl
97 Object oInterface
= Param
.getMSF().createInstance
98 ("com.sun.star.comp.framework.PathSettings") ;
100 oObj
= (XInterface
) oInterface
;
101 log
.println("ImplName: "+utils
.getImplName(oObj
));
103 log
.println( "creating a new environment for object" );
104 TestEnvironment tEnv
= new TestEnvironment( oObj
);
106 Set
<String
> exclProps
= new HashSet
<String
>();
107 exclProps
.add("UIConfig");
108 tEnv
.addObjRelation("XFastPropertySet.ExcludeProps", exclProps
);
109 tEnv
.addObjRelation("XMultiPropertySet.ExcludeProps", exclProps
);
111 saveAllPropertyValues(oObj
);
114 } // finish method getTestEnvironment
116 private void saveAllPropertyValues(XInterface oObj
){
118 xPS
= UnoRuntime
.queryInterface(
119 XPropertySet
.class, oObj
);
121 XPropertySetInfo xPSI
= xPS
.getPropertySetInfo();
123 Property
[] allProperties
= xPSI
.getProperties();
124 m_Properties
= new NamedValue
[allProperties
.length
];
126 for (int i
=0; i
< allProperties
.length
; i
++){
128 m_Properties
[i
] = new NamedValue(allProperties
[i
].Name
,
129 xPS
.getPropertyValue(allProperties
[i
].Name
));
131 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
132 } catch (WrappedTargetException e
){