1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.sdb;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.sdbc.XConnection;
27cdf0e10cSrcweir import com.sun.star.sdbc.XResultSet;
28cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
29cdf0e10cSrcweir import lib.MultiPropertyTest;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir public class _DataAccessDescriptor extends MultiPropertyTest {
32cdf0e10cSrcweir 
33cdf0e10cSrcweir     /**
34cdf0e10cSrcweir      * Tested with custom property tester.
35cdf0e10cSrcweir      */
_ResultSet()36cdf0e10cSrcweir     public void _ResultSet() {
37cdf0e10cSrcweir         String propName = "ResultSet";
38cdf0e10cSrcweir         try{
39cdf0e10cSrcweir 
40cdf0e10cSrcweir             log.println("try to get value from property...");
41cdf0e10cSrcweir             XResultSet oldValue = (XResultSet) UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName));
42cdf0e10cSrcweir 
43cdf0e10cSrcweir             log.println("try to get value from object relation...");
44cdf0e10cSrcweir             XResultSet newValue = (XResultSet) UnoRuntime.queryInterface(XResultSet.class,tEnv.getObjRelation("DataAccessDescriptor.XResultSet"));
45cdf0e10cSrcweir 
46cdf0e10cSrcweir             log.println("set property to a new value...");
47cdf0e10cSrcweir             oObj.setPropertyValue(propName, newValue);
48cdf0e10cSrcweir 
49cdf0e10cSrcweir             log.println("get the new value...");
50cdf0e10cSrcweir             XResultSet getValue = (XResultSet) UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName));
51cdf0e10cSrcweir 
52cdf0e10cSrcweir             tRes.tested(propName, this.compare(newValue, getValue));
53cdf0e10cSrcweir         } catch (com.sun.star.beans.PropertyVetoException e){
54cdf0e10cSrcweir             log.println("could not set property '"+ propName +"' to a new value!");
55cdf0e10cSrcweir             tRes.tested(propName, false);
56cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e){
57cdf0e10cSrcweir             log.println("could not set property '"+ propName +"' to a new value!");
58cdf0e10cSrcweir             tRes.tested(propName, false);
59cdf0e10cSrcweir         } catch (com.sun.star.beans.UnknownPropertyException e){
60cdf0e10cSrcweir             if (this.isOptional(propName)){
61cdf0e10cSrcweir                     // skipping optional property test
62cdf0e10cSrcweir                     log.println("Property '" + propName
63cdf0e10cSrcweir                             + "' is optional and not supported");
64cdf0e10cSrcweir                     tRes.tested(propName,true);
65cdf0e10cSrcweir 
66cdf0e10cSrcweir             } else {
67cdf0e10cSrcweir                 log.println("could not get property '"+ propName +"' from XPropertySet!");
68cdf0e10cSrcweir                 tRes.tested(propName, false);
69cdf0e10cSrcweir             }
70cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e){
71cdf0e10cSrcweir             log.println("could not get property '"+ propName +"' from XPropertySet!");
72cdf0e10cSrcweir             tRes.tested(propName, false);
73cdf0e10cSrcweir         }
74cdf0e10cSrcweir     }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     /**
77cdf0e10cSrcweir      * Tested with custom property tester.
78cdf0e10cSrcweir      */
_ActiveConnection()79cdf0e10cSrcweir     public void _ActiveConnection() {
80cdf0e10cSrcweir         String propName = "ActiveConnection";
81cdf0e10cSrcweir         try{
82cdf0e10cSrcweir 
83cdf0e10cSrcweir             log.println("try to get value from property...");
84cdf0e10cSrcweir             XConnection oldValue = (XConnection) UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName));
85cdf0e10cSrcweir 
86cdf0e10cSrcweir             log.println("try to get value from object relation...");
87cdf0e10cSrcweir             XConnection newValue = (XConnection) UnoRuntime.queryInterface(XConnection.class,tEnv.getObjRelation("DataAccessDescriptor.XConnection"));
88cdf0e10cSrcweir 
89cdf0e10cSrcweir             log.println("set property to a new value...");
90cdf0e10cSrcweir             oObj.setPropertyValue(propName, newValue);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir             log.println("get the new value...");
93cdf0e10cSrcweir             XConnection getValue = (XConnection) UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName));
94cdf0e10cSrcweir 
95cdf0e10cSrcweir             tRes.tested(propName, this.compare(newValue, getValue));
96cdf0e10cSrcweir         } catch (com.sun.star.beans.PropertyVetoException e){
97cdf0e10cSrcweir             log.println("could not set property '"+ propName +"' to a new value! " + e.toString());
98cdf0e10cSrcweir             tRes.tested(propName, false);
99cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e){
100cdf0e10cSrcweir             log.println("could not set property '"+ propName +"' to a new value! " + e.toString());
101cdf0e10cSrcweir             tRes.tested(propName, false);
102cdf0e10cSrcweir         } catch (com.sun.star.beans.UnknownPropertyException e){
103cdf0e10cSrcweir             if (this.isOptional(propName)){
104cdf0e10cSrcweir                     // skipping optional property test
105cdf0e10cSrcweir                     log.println("Property '" + propName
106cdf0e10cSrcweir                             + "' is optional and not supported");
107cdf0e10cSrcweir                     tRes.tested(propName,true);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir             } else {
110cdf0e10cSrcweir                 log.println("could not get property '"+ propName +"' from XPropertySet!");
111cdf0e10cSrcweir                 tRes.tested(propName, false);
112cdf0e10cSrcweir             }
113cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e){
114cdf0e10cSrcweir             log.println("could not get property '"+ propName +"' from XPropertySet!");
115cdf0e10cSrcweir             tRes.tested(propName, false);
116cdf0e10cSrcweir         }
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
122