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 package ifc.uno;
24 
25 import lib.MultiMethodTest;
26 import util.ValueComparer;
27 
28 import com.sun.star.lang.XMultiComponentFactory;
29 import com.sun.star.uno.UnoRuntime;
30 import com.sun.star.uno.XComponentContext;
31 
32 
33 public class _XComponentContext extends MultiMethodTest {
34     public XComponentContext oObj;
35     protected XMultiComponentFactory byValue = null;
36     protected XMultiComponentFactory directly = null;
37 
_getServiceManager()38     public void _getServiceManager() {
39         log.println("getting manager");
40 
41         directly = oObj.getServiceManager();
42         String[] names = directly.getAvailableServiceNames();
43         boolean res = true;
44 
45         for (int i = 0; i < names.length; i++) {
46             try {
47                 if (names[i].equals("com.sun.star.i18n.ConversionDictionary_ko")) continue;
48                 if (names[i].equals("com.sun.star.i18n.TextConversion_ko")) continue;
49                 log.println("try to instanciate found servicename " +
50                             names[i]);
51                 directly.createInstanceWithContext(names[i], oObj);
52                 log.println("worked .... ok");
53                 res &= true;
54             } catch (com.sun.star.uno.Exception e) {
55                 log.println("Exception occurred " + e.getMessage());
56                 res &= false;
57             }
58         }
59 
60         tRes.tested("getServiceManager()", res);
61     }
62 
_getValueByName()63     public void _getValueByName() {
64         requiredMethod("getServiceManager()");
65 
66         Object value = oObj.getValueByName(
67                                "/singletons/com.sun.star.lang.theServiceManager");
68         byValue = (XMultiComponentFactory) UnoRuntime.queryInterface(
69                           XMultiComponentFactory.class, value);
70 
71         String[] vNames = byValue.getAvailableServiceNames();
72         String[] dNames = directly.getAvailableServiceNames();
73 
74         boolean res = ValueComparer.equalValue(byValue, directly);
75         tRes.tested("getValueByName()", res);
76     }
77 }