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.ucb; 25 26 import lib.MultiMethodTest; 27 import lib.Status; 28 import lib.StatusException; 29 30 import com.sun.star.sdbc.XResultSet; 31 import com.sun.star.ucb.XCachedDynamicResultSetFactory; 32 import com.sun.star.ucb.XDynamicResultSet; 33 34 /** 35 * Testing <code>com.sun.star.ucb.XCachedDynamicResultSetFactory</code> 36 * interface methods : 37 * <ul> 38 * <li><code> createCachedDynamicResultSet()</code></li> 39 * </ul> <p> 40 * This test needs the following object relations : 41 * <ul> 42 * <li> <code>'CachedDynamicResultSetStub'</code> (of type 43 * <code>com.sun.star.sdbc.XDynamicResultSet</code>): 44 * this must be an imlementation of <code> 45 * com.sun.star.ucb.CachedDynamicResultSetStub</code> service.</li> 46 * <ul> <p> 47 * Test is <b> NOT </b> multithread compilant. <p> 48 * @see com.sun.star.ucb.XCachedDynamicResultSetFactory 49 */ 50 public class _XCachedDynamicResultSetFactory extends MultiMethodTest { 51 52 /** 53 * Conatins the tested object. 54 */ 55 public XCachedDynamicResultSetFactory oObj; 56 private XDynamicResultSet resSetStub = null ; 57 58 /** 59 * Retrieves object relation. 60 * @throws StatusException If relation not found. 61 */ before()62 public void before() { 63 resSetStub = (XDynamicResultSet) 64 tEnv.getObjRelation("CachedDynamicResultSetStub") ; 65 if (resSetStub == null) { 66 log.println("!!! Relation not found !!!") ; 67 throw new StatusException 68 (Status.failed("!!! Relation not found !!!")) ; 69 } 70 } 71 72 /** 73 * Creates result set from result set stub. After that number 74 * of rows from result set created and its stub are retrieved 75 * using their static representations and comared. <p> 76 * Has <b>OK</b> status if numbers of rows are equal and they are 77 * greater then 0 (because JAR file contains at least one entry). 78 */ _createCachedDynamicResultSet()79 public void _createCachedDynamicResultSet() { 80 boolean result = true ; 81 82 XDynamicResultSet resSet = oObj.createCachedDynamicResultSet 83 (resSetStub, null) ; 84 85 if (resSet == null) { 86 log.println("!!! Method returned null !!!") ; 87 result = false ; 88 } else { 89 try { 90 XResultSet resSetS = resSet.getStaticResultSet() ; 91 XResultSet resSetStubS = resSetStub.getStaticResultSet() ; 92 93 resSetStubS.last() ; 94 int stubRowNum = resSetStubS.getRow() ; 95 96 resSetS.last() ; 97 int setRowNum = resSetS.getRow() ; 98 99 result = stubRowNum == setRowNum && setRowNum > 0 ; 100 101 log.println("Number of rows : stub=" + stubRowNum + 102 " set=" + setRowNum) ; 103 } catch (com.sun.star.sdbc.SQLException e) { 104 log.println("!!! Something wrong with result sets :") ; 105 e.printStackTrace(log) ; 106 result = false ; 107 } catch (com.sun.star.ucb.ListenerAlreadySetException e) { 108 log.println("!!! Can't get static result sets :") ; 109 e.printStackTrace(log) ; 110 result = false ; 111 } 112 } 113 114 tRes.tested("createCachedDynamicResultSet()", result) ; 115 116 } 117 } 118 119