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.sdbc; 29 30 import lib.MultiMethodTest; 31 import lib.StatusException; 32 33 import com.sun.star.sdbc.SQLException; 34 import com.sun.star.sdbc.XCloseable; 35 import com.sun.star.sdbc.XResultSet; 36 import com.sun.star.uno.UnoRuntime; 37 38 /** 39 * Testing <code>com.sun.star.sdbc.XCloseable</code> 40 * interface methods : 41 * <ul> 42 * <li><code> close()</code></li> 43 * </ul> <p> 44 * After test object must be recreated. 45 * @see com.sun.star.sdbc.XCloseable 46 */ 47 public class _XCloseable extends MultiMethodTest { 48 49 // oObj filled by MultiMethodTest 50 public XCloseable oObj = null ; 51 52 /** 53 * Closes row set. If the component implements the interface 54 * <code>com.sun.star.sdbc.XResutlSet</code> then tries to move 55 * the cursor to the first row in the result set. 56 * Has OK status if no exceptions were thrown during first call and 57 * if expected SQL exception was thrown during cursor moving. 58 */ 59 public void _close() throws StatusException { 60 boolean res = false; 61 try { 62 oObj.close(); 63 res = true; 64 } catch (SQLException e) { 65 log.println("Unexpected SQL Exception occured:" + e) ; 66 res = false; 67 } 68 69 XResultSet resSet = (XResultSet) 70 UnoRuntime.queryInterface(XResultSet.class, oObj); 71 72 if (resSet != null) { 73 try { 74 resSet.first(); 75 log.println("Expected SQLException not occured !"); 76 res = false; 77 } catch(SQLException e) { 78 log.println("Expected SQLException occured"); 79 res = true; 80 } 81 } 82 83 tRes.tested("close()", res); 84 } 85 86 /** 87 * Forces environment recreation. 88 */ 89 public void after() { 90 disposeEnvironment() ; 91 } 92 93 } // finish class _XCloseable 94 95