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
.XEnumeration
;
25 import com
.sun
.star
.lang
.WrappedTargetException
;
28 * Testing <code>com.sun.star.container.XEnumeration</code>
31 * <li><code> hasMoreElements()</code></li>
32 * <li><code> nextElement()</code></li>
34 * Test is multithread compliant. <p>
35 * @see com.sun.star.container.XEnumeration
37 public class _XEnumeration
extends MultiMethodTest
{
39 public XEnumeration oObj
= null;
42 * Retrieves relation and sets oObj to a separate enumeration
43 * created. Retrieves all elements from enumeration.<p>
44 * Has <b> OK </b> status if all elements successfully retrieved
45 * and exceptions occurred.
47 public void _hasMoreElements() {
48 boolean result
= true;
50 log
.println("get all elements");
53 while ( oObj
.hasMoreElements() ) {
57 if (counter
- tmpCounter
> 10000) {
58 log
.println(counter
+ " Elements");
61 } catch (WrappedTargetException e
) {
62 log
.println("hasMoreElements() : " + e
);
65 } catch (NoSuchElementException e
) {
66 log
.println("hasMoreElements() : " + e
);
71 Object expCount
= tEnv
.getObjRelation("ExpectedCount");
72 if (expCount
!= null) {
73 int ec
= ((Integer
) expCount
).intValue();
74 boolean locResult
= counter
== ec
;
76 log
.println("Not all Elements are returned: ");
77 log
.println("\tExpected: "+ ec
);
78 log
.println("\tFound: "+counter
);
82 tRes
.tested("hasMoreElements()", result
);
83 } // end hasMoreElements
86 * Calls the method (on starting this method there is no more elements
87 * in the enumeration. <p>
88 * Has <b> OK </b> status if only <code>NoSuchElementException</code>
89 * exception rises. <p>
90 * The following method tests are to be completed successfully before :
92 * <li> <code> hasMoreElements() </code> : it retrieves all elements </li>
95 public void _nextElement(){
96 requiredMethod("hasMoreElements()");
97 boolean result
= true;
98 log
.println("additional call must throw NoSuchElementException");
102 log
.println("nextElement: no exception!");
104 } catch (WrappedTargetException e
) {
105 log
.println("nextElement: wrong exception!");
107 } catch (NoSuchElementException e
) {
108 log
.println("nextElement: correct exception");
111 tRes
.tested("nextElement()", result
);