bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _inv / Invocation.java
blob87cf3875c0fe7cced0bc2e1b11295a1e9f49dd1e
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 @Override
68 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
69 XMultiServiceFactory xMSF = tParam.getMSF();
71 try {
72 XInterface xInt = (XInterface)xMSF.createInstance(
73 "com.sun.star.script.Invocation");
75 TestEnvironment tEnv = new TestEnvironment(xInt);
77 // the createInstance should fail according to the documentation
78 tEnv.addObjRelation(
79 "XSingleServiceFactory.createInstance.negative", "true");
81 // creating parameters to createInstanceWithArguments
82 Object[] args = new Object[1];
84 args[0] = xMSF.createInstance("com.suns.star.io.Pipe");
86 tEnv.addObjRelation(
87 "XSingleServiceFactory.arguments", args);
89 tEnv.addObjRelation("XSingleServiceFactory.MustSupport",
90 new Class[] {com.sun.star.script.XInvocation.class});
92 return tEnv;
93 } catch (com.sun.star.uno.Exception e) {
94 e.printStackTrace(log);
95 throw new StatusException("Unexpected exception", e);