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