bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / uno / _XNamingService.java
blob38f96cb55cb586dce5548f99c87913012f8b3fea
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 compilant. <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 public void before() {
50 regObject = (XInterface)
51 tEnv.getObjRelation("XNamingService.RegisterObject") ;
52 if (regObject == null)
53 throw new StatusException("Can't create object to register",
54 new NullPointerException()) ;
57 /**
58 * Test calls the method and checks that
59 * no exceptions were thrown. <p>
60 * Has <b> OK </b> status if the method successfully returns
61 * and no exceptions were thrown. <p>
62 * The following method tests are to be completed successfully before :
64 public void _registerObject() throws StatusException{
65 try {
66 oObj.registerObject("MyFactory", regObject) ;
67 } catch (com.sun.star.uno.Exception e) {
68 log.println("Exception while registering object :" + e) ;
69 tRes.tested("registerObject()", false) ;
70 return ;
73 tRes.tested("registerObject()", true) ;
76 /**
77 * Test calls the method and checks return value and that
78 * no exceptions were thrown. <p>
79 * Has <b> OK </b> status if the method returns the same object
80 * that was registered and no exceptions were thrown. <p>
81 * The following method tests are to be completed successfully before :
82 * <ul>
83 * <li> <code> registerObject </code> : to get in this test the
84 * object that was registered.</li>
85 * </ul>
87 public void _getRegisteredObject() {
88 requiredMethod("registerObject()") ;
90 try {
91 Object getObject = oObj.getRegisteredObject("MyFactory") ;
93 tRes.tested("getRegisteredObject()" ,
94 regObject.equals(getObject)) ;
95 } catch (com.sun.star.uno.Exception e) {
96 log.println("Exception calling method :" + e) ;
97 tRes.tested("getRegisteredObject()", false) ;
98 return ;
103 * Test calls the method and trying to get revoked object. <p>
104 * Has <b> OK </b> status if the method successfully returns
105 * and if the method <code>getRegisteredObject</code> returns NULL or
106 * throws expected exception. <p>
107 * The following method tests are to be completed successfully before :
108 * <ul>
109 * <li> <code> registerObject </code> : to revoke the object registered</li>
110 * </ul>
111 * The following method tests are to be executed before :
112 * <ul>
113 * <li> <code> getRegisteredObject </code> : before object will be
114 * revoked </li>
115 * </ul>
117 public void _revokeObject() {
118 requiredMethod("registerObject()") ;
119 executeMethod("getRegisteredObject()") ;
121 try {
122 oObj.revokeObject("MyFactory");
123 log.println("Object was revoked");
124 } catch (com.sun.star.uno.Exception e) {
125 log.println("Exception revoking object :" + e) ;
126 tRes.tested("revokeObject()", false) ;
129 boolean res = true;
131 try {
132 log.println("Trying to getRegistered object ...");
133 Object objregObj = oObj.getRegisteredObject("MyFactory");
134 log.println("No exception");
135 res &= objregObj == null;
136 if (res) {
137 log.println("But NULL was returned");
139 } catch(com.sun.star.uno.Exception e) {
140 log.println("Expected exception - OK");
143 tRes.tested("revokeObject()", res);