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 10cdf0e10cSrcweir * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.sdbc; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import java.util.Vector; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import lib.MultiMethodTest; 29cdf0e10cSrcweir import lib.Status; 30cdf0e10cSrcweir 31cdf0e10cSrcweir import com.sun.star.io.XDataInputStream; 32cdf0e10cSrcweir import com.sun.star.io.XInputStream; 33cdf0e10cSrcweir import com.sun.star.io.XTextInputStream; 34cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 35cdf0e10cSrcweir import com.sun.star.sdbc.DataType; 36cdf0e10cSrcweir import com.sun.star.sdbc.SQLException; 37cdf0e10cSrcweir import com.sun.star.sdbc.XParameters; 38cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 39cdf0e10cSrcweir import com.sun.star.util.Date; 40cdf0e10cSrcweir import com.sun.star.util.DateTime; 41cdf0e10cSrcweir import com.sun.star.util.Time; 42cdf0e10cSrcweir 43cdf0e10cSrcweir /** 44cdf0e10cSrcweir /** 45cdf0e10cSrcweir * Testing <code>com.sun.star.sdbc.XParameters</code> 46cdf0e10cSrcweir * interface methods : 47cdf0e10cSrcweir * <ul> 48cdf0e10cSrcweir * <li><code> setNull()</code></li> 49cdf0e10cSrcweir * <li><code> setObjectNull()</code></li> 50cdf0e10cSrcweir * <li><code> setBoolean()</code></li> 51cdf0e10cSrcweir * <li><code> setByte()</code></li> 52cdf0e10cSrcweir * <li><code> setShort()</code></li> 53cdf0e10cSrcweir * <li><code> setInt()</code></li> 54cdf0e10cSrcweir * <li><code> setLong()</code></li> 55cdf0e10cSrcweir * <li><code> setFloat()</code></li> 56cdf0e10cSrcweir * <li><code> setDouble()</code></li> 57cdf0e10cSrcweir * <li><code> setString()</code></li> 58cdf0e10cSrcweir * <li><code> setBytes()</code></li> 59cdf0e10cSrcweir * <li><code> setDate()</code></li> 60cdf0e10cSrcweir * <li><code> setTime()</code></li> 61cdf0e10cSrcweir * <li><code> setTimestamp()</code></li> 62cdf0e10cSrcweir * <li><code> setBinaryStream()</code></li> 63cdf0e10cSrcweir * <li><code> setCharacterStream()</code></li> 64cdf0e10cSrcweir * <li><code> setObject()</code></li> 65cdf0e10cSrcweir * <li><code> setObjectWithInfo()</code></li> 66cdf0e10cSrcweir * <li><code> setRef()</code></li> 67cdf0e10cSrcweir * <li><code> setBlob()</code></li> 68cdf0e10cSrcweir * <li><code> setClob()</code></li> 69cdf0e10cSrcweir * <li><code> setArray()</code></li> 70cdf0e10cSrcweir * <li><code> clearParameters()</code></li> 71cdf0e10cSrcweir * </ul> <p> 72cdf0e10cSrcweir * Object relations required : 73cdf0e10cSrcweir * <ul> 74cdf0e10cSrcweir * <li> <code>'XParameters.ParamValues'</code> : is a 75cdf0e10cSrcweir * <code>java.util.Vector</code> object 76cdf0e10cSrcweir * that contains parameter types and values of the statement. Each 77cdf0e10cSrcweir * element of vector corresponds to appropriate parameter (element 78cdf0e10cSrcweir * with index 0 to parameter #1, 1 -> #2, etc.). <p> 79cdf0e10cSrcweir * The following <code>XParameters</code> methods correspond to classes 80cdf0e10cSrcweir * in Vector : 81cdf0e10cSrcweir * <ul> 82cdf0e10cSrcweir * <li> <code>setBinaryStream</code> - 83cdf0e10cSrcweir * <code>com.sun.star.io.XDataInputStream</code> class. </li> 84cdf0e10cSrcweir * <li> <code>setCharacterStream</code> - 85cdf0e10cSrcweir * <code>com.sun.star.io.XTextInputStream</code> class. </li> 86cdf0e10cSrcweir * <li> <code>setObject</code> - 87cdf0e10cSrcweir * <code>java.lang.Object[]</code> class, the element with 88cdf0e10cSrcweir * index 0 must be used. </li> 89cdf0e10cSrcweir * </ul> 90cdf0e10cSrcweir * Other methods uses types of their arguments (i.e. 91cdf0e10cSrcweir * <code>java.lang.String</code> 92cdf0e10cSrcweir * for <code>setString</code> method, <code>com.sun.star.sdbc.XRef</code> 93cdf0e10cSrcweir * for <code>setRef</code> method). 94cdf0e10cSrcweir * </li> 95cdf0e10cSrcweir * </ul> 96cdf0e10cSrcweir * @see com.sun.star.sdbc.XParameters 97cdf0e10cSrcweir */ 98cdf0e10cSrcweir public class _XParameters extends MultiMethodTest { 99cdf0e10cSrcweir 100cdf0e10cSrcweir // oObj filled by MultiMethodTest 101cdf0e10cSrcweir public XParameters oObj = null ; 102cdf0e10cSrcweir 103cdf0e10cSrcweir private Vector data = null ; 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** 106cdf0e10cSrcweir * Gets object relation 107cdf0e10cSrcweir */ before()108cdf0e10cSrcweir public void before() { 109cdf0e10cSrcweir data = (Vector) tEnv.getObjRelation("XParameters.ParamValues") ; 110cdf0e10cSrcweir if (data == null) { 111cdf0e10cSrcweir log.println("!!! Relation not found !!!") ; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir /** 116cdf0e10cSrcweir * Sets String parameter (if exists) to SQL NULL value. <p> 117cdf0e10cSrcweir * Has OK status if no exceptions occured. 118cdf0e10cSrcweir */ _setNull()119cdf0e10cSrcweir public void _setNull() { 120cdf0e10cSrcweir boolean result = true ; 121cdf0e10cSrcweir int idx = findParamOfType(String.class) ; 122cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 123cdf0e10cSrcweir else { 124cdf0e10cSrcweir try { 125cdf0e10cSrcweir oObj.setNull(idx, DataType.VARCHAR) ; 126cdf0e10cSrcweir } catch (SQLException e) { 127cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 128cdf0e10cSrcweir log.println(e) ; 129cdf0e10cSrcweir result = false ; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir tRes.tested("setNull()", result) ; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir _setObjectNull()136cdf0e10cSrcweir public void _setObjectNull() { 137cdf0e10cSrcweir /* 138cdf0e10cSrcweir !!! TO DO !!! 139cdf0e10cSrcweir */ 140cdf0e10cSrcweir tRes.tested("setObjectNull()", Status.skipped(true)) ; 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir /** 144cdf0e10cSrcweir * Sets String parameter (if exists) to new value. <p> 145cdf0e10cSrcweir * Has OK status if no exceptions occured. 146cdf0e10cSrcweir */ _setString()147cdf0e10cSrcweir public void _setString() { 148cdf0e10cSrcweir boolean result = true ; 149cdf0e10cSrcweir int idx = findParamOfType(String.class) ; 150cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 151cdf0e10cSrcweir else { 152cdf0e10cSrcweir try { 153cdf0e10cSrcweir oObj.setString(idx, "XParameters") ; 154cdf0e10cSrcweir } catch (SQLException e) { 155cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 156cdf0e10cSrcweir log.println(e) ; 157cdf0e10cSrcweir result = false ; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir tRes.tested("setString()", result) ; 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir /** 165cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 166cdf0e10cSrcweir * Has OK status if no exceptions occured. 167cdf0e10cSrcweir */ _setBoolean()168cdf0e10cSrcweir public void _setBoolean() { 169cdf0e10cSrcweir boolean result = true ; 170cdf0e10cSrcweir int idx = findParamOfType(Boolean.class) ; 171cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 172cdf0e10cSrcweir else { 173cdf0e10cSrcweir try { 174cdf0e10cSrcweir oObj.setBoolean(idx, true) ; 175cdf0e10cSrcweir } catch (SQLException e) { 176cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 177cdf0e10cSrcweir log.println(e) ; 178cdf0e10cSrcweir result = false ; 179cdf0e10cSrcweir } 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir tRes.tested("setBoolean()", result) ; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir /** 186cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 187cdf0e10cSrcweir * Has OK status if no exceptions occured. 188cdf0e10cSrcweir */ _setByte()189cdf0e10cSrcweir public void _setByte() { 190cdf0e10cSrcweir boolean result = true ; 191cdf0e10cSrcweir int idx = findParamOfType(Byte.class) ; 192cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 193cdf0e10cSrcweir else { 194cdf0e10cSrcweir try { 195cdf0e10cSrcweir oObj.setByte(idx, (byte)122) ; 196cdf0e10cSrcweir } catch (SQLException e) { 197cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 198cdf0e10cSrcweir log.println(e) ; 199cdf0e10cSrcweir result = false ; 200cdf0e10cSrcweir } 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir tRes.tested("setByte()", result) ; 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir /** 207cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 208cdf0e10cSrcweir * Has OK status if no exceptions occured. 209cdf0e10cSrcweir */ _setShort()210cdf0e10cSrcweir public void _setShort() { 211cdf0e10cSrcweir boolean result = true ; 212cdf0e10cSrcweir int idx = findParamOfType(Short.class) ; 213cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 214cdf0e10cSrcweir else { 215cdf0e10cSrcweir try { 216cdf0e10cSrcweir oObj.setShort(idx, (short)133) ; 217cdf0e10cSrcweir } catch (SQLException e) { 218cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 219cdf0e10cSrcweir log.println(e) ; 220cdf0e10cSrcweir result = false ; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir } 223cdf0e10cSrcweir 224cdf0e10cSrcweir tRes.tested("setShort()", result) ; 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir /** 228cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 229cdf0e10cSrcweir * Has OK status if no exceptions occured. 230cdf0e10cSrcweir */ _setInt()231cdf0e10cSrcweir public void _setInt() { 232cdf0e10cSrcweir boolean result = true ; 233cdf0e10cSrcweir int idx = findParamOfType(Integer.class) ; 234cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 235cdf0e10cSrcweir else { 236cdf0e10cSrcweir try { 237cdf0e10cSrcweir oObj.setInt(idx, 13300) ; 238cdf0e10cSrcweir } catch (SQLException e) { 239cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 240cdf0e10cSrcweir log.println(e) ; 241cdf0e10cSrcweir result = false ; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir tRes.tested("setInt()", result) ; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir 248cdf0e10cSrcweir /** 249cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 250cdf0e10cSrcweir * Has OK status if no exceptions occured. 251cdf0e10cSrcweir */ _setLong()252cdf0e10cSrcweir public void _setLong() { 253cdf0e10cSrcweir boolean result = true ; 254cdf0e10cSrcweir int idx = findParamOfType(Long.class) ; 255cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 256cdf0e10cSrcweir else { 257cdf0e10cSrcweir try { 258cdf0e10cSrcweir oObj.setLong(idx, 13362453) ; 259cdf0e10cSrcweir } catch (SQLException e) { 260cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 261cdf0e10cSrcweir log.println(e) ; 262cdf0e10cSrcweir result = false ; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir } 265cdf0e10cSrcweir 266cdf0e10cSrcweir tRes.tested("setLong()", result) ; 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir /** 270cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 271cdf0e10cSrcweir * Has OK status if no exceptions occured. 272cdf0e10cSrcweir */ _setFloat()273cdf0e10cSrcweir public void _setFloat() { 274cdf0e10cSrcweir boolean result = true ; 275cdf0e10cSrcweir int idx = findParamOfType(Float.class) ; 276cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 277cdf0e10cSrcweir else { 278cdf0e10cSrcweir try { 279cdf0e10cSrcweir oObj.setFloat(idx, (float)133.55) ; 280cdf0e10cSrcweir } catch (SQLException e) { 281cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 282cdf0e10cSrcweir log.println(e) ; 283cdf0e10cSrcweir result = false ; 284cdf0e10cSrcweir } 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir tRes.tested("setFloat()", result) ; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir /** 291cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 292cdf0e10cSrcweir * Has OK status if no exceptions occured. 293cdf0e10cSrcweir */ _setDouble()294cdf0e10cSrcweir public void _setDouble() { 295cdf0e10cSrcweir boolean result = true ; 296cdf0e10cSrcweir int idx = findParamOfType(Double.class) ; 297cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 298cdf0e10cSrcweir else { 299cdf0e10cSrcweir try { 300cdf0e10cSrcweir oObj.setDouble(idx, 133) ; 301cdf0e10cSrcweir } catch (SQLException e) { 302cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 303cdf0e10cSrcweir log.println(e) ; 304cdf0e10cSrcweir result = false ; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 308cdf0e10cSrcweir tRes.tested("setDouble()", result) ; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir /** 312cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 313cdf0e10cSrcweir * Has OK status if no exceptions occured. 314cdf0e10cSrcweir */ _setBytes()315cdf0e10cSrcweir public void _setBytes() { 316cdf0e10cSrcweir boolean result = true ; 317cdf0e10cSrcweir int idx = findParamOfType(byte[].class) ; 318cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 319cdf0e10cSrcweir else { 320cdf0e10cSrcweir try { 321cdf0e10cSrcweir oObj.setBytes(idx, new byte[] {5}) ; 322cdf0e10cSrcweir } catch (SQLException e) { 323cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 324cdf0e10cSrcweir log.println(e) ; 325cdf0e10cSrcweir result = false ; 326cdf0e10cSrcweir } 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir tRes.tested("setBytes()", result) ; 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir /** 333cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 334cdf0e10cSrcweir * Has OK status if no exceptions occured. 335cdf0e10cSrcweir */ _setDate()336cdf0e10cSrcweir public void _setDate() { 337cdf0e10cSrcweir boolean result = true ; 338cdf0e10cSrcweir int idx = findParamOfType(Date.class) ; 339cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 340cdf0e10cSrcweir else { 341cdf0e10cSrcweir try { 342cdf0e10cSrcweir oObj.setDate( 343cdf0e10cSrcweir idx, new Date ((short)19, (short)01, (short)1979)) ; 344cdf0e10cSrcweir } catch (SQLException e) { 345cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 346cdf0e10cSrcweir log.println(e) ; 347cdf0e10cSrcweir result = false ; 348cdf0e10cSrcweir } 349cdf0e10cSrcweir } 350cdf0e10cSrcweir 351cdf0e10cSrcweir tRes.tested("setDate()", result) ; 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354cdf0e10cSrcweir /** 355cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 356cdf0e10cSrcweir * Has OK status if no exceptions occured. 357cdf0e10cSrcweir */ _setTime()358cdf0e10cSrcweir public void _setTime() { 359cdf0e10cSrcweir boolean result = true ; 360cdf0e10cSrcweir int idx = findParamOfType(Time.class) ; 361cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 362cdf0e10cSrcweir else { 363cdf0e10cSrcweir try { 364cdf0e10cSrcweir oObj.setTime( 365cdf0e10cSrcweir idx, new Time((short)1,(short)2,(short)3,(short)44)) ; 366cdf0e10cSrcweir } catch (SQLException e) { 367cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 368cdf0e10cSrcweir log.println(e) ; 369cdf0e10cSrcweir result = false ; 370cdf0e10cSrcweir } 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir tRes.tested("setTime()", result) ; 374cdf0e10cSrcweir } 375cdf0e10cSrcweir 376cdf0e10cSrcweir /** 377cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 378cdf0e10cSrcweir * Has OK status if no exceptions occured. 379cdf0e10cSrcweir */ _setTimestamp()380cdf0e10cSrcweir public void _setTimestamp() { 381cdf0e10cSrcweir boolean result = true ; 382cdf0e10cSrcweir int idx = findParamOfType(DateTime.class) ; 383cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 384cdf0e10cSrcweir else { 385cdf0e10cSrcweir try { 386cdf0e10cSrcweir oObj.setTimestamp(idx, new DateTime((short)1,(short)2,(short)3, 387cdf0e10cSrcweir (short)4, (short)19, (short)01, (short)1979)) ; 388cdf0e10cSrcweir } catch (SQLException e) { 389cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 390cdf0e10cSrcweir log.println(e) ; 391cdf0e10cSrcweir result = false ; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir tRes.tested("setTimestamp()", result) ; 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir /** 399cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 400cdf0e10cSrcweir * Has OK status if no exceptions occured. 401cdf0e10cSrcweir */ _setBinaryStream()402cdf0e10cSrcweir public void _setBinaryStream() { 403cdf0e10cSrcweir boolean result = true ; 404cdf0e10cSrcweir int idx = findParamOfType(XDataInputStream.class) ; 405cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 406cdf0e10cSrcweir else { 407cdf0e10cSrcweir try { 408cdf0e10cSrcweir Object oStream = ((XMultiServiceFactory)tParam.getMSF()). 409cdf0e10cSrcweir createInstance("com.sun.star.io.DataInputStream") ; 410cdf0e10cSrcweir XInputStream xStream = (XInputStream)UnoRuntime.queryInterface 411cdf0e10cSrcweir (XInputStream.class, oStream); 412cdf0e10cSrcweir 413cdf0e10cSrcweir oObj.setBinaryStream(idx, xStream, 2) ; 414cdf0e10cSrcweir } catch (SQLException e) { 415cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 416cdf0e10cSrcweir log.println(e) ; 417cdf0e10cSrcweir result = false ; 418cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 419cdf0e10cSrcweir log.println("Unexpected exception:") ; 420cdf0e10cSrcweir log.println(e) ; 421cdf0e10cSrcweir result = false ; 422cdf0e10cSrcweir } 423cdf0e10cSrcweir } 424cdf0e10cSrcweir 425cdf0e10cSrcweir tRes.tested("setBinaryStream()", result) ; 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir /** 429cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 430cdf0e10cSrcweir * Has OK status if no exceptions occured. 431cdf0e10cSrcweir */ _setCharacterStream()432cdf0e10cSrcweir public void _setCharacterStream() { 433cdf0e10cSrcweir boolean result = true ; 434cdf0e10cSrcweir int idx = findParamOfType(XTextInputStream.class) ; 435cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 436cdf0e10cSrcweir else { 437cdf0e10cSrcweir try { 438cdf0e10cSrcweir Object oStream = ((XMultiServiceFactory)tParam.getMSF()) 439cdf0e10cSrcweir .createInstance("com.sun.star.io.TextInputStream") ; 440cdf0e10cSrcweir XInputStream xStream = (XInputStream)UnoRuntime.queryInterface 441cdf0e10cSrcweir (XInputStream.class, oStream); 442cdf0e10cSrcweir 443cdf0e10cSrcweir oObj.setCharacterStream(idx, xStream, 2) ; 444cdf0e10cSrcweir } catch (SQLException e) { 445cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 446cdf0e10cSrcweir log.println(e) ; 447cdf0e10cSrcweir result = false ; 448cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 449cdf0e10cSrcweir log.println("Unexpected exception:") ; 450cdf0e10cSrcweir log.println(e) ; 451cdf0e10cSrcweir result = false ; 452cdf0e10cSrcweir } 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir tRes.tested("setCharacterStream()", result) ; 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir /** 459cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 460cdf0e10cSrcweir * Has OK status if no exceptions occured. 461cdf0e10cSrcweir */ _setObject()462cdf0e10cSrcweir public void _setObject() { 463cdf0e10cSrcweir boolean result = true ; 464cdf0e10cSrcweir int idx = findParamOfType(Object[].class) ; 465cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 466cdf0e10cSrcweir else { 467cdf0e10cSrcweir try { 468cdf0e10cSrcweir Object obj = ((XMultiServiceFactory)tParam.getMSF()). 469cdf0e10cSrcweir createInstance("com.sun.star.io.Pipe") ; 470cdf0e10cSrcweir 471cdf0e10cSrcweir oObj.setObject(idx, obj) ; 472cdf0e10cSrcweir } catch (SQLException e) { 473cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 474cdf0e10cSrcweir log.println(e) ; 475cdf0e10cSrcweir result = false ; 476cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 477cdf0e10cSrcweir log.println("Unexpected exception:") ; 478cdf0e10cSrcweir log.println(e) ; 479cdf0e10cSrcweir result = false ; 480cdf0e10cSrcweir } 481cdf0e10cSrcweir } 482cdf0e10cSrcweir 483cdf0e10cSrcweir tRes.tested("setObject()", result) ; 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir /** 487cdf0e10cSrcweir * Sets parameter (if exists) to new value. <p> 488cdf0e10cSrcweir * Has OK status if no exceptions occured. 489cdf0e10cSrcweir */ _setObjectWithInfo()490cdf0e10cSrcweir public void _setObjectWithInfo() { 491cdf0e10cSrcweir boolean result = true ; 492cdf0e10cSrcweir int idx = findParamOfType(Object[].class) ; 493cdf0e10cSrcweir if (idx < 0) log.println("Type not found in relation: not tested"); 494cdf0e10cSrcweir else { 495cdf0e10cSrcweir try { 496cdf0e10cSrcweir Object obj = ((XMultiServiceFactory)tParam.getMSF()). 497cdf0e10cSrcweir createInstance("com.sun.star.io.Pipe") ; 498cdf0e10cSrcweir 499cdf0e10cSrcweir oObj.setObjectWithInfo(idx, obj, DataType.OBJECT, 0) ; 500cdf0e10cSrcweir } catch (SQLException e) { 501cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 502cdf0e10cSrcweir log.println(e) ; 503cdf0e10cSrcweir result = false ; 504cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 505cdf0e10cSrcweir log.println("Unexpected exception:") ; 506cdf0e10cSrcweir log.println(e) ; 507cdf0e10cSrcweir result = false ; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir tRes.tested("setObjectWithInfo()", result) ; 512cdf0e10cSrcweir } 513cdf0e10cSrcweir _setRef()514cdf0e10cSrcweir public void _setRef() { 515cdf0e10cSrcweir /* 516cdf0e10cSrcweir !!! TO DO !!! 517cdf0e10cSrcweir */ 518cdf0e10cSrcweir tRes.tested("setRef()", Status.skipped(true)) ; 519cdf0e10cSrcweir } _setBlob()520cdf0e10cSrcweir public void _setBlob() { 521cdf0e10cSrcweir /* 522cdf0e10cSrcweir !!! TO DO !!! 523cdf0e10cSrcweir */ 524cdf0e10cSrcweir tRes.tested("setBlob()", Status.skipped(true)) ; 525cdf0e10cSrcweir } _setClob()526cdf0e10cSrcweir public void _setClob() { 527cdf0e10cSrcweir /* 528cdf0e10cSrcweir !!! TO DO !!! 529cdf0e10cSrcweir */ 530cdf0e10cSrcweir tRes.tested("setClob()", Status.skipped(true)) ; 531cdf0e10cSrcweir } _setArray()532cdf0e10cSrcweir public void _setArray() { 533cdf0e10cSrcweir /* 534cdf0e10cSrcweir !!! TO DO !!! 535cdf0e10cSrcweir */ 536cdf0e10cSrcweir tRes.tested("setArray()", Status.skipped(true)) ; 537cdf0e10cSrcweir } 538cdf0e10cSrcweir 539cdf0e10cSrcweir /** 540cdf0e10cSrcweir * Calls method. <p> 541cdf0e10cSrcweir * Has OK status if no exceptions occured. 542cdf0e10cSrcweir */ _clearParameters()543cdf0e10cSrcweir public void _clearParameters() { 544cdf0e10cSrcweir boolean result = true ; 545cdf0e10cSrcweir try { 546cdf0e10cSrcweir oObj.clearParameters() ; 547cdf0e10cSrcweir } catch (SQLException e) { 548cdf0e10cSrcweir log.println("Unexpected SQL exception:") ; 549cdf0e10cSrcweir log.println(e) ; 550cdf0e10cSrcweir result = false ; 551cdf0e10cSrcweir } 552cdf0e10cSrcweir 553cdf0e10cSrcweir tRes.tested("clearParameters()", result) ; 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir 557cdf0e10cSrcweir /** 558cdf0e10cSrcweir * Finds in relation vector index of parameter of the appropriate 559cdf0e10cSrcweir * type. 560cdf0e10cSrcweir */ findParamOfType(Class clz)561cdf0e10cSrcweir private int findParamOfType(Class clz) { 562cdf0e10cSrcweir 563cdf0e10cSrcweir for (int i = 0; i < data.size(); i++) 564cdf0e10cSrcweir if (clz.isInstance(data.get(i))) return i + 1 ; 565cdf0e10cSrcweir return -1 ; 566cdf0e10cSrcweir } 567cdf0e10cSrcweir 568cdf0e10cSrcweir } // finish class _XParameters 569cdf0e10cSrcweir 570cdf0e10cSrcweir 571