1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package com.sun.star.lib.uno.bridges.javaremote; 25 26 import com.sun.star.bridge.XInstanceProvider; 27 import com.sun.star.lib.TestBed; 28 import com.sun.star.lib.uno.typeinfo.MethodTypeInfo; 29 import com.sun.star.lib.uno.typeinfo.TypeInfo; 30 import com.sun.star.uno.UnoRuntime; 31 import com.sun.star.uno.XComponentContext; 32 import com.sun.star.uno.XInterface; 33 import complexlib.ComplexTestCase; 34 35 public final class Bug92174_Test extends ComplexTestCase { getTestMethodNames()36 public String[] getTestMethodNames() { 37 return new String[] { "test" }; 38 } 39 test()40 public void test() throws Exception { 41 assure("test", 42 new TestBed().execute(new Provider(), false, Client.class, 0)); 43 } 44 45 public static final class Client extends TestBed.Client { main(String[] args)46 public static void main(String[] args) { 47 new Client().execute(); 48 } 49 run(XComponentContext context)50 protected boolean run(XComponentContext context) throws Throwable { 51 XTransport t = UnoRuntime.queryInterface( 52 XTransport.class, getBridge(context).getInstance("Transport")); 53 t.setDerived(new XDerived() { 54 public void fn() {} 55 }); 56 t.getBase().fn(); 57 return true; 58 } 59 } 60 61 private static final class Provider implements XInstanceProvider { getInstance(String instanceName)62 public Object getInstance(String instanceName) { 63 return new XTransport() { 64 public XBase getBase() { 65 return derived; 66 } 67 68 public synchronized void setDerived(XDerived derived) { 69 this.derived = derived; 70 } 71 72 private XDerived derived = null; 73 }; 74 } 75 } 76 77 public interface XBase extends XInterface { 78 void fn(); 79 80 TypeInfo[] UNOTYPEINFO = { new MethodTypeInfo("fn", 0, 0) }; 81 } 82 83 public interface XDerived extends XBase { 84 TypeInfo[] UNOTYPEINFO = null; 85 } 86 87 public interface XTransport extends XInterface { 88 XBase getBase(); 89 90 void setDerived(XDerived derived); 91 92 TypeInfo[] UNOTYPEINFO = { new MethodTypeInfo("getBase", 0, 0), 93 new MethodTypeInfo("setDerived", 1, 0) }; 94 } 95 } 96