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