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.sdbc; 25 26 import lib.MultiMethodTest; 27 28 import com.sun.star.sdbc.XConnection; 29 import com.sun.star.sdbc.XDataSource; 30 31 /** 32 * Testing <code>com.sun.star.sdbc.XDataSource</code> 33 * interface methods : 34 * <ul> 35 * <li><code>getConnection()</code></li> 36 * <li><code>setLoginTimeout()</code></li> 37 * <li><code>getLoginTimeout()</code></li> 38 * </ul> <p> 39 * @see com.sun.star.sdbc.XDataSource 40 */ 41 public class _XDataSource extends MultiMethodTest { 42 // oObj filled by MultiMethodTest 43 public XDataSource oObj = null; 44 45 /** 46 * Calls the method and checks returned value. 47 * Has OK status if exception wasn't thrown and 48 * if returned value isn't null. 49 */ _getConnection()50 public void _getConnection() { 51 boolean res = true; 52 53 try { 54 XConnection connection = oObj.getConnection("", ""); 55 res = connection != null; 56 } catch(com.sun.star.sdbc.SQLException e) { 57 log.println("Unexpected exception:"); 58 e.printStackTrace(log); 59 res = false; 60 } 61 62 tRes.tested("getConnection()", res); 63 } 64 65 /** 66 * Sets new timeout, compares with timeout returned by the method 67 * <code>getLoginTimeout()</code>. 68 * Has OK status if exception wasn't thrown and if timeout values are equal. 69 */ _setLoginTimeout()70 public void _setLoginTimeout() { 71 requiredMethod("getLoginTimeout()"); 72 boolean res = true; 73 74 try { 75 final int TO = 111; 76 log.println("setLoginTimeout(" + TO + ")"); 77 oObj.setLoginTimeout(TO); 78 int timeout = oObj.getLoginTimeout(); 79 res = timeout == TO; 80 log.println("getLoginTimeout(): " + timeout); 81 } catch(com.sun.star.sdbc.SQLException e) { 82 log.println("Unexpected exception:"); 83 e.printStackTrace(log); 84 res = false; 85 } 86 87 tRes.tested("setLoginTimeout()", res); 88 } 89 90 /** 91 * Calls the method and checks returned value. 92 * Has OK status if exception wasn't thrown and 93 * if returned value is equal to zero. 94 */ _getLoginTimeout()95 public void _getLoginTimeout() { 96 boolean res = true; 97 98 try { 99 int timeout = oObj.getLoginTimeout(); 100 log.println("getLoginTimeout(): " + timeout); 101 res = timeout == 0; 102 } catch(com.sun.star.sdbc.SQLException e) { 103 log.println("Unexpected exception:"); 104 e.printStackTrace(log); 105 res = false; 106 } 107 108 tRes.tested("getLoginTimeout()", res); 109 } 110 }