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