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
._invocation
.uno
;
21 import com
.sun
.star
.lang
.XMultiServiceFactory
;
22 import com
.sun
.star
.uno
.XInterface
;
23 import java
.io
.PrintWriter
;
24 import lib
.StatusException
;
26 import lib
.TestEnvironment
;
27 import lib
.TestParameters
;
30 * Test for object which is represented by service
31 * <code>com.sun.star.script.Invocation</code>. <p>
32 * Object implements the following interfaces :
34 * <li> <code>com::sun::star::lang::XSingleServiceFactory</code></li>
36 * @see com.sun.star.script.Invocation
37 * @see com.sun.star.lang.XSingleServiceFactory
38 * @see ifc.lang._XSingleServiceFactory
40 public class Invocation
extends TestCase
{
43 * Creating a Testenvironment for the interfaces to be tested.
44 * Creates service <code>com.sun.star.script.Invocation</code>.
45 * Object relations created :
47 * <li> <code>'XSingleServiceFactory.createInstance.negative'</code> :
48 * for interface {@link _ifc.lang.XSingleServiceFactory} ;
49 * <code>String</code> relation; If its value 'true' then
50 * <code>createInstance</code> method for the object isn't
51 * supported. In this case object doesn't support this method.</li>
52 * <li> <code>'XSingleServiceFactory.arguments'</code> :
53 * for interface {@link _ifc.lang.XSingleServiceFactory} ;
54 * has <code>Object[]</code> type. This relation is used as
55 * a parameter for <code>createInstanceWithArguments</code>
56 * method call. If this relation doesn't exist test pass
57 * zerro length array as argument. Here
58 * <code>com.sun.star.io.Pipe</code> instance is passed.</li>
59 * <li> <code>'XSingleServiceFactory.MustSupport'</code> :
60 * for interface {@link _ifc.lang.XSingleServiceFactory}.
61 * Specifies that created instance must support
62 * <code>com.sun.star.script.XInvocation</code> interface.
66 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
67 XMultiServiceFactory xMSF
= tParam
.getMSF();
70 XInterface xInt
= (XInterface
)xMSF
.createInstance(
71 "com.sun.star.script.Invocation");
73 TestEnvironment tEnv
= new TestEnvironment(xInt
);
75 // the createInstance should fail according to the documentation
77 "XSingleServiceFactory.createInstance.negative", "true");
79 // creating parameters to createInstanceWithArguments
80 Object
[] args
= new Object
[1];
82 args
[0] = xMSF
.createInstance("com.suns.star.io.Pipe");
85 "XSingleServiceFactory.arguments", args
);
87 tEnv
.addObjRelation("XSingleServiceFactory.MustSupport",
88 new Class
[] {com
.sun
.star
.script
.XInvocation
.class});
91 } catch (com
.sun
.star
.uno
.Exception e
) {
92 e
.printStackTrace(log
);
93 throw new StatusException("Unexpected exception", e
);