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.uno.XComponentContext;
29 import com.sun.star.uno.XInterface;
30 import complexlib.ComplexTestCase;
31 import util.WaitUnreachable;
32 
33 /**
34  * Test case for bug #114133#.
35  *
36  * <p>Bug #114133# "Java UNO: UnoRuntime.getBride and disposed bridges."  The
37  * client calls UnoRuntime.getBridge to get a bridge to the server, uses the
38  * bridge, waits until it terminates itself (when all bridged objects have been
39  * garbage-collected), then calls UnoRuntime.getBridge again.  This must return
40  * a fresh, unterminated bridge.</p>
41  */
42 public final class Bug114133_Test extends ComplexTestCase {
getTestMethodNames()43     public String[] getTestMethodNames() {
44         return new String[] { "test" };
45     }
46 
test()47     public void test() throws Exception {
48         assure(
49             "test",
50             new TestBed().execute(new Provider(), false, Client.class, 0));
51     }
52 
53     public static final class Client extends TestBed.Client {
main(String[] args)54         public static void main(String[] args) {
55             new Client().execute();
56         }
57 
run(XComponentContext context)58         protected boolean run(XComponentContext context) throws Throwable {
59             new WaitUnreachable(getBridge(context).getInstance("Test")).
60                 waitUnreachable();
61             new WaitUnreachable(getBridge(context).getInstance("Test")).
62                 waitUnreachable();
63             return true;
64         }
65     }
66 
67     private static final class Provider implements XInstanceProvider {
getInstance(String instanceName)68         public Object getInstance(String instanceName) {
69             return new XInterface() {};
70         }
71     }
72 }
73