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 lib
.MultiMethodTest
;
22 import lib
.StatusException
;
24 import com
.sun
.star
.io
.XInputStream
;
25 import com
.sun
.star
.lang
.XMultiServiceFactory
;
26 import com
.sun
.star
.lang
.XSingleServiceFactory
;
27 import com
.sun
.star
.script
.XInvocation
;
28 import com
.sun
.star
.script
.XInvocationAdapterFactory2
;
29 import com
.sun
.star
.uno
.Type
;
30 import com
.sun
.star
.uno
.UnoRuntime
;
31 import com
.sun
.star
.uno
.XInterface
;
34 * Testing <code>com.sun.star.script.XInvocationAdapterFactory</code>
37 * <li><code> createAdapter()</code></li>
39 * Test is <b> NOT </b> multithread compliant. <p>
40 * @see com.sun.star.script.XInvocationAdapterFactory
42 public class _XInvocationAdapterFactory2
extends MultiMethodTest
{
45 * oObj filled by MultiMethodTest
47 public XInvocationAdapterFactory2 oObj
= null;
50 * First an invocation object of <code>com.sun.star.io.Pipe</code>
51 * instance is created using <code>com.sun.star.script.Invocation
52 * </code> service. Then trying to create an adapter of this
53 * invocation for <code>com.sun.star.io.XInputStream</code>
55 * Has <b>OK</b> status if the adapter returned is successfully
56 * queried for <code>com.sun.star.io.XInputStream</code>
58 * @see com.sun.star.script.Invocation
59 * @see com.sun.star.script.XInvocation
60 * @see com.sun.star.io.Pipe
62 public void _createAdapter() {
63 XInvocation xInv
= null ;
64 XMultiServiceFactory xMSF
= null;
66 xMSF
= tParam
.getMSF();
67 Object
[] args
= {xMSF
.createInstance
68 ("com.sun.star.io.Pipe")};
70 Object oInvFac
= xMSF
.createInstance
71 ("com.sun.star.script.Invocation") ;
73 XSingleServiceFactory xInvFac
= UnoRuntime
.
74 queryInterface(XSingleServiceFactory
.class, oInvFac
) ;
76 Object oInv
= xInvFac
.createInstanceWithArguments(args
) ;
78 xInv
= UnoRuntime
.queryInterface
79 (XInvocation
.class, oInv
) ;
81 } catch (com
.sun
.star
.uno
.Exception e
) {
82 e
.printStackTrace(log
) ;
83 throw new StatusException("Cann't create invocation for object", e
) ;
86 XInterface xInStr
= null ;
88 Type
[] types
= new Type
[1];
89 types
[0] = new Type(XInputStream
.class);
91 Object adp
= oObj
.createAdapter(xInv
,types
);
93 xInStr
= UnoRuntime
.queryInterface
94 (XInputStream
.class, adp
) ;
98 tRes
.tested("createAdapter()", true) ;
100 log
.println("Adapter created doesn't implement required interface") ;
101 tRes
.tested("createAdapter()", false) ;