1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
31 import lib
.StatusException
;
33 import com
.sun
.star
.io
.XInputStream
;
34 import com
.sun
.star
.lang
.XMultiServiceFactory
;
35 import com
.sun
.star
.lang
.XSingleServiceFactory
;
36 import com
.sun
.star
.script
.XInvocation
;
37 import com
.sun
.star
.script
.XInvocationAdapterFactory
;
38 import com
.sun
.star
.uno
.Type
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
40 import com
.sun
.star
.uno
.XInterface
;
43 * Testing <code>com.sun.star.script.XInvocationAdapterFactory</code>
46 * <li><code> createAdapter()</code></li>
48 * Test is <b> NOT </b> multithread compilant. <p>
49 * @see com.sun.star.script.XInvocationAdapterFactory
51 public class _XInvocationAdapterFactory
extends MultiMethodTest
{
54 * oObj filled by MultiMethodTest
56 public XInvocationAdapterFactory oObj
= null;
59 * First an invocation object of <code>com.sun.star.io.Pipe</code>
60 * instance is created using <code>com.sun.star.script.Invocation
61 * </code> service. Then trying to create an adapter of this
62 * invocation for <code>com.sun.star.io.XInputStream</code>
64 * Has <b>OK</b> status if the adapter returned is successfully
65 * queried for <code>com.sun.star.io.XInputStream</code>
67 * @see com.sun.star.script.Invocation
68 * @see com.sun.star.script.XInvocation
69 * @see com.sun.star.io.Pipe
71 public void _createAdapter() {
72 XInvocation xInv
= null ;
73 XMultiServiceFactory xMSF
= null;
75 xMSF
= (XMultiServiceFactory
)tParam
.getMSF();
76 Object
[] args
= {xMSF
.createInstance
77 ("com.sun.star.io.Pipe")};
79 Object oInvFac
= xMSF
.createInstance
80 ("com.sun.star.script.Invocation") ;
82 XSingleServiceFactory xInvFac
= (XSingleServiceFactory
) UnoRuntime
.
83 queryInterface(XSingleServiceFactory
.class, oInvFac
) ;
85 Object oInv
= xInvFac
.createInstanceWithArguments(args
) ;
87 xInv
= (XInvocation
) UnoRuntime
.queryInterface
88 (XInvocation
.class, oInv
) ;
90 } catch (com
.sun
.star
.uno
.Exception e
) {
91 e
.printStackTrace(log
) ;
92 throw new StatusException("Cann't create invocation for object", e
) ;
95 XInterface xInStr
= null ;
97 Object adp
= oObj
.createAdapter(xInv
,
98 new Type(XInputStream
.class)) ;
100 xInStr
= (XInterface
) UnoRuntime
.queryInterface
101 (XInputStream
.class, adp
) ;
105 tRes
.tested("createAdapter()", true) ;
107 log
.println("Adapter created doesn't implement required interface") ;
108 tRes
.tested("createAdapter()", false) ;