merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _cfgmgr2 / ORootElementSetInfoAccess.java
blob4c58a9757b9a9597f782d98ebdc1f372c369ad5d
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: ORootElementSetInfoAccess.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 ************************************************************************/
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.XNameAccess;
42 import com.sun.star.container.XNameReplace;
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;
47 import com.sun.star.util.XChangesBatch;
50 public class ORootElementSetInfoAccess 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,
67 PrintWriter log) {
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/Jobs";
75 nodepath.Handle = -1;
76 nodepath.State = PropertyState.DEFAULT_VALUE;
77 nodeArgs[0] = nodepath;
79 XInterface changeView = null;
80 Object instance = null;
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 oObj = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,
88 pMSF.createInstanceWithArguments(
89 "com.sun.star.configuration.ConfigurationAccess",
90 nodeArgs));
91 changeView = (XNameReplace) UnoRuntime.queryInterface(XNameReplace.class,
92 pMSF.createInstanceWithArguments(
93 "com.sun.star.configuration.ConfigurationUpdateAccess",
94 nodeArgs));
95 XSingleServiceFactory jobsFac = (XSingleServiceFactory) UnoRuntime.queryInterface(
96 XSingleServiceFactory.class,
97 changeView);
98 instance = jobsFac.createInstance();
100 } catch (com.sun.star.uno.Exception e) {
101 e.printStackTrace();
104 log.println("ImplementationName: " + utils.getImplName(oObj));
105 log.println("ChangeView: " + utils.getImplName(changeView));
107 TestEnvironment tEnv = new TestEnvironment(oObj);
109 XNameReplace container = (XNameReplace)UnoRuntime.queryInterface(XNameReplace.class, changeView);
110 tEnv.addObjRelation("XContainer.NewValue", instance);
111 tEnv.addObjRelation("XContainer.ElementName", "RegistrationRequest");
112 tEnv.addObjRelation("XContainer.Container", container);
114 tEnv.addObjRelation("XChangesNotifier.ChangesBatch", (XChangesBatch)UnoRuntime.queryInterface(XChangesBatch.class, changeView));
115 tEnv.addObjRelation("XChangesNotifier.ChangeElement", instance);
116 tEnv.addObjRelation("XChangesNotifier.PropertyName", "RegistrationRequest");
117 tEnv.addObjRelation("XChangesNotifier.NameReplace", container);
119 tEnv.addObjRelation("XLocalizable.ReadOnly", "Locale of ORootElementSetInfoAccess is read Only");
120 tEnv.addObjRelation("allReadOnly",
121 "all Properties of ORootElementSetInfoAccess are read Only");
122 tEnv.addObjRelation("NoSetName", "ORootElementSetInfoAccess");
123 tEnv.addObjRelation("TemplateName", "org.openoffice.Office.Jobs/Job");
124 tEnv.addObjRelation("HierachicalName", "/org.openoffice");
125 tEnv.addObjRelation("ElementName", "RegistrationRequest");
126 tEnv.addObjRelation("expectedName", "RegistrationRequest");
128 return tEnv;