Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / container / _XSet.java
blob191b107ebc0804e8053bbcff71d6c37421108c1a
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;
35 /**
36 * Testing <code>com.sun.star.container.XSet</code>
37 * interface methods :
38 * <ul>
39 * <li><code> has()</code></li>
40 * <li><code> insert()</code></li>
41 * <li><code> remove()</code></li>
42 * </ul> <p>
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 ;
53 /**
54 * Inserts the element stored and removed before. <p>
55 * Has <b> OK </b> status if <code>has()</code> method returns
56 * <code>true</code>.
57 * The following method tests are to be completed successfully before :
58 * <ul>
59 * <li> <code> remove() </code> : element from set is stored and
60 * removed </li>
61 * </ul>
63 public void _insert() {
64 boolean res = true ;
65 try {
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)) {
74 res = false ;
75 log.println("After adding element method has()" +
76 " returned false") ;
77 hasResult = false ;
79 } catch (com.sun.star.container.ElementExistException e) {
80 e.printStackTrace(log) ;
81 res = false ;
82 } catch (com.sun.star.lang.IllegalArgumentException e) {
83 e.printStackTrace(log) ;
84 res = false ;
86 catch(com.sun.star.uno.Exception e) {
87 e.printStackTrace(log);
88 res = false;
91 tRes.tested("insert()", res) ;
94 /**
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
98 * returns false.
100 public void _remove() {
101 requiredMethod("insert()");
102 boolean res = true ;
104 try {
106 // get an element to be removed/inserted
108 oObj.remove(element) ;
110 if (oObj.has(element)) {
111 res = false ;
112 log.println("After removing element method has()" +
113 " returned true") ;
114 hasResult = false ;
119 } catch (com.sun.star.container.NoSuchElementException e) {
120 e.printStackTrace(log) ;
121 res = false ;
122 } catch (com.sun.star.lang.IllegalArgumentException e) {
123 e.printStackTrace(log) ;
124 res = false ;
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 :
136 * <ul>
137 * <li> <code> insert() </code> : here the method is checked </li>
138 * <li> <code> remove() </code> : here the method is checked </li>
139 * </ul>
141 public void _has() {
143 requiredMethod("insert()") ;
144 requiredMethod("remove()") ;
146 tRes.tested("has()", hasResult) ;
149 } // finished class _XSet