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
;
23 import com
.sun
.star
.beans
.PropertyValue
;
26 * Testing <code>com.sun.star.sdb.DataSource</code>
27 * service properties :
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>
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
{
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 excepions.
59 * @see com.sun.star.beans.PropertyValue
63 Object oldInfo
= oObj
.getPropertyValue("Info") ;
65 testProperty("Info", new PropertyTester() {
66 protected Object
getNewValue(String propName
, Object oldValue
) {
68 PropertyValue propUsr
= new PropertyValue(),
69 propPass
= new PropertyValue() ;
71 propUsr
.Name
= "user" ;
72 propUsr
.Value
= "API_QA_Tester" ;
73 propPass
.Name
= "password" ;
74 propPass
.Value
= "guest" ;
76 return new PropertyValue
[] { propUsr
, propPass
} ;
80 oObj
.setPropertyValue("Info", oldInfo
) ;
81 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {}
82 catch(com
.sun
.star
.beans
.PropertyVetoException e
) {}
83 catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {}
84 catch(com
.sun
.star
.lang
.WrappedTargetException e
) {}
88 * Property is tested by the common method, but after testing
89 * old value is set for this property.
93 Object oldURL
= oObj
.getPropertyValue("URL") ;
97 oObj
.setPropertyValue("URL", oldURL
) ;
98 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {}
99 catch(com
.sun
.star
.beans
.PropertyVetoException e
) {}
100 catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {}
101 catch(com
.sun
.star
.lang
.WrappedTargetException e
) {}
105 * Property is tested by the common method, but after testing
106 * old value is set for this property.
108 public void _User() {
110 Object oldUser
= oObj
.getPropertyValue("User") ;
112 testProperty("User") ;
114 oObj
.setPropertyValue("User", oldUser
) ;
115 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {}
116 catch(com
.sun
.star
.beans
.PropertyVetoException e
) {}
117 catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {}
118 catch(com
.sun
.star
.lang
.WrappedTargetException e
) {}
122 * Property is tested by the common method, but after testing
123 * old value is set for this property.
125 public void _Password() {
127 Object oldPass
= oObj
.getPropertyValue("Password") ;
129 testProperty("Password") ;
131 oObj
.setPropertyValue("Password", oldPass
) ;
132 } catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {}
133 catch(com
.sun
.star
.beans
.PropertyVetoException e
) {}
134 catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {}
135 catch(com
.sun
.star
.lang
.WrappedTargetException e
) {}
139 * New value for the test is always <code>null</code>.
141 public void _NumberFormatsSupplier() {
142 testProperty("NumberFormatsSupplier", new PropertyTester() {
143 protected Object
getNewValue(String propName
, Object oldValue
) {
150 * If object test allows to recreate environment it is better to do it.
152 public void after() {
154 oObj
.setPropertyValue("IsPasswordRequired",new Boolean(false));
155 } catch (Exception e
) {
156 log
.println("Couldn't set 'IsPasswordRequired' to false");
160 } // finish class _DataSource