xref: /trunk/main/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java (revision 3309286857f19787ae62bd793a98b5af4edd2ad3)
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.environments.java;
25 
26 import com.sun.star.uno.Type;
27 import com.sun.star.uno.XInterface;
28 
29 import org.junit.Test;
30 import static org.junit.Assert.*;
31 
32 public final class java_environment_Test {
33     @Test
test()34     public void test() {
35         java_environment env = new java_environment(null);
36 
37         Object obj = new Integer(3);
38         String[] oid = new String[1];
39 
40         Object obj2 = env.registerInterface(obj, oid,
41                                             new Type(XInterface.class));
42         Object obj3 = env.registerInterface(obj, oid,
43                                             new Type(XInterface.class));
44         assertTrue("register ordinary interface twice",
45                obj2 == obj && obj3 == obj);
46 
47         assertTrue("ask for registered interface",
48                env.getRegisteredInterface(oid[0], new Type(XInterface.class))
49                == obj);
50 
51         env.revokeInterface(oid[0], new Type(XInterface.class));
52         env.revokeInterface(oid[0], new Type(XInterface.class));
53         assertTrue("revoke interface",
54                env.getRegisteredInterface(oid[0], new Type(XInterface.class))
55                == null);
56     }
57 }
58