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.XBridgeFactory; 27 import com.sun.star.bridge.XInstanceProvider; 28 import com.sun.star.connection.Connector; 29 import com.sun.star.connection.XConnection; 30 import com.sun.star.lib.TestBed; 31 import com.sun.star.uno.UnoRuntime; 32 import com.sun.star.uno.XComponentContext; 33 import com.sun.star.uno.XInterface; 34 import complexlib.ComplexTestCase; 35 import util.WaitUnreachable; 36 37 /** 38 * Test case for bug #i51323#. 39 * 40 * <p>Bug #i51323# "jurt: BridgeFactory.createBridge creates bridge names." 41 * Make sure that multiple calls to BridgeFactory.getBridge with empty names 42 * create different bridges.</p> 43 */ 44 public final class Bug51323_Test extends ComplexTestCase { getTestMethodNames()45 public String[] getTestMethodNames() { 46 return new String[] { "test" }; 47 } 48 test()49 public void test() throws Exception { 50 assure( 51 "test", 52 new TestBed().execute(new Provider(), false, Client.class, 0)); 53 } 54 55 public static final class Client extends TestBed.Client { main(String[] args)56 public static void main(String[] args) { 57 new Client().execute(); 58 } 59 run(XComponentContext context)60 protected boolean run(XComponentContext context) throws Throwable { 61 XConnection connection = 62 Connector.create(context).connect(getConnectionDescription()); 63 XBridgeFactory factory = UnoRuntime.queryInterface( 64 XBridgeFactory.class, 65 context.getServiceManager().createInstanceWithContext( 66 "com.sun.star.bridge.BridgeFactory", context)); 67 return !UnoRuntime.areSame( 68 factory.createBridge( 69 "", getProtocolDescription(), connection, null), 70 factory.createBridge( 71 "", getProtocolDescription(), connection, null)); 72 } 73 } 74 75 private static final class Provider implements XInstanceProvider { getInstance(String instanceName)76 public Object getInstance(String instanceName) { 77 return new XInterface() {}; 78 } 79 } 80 } 81