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 34 import org.junit.Test; 35 import static org.junit.Assert.*; 36 37 public final class Bug92174_Test { 38 @Test test()39 public void test() throws Exception { 40 assertTrue("test", 41 new TestBed().execute(new Provider(), false, Client.class, 0)); 42 } 43 44 public static final class Client extends TestBed.Client { main(String[] args)45 public static void main(String[] args) { 46 new Client().execute(); 47 } 48 run(XComponentContext context)49 protected boolean run(XComponentContext context) throws Throwable { 50 XTransport t = UnoRuntime.queryInterface( 51 XTransport.class, getBridge(context).getInstance("Transport")); 52 t.setDerived(new XDerived() { 53 public void fn() {} 54 }); 55 t.getBase().fn(); 56 return true; 57 } 58 } 59 60 private static final class Provider implements XInstanceProvider { getInstance(String instanceName)61 public Object getInstance(String instanceName) { 62 return new XTransport() { 63 public XBase getBase() { 64 return derived; 65 } 66 67 public synchronized void setDerived(XDerived derived) { 68 this.derived = derived; 69 } 70 71 private XDerived derived = null; 72 }; 73 } 74 } 75 76 public interface XBase extends XInterface { 77 void fn(); 78 79 TypeInfo[] UNOTYPEINFO = { new MethodTypeInfo("fn", 0, 0) }; 80 } 81 82 public interface XDerived extends XBase { 83 TypeInfo[] UNOTYPEINFO = null; 84 } 85 86 public interface XTransport extends XInterface { 87 XBase getBase(); 88 89 void setDerived(XDerived derived); 90 91 TypeInfo[] UNOTYPEINFO = { new MethodTypeInfo("getBase", 0, 0), 92 new MethodTypeInfo("setDerived", 1, 0) }; 93 } 94 } 95