Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / container / _XSet.java
bloba844682a51192636e0632d70480bcf503b6074b6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XSet.java,v $
10 * $Revision: 1.5 $
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;
38 /**
39 * Testing <code>com.sun.star.container.XSet</code>
40 * interface methods :
41 * <ul>
42 * <li><code> has()</code></li>
43 * <li><code> insert()</code></li>
44 * <li><code> remove()</code></li>
45 * </ul> <p>
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 ;
56 /**
57 * Inserts the element stored and removed before. <p>
58 * Has <b> OK </b> status if <code>has()</code> method returns
59 * <code>true</code>.
60 * The following method tests are to be completed successfully before :
61 * <ul>
62 * <li> <code> remove() </code> : element from set is stored and
63 * removed </li>
64 * </ul>
66 public void _insert() {
67 boolean res = true ;
68 try {
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)) {
77 res = false ;
78 log.println("After adding element method has()" +
79 " returned false") ;
80 hasResult = false ;
82 } catch (com.sun.star.container.ElementExistException e) {
83 e.printStackTrace(log) ;
84 res = false ;
85 } catch (com.sun.star.lang.IllegalArgumentException e) {
86 e.printStackTrace(log) ;
87 res = false ;
89 catch(com.sun.star.uno.Exception e) {
90 e.printStackTrace(log);
91 res = false;
94 tRes.tested("insert()", res) ;
97 /**
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
101 * returns false.
103 public void _remove() {
104 requiredMethod("insert()");
105 boolean res = true ;
107 try {
109 // get an element to be removed/inserted
111 oObj.remove(element) ;
113 if (oObj.has(element)) {
114 res = false ;
115 log.println("After removing element method has()" +
116 " returned true") ;
117 hasResult = false ;
122 } catch (com.sun.star.container.NoSuchElementException e) {
123 e.printStackTrace(log) ;
124 res = false ;
125 } catch (com.sun.star.lang.IllegalArgumentException e) {
126 e.printStackTrace(log) ;
127 res = false ;
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 :
139 * <ul>
140 * <li> <code> insert() </code> : here the method is checked </li>
141 * <li> <code> remove() </code> : here the method is checked </li>
142 * </ul>
144 public void _has() {
146 requiredMethod("insert()") ;
147 requiredMethod("remove()") ;
149 tRes.tested("has()", hasResult) ;
152 } // finished class _XSet