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