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