/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: Bug92174_Test.java,v $
*
* $Revision: 1.6 $
*
* last change: $Author: ihi $ $Date: 2007/11/23 13:08:25 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
package com.sun.star.lib.uno.bridges.javaremote;
import com.sun.star.bridge.XInstanceProvider;
import com.sun.star.lib.TestBed;
import com.sun.star.lib.uno.typeinfo.MethodTypeInfo;
import com.sun.star.lib.uno.typeinfo.TypeInfo;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.XInterface;
import complexlib.ComplexTestCase;
public final class Bug92174_Test extends ComplexTestCase {
public String[] getTestMethodNames() {
return new String[] { "test" };
}
public void test() throws Exception {
assure("test",
new TestBed().execute(new Provider(), false, Client.class, 0));
}
public static final class Client extends TestBed.Client {
public static void main(String[] args) {
new Client().execute();
}
protected boolean run(XComponentContext context) throws Throwable {
XTransport t = (XTransport) UnoRuntime.queryInterface(
XTransport.class, getBridge(context).getInstance("Transport"));
t.setDerived(new XDerived() {
public void fn() {}
});
t.getBase().fn();
return true;
}
}
private static final class Provider implements XInstanceProvider {
public Object getInstance(String instanceName) {
return new XTransport() {
public XBase getBase() {
return derived;
}
public synchronized void setDerived(XDerived derived) {
this.derived = derived;
}
private XDerived derived = null;
};
}
}
public interface XBase extends XInterface {
void fn();
TypeInfo[] UNOTYPEINFO = { new MethodTypeInfo("fn", 0, 0) };
}
public interface XDerived extends XBase {
TypeInfo[] UNOTYPEINFO = null;
}
public interface XTransport extends XInterface {
XBase getBase();
void setDerived(XDerived derived);
TypeInfo[] UNOTYPEINFO = { new MethodTypeInfo("getBase", 0, 0),
new MethodTypeInfo("setDerived", 1, 0) };
}
}