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 ifc.container; 25 26 import lib.MultiMethodTest; 27 28 import com.sun.star.container.NoSuchElementException; 29 import com.sun.star.container.XHierarchicalNameAccess; 30 31 /** 32 * Testing <code>com.sun.star.container.XHierarchicalNameAccess</code> 33 * interface methods : 34 * <ul> 35 * <li><code> getByHierarchicalName()</code></li> 36 * <li><code> hasByHierarchicalName()</code></li> 37 * </ul> <p> 38 * This test needs the following object relations : 39 * <ul> 40 * <li> <code>'ElementName'</code> (of type <code>String</code>): 41 * name of the element which exists in the container. </li> 42 * <ul> <p> 43 * Test is <b> NOT </b> multithread compilant. <p> 44 * @see com.sun.star.container.XHierarchicalNameAccess 45 */ 46 public class _XHierarchicalNameAccess extends MultiMethodTest{ 47 public XHierarchicalNameAccess oObj = null; 48 49 /** 50 * Calls the method with existing and nonexisting 51 * element names. <p> 52 * Has <b>OK</b> status if for existing name <code>true</code> 53 * is returned and for nonexisting - <code>false</code>. 54 */ _hasByHierarchicalName()55 public void _hasByHierarchicalName(){ 56 String name = (String) tEnv.getObjRelation("ElementName") ; 57 boolean res = oObj.hasByHierarchicalName(name) ; 58 name +="ItMakesThisNameNonExistantForSure"; 59 boolean res2 = oObj.hasByHierarchicalName(name); 60 res &= !res2; 61 tRes.tested("hasByHierarchicalName()", res) ; 62 } // end _hasByHierarchicalName() 63 64 /** 65 * Tries to retrieve an element with existing name. <p> 66 * Has <b>OK</b> status if non null object is returned. 67 */ _getByHierarchicalName()68 public void _getByHierarchicalName(){ 69 String name = (String) tEnv.getObjRelation("ElementName") ; 70 Object res ; 71 72 try { 73 res = oObj.getByHierarchicalName(name) ; 74 75 } catch (NoSuchElementException e) { 76 log.println("Element with name '" + name + 77 "' doesn't exist in this container") ; 78 res = null ; 79 } 80 81 tRes.tested("getByHierarchicalName()", res != null) ; 82 83 } // end _getByHierarchicalName() 84 85 } // finish class _XHierarchicalNameAccess 86 87 88 89