Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / reflection / _XProxyFactory.java
blob4943a5909b3cf0a3620c1230614b0301cea9f55b
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 ************************************************************************/
28 package ifc.reflection;
30 import lib.MultiMethodTest;
32 import com.sun.star.lang.XInitialization;
33 import com.sun.star.reflection.XProxyFactory;
34 import com.sun.star.uno.UnoRuntime;
35 import com.sun.star.uno.XAggregation;
37 /**
38 /**
39 * Testing <code>com.sun.star.reflection.XProxyFactory</code>
40 * interface methods :
41 * <ul>
42 * <li><code> createProxy()</code></li>
43 * </ul> <p>
44 * Test is <b> NOT </b> multithread compilant. <p>
45 * @see com.sun.star.reflection.XProxyFactory
47 public class _XProxyFactory extends MultiMethodTest {
48 /** Is initialized in super class(using reflection API)
49 * when instantiating the test.
51 public XProxyFactory oObj;
53 /**
54 * First an implementation of
55 * <code>com.sun.star.lang.XInitialization</code> interface
56 * is made which sets a flag when its <code>initialize()</code>
57 * method is called. Then an instance of this implementation
58 * is created and a proxy object is created for it. Proxy
59 * object is tried to query for <code>XInitialization</code>
60 * interface and it's <code>initialize</code> method is
61 * called. The goal is to check if the real object method
62 * was called throwgh it's proxy. <p>
63 * Has <b>OK</b> status if the real object method was
64 * called and parameters were passed correctly.
66 public void _createProxy() {
67 class MyObject implements XInitialization {
68 Object[] params;
70 public void initialize(Object args[]) {
71 params = args;
75 MyObject obj = new MyObject();
77 XAggregation xAggr = oObj.createProxy(obj);
79 XInitialization xInit = (XInitialization)UnoRuntime.queryInterface(
80 XInitialization.class, xAggr);
82 Object params[] = new Object[0];
84 try {
85 xInit.initialize(params);
86 } catch(com.sun.star.uno.Exception e) {
87 log.println("Unexpected exception : " + e.getMessage());
88 e.printStackTrace(log);
89 tRes.tested("createProxy()", false);
90 return;
93 tRes.tested("createProxy()",
94 util.ValueComparer.equalValue(params, obj.params));