xref: /AOO41X/main/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java (revision 2be432768a66cc90838f6a32e76ec156f587e741)
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 import complexlib.ComplexTestCase;
29 
30 public final class java_environment_Test extends ComplexTestCase {
getTestObjectName()31     public String getTestObjectName() {
32         return getClass().getName();
33     }
34 
getTestMethodNames()35     public String[] getTestMethodNames() {
36         return new String[] { "test" };
37     }
38 
test()39     public void test() {
40         java_environment env = new java_environment(null);
41 
42         Object obj = new Integer(3);
43         String[] oid = new String[1];
44 
45         Object obj2 = env.registerInterface(obj, oid,
46                                             new Type(XInterface.class));
47         Object obj3 = env.registerInterface(obj, oid,
48                                             new Type(XInterface.class));
49         assure("register ordinary interface twice",
50                obj2 == obj && obj3 == obj);
51 
52         assure("ask for registered interface",
53                env.getRegisteredInterface(oid[0], new Type(XInterface.class))
54                == obj);
55 
56         env.revokeInterface(oid[0], new Type(XInterface.class));
57         env.revokeInterface(oid[0], new Type(XInterface.class));
58         assure("revoke interface",
59                env.getRegisteredInterface(oid[0], new Type(XInterface.class))
60                == null);
61     }
62 }
63