1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XProxyFactory.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc
.reflection
;
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.lang
.XInitialization
;
36 import com
.sun
.star
.reflection
.XProxyFactory
;
37 import com
.sun
.star
.uno
.UnoRuntime
;
38 import com
.sun
.star
.uno
.XAggregation
;
42 * Testing <code>com.sun.star.reflection.XProxyFactory</code>
45 * <li><code> createProxy()</code></li>
47 * Test is <b> NOT </b> multithread compilant. <p>
48 * @see com.sun.star.reflection.XProxyFactory
50 public class _XProxyFactory
extends MultiMethodTest
{
51 /** Is initialized in super class(using reflection API)
52 * when instantiating the test.
54 public XProxyFactory oObj
;
57 * First an implementation of
58 * <code>com.sun.star.lang.XInitialization</code> interface
59 * is made which sets a flag when its <code>initialize()</code>
60 * method is called. Then an instance of this implementation
61 * is created and a proxy object is created for it. Proxy
62 * object is tried to query for <code>XInitialization</code>
63 * interface and it's <code>initialize</code> method is
64 * called. The goal is to check if the real object method
65 * was called throwgh it's proxy. <p>
66 * Has <b>OK</b> status if the real object method was
67 * called and paramters were passed correctly.
69 public void _createProxy() {
70 class MyObject
implements XInitialization
{
73 public void initialize(Object args
[]) {
78 MyObject obj
= new MyObject();
80 XAggregation xAggr
= oObj
.createProxy(obj
);
82 XInitialization xInit
= (XInitialization
)UnoRuntime
.queryInterface(
83 XInitialization
.class, xAggr
);
85 Object params
[] = new Object
[0];
88 xInit
.initialize(params
);
89 } catch(com
.sun
.star
.uno
.Exception e
) {
90 log
.println("Unexpected exception : " + e
.getMessage());
91 e
.printStackTrace(log
);
92 tRes
.tested("createProxy()", false);
96 tRes
.tested("createProxy()",
97 util
.ValueComparer
.equalValue(params
, obj
.params
));