1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski package ifc.sdb; 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski import lib.MultiPropertyTest; 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski import com.sun.star.beans.PropertyValue; 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim Jagielski /** 31*b1cdbd2cSJim Jagielski * Testing <code>com.sun.star.sdb.DataSource</code> 32*b1cdbd2cSJim Jagielski * service properties : 33*b1cdbd2cSJim Jagielski * <ul> 34*b1cdbd2cSJim Jagielski * <li><code> Name</code></li> 35*b1cdbd2cSJim Jagielski * <li><code> URL</code></li> 36*b1cdbd2cSJim Jagielski * <li><code> Info</code></li> 37*b1cdbd2cSJim Jagielski * <li><code> User</code></li> 38*b1cdbd2cSJim Jagielski * <li><code> Password</code></li> 39*b1cdbd2cSJim Jagielski * <li><code> IsPasswordRequired</code></li> 40*b1cdbd2cSJim Jagielski * <li><code> SuppressVersionColumns</code></li> 41*b1cdbd2cSJim Jagielski * <li><code> IsReadOnly</code></li> 42*b1cdbd2cSJim Jagielski * <li><code> NumberFormatsSupplier</code></li> 43*b1cdbd2cSJim Jagielski * <li><code> TableFilter</code></li> 44*b1cdbd2cSJim Jagielski * <li><code> TableTypeFilter</code></li> 45*b1cdbd2cSJim Jagielski * </ul> <p> 46*b1cdbd2cSJim Jagielski * Properties testing is automated by <code>lib.MultiPropertyTest</code> <p>. 47*b1cdbd2cSJim Jagielski * After this interface test <b>it's better to recreate</b> object tested. 48*b1cdbd2cSJim Jagielski * @see com.sun.star.beans.XPropertySet 49*b1cdbd2cSJim Jagielski * @see com.sun.star.beans.XPropertySetInfo 50*b1cdbd2cSJim Jagielski * @see com.sun.star.beans.Property 51*b1cdbd2cSJim Jagielski * @see com.sun.star.lang.XServiceInfo 52*b1cdbd2cSJim Jagielski */ 53*b1cdbd2cSJim Jagielski public class _DataSource extends MultiPropertyTest { 54*b1cdbd2cSJim Jagielski 55*b1cdbd2cSJim Jagielski /** 56*b1cdbd2cSJim Jagielski * This property is an array of additional parameters for database 57*b1cdbd2cSJim Jagielski * connecting. Parameter is <code>PropertyValue</code> structure. 58*b1cdbd2cSJim Jagielski * The test just changes existing array onto array with a single 59*b1cdbd2cSJim Jagielski * element <code>("user", "API_QA_Tester")</code> <p> 60*b1cdbd2cSJim Jagielski * 61*b1cdbd2cSJim Jagielski * After testing old value is set for this property. <p> 62*b1cdbd2cSJim Jagielski * 63*b1cdbd2cSJim Jagielski * Result is OK: if property successfully changed with no excepions. 64*b1cdbd2cSJim Jagielski * @see com.sun.star.beans.PropertyValue 65*b1cdbd2cSJim Jagielski */ _Info()66*b1cdbd2cSJim Jagielski public void _Info() { 67*b1cdbd2cSJim Jagielski try { 68*b1cdbd2cSJim Jagielski Object oldInfo = oObj.getPropertyValue("Info") ; 69*b1cdbd2cSJim Jagielski 70*b1cdbd2cSJim Jagielski testProperty("Info", new PropertyTester() { 71*b1cdbd2cSJim Jagielski protected Object getNewValue(String propName, Object oldValue) { 72*b1cdbd2cSJim Jagielski 73*b1cdbd2cSJim Jagielski PropertyValue propUsr = new PropertyValue(), 74*b1cdbd2cSJim Jagielski propPass = new PropertyValue() ; 75*b1cdbd2cSJim Jagielski 76*b1cdbd2cSJim Jagielski propUsr.Name = "user" ; 77*b1cdbd2cSJim Jagielski propUsr.Value = "API_QA_Tester" ; 78*b1cdbd2cSJim Jagielski propPass.Name = "password" ; 79*b1cdbd2cSJim Jagielski propPass.Value = "guest" ; 80*b1cdbd2cSJim Jagielski 81*b1cdbd2cSJim Jagielski return new PropertyValue[] { propUsr, propPass } ; 82*b1cdbd2cSJim Jagielski } 83*b1cdbd2cSJim Jagielski }) ; 84*b1cdbd2cSJim Jagielski 85*b1cdbd2cSJim Jagielski oObj.setPropertyValue("Info", oldInfo) ; 86*b1cdbd2cSJim Jagielski } catch(com.sun.star.beans.UnknownPropertyException e) {} 87*b1cdbd2cSJim Jagielski catch(com.sun.star.beans.PropertyVetoException e) {} 88*b1cdbd2cSJim Jagielski catch(com.sun.star.lang.IllegalArgumentException e) {} 89*b1cdbd2cSJim Jagielski catch(com.sun.star.lang.WrappedTargetException e) {} 90*b1cdbd2cSJim Jagielski } 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski /** 93*b1cdbd2cSJim Jagielski * Property is tested by the common method, but after testing 94*b1cdbd2cSJim Jagielski * old value is set for this property. 95*b1cdbd2cSJim Jagielski */ _URL()96*b1cdbd2cSJim Jagielski public void _URL() { 97*b1cdbd2cSJim Jagielski try { 98*b1cdbd2cSJim Jagielski Object oldURL = oObj.getPropertyValue("URL") ; 99*b1cdbd2cSJim Jagielski 100*b1cdbd2cSJim Jagielski testProperty("URL") ; 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielski oObj.setPropertyValue("URL", oldURL) ; 103*b1cdbd2cSJim Jagielski } catch(com.sun.star.beans.UnknownPropertyException e) {} 104*b1cdbd2cSJim Jagielski catch(com.sun.star.beans.PropertyVetoException e) {} 105*b1cdbd2cSJim Jagielski catch(com.sun.star.lang.IllegalArgumentException e) {} 106*b1cdbd2cSJim Jagielski catch(com.sun.star.lang.WrappedTargetException e) {} 107*b1cdbd2cSJim Jagielski } 108*b1cdbd2cSJim Jagielski 109*b1cdbd2cSJim Jagielski /** 110*b1cdbd2cSJim Jagielski * Property is tested by the common method, but after testing 111*b1cdbd2cSJim Jagielski * old value is set for this property. 112*b1cdbd2cSJim Jagielski */ _User()113*b1cdbd2cSJim Jagielski public void _User() { 114*b1cdbd2cSJim Jagielski try { 115*b1cdbd2cSJim Jagielski Object oldUser = oObj.getPropertyValue("User") ; 116*b1cdbd2cSJim Jagielski 117*b1cdbd2cSJim Jagielski testProperty("User") ; 118*b1cdbd2cSJim Jagielski 119*b1cdbd2cSJim Jagielski oObj.setPropertyValue("User", oldUser) ; 120*b1cdbd2cSJim Jagielski } catch(com.sun.star.beans.UnknownPropertyException e) {} 121*b1cdbd2cSJim Jagielski catch(com.sun.star.beans.PropertyVetoException e) {} 122*b1cdbd2cSJim Jagielski catch(com.sun.star.lang.IllegalArgumentException e) {} 123*b1cdbd2cSJim Jagielski catch(com.sun.star.lang.WrappedTargetException e) {} 124*b1cdbd2cSJim Jagielski } 125*b1cdbd2cSJim Jagielski 126*b1cdbd2cSJim Jagielski /** 127*b1cdbd2cSJim Jagielski * Property is tested by the common method, but after testing 128*b1cdbd2cSJim Jagielski * old value is set for this property. 129*b1cdbd2cSJim Jagielski */ _Password()130*b1cdbd2cSJim Jagielski public void _Password() { 131*b1cdbd2cSJim Jagielski try { 132*b1cdbd2cSJim Jagielski Object oldPass = oObj.getPropertyValue("Password") ; 133*b1cdbd2cSJim Jagielski 134*b1cdbd2cSJim Jagielski testProperty("Password") ; 135*b1cdbd2cSJim Jagielski 136*b1cdbd2cSJim Jagielski oObj.setPropertyValue("Password", oldPass) ; 137*b1cdbd2cSJim Jagielski } catch(com.sun.star.beans.UnknownPropertyException e) {} 138*b1cdbd2cSJim Jagielski catch(com.sun.star.beans.PropertyVetoException e) {} 139*b1cdbd2cSJim Jagielski catch(com.sun.star.lang.IllegalArgumentException e) {} 140*b1cdbd2cSJim Jagielski catch(com.sun.star.lang.WrappedTargetException e) {} 141*b1cdbd2cSJim Jagielski } 142*b1cdbd2cSJim Jagielski 143*b1cdbd2cSJim Jagielski /** 144*b1cdbd2cSJim Jagielski * New value for the test is always <code>null</code>. 145*b1cdbd2cSJim Jagielski */ _NumberFormatsSupplier()146*b1cdbd2cSJim Jagielski public void _NumberFormatsSupplier() { 147*b1cdbd2cSJim Jagielski testProperty("NumberFormatsSupplier", new PropertyTester() { 148*b1cdbd2cSJim Jagielski protected Object getNewValue(String propName, Object oldValue) { 149*b1cdbd2cSJim Jagielski return null ; 150*b1cdbd2cSJim Jagielski } 151*b1cdbd2cSJim Jagielski }) ; 152*b1cdbd2cSJim Jagielski } 153*b1cdbd2cSJim Jagielski 154*b1cdbd2cSJim Jagielski /** 155*b1cdbd2cSJim Jagielski * If object test allows to recreate environment it is better to do it. 156*b1cdbd2cSJim Jagielski */ after()157*b1cdbd2cSJim Jagielski public void after() { 158*b1cdbd2cSJim Jagielski try { 159*b1cdbd2cSJim Jagielski oObj.setPropertyValue("IsPasswordRequired",new Boolean(false)); 160*b1cdbd2cSJim Jagielski } catch (Exception e) { 161*b1cdbd2cSJim Jagielski log.println("Couldn't set 'IsPasswordRequired' to false"); 162*b1cdbd2cSJim Jagielski } 163*b1cdbd2cSJim Jagielski } 164*b1cdbd2cSJim Jagielski 165*b1cdbd2cSJim Jagielski } // finish class _DataSource 166*b1cdbd2cSJim Jagielski 167*b1cdbd2cSJim Jagielski 168