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 .
21 import lib
.MultiPropertyTest
;
22 import lib
.StatusException
;
24 import com
.sun
.star
.sdbc
.XConnection
;
25 import com
.sun
.star
.uno
.AnyConverter
;
26 import com
.sun
.star
.uno
.Type
;
29 * Testing <code>com.sun.star.sdb.RowSet</code>
30 * service properties :
32 * <li><code> ActiveConnection</code></li>
33 * <li><code> DataSourceName</code></li>
34 * <li><code> Command</code></li>
35 * <li><code> CommandType</code></li>
36 * <li><code> ActiveCommand</code></li>
37 * <li><code> IgnoreResult</code></li>
38 * <li><code> Filter</code></li>
39 * <li><code> ApplyFilter</code></li>
40 * <li><code> Order</code></li>
41 * <li><code> Privileges</code></li>
42 * <li><code> IsModified</code></li>
43 * <li><code> IsNew</code></li>
44 * <li><code> RowCount</code></li>
45 * <li><code> IsRowCountFinal</code></li>
46 * <li><code> UpdateTableName</code></li>
47 * <li><code> UpdateCatalogName</code></li>
48 * <li><code> UpdateSchemaName</code></li>
51 * Properties are tested in a safe way, this means that old
52 * properties' values are restored to their previous values
53 * after testing. These values are meaningful for further
56 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
57 * @see com.sun.star.sdb.RowSet
59 public class _RowSet
extends MultiPropertyTest
{
62 * The tester implementation which restores properties
63 * values after testing.
65 protected class SafeTester
extends PropertyTester
{
66 Object oldValue
= null ;
69 protected Object
getNewValue(String prop
, Object old
) {
70 log
.println("Testing with SafeTester ...") ;
72 return super.getNewValue(prop
, old
) ;
76 protected void checkResult(String propName
, Object oldValue
,
77 Object newValue
, Object resValue
, Exception exception
)
80 super.checkResult(propName
, oldValue
, newValue
, resValue
, exception
);
83 oObj
.setPropertyValue(propName
, this.oldValue
);
84 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
85 log
.println("Exception while setting property to its old value '" +
86 this.oldValue
+ "' (ignoring) : " + e
);
87 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
88 log
.println("Exception while setting property to its old value '" +
89 this.oldValue
+ "' (ignoring) : " + e
);
90 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
91 log
.println("Exception while setting property to its old value '" +
92 this.oldValue
+ "' (ignoring) : " + e
);
93 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
94 log
.println("Exception while setting property to its old value '" +
95 this.oldValue
+ "' (ignoring) : " + e
);
102 * Overridden method which tests all the properties
103 * with <code>SafeTester</code>.
108 protected void testProperty(String propName
) {
109 testProperty(propName
, new SafeTester()) ;
112 public void _ActiveConnection() {
113 boolean result
= false;
115 XConnection the_connection
= null;
118 the_connection
= (XConnection
) AnyConverter
.toObject(
119 new Type(XConnection
.class),
120 oObj
.getPropertyValue("ActiveConnection"));
121 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
122 throw new StatusException("couldn't convert Any",iae
);
125 result
= (the_connection
!= null);
126 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
127 log
.println("the property is unknown");
128 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
129 log
.println(e
.getMessage());
132 tRes
.tested("ActiveConnection", result
) ;
136 * Forces environment recreation.
139 protected void after() {
140 disposeEnvironment();
143 } // EOF DatasourceAdministrationDialog