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.Status; 32 import lib.StatusException; 33 34 import com.sun.star.sdbc.SQLException; 35 import com.sun.star.sdbc.XColumnLocate; 36 37 /** 38 /** 39 * Testing <code>com.sun.star.sdbc.XColumnLocate</code> 40 * interface methods : 41 * <ul> 42 * <li><code> findColumn()</code></li> 43 * </ul> <p> 44 * The test required the following relations : 45 * <ul> 46 * <li> <code> XColumnLocate.ColumnName </code> : The name of the first 47 * column. </li> 48 * </ul> 49 * @see com.sun.star.sdbc.XColumnLocate 50 */ 51 public class _XColumnLocate extends MultiMethodTest { 52 53 // oObj filled by MultiMethodTest 54 public XColumnLocate oObj = null ; 55 56 /** 57 * Using column name from object relation trying to find out 58 * the index of this column. <p> 59 * Has OK status if column index returned by method equals to 1, 60 * FAILED otherwise. 61 */ 62 public void _findColumn() { 63 boolean result = false ; 64 String colName = (String) tEnv.getObjRelation("XColumnLocate.ColumnName") ; 65 66 if (colName == null) { 67 throw new StatusException( 68 Status.failed("Object relation 'XColumnLocate.ColumnName' " + 69 "for this interface not found")); 70 } 71 72 try { 73 int colIdx = oObj.findColumn(colName) ; 74 result = colIdx == 1 ; 75 } catch (SQLException e) { 76 log.println("Exception occured:"); 77 e.printStackTrace(log); 78 result = false; 79 } 80 81 tRes.tested("findColumn()", result); 82 } 83 84 } // finish class _XColumnLocate 85 86