bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _inv / Invocation.java
blobc91a25b010378617b61422d2d5880bbeb1dc9b7b
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 mod._inv;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
28 import com.sun.star.lang.XMultiServiceFactory;
29 import com.sun.star.uno.XInterface;
31 /**
32 * Test for object which is represented by service
33 * <code>com.sun.star.script.Invocation</code>. <p>
34 * Object implements the following interfaces :
35 * <ul>
36 * <li> <code>com::sun::star::lang::XSingleServiceFactory</code></li>
37 * </ul>
38 * @see com.sun.star.script.Invocation
39 * @see com.sun.star.lang.XSingleServiceFactory
40 * @see ifc.lang._XSingleServiceFactory
42 public class Invocation extends TestCase {
44 /**
45 * Creating a TestEnvironment for the interfaces to be tested.
46 * Creates service <code>com.sun.star.script.Invocation</code>.
47 * Object relations created :
48 * <ul>
49 * <li> <code>'XSingleServiceFactory.createInstance.negative'</code> :
50 * for interface {@link ifc.lang._XSingleServiceFactory} ;
51 * <code>String</code> relation; If its value 'true' then
52 * <code>createInstance</code> method for the object isn't
53 * supported. In this case object doesn't support this method.</li>
54 * <li> <code>'XSingleServiceFactory.arguments'</code> :
55 * for interface {@link ifc.lang._XSingleServiceFactory} ;
56 * has <code>Object[]</code> type. This relation is used as
57 * a parameter for <code>createInstanceWithArguments</code>
58 * method call. If this relation doesn't exist test pass
59 * zero length array as argument. Here
60 * <code>com.sun.star.io.Pipe</code> instance is passed.</li>
61 * <li> <code>'XSingleServiceFactory.MustSupport'</code> :
62 * for interface {@link ifc.lang._XSingleServiceFactory}.
63 * Specifies that created instance must support
64 * <code>com.sun.star.script.XInvocation</code> interface.
65 * </ul>
67 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
68 XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF();
70 try {
71 XInterface xInt = (XInterface)xMSF.createInstance(
72 "com.sun.star.script.Invocation");
74 TestEnvironment tEnv = new TestEnvironment(xInt);
76 // the createInstance should fail according to the documentation
77 tEnv.addObjRelation(
78 "XSingleServiceFactory.createInstance.negative", "true");
80 // creating parameters to createInstanceWithArguments
81 Object[] args = new Object[1];
83 args[0] = xMSF.createInstance("com.suns.star.io.Pipe");
85 tEnv.addObjRelation(
86 "XSingleServiceFactory.arguments", args);
88 tEnv.addObjRelation("XSingleServiceFactory.MustSupport",
89 new Class[] {com.sun.star.script.XInvocation.class});
91 return tEnv;
92 } catch (com.sun.star.uno.Exception e) {
93 e.printStackTrace(log);
94 throw new StatusException("Unexpected exception", e);