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: OSetElementGroupUpdateAccess.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 ************************************************************************/
32 import java
.io
.PrintWriter
;
35 import lib
.TestEnvironment
;
36 import lib
.TestParameters
;
39 import com
.sun
.star
.beans
.PropertyState
;
40 import com
.sun
.star
.beans
.PropertyValue
;
41 import com
.sun
.star
.container
.XHierarchicalNameAccess
;
42 import com
.sun
.star
.container
.XNameAccess
;
43 import com
.sun
.star
.container
.XNameReplace
;
44 import com
.sun
.star
.lang
.XMultiServiceFactory
;
45 import com
.sun
.star
.lang
.XSingleServiceFactory
;
46 import com
.sun
.star
.uno
.UnoRuntime
;
47 import com
.sun
.star
.uno
.XInterface
;
50 public class OSetElementGroupUpdateAccess
extends TestCase
{
51 /** Called to create an instance of <code>TestEnvironment</code> with an
52 * object to test and related objects. <br>
54 * An instance of com.sun.star.comp.configuration.ConfigurationProvider
55 * is created at the MultiServiceFactory of the Office<br>
56 * At this an instance of com.sun.star.configuration.ConfigurationAccess is created
57 * and from the resulting XNameAccess the first element is taken.
59 * @param tParam test parameters
60 * @param log writer to log information while testing
62 * @see TestEnvironment
63 * @see #getTestEnvironment()
66 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
68 XInterface oObj
= null;
69 log
.println("creating the Environment");
71 PropertyValue
[] nodeArgs
= new PropertyValue
[1];
72 PropertyValue nodepath
= new PropertyValue();
73 nodepath
.Name
= "nodepath";
74 nodepath
.Value
= "org.openoffice.Office.Jobs";
76 nodepath
.State
= PropertyState
.DEFAULT_VALUE
;
77 nodeArgs
[0] = nodepath
;
80 XInterface Provider
= (XInterface
) ((XMultiServiceFactory
)tParam
.getMSF())
81 .createInstance("com.sun.star.comp.configuration.ConfigurationProvider");
82 XMultiServiceFactory pMSF
= (XMultiServiceFactory
) UnoRuntime
.queryInterface(
83 XMultiServiceFactory
.class,
85 XHierarchicalNameAccess names
= (XHierarchicalNameAccess
) UnoRuntime
.queryInterface(
86 XHierarchicalNameAccess
.class,
87 pMSF
.createInstanceWithArguments(
88 "com.sun.star.configuration.ConfigurationUpdateAccess",
91 XSingleServiceFactory jobsFac
= (XSingleServiceFactory
) UnoRuntime
.queryInterface(
92 XSingleServiceFactory
.class,
93 names
.getByHierarchicalName("Jobs"));
94 oObj
= (XInterface
) jobsFac
.createInstance();
95 } catch (com
.sun
.star
.uno
.Exception e
) {
99 log
.println("ImplementationName: " + utils
.getImplName(oObj
));
101 TestEnvironment tEnv
= new TestEnvironment(oObj
);
103 XNameAccess names
= (XNameAccess
) UnoRuntime
.queryInterface(
104 XNameAccess
.class, oObj
);
106 String
[] pNames
= names
.getElementNames();
107 String
[] pTypes
= new String
[pNames
.length
];
109 for (int k
=0;k
<pNames
.length
;k
++) {
110 pTypes
[k
] = "boolean";
114 tEnv
.addObjRelation("ElementName", pNames
[0]);
116 tEnv
.addObjRelation("PropertyNames", pNames
);
117 tEnv
.addObjRelation("PropertyTypes", pTypes
);
119 tEnv
.addObjRelation("cannotSwitchParent",
120 "configmgr: BasicElement::setParent: cannot move Entry");
122 tEnv
.addObjRelation("expectedName", pNames
[0]);
123 tEnv
.addObjRelation("INSTANCE1", "newValue");
124 tEnv
.addObjRelation("HierachicalName", "//Job");
125 tEnv
.addObjRelation("NoSetName", "OSetElementGroupUpdateAccess");
127 tEnv
.addObjRelation("XContainer.NewValue", "aValue");
128 tEnv
.addObjRelation("XContainer.ElementName", pNames
[0]);
129 tEnv
.addObjRelation("XContainer.Container", (XNameReplace
)
130 UnoRuntime
.queryInterface(XNameReplace
.class, oObj
));
132 tEnv
.addObjRelation("TemplateInstance", (String
)nodepath
.Value
+ "/Job");