merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / sdb / _DataSource.java
blob9e3fa7df941e70fd3d2e0127c95ee1d3d030fdd2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _DataSource.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.sdb;
33 import lib.MultiPropertyTest;
35 import com.sun.star.beans.PropertyValue;
37 /**
38 * Testing <code>com.sun.star.sdb.DataSource</code>
39 * service properties :
40 * <ul>
41 * <li><code> Name</code></li>
42 * <li><code> URL</code></li>
43 * <li><code> Info</code></li>
44 * <li><code> User</code></li>
45 * <li><code> Password</code></li>
46 * <li><code> IsPasswordRequired</code></li>
47 * <li><code> SuppressVersionColumns</code></li>
48 * <li><code> IsReadOnly</code></li>
49 * <li><code> NumberFormatsSupplier</code></li>
50 * <li><code> TableFilter</code></li>
51 * <li><code> TableTypeFilter</code></li>
52 * </ul> <p>
53 * Properties testing is automated by <code>lib.MultiPropertyTest</code> <p>.
54 * After this interface test <b>it's better to recreate</b> object tested.
55 * @see com.sun.star.beans.XPropertySet
56 * @see com.sun.star.beans.XPropertySetInfo
57 * @see com.sun.star.beans.Property
58 * @see com.sun.star.lang.XServiceInfo
60 public class _DataSource extends MultiPropertyTest {
62 /**
63 * This property is an array of additional parameters for database
64 * connecting. Parameter is <code>PropertyValue</code> structure.
65 * The test just changes existing array onto array with a single
66 * element <code>("user", "API_QA_Tester")</code> <p>
68 * After testing old value is set for this property. <p>
70 * Result is OK: if property successfully changed with no excepions.
71 * @see com.sun.star.beans.PropertyValue
73 public void _Info() {
74 try {
75 Object oldInfo = oObj.getPropertyValue("Info") ;
77 testProperty("Info", new PropertyTester() {
78 protected Object getNewValue(String propName, Object oldValue) {
80 PropertyValue propUsr = new PropertyValue(),
81 propPass = new PropertyValue() ;
83 propUsr.Name = "user" ;
84 propUsr.Value = "API_QA_Tester" ;
85 propPass.Name = "password" ;
86 propPass.Value = "guest" ;
88 return new PropertyValue[] { propUsr, propPass } ;
90 }) ;
92 oObj.setPropertyValue("Info", oldInfo) ;
93 } catch(com.sun.star.beans.UnknownPropertyException e) {}
94 catch(com.sun.star.beans.PropertyVetoException e) {}
95 catch(com.sun.star.lang.IllegalArgumentException e) {}
96 catch(com.sun.star.lang.WrappedTargetException e) {}
99 /**
100 * Property is tested by the common method, but after testing
101 * old value is set for this property.
103 public void _URL() {
104 try {
105 Object oldURL = oObj.getPropertyValue("URL") ;
107 testProperty("URL") ;
109 oObj.setPropertyValue("URL", oldURL) ;
110 } catch(com.sun.star.beans.UnknownPropertyException e) {}
111 catch(com.sun.star.beans.PropertyVetoException e) {}
112 catch(com.sun.star.lang.IllegalArgumentException e) {}
113 catch(com.sun.star.lang.WrappedTargetException e) {}
117 * Property is tested by the common method, but after testing
118 * old value is set for this property.
120 public void _User() {
121 try {
122 Object oldUser = oObj.getPropertyValue("User") ;
124 testProperty("User") ;
126 oObj.setPropertyValue("User", oldUser) ;
127 } catch(com.sun.star.beans.UnknownPropertyException e) {}
128 catch(com.sun.star.beans.PropertyVetoException e) {}
129 catch(com.sun.star.lang.IllegalArgumentException e) {}
130 catch(com.sun.star.lang.WrappedTargetException e) {}
134 * Property is tested by the common method, but after testing
135 * old value is set for this property.
137 public void _Password() {
138 try {
139 Object oldPass = oObj.getPropertyValue("Password") ;
141 testProperty("Password") ;
143 oObj.setPropertyValue("Password", oldPass) ;
144 } catch(com.sun.star.beans.UnknownPropertyException e) {}
145 catch(com.sun.star.beans.PropertyVetoException e) {}
146 catch(com.sun.star.lang.IllegalArgumentException e) {}
147 catch(com.sun.star.lang.WrappedTargetException e) {}
151 * New value for the test is always <code>null</code>.
153 public void _NumberFormatsSupplier() {
154 testProperty("NumberFormatsSupplier", new PropertyTester() {
155 protected Object getNewValue(String propName, Object oldValue) {
156 return null ;
158 }) ;
162 * If object test allows to recreate environment it is better to do it.
164 public void after() {
165 try {
166 oObj.setPropertyValue("IsPasswordRequired",new Boolean(false));
167 } catch (Exception e) {
168 log.println("Couldn't set 'IsPasswordRequired' to false");
172 } // finish class _DataSource