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