Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / ucb / _XCachedContentResultSetFactory.java
blob0d6a95bdb459159fb488d4d64c00743f1fd33ac0
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: _XCachedContentResultSetFactory.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.XCachedContentResultSetFactory;
40 /**
41 * Testing <code>com.sun.star.ucb.XCachedContentResultSetFactory</code>
42 * interface methods :
43 * <ul>
44 * <li><code> createCachedContentResultSet()</code></li>
45 * </ul> <p>
46 * This test needs the following object relations :
47 * <ul>
48 * <li> <code>'CachedContentResultSetStub'</code> (of type
49 * <code>com.sun.star.sdbc.XResultSet</code>):
50 * this must be an imlementation of <code>
51 * com.sun.star.ucb.CachedContentResultSetStub</code> service.</li>
52 * <ul> <p>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.ucb.XCachedContentResultSetFactory
56 public class _XCachedContentResultSetFactory extends MultiMethodTest {
58 /**
59 * Conatins the tested object.
61 public XCachedContentResultSetFactory oObj;
62 private XResultSet resSetStub = null ;
64 /**
65 * Retrieves object relation.
66 * @throws StatusException If relation not found.
68 public void before() {
69 resSetStub = (XResultSet)
70 tEnv.getObjRelation("CachedContentResultSetStub") ;
71 if (resSetStub == null) {
72 log.println("!!! Relation not found !!!") ;
73 throw new StatusException
74 (Status.failed("!!! Relation not found !!!")) ;
78 /**
79 * Creates result set from result set stub. After that number
80 * of rows from result set created and its stub are retrieved
81 * using their static representations and comared. <p>
82 * Has <b>OK</b> status if numbers of rows are equal and they are
83 * greater then 0 (because JAR file contains at least one entry).
85 public void _createCachedContentResultSet() {
86 boolean result = true ;
88 XResultSet resSet = oObj.createCachedContentResultSet
89 (resSetStub, null) ;
91 if (resSet == null) {
92 log.println("!!! Method returned null !!!") ;
93 result = false ;
94 } else {
95 try {
96 resSetStub.last() ;
97 int stubRowNum = resSetStub.getRow() ;
99 resSet.last() ;
100 int setRowNum = resSet.getRow() ;
102 result = stubRowNum == setRowNum && setRowNum > 0 ;
104 log.println("Number of rows : stub=" + stubRowNum +
105 " set=" + setRowNum) ;
106 } catch (com.sun.star.sdbc.SQLException e) {
107 log.println("!!! Something wrong with result sets :") ;
108 e.printStackTrace(log) ;
109 result = false ;
113 tRes.tested("createCachedContentResultSet()", result) ;