Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / sdb / _DataSource.java
blobe693d781a8b0e38a037d695d3c7f4821e4c32aa7
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.sdb;
21 import lib.MultiPropertyTest;
23 import com.sun.star.beans.PropertyValue;
25 /**
26 * Testing <code>com.sun.star.sdb.DataSource</code>
27 * service properties :
28 * <ul>
29 * <li><code> Name</code></li>
30 * <li><code> URL</code></li>
31 * <li><code> Info</code></li>
32 * <li><code> User</code></li>
33 * <li><code> Password</code></li>
34 * <li><code> IsPasswordRequired</code></li>
35 * <li><code> SuppressVersionColumns</code></li>
36 * <li><code> IsReadOnly</code></li>
37 * <li><code> NumberFormatsSupplier</code></li>
38 * <li><code> TableFilter</code></li>
39 * <li><code> TableTypeFilter</code></li>
40 * </ul> <p>
41 * Properties testing is automated by <code>lib.MultiPropertyTest</code> <p>.
42 * After this interface test <b>it's better to recreate</b> object tested.
43 * @see com.sun.star.beans.XPropertySet
44 * @see com.sun.star.beans.XPropertySetInfo
45 * @see com.sun.star.beans.Property
46 * @see com.sun.star.lang.XServiceInfo
48 public class _DataSource extends MultiPropertyTest {
50 /**
51 * This property is an array of additional parameters for database
52 * connecting. Parameter is <code>PropertyValue</code> structure.
53 * The test just changes existing array onto array with a single
54 * element <code>("user", "API_QA_Tester")</code> <p>
56 * After testing old value is set for this property. <p>
58 * Result is OK: if property successfully changed with no exceptions.
59 * @see com.sun.star.beans.PropertyValue
61 public void _Info() {
62 try {
63 Object oldInfo = oObj.getPropertyValue("Info") ;
65 testProperty("Info", new PropertyTester() {
66 @Override
67 protected Object getNewValue(String propName, Object oldValue) {
69 PropertyValue propUsr = new PropertyValue(),
70 propPass = new PropertyValue() ;
72 propUsr.Name = "user" ;
73 propUsr.Value = "API_QA_Tester" ;
74 propPass.Name = "password" ;
75 propPass.Value = "guest" ;
77 return new PropertyValue[] { propUsr, propPass } ;
79 }) ;
81 oObj.setPropertyValue("Info", oldInfo) ;
82 } catch(com.sun.star.beans.UnknownPropertyException e) {}
83 catch(com.sun.star.beans.PropertyVetoException e) {}
84 catch(com.sun.star.lang.IllegalArgumentException e) {}
85 catch(com.sun.star.lang.WrappedTargetException e) {}
88 /**
89 * Property is tested by the common method, but after testing
90 * old value is set for this property.
92 public void _URL() {
93 try {
94 Object oldURL = oObj.getPropertyValue("URL") ;
96 testProperty("URL") ;
98 oObj.setPropertyValue("URL", oldURL) ;
99 } catch(com.sun.star.beans.UnknownPropertyException e) {}
100 catch(com.sun.star.beans.PropertyVetoException e) {}
101 catch(com.sun.star.lang.IllegalArgumentException e) {}
102 catch(com.sun.star.lang.WrappedTargetException e) {}
106 * Property is tested by the common method, but after testing
107 * old value is set for this property.
109 public void _User() {
110 try {
111 Object oldUser = oObj.getPropertyValue("User") ;
113 testProperty("User") ;
115 oObj.setPropertyValue("User", oldUser) ;
116 } catch(com.sun.star.beans.UnknownPropertyException e) {}
117 catch(com.sun.star.beans.PropertyVetoException e) {}
118 catch(com.sun.star.lang.IllegalArgumentException e) {}
119 catch(com.sun.star.lang.WrappedTargetException e) {}
123 * Property is tested by the common method, but after testing
124 * old value is set for this property.
126 public void _Password() {
127 try {
128 Object oldPass = oObj.getPropertyValue("Password") ;
130 testProperty("Password") ;
132 oObj.setPropertyValue("Password", oldPass) ;
133 } catch(com.sun.star.beans.UnknownPropertyException e) {}
134 catch(com.sun.star.beans.PropertyVetoException e) {}
135 catch(com.sun.star.lang.IllegalArgumentException e) {}
136 catch(com.sun.star.lang.WrappedTargetException e) {}
140 * New value for the test is always <code>null</code>.
142 public void _NumberFormatsSupplier() {
143 testProperty("NumberFormatsSupplier", new PropertyTester() {
144 @Override
145 protected Object getNewValue(String propName, Object oldValue) {
146 return null ;
148 }) ;
152 * If object test allows to recreate environment it is better to do it.
154 @Override
155 public void after() {
156 try {
157 oObj.setPropertyValue("IsPasswordRequired",Boolean.FALSE);
158 } catch (Exception e) {
159 log.println("Couldn't set 'IsPasswordRequired' to false");
163 } // finish class _DataSource