bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / lang / _XMultiComponentFactory.java
blob768449984e615b49458f4bc14433a01092714415
1 /*
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 .
19 package ifc.lang;
21 import lib.MultiMethodTest;
23 import com.sun.star.lang.XMultiComponentFactory;
24 import com.sun.star.uno.XComponentContext;
25 import com.sun.star.uno.XInterface;
27 /**
28 * Testing <code>com.sun.star.lang.XMultiComponentFactory</code>
29 * interface methods :
30 * <ul>
31 * <li><code> createInstanceWithContext()</code></li>
32 * <li><code> createInstanceWithArgumentsAndContext()</code></li>
33 * <li><code> getAvailableServiceNames()</code></li>
34 * </ul> <p>
35 * Test is <b> NOT </b> multithread compilant. <p>
36 * @see com.sun.star.lang.XMultiComponentFactory
38 public class _XMultiComponentFactory extends MultiMethodTest {
39 public XMultiComponentFactory oObj = null;
41 public XComponentContext xContext = null;
42 private String[] availableServiceNames = null;
44 public void before(){
45 xContext = (XComponentContext)tEnv.getObjRelation("DC");
46 availableServiceNames = (String[])tEnv.getObjRelation("XMultiComponentFactory.ServiceNames");
49 /**
50 * Calls the method with one of the available service names
51 * obtained by method getAvailableServiceNames. <p>
52 * Has <b> OK </b> status if no runtime exceptions occurred
53 * and returned value is not null.
55 public void _createInstanceWithContext() {
56 requiredMethod("getAvailableServiceNames()");
57 boolean result = true;
59 try {
60 XInterface component = (XInterface)
61 oObj.createInstanceWithContext(
62 availableServiceNames[0], xContext);
63 result = (component != null);
64 } catch (com.sun.star.uno.Exception e) {
65 log.println("Couldn't create instance " + availableServiceNames[0]);
66 result = false;
69 tRes.tested("createInstanceWithContext()", result);
72 /**
73 * Calls the method with one of the available service names
74 * obtained by method getAvailableServiceNames. <p>
75 * Has <b> OK </b> status if no runtime exceptions occurred
76 * and returned value is not null.
78 public void _createInstanceWithArgumentsAndContext() {
79 requiredMethod("getAvailableServiceNames()");
80 boolean result = true;
81 XInterface component = null;
83 try {
84 component = (XInterface)oObj.createInstanceWithArgumentsAndContext(
85 availableServiceNames[0], new Object[0], xContext);
86 result = (component != null);
87 } catch (com.sun.star.uno.Exception e) {
88 log.println("Couldn't create instance " + availableServiceNames[0]);
89 result = false;
92 tRes.tested("createInstanceWithArgumentsAndContext()", result);
95 /**
96 * Just calls the method. <p>
97 * Has <b> OK </b> status if no runtime exceptions occurred
98 * and returned value is not null.
100 public void _getAvailableServiceNames() {
101 boolean result = true;
102 if (availableServiceNames == null) {
103 availableServiceNames = oObj.getAvailableServiceNames();
104 result = (availableServiceNames != null);
106 else { // if service names are given, ignore result
107 String[]erg = oObj.getAvailableServiceNames();
108 result = (erg != null);
111 log.println("Available service names:");
112 for(int i = 0; i < availableServiceNames.length; i++) {
113 log.println(" " + availableServiceNames[i]);
116 tRes.tested("getAvailableServiceNames()", result);