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 meaningfull 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 ;
68 protected Object
getNewValue(String prop
, Object old
) {
69 log
.println("Testing with SafeTester ...") ;
71 return super.getNewValue(prop
, old
) ;
74 protected void checkResult(String propName
, Object oldValue
,
75 Object newValue
, Object resValue
, Exception exception
)
78 super.checkResult(propName
, oldValue
, newValue
, resValue
, exception
);
81 oObj
.setPropertyValue(propName
, this.oldValue
);
82 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
83 log
.println("Exception while setting property to its old value '" +
84 this.oldValue
+ "' (ignoring) : " + e
);
85 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
86 log
.println("Exception while setting property to its old value '" +
87 this.oldValue
+ "' (ignoring) : " + e
);
88 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
89 log
.println("Exception while setting property to its old value '" +
90 this.oldValue
+ "' (ignoring) : " + e
);
91 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
92 log
.println("Exception while setting property to its old value '" +
93 this.oldValue
+ "' (ignoring) : " + e
);
100 * Overriden method which tests all the properties
101 * with <code>SafeTester</code>.
105 protected void testProperty(String propName
) {
106 testProperty(propName
, new SafeTester()) ;
109 public void _ActiveConnection() {
110 boolean result
= false;
112 XConnection the_connection
= null;
115 the_connection
= (XConnection
) AnyConverter
.toObject(
116 new Type(XConnection
.class),
117 oObj
.getPropertyValue("ActiveConnection"));
118 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
119 throw new StatusException("couldn't convert Any",iae
);
122 result
= (the_connection
!= null);
123 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
124 log
.println("the property is unknown");
125 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
126 log
.println(e
.getMessage());
129 tRes
.tested("ActiveConnection", result
) ;
133 * Forces environment recreation.
135 protected void after() {
136 disposeEnvironment();
139 } // EOF DatasourceAdministrationDialog