merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / sdb / _RowSet.java
blobf84d065acf61fd47e572eb4cf6dc2cd02344bfba
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: _RowSet.java,v $
10 * $Revision: 1.5 $
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;
34 import lib.StatusException;
36 import com.sun.star.sdbc.XConnection;
37 import com.sun.star.uno.AnyConverter;
38 import com.sun.star.uno.Type;
40 /**
41 * Testing <code>com.sun.star.sdb.RowSet</code>
42 * service properties :
43 * <ul>
44 * <li><code> ActiveConnection</code></li>
45 * <li><code> DataSourceName</code></li>
46 * <li><code> Command</code></li>
47 * <li><code> CommandType</code></li>
48 * <li><code> ActiveCommand</code></li>
49 * <li><code> IgnoreResult</code></li>
50 * <li><code> Filter</code></li>
51 * <li><code> ApplyFilter</code></li>
52 * <li><code> Order</code></li>
53 * <li><code> Privileges</code></li>
54 * <li><code> IsModified</code></li>
55 * <li><code> IsNew</code></li>
56 * <li><code> RowCount</code></li>
57 * <li><code> IsRowCountFinal</code></li>
58 * <li><code> UpdateTableName</code></li>
59 * <li><code> UpdateCatalogName</code></li>
60 * <li><code> UpdateSchemaName</code></li>
61 * </ul> <p>
63 * Properties are tested in a safe way, this means that old
64 * properties' values are restored to their previous values
65 * after testing. These values are meaningfull for further
66 * testing. <p>
68 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
69 * @see com.sun.star.sdb.RowSet
71 public class _RowSet extends MultiPropertyTest {
73 /**
74 * The tester implementation which restores properties
75 * values after testing.
77 protected class SafeTester extends PropertyTester {
78 Object oldValue = null ;
80 protected Object getNewValue(String prop, Object old) {
81 log.println("Testing with SafeTester ...") ;
82 oldValue = old ;
83 return super.getNewValue(prop, old) ;
86 protected void checkResult(String propName, Object oldValue,
87 Object newValue, Object resValue, Exception exception)
88 throws Exception {
90 super.checkResult(propName, oldValue, newValue, resValue, exception);
92 try {
93 oObj.setPropertyValue(propName, this.oldValue);
94 } catch (com.sun.star.lang.WrappedTargetException e) {
95 log.println("Exception while setting property to its old value '" +
96 this.oldValue + "' (ignoring) : " + e );
97 } catch (com.sun.star.lang.IllegalArgumentException e) {
98 log.println("Exception while setting property to its old value '" +
99 this.oldValue + "' (ignoring) : " + e );
100 } catch (com.sun.star.beans.PropertyVetoException e) {
101 log.println("Exception while setting property to its old value '" +
102 this.oldValue + "' (ignoring) : " + e );
103 } catch (com.sun.star.beans.UnknownPropertyException e) {
104 log.println("Exception while setting property to its old value '" +
105 this.oldValue + "' (ignoring) : " + e );
112 * Overriden method which tests all the properties
113 * with <code>SafeTester</code>.
115 * @see #SafeTester
117 protected void testProperty(String propName) {
118 testProperty(propName, new SafeTester()) ;
121 public void _ActiveConnection() {
122 boolean result = false;
123 try {
124 XConnection the_connection = null;
126 try {
127 the_connection = (XConnection) AnyConverter.toObject(
128 new Type(XConnection.class),
129 oObj.getPropertyValue("ActiveConnection"));
130 } catch (com.sun.star.lang.IllegalArgumentException iae) {
131 throw new StatusException("couldn't convert Any",iae);
134 result = (the_connection != null);
135 } catch (com.sun.star.beans.UnknownPropertyException e) {
136 log.println("the property is unknown");
137 } catch (com.sun.star.lang.WrappedTargetException e) {
138 log.println(e.getMessage());
141 tRes.tested("ActiveConnection", result) ;
145 * Forces environment recreation.
147 protected void after() {
148 disposeEnvironment();
151 } // EOF DatasourceAdministrationDialog