Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / ucb / _XCachedContentResultSetStubFactory.java
blobf8f49561dfabf95d407983b095a6286088b688eb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XCachedContentResultSetStubFactory.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.ucb;
33 import lib.MultiMethodTest;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.sdbc.XResultSet;
38 import com.sun.star.ucb.XCachedContentResultSetStubFactory;
40 /**
41 * Testing <code>com.sun.star.ucb.XCachedContentResultSetStubFactory</code>
42 * interface methods :
43 * <ul>
44 * <li><code> createCachedContentResultSetStub()</code></li>
45 * </ul> <p>
46 * This test needs the following object relations :
47 * <ul>
48 * <li> <code>'ContentResultSet'</code> (of type
49 * <code>com.sun.star.sdbc.XResultSet</code>):
50 * this must be an imlementation of <code>
51 * com.sun.star.ucb.ContentResultSet</code> service.</li>
52 * <ul> <p>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.ucb.XCachedContentResultSetStubFactory
56 public class _XCachedContentResultSetStubFactory extends MultiMethodTest {
58 /**
59 * Conatins the tested object.
61 public XCachedContentResultSetStubFactory oObj;
62 private XResultSet resSet = null ;
64 /**
65 * Retrieves object relation.
66 * @throws StatusException If relation not found.
68 public void before() {
69 resSet = (XResultSet) tEnv.getObjRelation("ContentResultSet") ;
70 if (resSet == null) {
71 log.println("!!! Relation not found !!!") ;
72 throw new StatusException(Status.failed("!!! Relation not found !!!")) ;
76 /**
77 * Creates cached result set stub from static result set. After that number
78 * of rows in cached result set created and its source set are retrieved
79 * and comared. <p>
80 * Has <b>OK</b> status if numbers of rows are equal and they are
81 * greater then 0 (because JAR file contains at least one entry).
83 public void _createCachedContentResultSetStub() {
84 boolean result = true ;
86 XResultSet resSetStub = oObj.createCachedContentResultSetStub
87 (resSet) ;
89 if (resSetStub == null) {
90 log.println("!!! Method returned null !!!") ;
91 result = false ;
92 } else {
93 try {
94 resSetStub.last() ;
95 int stubRowNum = resSetStub.getRow() ;
97 resSet.last() ;
98 int setRowNum = resSet.getRow() ;
100 result = stubRowNum == setRowNum && setRowNum > 0 ;
102 log.println("Number of rows : set=" + setRowNum +
103 " stub=" + stubRowNum) ;
104 } catch (com.sun.star.sdbc.SQLException e) {
105 log.println("!!! Something wrong with result sets :") ;
106 e.printStackTrace(log) ;
107 result = false ;
111 tRes.tested("createCachedContentResultSetStub()", result) ;