1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package ifc.sdb;
29 
30 import com.sun.star.sdbc.XConnection;
31 import com.sun.star.sdbc.XResultSet;
32 import com.sun.star.uno.UnoRuntime;
33 import lib.MultiPropertyTest;
34 
35 public class _DataAccessDescriptor extends MultiPropertyTest {
36 
37     /**
38      * Tested with custom property tester.
39      */
40     public void _ResultSet() {
41         String propName = "ResultSet";
42         try{
43 
44             log.println("try to get value from property...");
45             XResultSet oldValue = (XResultSet) UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName));
46 
47             log.println("try to get value from object relation...");
48             XResultSet newValue = (XResultSet) UnoRuntime.queryInterface(XResultSet.class,tEnv.getObjRelation("DataAccessDescriptor.XResultSet"));
49 
50             log.println("set property to a new value...");
51             oObj.setPropertyValue(propName, newValue);
52 
53             log.println("get the new value...");
54             XResultSet getValue = (XResultSet) UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName));
55 
56             tRes.tested(propName, this.compare(newValue, getValue));
57         } catch (com.sun.star.beans.PropertyVetoException e){
58             log.println("could not set property '"+ propName +"' to a new value!");
59             tRes.tested(propName, false);
60         } catch (com.sun.star.lang.IllegalArgumentException e){
61             log.println("could not set property '"+ propName +"' to a new value!");
62             tRes.tested(propName, false);
63         } catch (com.sun.star.beans.UnknownPropertyException e){
64             if (this.isOptional(propName)){
65                     // skipping optional property test
66                     log.println("Property '" + propName
67                             + "' is optional and not supported");
68                     tRes.tested(propName,true);
69 
70             } else {
71                 log.println("could not get property '"+ propName +"' from XPropertySet!");
72                 tRes.tested(propName, false);
73             }
74         } catch (com.sun.star.lang.WrappedTargetException e){
75             log.println("could not get property '"+ propName +"' from XPropertySet!");
76             tRes.tested(propName, false);
77         }
78     }
79 
80     /**
81      * Tested with custom property tester.
82      */
83     public void _ActiveConnection() {
84         String propName = "ActiveConnection";
85         try{
86 
87             log.println("try to get value from property...");
88             XConnection oldValue = (XConnection) UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName));
89 
90             log.println("try to get value from object relation...");
91             XConnection newValue = (XConnection) UnoRuntime.queryInterface(XConnection.class,tEnv.getObjRelation("DataAccessDescriptor.XConnection"));
92 
93             log.println("set property to a new value...");
94             oObj.setPropertyValue(propName, newValue);
95 
96             log.println("get the new value...");
97             XConnection getValue = (XConnection) UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName));
98 
99             tRes.tested(propName, this.compare(newValue, getValue));
100         } catch (com.sun.star.beans.PropertyVetoException e){
101             log.println("could not set property '"+ propName +"' to a new value! " + e.toString());
102             tRes.tested(propName, false);
103         } catch (com.sun.star.lang.IllegalArgumentException e){
104             log.println("could not set property '"+ propName +"' to a new value! " + e.toString());
105             tRes.tested(propName, false);
106         } catch (com.sun.star.beans.UnknownPropertyException e){
107             if (this.isOptional(propName)){
108                     // skipping optional property test
109                     log.println("Property '" + propName
110                             + "' is optional and not supported");
111                     tRes.tested(propName,true);
112 
113             } else {
114                 log.println("could not get property '"+ propName +"' from XPropertySet!");
115                 tRes.tested(propName, false);
116             }
117         } catch (com.sun.star.lang.WrappedTargetException e){
118             log.println("could not get property '"+ propName +"' from XPropertySet!");
119             tRes.tested(propName, false);
120         }
121     }
122 
123 }
124 
125 
126