1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc
.container
;
30 import lib
.MultiMethodTest
;
32 import com
.sun
.star
.container
.XSet
;
33 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 * Testing <code>com.sun.star.container.XSet</code>
39 * <li><code> has()</code></li>
40 * <li><code> insert()</code></li>
41 * <li><code> remove()</code></li>
43 * Test is <b> NOT </b> multithread compilant. <p>
44 * @see com.sun.star.container.XSet
46 public class _XSet
extends MultiMethodTest
{
48 public static XSet oObj
= null;
50 private Object element
= null ;
51 private boolean hasResult
= true ;
54 * Inserts the element stored and removed before. <p>
55 * Has <b> OK </b> status if <code>has()</code> method returns
57 * The following method tests are to be completed successfully before :
59 * <li> <code> remove() </code> : element from set is stored and
63 public void _insert() {
66 XMultiServiceFactory xMSF
= (XMultiServiceFactory
)tParam
.getMSF();
67 element
= xMSF
.createInstance(
68 "com.sun.star.reflection.TypeDescriptionProvider");
71 oObj
.insert(element
) ;
73 if (!oObj
.has(element
)) {
75 log
.println("After adding element method has()" +
79 } catch (com
.sun
.star
.container
.ElementExistException e
) {
80 e
.printStackTrace(log
) ;
82 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
83 e
.printStackTrace(log
) ;
86 catch(com
.sun
.star
.uno
.Exception e
) {
87 e
.printStackTrace(log
);
91 tRes
.tested("insert()", res
) ;
95 * Through <code>XEnumeration</code> interface an element from the set
96 * is retrieved. Then this element removed.<p>
97 * Has <b> OK </b> status if after removing <code>has()</code> method
100 public void _remove() {
101 requiredMethod("insert()");
106 // get an element to be removed/inserted
108 oObj
.remove(element
) ;
110 if (oObj
.has(element
)) {
112 log
.println("After removing element method has()" +
119 } catch (com
.sun
.star
.container
.NoSuchElementException e
) {
120 e
.printStackTrace(log
) ;
122 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
123 e
.printStackTrace(log
) ;
127 tRes
.tested("remove()", res
) ;
131 * Does nothing. Testing performed in previous methods.<p>
132 * Has <b> OK </b> status if after <code>remove()</code> call
133 * methods returned <code>false</code>, and after <code>remove()</code>
134 * call methods returned <code>true</code>.
135 * The following method tests are to be completed successfully before :
137 * <li> <code> insert() </code> : here the method is checked </li>
138 * <li> <code> remove() </code> : here the method is checked </li>
143 requiredMethod("insert()") ;
144 requiredMethod("remove()") ;
146 tRes
.tested("has()", hasResult
) ;
149 } // finished class _XSet