fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / jurt / test / com / sun / star / uno / UnoRuntime_EnvironmentTest.java
blob1e91a19412317b42c5972ce0d92dd40f382c70be
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package com.sun.star.uno;
21 import com.sun.star.comp.connections.PipedConnection;
22 import org.junit.Test;
23 import util.WaitUnreachable;
24 import static org.junit.Assert.*;
26 public final class UnoRuntime_EnvironmentTest {
27 @Test public void test_getEnvironment() throws java.lang.Exception {
28 Object o1 = new Object();
29 Object o2 = new Object();
31 // get two environments with different contexts
32 WaitUnreachable java_environment1 = new WaitUnreachable(
33 UnoRuntime.getEnvironment("java", o1));
34 WaitUnreachable java_environment2 = new WaitUnreachable(
35 UnoRuntime.getEnvironment("java", o2));
37 // ensure that the environments are different
38 assertNotSame(java_environment1.get(), java_environment2.get());
40 // test if we get the same environment when we reget it
41 assertTrue(
42 UnoRuntime.areSame(
43 java_environment1.get(),
44 UnoRuntime.getEnvironment("java", o1)));
45 assertTrue(
46 UnoRuntime.areSame(
47 java_environment2.get(),
48 UnoRuntime.getEnvironment("java", o2)));
50 // drop the environments and wait until they are gc
51 java_environment1.waitUnreachable();
52 java_environment2.waitUnreachable();
55 @Test public void test_getBridge() throws java.lang.Exception {
56 PipedConnection conn = new PipedConnection(new Object[0]);
57 new PipedConnection(new Object[] { conn });
59 // get a bridge
60 IBridge iBridge = UnoRuntime.getBridgeByName(
61 "java", null, "remote", "testname",
62 new Object[] { "urp", conn, null });
64 // reget the bridge, it must be the same as above
65 IBridge iBridge_tmp = UnoRuntime.getBridgeByName(
66 "java", null, "remote", "testname",
67 new Object[] { "urp", conn, null });
68 assertTrue(UnoRuntime.areSame(iBridge_tmp, iBridge));
70 // dispose the bridge, this removes the entry from the runtime
71 iBridge.dispose();
73 conn = new PipedConnection(new Object[0]);
74 new PipedConnection(new Object[] { conn });
76 // reget the bridge, it must be a different one
77 iBridge_tmp = UnoRuntime.getBridgeByName(
78 "java", null, "remote", "testname",
79 new Object[]{ "urp", conn, null });
80 assertFalse(UnoRuntime.areSame(iBridge_tmp, iBridge));