Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / mod / _cfgmgr2 / OInnerTreeSetUpdateAccess.java
blobb9f0ee719ca5cc17c2e5ed95f861725f7e8dd000
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: OInnerTreeSetUpdateAccess.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
30 package mod._cfgmgr2;
32 import java.io.PrintWriter;
34 import lib.TestCase;
35 import lib.TestEnvironment;
36 import lib.TestParameters;
37 import util.utils;
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.lang.XMultiServiceFactory;
44 import com.sun.star.lang.XSingleServiceFactory;
45 import com.sun.star.uno.UnoRuntime;
46 import com.sun.star.uno.XInterface;
49 public class OInnerTreeSetUpdateAccess extends TestCase {
50 /** Called to create an instance of <code>TestEnvironment</code> with an
51 * object to test and related objects. <br>
53 * An instance of com.sun.star.comp.configuration.ConfigurationProvider
54 * is created at the MultiServiceFactory of the Office<br>
55 * At this an instance of com.sun.star.configuration.ConfigurationAccess is created
56 * and from the resulting XNameAccess the first element is taken.
58 * @param tParam test parameters
59 * @param log writer to log information while testing
61 * @see TestEnvironment
62 * @see #getTestEnvironment()
65 protected TestEnvironment createTestEnvironment(TestParameters tParam,
66 PrintWriter log) {
67 XInterface oObj = null;
68 Object instance = null;
69 Object instance1 = null;
70 Object instance2 = null;
71 log.println("creating the Environment");
73 PropertyValue[] nodeArgs = new PropertyValue[1];
74 PropertyValue nodepath = new PropertyValue();
75 nodepath.Name = "nodepath";
76 nodepath.Value = "org.openoffice.Office.Jobs";
77 nodepath.Handle = -1;
78 nodepath.State = PropertyState.DEFAULT_VALUE;
79 nodeArgs[0] = nodepath;
81 try {
82 XInterface Provider = (XInterface) ((XMultiServiceFactory)tParam.getMSF())
83 .createInstance("com.sun.star.comp.configuration.ConfigurationProvider");
84 XMultiServiceFactory pMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(
85 XMultiServiceFactory.class,
86 Provider);
87 XHierarchicalNameAccess names = (XHierarchicalNameAccess) UnoRuntime.queryInterface(
88 XHierarchicalNameAccess.class,
89 pMSF.createInstanceWithArguments(
90 "com.sun.star.configuration.ConfigurationUpdateAccess",
91 nodeArgs));
92 oObj = (XInterface) names.getByHierarchicalName("Jobs");
94 XSingleServiceFactory jobsFac = (XSingleServiceFactory) UnoRuntime.queryInterface(
95 XSingleServiceFactory.class,
96 oObj);
97 instance = jobsFac.createInstance();
98 instance1 = jobsFac.createInstance();
99 instance2 = jobsFac.createInstance();
100 } catch (com.sun.star.uno.Exception e) {
101 e.printStackTrace();
104 log.println("ImplementationName: " + utils.getImplName(oObj));
106 TestEnvironment tEnv = new TestEnvironment(oObj);
108 XNameAccess names = (XNameAccess) UnoRuntime.queryInterface(
109 XNameAccess.class, oObj);
111 String[] pNames = names.getElementNames();
113 tEnv.addObjRelation("ElementName", pNames[0]);
115 tEnv.addObjRelation("cannotSwitchParent",
116 "configmgr: BasicElement::setParent: cannot move Entry");
118 tEnv.addObjRelation("expectedName", pNames[0]);
119 tEnv.addObjRelation("HierachicalName", "/org.openoffice.Office");
120 tEnv.addObjRelation("INSTANCE", instance);
121 tEnv.addObjRelation("INSTANCE1", instance1);
122 tEnv.addObjRelation("INSTANCE2", instance1);
123 tEnv.addObjRelation("NAMEREPLACE", pNames[0]);
124 tEnv.addObjRelation("NoSetName", "OInnerTreeSetInfoAccess");
125 tEnv.addObjRelation("TemplateName", "org.openoffice.Office.Jobs/Job");
127 return tEnv;