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
.XSet
;
24 import com
.sun
.star
.lang
.XMultiServiceFactory
;
27 * Testing <code>com.sun.star.container.XSet</code>
30 * <li><code> has()</code></li>
31 * <li><code> insert()</code></li>
32 * <li><code> remove()</code></li>
34 * Test is <b> NOT </b> multithread compliant. <p>
35 * @see com.sun.star.container.XSet
37 public class _XSet
extends MultiMethodTest
{
39 public static XSet oObj
= null;
41 private Object element
= null ;
42 private boolean hasResult
= true ;
45 * Inserts the element stored and removed before. <p>
46 * Has <b> OK </b> status if <code>has()</code> method returns
48 * The following method tests are to be completed successfully before :
50 * <li> <code> remove() </code> : element from set is stored and
54 public void _insert() {
57 XMultiServiceFactory xMSF
= tParam
.getMSF();
58 element
= xMSF
.createInstance(
59 "com.sun.star.reflection.TypeDescriptionProvider");
62 oObj
.insert(element
) ;
64 if (!oObj
.has(element
)) {
66 log
.println("After adding element method has()" +
70 } catch (com
.sun
.star
.container
.ElementExistException e
) {
71 e
.printStackTrace(log
) ;
73 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
74 e
.printStackTrace(log
) ;
77 catch(com
.sun
.star
.uno
.Exception e
) {
78 e
.printStackTrace(log
);
82 tRes
.tested("insert()", res
) ;
86 * Through <code>XEnumeration</code> interface an element from the set
87 * is retrieved. Then this element removed.<p>
88 * Has <b> OK </b> status if after removing <code>has()</code> method
91 public void _remove() {
92 requiredMethod("insert()");
97 // get an element to be removed/inserted
99 oObj
.remove(element
) ;
101 if (oObj
.has(element
)) {
103 log
.println("After removing element method has()" +
110 } catch (com
.sun
.star
.container
.NoSuchElementException e
) {
111 e
.printStackTrace(log
) ;
113 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
114 e
.printStackTrace(log
) ;
118 tRes
.tested("remove()", res
) ;
122 * Does nothing. Testing performed in previous methods.<p>
123 * Has <b> OK </b> status if after <code>remove()</code> call
124 * methods returned <code>false</code>, and after <code>remove()</code>
125 * call methods returned <code>true</code>.
126 * The following method tests are to be completed successfully before :
128 * <li> <code> insert() </code> : here the method is checked </li>
129 * <li> <code> remove() </code> : here the method is checked </li>
134 requiredMethod("insert()") ;
135 requiredMethod("remove()") ;
137 tRes
.tested("has()", hasResult
) ;
140 } // finished class _XSet