1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XSet.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc
.container
;
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.container
.XSet
;
36 import com
.sun
.star
.lang
.XMultiServiceFactory
;
39 * Testing <code>com.sun.star.container.XSet</code>
42 * <li><code> has()</code></li>
43 * <li><code> insert()</code></li>
44 * <li><code> remove()</code></li>
46 * Test is <b> NOT </b> multithread compilant. <p>
47 * @see com.sun.star.container.XSet
49 public class _XSet
extends MultiMethodTest
{
51 public static XSet oObj
= null;
53 private Object element
= null ;
54 private boolean hasResult
= true ;
57 * Inserts the element stored and removed before. <p>
58 * Has <b> OK </b> status if <code>has()</code> method returns
60 * The following method tests are to be completed successfully before :
62 * <li> <code> remove() </code> : element from set is stored and
66 public void _insert() {
69 XMultiServiceFactory xMSF
= (XMultiServiceFactory
)tParam
.getMSF();
70 element
= xMSF
.createInstance(
71 "com.sun.star.reflection.TypeDescriptionProvider");
74 oObj
.insert(element
) ;
76 if (!oObj
.has(element
)) {
78 log
.println("After adding element method has()" +
82 } catch (com
.sun
.star
.container
.ElementExistException e
) {
83 e
.printStackTrace(log
) ;
85 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
86 e
.printStackTrace(log
) ;
89 catch(com
.sun
.star
.uno
.Exception e
) {
90 e
.printStackTrace(log
);
94 tRes
.tested("insert()", res
) ;
98 * Through <code>XEnumeration</code> interface an element from the set
99 * is retrieved. Then this element removed.<p>
100 * Has <b> OK </b> status if after removing <code>has()</code> method
103 public void _remove() {
104 requiredMethod("insert()");
109 // get an element to be removed/inserted
111 oObj
.remove(element
) ;
113 if (oObj
.has(element
)) {
115 log
.println("After removing element method has()" +
122 } catch (com
.sun
.star
.container
.NoSuchElementException e
) {
123 e
.printStackTrace(log
) ;
125 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
126 e
.printStackTrace(log
) ;
130 tRes
.tested("remove()", res
) ;
134 * Does nothing. Testing performed in previous methods.<p>
135 * Has <b> OK </b> status if after <code>remove()</code> call
136 * methods returned <code>false</code>, and after <code>remove()</code>
137 * call methods returned <code>true</code>.
138 * The following method tests are to be completed successfully before :
140 * <li> <code> insert() </code> : here the method is checked </li>
141 * <li> <code> remove() </code> : here the method is checked </li>
146 requiredMethod("insert()") ;
147 requiredMethod("remove()") ;
149 tRes
.tested("has()", hasResult
) ;
152 } // finished class _XSet