tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / uno / _XNamingService.java
blobe2469d13898527347a33e26aa87fca9b9948d98c
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 ifc.uno;
21 import lib.MultiMethodTest;
22 import lib.StatusException;
24 import com.sun.star.uno.XInterface;
25 import com.sun.star.uno.XNamingService;
28 /**
29 * Testing <code>com.sun.star.uno.XNamingService</code>
30 * interface methods. <p>
31 * This test need the following object relations :
32 * <ul>
33 * <li> <code>'XNamingService.RegisterObject'</code> :
34 * object to be registered.</li>
35 * <ul> <p>
36 * Test is <b> NOT </b> multithread compliant. <p>
37 * After test completion object environment has to be recreated.
39 public class _XNamingService extends MultiMethodTest {
41 public static XNamingService oObj = null;
43 private XInterface regObject = null ;
45 /**
46 * Retrieves object relation.
47 * @throws StatusException If the relation not found.
49 @Override
50 public void before() {
51 regObject = (XInterface)
52 tEnv.getObjRelation("XNamingService.RegisterObject") ;
53 if (regObject == null)
54 throw new StatusException("Can't create object to register",
55 new NullPointerException()) ;
58 /**
59 * Test calls the method and checks that
60 * no exceptions were thrown. <p>
61 * Has <b> OK </b> status if the method successfully returns
62 * and no exceptions were thrown. <p>
63 * The following method tests are to be completed successfully before :
65 public void _registerObject() throws StatusException{
66 try {
67 oObj.registerObject("MyFactory", regObject) ;
68 } catch (com.sun.star.uno.Exception e) {
69 log.println("Exception while registering object :" + e) ;
70 tRes.tested("registerObject()", false) ;
71 return ;
74 tRes.tested("registerObject()", true) ;
77 /**
78 * Test calls the method and checks return value and that
79 * no exceptions were thrown. <p>
80 * Has <b> OK </b> status if the method returns the same object
81 * that was registered and no exceptions were thrown. <p>
82 * The following method tests are to be completed successfully before :
83 * <ul>
84 * <li> <code> registerObject </code> : to get in this test the
85 * object that was registered.</li>
86 * </ul>
88 public void _getRegisteredObject() {
89 requiredMethod("registerObject()") ;
91 try {
92 Object getObject = oObj.getRegisteredObject("MyFactory") ;
94 tRes.tested("getRegisteredObject()" ,
95 regObject.equals(getObject)) ;
96 } catch (com.sun.star.uno.Exception e) {
97 log.println("Exception calling method :" + e) ;
98 tRes.tested("getRegisteredObject()", false) ;
99 return ;
104 * Test calls the method and trying to get revoked object. <p>
105 * Has <b> OK </b> status if the method successfully returns
106 * and if the method <code>getRegisteredObject</code> returns NULL or
107 * throws expected exception. <p>
108 * The following method tests are to be completed successfully before :
109 * <ul>
110 * <li> <code> registerObject </code> : to revoke the object registered</li>
111 * </ul>
112 * The following method tests are to be executed before :
113 * <ul>
114 * <li> <code> getRegisteredObject </code> : before object will be
115 * revoked </li>
116 * </ul>
118 public void _revokeObject() {
119 requiredMethod("registerObject()") ;
120 executeMethod("getRegisteredObject()") ;
122 try {
123 oObj.revokeObject("MyFactory");
124 log.println("Object was revoked");
125 } catch (com.sun.star.uno.Exception e) {
126 log.println("Exception revoking object :" + e) ;
127 tRes.tested("revokeObject()", false) ;
130 boolean res = true;
132 try {
133 log.println("Trying to getRegistered object ...");
134 Object objregObj = oObj.getRegisteredObject("MyFactory");
135 log.println("No exception");
136 res &= objregObj == null;
137 if (res) {
138 log.println("But NULL was returned");
140 } catch(com.sun.star.uno.Exception e) {
141 log.println("Expected exception - OK");
144 tRes.tested("revokeObject()", res);