bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / container / _XContainerQuery.java
blob2d7659bfb244758deb89252c447fee053eab57cc
1 /*
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;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.beans.NamedValue;
26 import com.sun.star.container.XContainerQuery;
27 import com.sun.star.container.XEnumeration;
30 /**
31 * Testing <code>com.sun.star.container.XContainerQuery</code>
32 * interface methods :
33 * <ul>
34 * <li><code> createSubSetEnumerationByProperties()</code></li>
35 * <li><code> createSubSetEnumerationByQuery()</code></li>
36 * </ul>
37 * This test needs the following object relations :
38 * <ul>
39 * <li> <code>'XContainerQuery.createSubSetEnumerationByProperties'</code> :
40 * <code>NameValue[]</code> which is a valid argument for
41 * <code>createSubSetEnumerationByProperties()</code>.</li>
42 * <li> <code>'XContainerQuery.createSubSetEnumerationByQuery'</code> : <b>(optional)</b>
43 * Normaly <code>createSubSetEnumerationByProperties()</code> covers all
44 * possible queries. But for special cases, i.e. sorted output, the function
45 * <code>createSubSetEnumerationByQuery()</code> was made. The special cases was not
46 * implemented by default in the implemetation object. So this function could be
47 * marked as <code>optional</code></li>
48 * <ul> <p>
49 * <p>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.container.XContainerQuery
53 public class _XContainerQuery extends MultiMethodTest {
55 public XContainerQuery oObj = null;
56 private NamedValue[] m_querySequenze = null;
57 private String[] m_queryStrings = null;
60 /**
61 * Retrieves object relations
62 * @throws StatusException If one of relations not found.
64 public void before() throws StatusException {
66 m_querySequenze = (NamedValue[]) tEnv.getObjRelation(
67 "XContainerQuery.createSubSetEnumerationByProperties");
68 if (m_querySequenze == null) {
69 throw new StatusException(
70 Status.failed("Could not get object relation " +
71 "'XContainerQuery.createSubSetEnumerationByProperties'")) ;
74 m_queryStrings = (String[]) tEnv.getObjRelation(
75 "XContainerQuery.createSubSetEnumerationByQuery");
76 if (m_queryStrings == null) {
77 log.println("Could not get object relation " +
78 "'XContainerQuery.createSubSetEnumerationByQuery'");
83 /**
84 * If object relation is available, the function was called with relation
85 * as parameter. The returned <code>XEnumeration</code> must not be null and
86 * elements of it must be valid.
87 * If object relation is not available, the result is always <code>true</coed>
89 public void _createSubSetEnumerationByQuery() {
91 boolean bResult = true;
92 if ( m_queryStrings == null ) {
93 log.println("This object does not have an implemetation for this function");
94 // This is not a bug, because it's a feature for future purposes
95 } else {
96 for (int i = 0; i < m_queryStrings.length; i++){
97 String queryString = m_queryStrings[i];
98 XEnumeration subSet = oObj.createSubSetEnumerationByQuery( queryString );
100 bResult &= subSet.hasMoreElements();
102 while (subSet.hasMoreElements()) {
103 try{
104 subSet.nextElement();
106 } catch (com.sun.star.container.NoSuchElementException e){
107 log.println("Exception occurred ");
108 e.printStackTrace(log);
109 bResult = false;
110 } catch (com.sun.star.lang.WrappedTargetException e){
111 log.println("Exception occurred ");
112 e.printStackTrace(log);
113 bResult = false;
119 tRes.tested("createSubSetEnumerationByQuery()", bResult);
123 * The function was called with object relation
124 * as parameter. The returned <code>XEnumeration</code> must not be null and
125 * elements of it must be valid.
128 public void _createSubSetEnumerationByProperties() {
130 boolean bResult = true;
132 XEnumeration subSet = oObj.createSubSetEnumerationByProperties( m_querySequenze );
134 bResult = subSet.hasMoreElements();
136 while (subSet.hasMoreElements()) {
137 try{
138 subSet.nextElement();
140 } catch (com.sun.star.container.NoSuchElementException e){
141 log.println("Exception occurred ");
142 e.printStackTrace(log);
143 bResult = false;
144 } catch (com.sun.star.lang.WrappedTargetException e){
145 log.println("Exception occurred ");
146 e.printStackTrace(log);
147 bResult = false;
151 tRes.tested("createSubSetEnumerationByProperties()", bResult);