merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / lang / _XMultiComponentFactory.java
blobd677c8558fc0249e05a9a6a9b724620ff9e1b900
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: _XMultiComponentFactory.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 ************************************************************************/
31 package ifc.lang;
33 import lib.MultiMethodTest;
35 import com.sun.star.lang.XMultiComponentFactory;
36 import com.sun.star.uno.XComponentContext;
37 import com.sun.star.uno.XInterface;
39 /**
40 * Testing <code>com.sun.star.lang.XMultiComponentFactory</code>
41 * interface methods :
42 * <ul>
43 * <li><code> createInstanceWithContext()</code></li>
44 * <li><code> createInstanceWithArgumentsAndContext()</code></li>
45 * <li><code> getAvailableServiceNames()</code></li>
46 * </ul> <p>
47 * Test is <b> NOT </b> multithread compilant. <p>
48 * @see com.sun.star.lang.XMultiComponentFactory
50 public class _XMultiComponentFactory extends MultiMethodTest {
51 public XMultiComponentFactory oObj = null;
53 public XComponentContext xContext = null;
54 private String[] availableServiceNames = null;
56 public void before(){
57 xContext = (XComponentContext)tEnv.getObjRelation("DC");
58 availableServiceNames = (String[])tEnv.getObjRelation("XMultiComponentFactory.ServiceNames");
61 /**
62 * Calls the method with one of the available service names
63 * obtained by method getAvailableServiceNames. <p>
64 * Has <b> OK </b> status if no runtime exceptions occured
65 * and returned value is not null.
67 public void _createInstanceWithContext() {
68 requiredMethod("getAvailableServiceNames()");
69 boolean result = true;
71 try {
72 XInterface component = (XInterface)
73 oObj.createInstanceWithContext(
74 availableServiceNames[0], xContext);
75 result = (component != null);
76 } catch (com.sun.star.uno.Exception e) {
77 log.println("Couldn't create instance " + availableServiceNames[0]);
78 result = false;
81 tRes.tested("createInstanceWithContext()", result);
84 /**
85 * Calls the method with one of the available service names
86 * obtained by method getAvailableServiceNames. <p>
87 * Has <b> OK </b> status if no runtime exceptions occured
88 * and returned value is not null.
90 public void _createInstanceWithArgumentsAndContext() {
91 requiredMethod("getAvailableServiceNames()");
92 boolean result = true;
93 XInterface component = null;
95 try {
96 component = (XInterface)oObj.createInstanceWithArgumentsAndContext(
97 availableServiceNames[0], new Object[0], xContext);
98 result = (component != null);
99 } catch (com.sun.star.uno.Exception e) {
100 log.println("Couldn't create instance " + availableServiceNames[0]);
101 result = false;
104 tRes.tested("createInstanceWithArgumentsAndContext()", result);
108 * Just calls the method. <p>
109 * Has <b> OK </b> status if no runtime exceptions occured
110 * and returned value is not null.
112 public void _getAvailableServiceNames() {
113 boolean result = true;
114 if (availableServiceNames == null) {
115 availableServiceNames = oObj.getAvailableServiceNames();
116 result = (availableServiceNames != null);
118 else { // if service names are given, ignore result
119 String[]erg = oObj.getAvailableServiceNames();
120 result = (erg != null);
123 log.println("Available service names:");
124 for(int i = 0; i < availableServiceNames.length; i++) {
125 log.println(" " + availableServiceNames[i]);
128 tRes.tested("getAvailableServiceNames()", result);