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 com
.sun
.star
.sdbc
.XConnection
;
22 import com
.sun
.star
.sdbc
.XResultSet
;
23 import com
.sun
.star
.uno
.UnoRuntime
;
24 import lib
.MultiPropertyTest
;
26 public class _DataAccessDescriptor
extends MultiPropertyTest
{
29 * Tested with custom property tester.
31 public void _ResultSet() {
32 String propName
= "ResultSet";
35 log
.println("try to get value from property...");
36 UnoRuntime
.queryInterface(XResultSet
.class,oObj
.getPropertyValue(propName
));
38 log
.println("try to get value from object relation...");
39 XResultSet newValue
= UnoRuntime
.queryInterface(XResultSet
.class,tEnv
.getObjRelation("DataAccessDescriptor.XResultSet"));
41 log
.println("set property to a new value...");
42 oObj
.setPropertyValue(propName
, newValue
);
44 log
.println("get the new value...");
45 XResultSet getValue
= UnoRuntime
.queryInterface(XResultSet
.class,oObj
.getPropertyValue(propName
));
47 tRes
.tested(propName
, this.compare(newValue
, getValue
));
48 } catch (com
.sun
.star
.beans
.PropertyVetoException e
){
49 log
.println("could not set property '"+ propName
+"' to a new value!");
50 tRes
.tested(propName
, false);
51 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
){
52 log
.println("could not set property '"+ propName
+"' to a new value!");
53 tRes
.tested(propName
, false);
54 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
55 if (this.isOptional(propName
)){
56 // skipping optional property test
57 log
.println("Property '" + propName
58 + "' is optional and not supported");
59 tRes
.tested(propName
,true);
62 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
63 tRes
.tested(propName
, false);
65 } catch (com
.sun
.star
.lang
.WrappedTargetException e
){
66 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
67 tRes
.tested(propName
, false);
72 * Tested with custom property tester.
74 public void _ActiveConnection() {
75 String propName
= "ActiveConnection";
78 log
.println("try to get value from property...");
79 UnoRuntime
.queryInterface(XConnection
.class,oObj
.getPropertyValue(propName
));
81 log
.println("try to get value from object relation...");
82 XConnection newValue
= UnoRuntime
.queryInterface(XConnection
.class,tEnv
.getObjRelation("DataAccessDescriptor.XConnection"));
84 log
.println("set property to a new value...");
85 oObj
.setPropertyValue(propName
, newValue
);
87 log
.println("get the new value...");
88 XConnection getValue
= UnoRuntime
.queryInterface(XConnection
.class,oObj
.getPropertyValue(propName
));
90 tRes
.tested(propName
, this.compare(newValue
, getValue
));
91 } catch (com
.sun
.star
.beans
.PropertyVetoException e
){
92 log
.println("could not set property '"+ propName
+"' to a new value! " + e
.toString());
93 tRes
.tested(propName
, false);
94 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
){
95 log
.println("could not set property '"+ propName
+"' to a new value! " + e
.toString());
96 tRes
.tested(propName
, false);
97 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
98 if (this.isOptional(propName
)){
99 // skipping optional property test
100 log
.println("Property '" + propName
101 + "' is optional and not supported");
102 tRes
.tested(propName
,true);
105 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
106 tRes
.tested(propName
, false);
108 } catch (com
.sun
.star
.lang
.WrappedTargetException e
){
109 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
110 tRes
.tested(propName
, false);