1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XCachedDynamicResultSetFactory.java,v $
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 ************************************************************************/
33 import lib
.MultiMethodTest
;
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
;
42 * Testing <code>com.sun.star.ucb.XCachedDynamicResultSetFactory</code>
45 * <li><code> createCachedDynamicResultSet()</code></li>
47 * This test needs the following object relations :
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>
54 * Test is <b> NOT </b> multithread compilant. <p>
55 * @see com.sun.star.ucb.XCachedDynamicResultSetFactory
57 public class _XCachedDynamicResultSetFactory
extends MultiMethodTest
{
60 * Conatins the tested object.
62 public XCachedDynamicResultSetFactory oObj
;
63 private XDynamicResultSet resSetStub
= null ;
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 !!!")) ;
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
93 log
.println("!!! Method returned null !!!") ;
97 XResultSet resSetS
= resSet
.getStaticResultSet() ;
98 XResultSet resSetStubS
= resSetStub
.getStaticResultSet() ;
101 int stubRowNum
= resSetStubS
.getRow() ;
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
) ;
114 } catch (com
.sun
.star
.ucb
.ListenerAlreadySetException e
) {
115 log
.println("!!! Can't get static result sets :") ;
116 e
.printStackTrace(log
) ;
121 tRes
.tested("createCachedDynamicResultSet()", result
) ;