1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 package ifc.reflection; 29 30 import lib.MultiMethodTest; 31 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; 36 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 46 */ 47 public class _XProxyFactory extends MultiMethodTest { 48 /** Is initialized in super class(using reflection API) 49 * when instantiating the test. 50 */ 51 public XProxyFactory oObj; 52 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 paramters were passed correctly. 65 */ 66 public void _createProxy() { 67 class MyObject implements XInitialization { 68 Object[] params; 69 70 public void initialize(Object args[]) { 71 params = args; 72 } 73 } 74 75 MyObject obj = new MyObject(); 76 77 XAggregation xAggr = oObj.createProxy(obj); 78 79 XInitialization xInit = (XInitialization)UnoRuntime.queryInterface( 80 XInitialization.class, xAggr); 81 82 Object params[] = new Object[0]; 83 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; 91 } 92 93 tRes.tested("createProxy()", 94 util.ValueComparer.equalValue(params, obj.params)); 95 } 96 } 97 98