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
;
30 * Testing <code>com.sun.star.reflection.XProxyFactory</code>
33 * <li><code> createProxy()</code></li>
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
;
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 through its 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
{
61 public void initialize(Object 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];
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);
84 tRes
.tested("createProxy()",
85 util
.ValueComparer
.equalValue(params
, obj
.params
));