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 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
28 import com
.sun
.star
.lang
.XMultiServiceFactory
;
29 import com
.sun
.star
.uno
.XInterface
;
32 * Test for object which is represented by service
33 * <code>com.sun.star.script.Invocation</code>. <p>
34 * Object implements the following interfaces :
36 * <li> <code>com::sun::star::lang::XSingleServiceFactory</code></li>
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
{
45 * Creating a TestEnvironment for the interfaces to be tested.
46 * Creates service <code>com.sun.star.script.Invocation</code>.
47 * Object relations created :
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.
68 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
69 XMultiServiceFactory xMSF
= tParam
.getMSF();
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
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");
87 "XSingleServiceFactory.arguments", args
);
89 tEnv
.addObjRelation("XSingleServiceFactory.MustSupport",
90 new Class
[] {com
.sun
.star
.script
.XInvocation
.class});
93 } catch (com
.sun
.star
.uno
.Exception e
) {
94 e
.printStackTrace(log
);
95 throw new StatusException("Unexpected exception", e
);