merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _invocation.uno / Invocation.java
blobd3974f58842a3c75b874ea08f3dc145dc959e36a
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: Invocation.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 ************************************************************************/
31 package mod._invocation.uno;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.uno.XInterface;
35 import java.io.PrintWriter;
36 import lib.StatusException;
37 import lib.TestCase;
38 import lib.TestEnvironment;
39 import lib.TestParameters;
41 /**
42 * Test for object which is represented by service
43 * <code>com.sun.star.script.Invocation</code>. <p>
44 * Object implements the following interfaces :
45 * <ul>
46 * <li> <code>com::sun::star::lang::XSingleServiceFactory</code></li>
47 * </ul>
48 * @see com.sun.star.script.Invocation
49 * @see com.sun.star.lang.XSingleServiceFactory
50 * @see ifc.lang._XSingleServiceFactory
52 public class Invocation extends TestCase {
54 /**
55 * Creating a Testenvironment for the interfaces to be tested.
56 * Creates service <code>com.sun.star.script.Invocation</code>.
57 * Object relations created :
58 * <ul>
59 * <li> <code>'XSingleServiceFactory.createInstance.negative'</code> :
60 * for interface {@link _ifc.lang.XSingleServiceFactory} ;
61 * <code>String</code> relation; If its value 'true' then
62 * <code>createInstance</code> method for the object isn't
63 * supported. In this case object doesn't support this method.</li>
64 * <li> <code>'XSingleServiceFactory.arguments'</code> :
65 * for interface {@link _ifc.lang.XSingleServiceFactory} ;
66 * has <code>Object[]</code> type. This relation is used as
67 * a parameter for <code>createInstanceWithArguments</code>
68 * method call. If this relation doesn't exist test pass
69 * zerro length array as argument. Here
70 * <code>com.sun.star.io.Pipe</code> instance is passed.</li>
71 * <li> <code>'XSingleServiceFactory.MustSupport'</code> :
72 * for interface {@link _ifc.lang.XSingleServiceFactory}.
73 * Specifies that created instance must support
74 * <code>com.sun.star.script.XInvocation</code> interface.
75 * </ul>
77 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
78 XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF();
80 try {
81 XInterface xInt = (XInterface)xMSF.createInstance(
82 "com.sun.star.script.Invocation");
84 TestEnvironment tEnv = new TestEnvironment(xInt);
86 // the createInstance should fail according to the documentation
87 tEnv.addObjRelation(
88 "XSingleServiceFactory.createInstance.negative", "true");
90 // creating parameters to createInstanceWithArguments
91 Object[] args = new Object[1];
93 args[0] = xMSF.createInstance("com.suns.star.io.Pipe");
95 tEnv.addObjRelation(
96 "XSingleServiceFactory.arguments", args);
98 tEnv.addObjRelation("XSingleServiceFactory.MustSupport",
99 new Class[] {com.sun.star.script.XInvocation.class});
101 return tEnv;
102 } catch (com.sun.star.uno.Exception e) {
103 e.printStackTrace(log);
104 throw new StatusException("Unexpected exception", e);