Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / beans / _XPropertySetInfo.java
blobdc6ad368f7cbd04076a1b9e6c6b3cb89bcadf33c
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.beans;
21 import lib.MultiMethodTest;
23 import com.sun.star.beans.Property;
24 import com.sun.star.beans.UnknownPropertyException;
25 import com.sun.star.beans.XPropertySetInfo;
27 /**
28 * Testing <code>com.sun.star.beans.XPropertySetInfo</code>
29 * interface methods :
30 * <ul>
31 * <li><code>getProperties()</code></li>
32 * <li><code>getPropertyByName()</code></li>
33 * <li><code>hasPropertyByName()</code></li>
34 * </ul>
35 * @see com.sun.star.beans.XPropertySetInfo
37 public class _XPropertySetInfo extends MultiMethodTest {
39 public XPropertySetInfo oObj = null;// oObj filled by MultiMethodTest
41 public Property IsThere = null;
43 /**
44 * Test calls the method and stores one of the properties.<p>
45 * Has <b> OK </b> status if the method successfully returns
46 * value that isn't null.<p>
48 public void _getProperties() {
49 Property[] properties = oObj.getProperties();
50 IsThere = properties[0];
51 tRes.tested("getProperties()", ( properties != null ));
54 /**
55 * Test calls the method with property name that certainly present
56 * in the property set and again calls the method with property name
57 * that certainly doesn't present in the property set.<p>
58 * Has <b> OK </b> status if the method in one case successfully
59 * returns value that isn't null and no exceptions were thrown and
60 * in other case exception was thrown.<p>
61 * The following method tests are to be completed successfully before :
62 * <ul>
63 * <li> <code>getProperties()</code> : to have a property that certainly
64 * present in the property set</li>
65 * </ul>
67 public void _getPropertyByName() {
68 requiredMethod("getProperties()");
69 boolean result;
70 try {
71 Property prop = oObj.getPropertyByName(IsThere.Name);
72 result = (prop != null);
73 } catch (com.sun.star.beans.UnknownPropertyException e) {
74 log.println("Exception occurred while testing" +
75 " getPropertyByName with existing property");
76 e.printStackTrace(log);
77 result = false;
80 try {
81 oObj.getPropertyByName("Jupp");
82 log.println("No Exception thrown while testing"+
83 " getPropertyByName with non existing property");
84 result = false;
86 catch (UnknownPropertyException e) {
87 result = true;
89 tRes.tested("getPropertyByName()", result);
92 /**
93 * Test calls the method with property name that certainly present
94 * in the property set and again calls the method with property name
95 * that certainly doesn't present in the property set.<p>
96 * Has <b> OK </b> status if the method successfully returns true in
97 * one case and false in other case.<p>
98 * The following method tests are to be completed successfully before :
99 * <ul>
100 * <li> <code>getProperties()</code> : to have a property that certainly
101 * present in the property set</li>
102 * </ul>
104 public void _hasPropertyByName() {
105 requiredMethod("getProperties()");
106 tRes.tested("hasPropertyByName()",
108 (oObj.hasPropertyByName(IsThere.Name)) &&
109 (!oObj.hasPropertyByName("Jupp")) )
113 } /// finish class XPropertySetInfo