merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _dbaccess / ORowSet.java
blob77d2f47f8f9edde40ae769b654c9a14bfd3bf41c
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: ORowSet.java,v $
10 * $Revision: 1.8 $
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 mod._dbaccess;
33 import java.io.PrintWriter;
34 import java.util.Vector;
36 import lib.Status;
37 import lib.StatusException;
38 import lib.TestCase;
39 import lib.TestEnvironment;
40 import lib.TestParameters;
41 import util.DBTools;
42 import util.utils;
44 import com.sun.star.beans.PropertyValue;
45 import com.sun.star.beans.XPropertySet;
46 import com.sun.star.lang.XMultiServiceFactory;
47 import com.sun.star.sdb.CommandType;
48 import com.sun.star.sdb.ParametersRequest;
49 import com.sun.star.sdb.RowChangeEvent;
50 import com.sun.star.sdb.XInteractionSupplyParameters;
51 import com.sun.star.sdbc.SQLException;
52 import com.sun.star.sdbc.XConnection;
53 import com.sun.star.sdbc.XResultSet;
54 import com.sun.star.sdbc.XResultSetUpdate;
55 import com.sun.star.sdbc.XRow;
56 import com.sun.star.sdbc.XRowSet;
57 import com.sun.star.sdbc.XRowUpdate;
58 import com.sun.star.task.XInteractionAbort;
59 import com.sun.star.task.XInteractionContinuation;
60 import com.sun.star.task.XInteractionRequest;
61 import com.sun.star.ucb.AuthenticationRequest;
62 import com.sun.star.ucb.XSimpleFileAccess;
63 import com.sun.star.uno.AnyConverter;
64 import com.sun.star.uno.Type;
65 import com.sun.star.uno.UnoRuntime;
66 import com.sun.star.uno.XInterface;
67 import ifc.sdb._XCompletedExecution;
69 /**
70 * Test for object which is represented by service
71 * <code>com.sun.star.sdb.DataSource</code>. <p>
73 * Object implements the following interfaces :
74 * <ul>
75 * <li> <code>com::sun::star::sdbc::RowSet</code></li>
76 * <li> <code>com::sun::star::sdbcx::XRowLocate</code></li>
77 * <li> <code>com::sun::star::sdbc::XResultSetUpdate</code></li>
78 * <li> <code>com::sun::star::util::XCancellable</code></li>
79 * <li> <code>com::sun::star::sdbc::XParameters</code></li>
80 * <li> <code>com::sun::star::sdbc::XResultSetMetaDataSupplier</code></li>
81 * <li> <code>com::sun::star::sdbcx::XDeleteRows</code></li>
82 * <li> <code>com::sun::star::sdbc::XCloseable</code></li>
83 * <li> <code>com::sun::star::sdbcx::XColumnsSupplier</code></li>
84 * <li> <code>com::sun::star::sdb::XResultSetAccess</code></li>
85 * <li> <code>com::sun::star::sdbc::XResultSet</code></li>
86 * <li> <code>com::sun::star::sdbc::XColumnLocate</code></li>
87 * <li> <code>com::sun::star::sdbc::XRowSet</code></li>
88 * <li> <code>com::sun::star::sdb::RowSet</code></li>
89 * <li> <code>com::sun::star::sdbc::XRowUpdate</code></li>
90 * <li> <code>com::sun::star::sdb::XRowSetApproveBroadcaster</code></li>
91 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
92 * <li> <code>com::sun::star::sdbc::XRow</code></li>
93 * <li> <code>com::sun::star::sdbc::XWarningsSupplier</code></li>
94 * <li> <code>com::sun::star::lang::XComponent</code></li>
95 * <li> <code>com::sun::star::sdbcx::ResultSet</code></li>
96 * <li> <code>com::sun::star::sdbc::ResultSet</code></li>
97 * </ul> <p>
98 * The following files used by this test :
99 * <ul>
100 * <li><b> TestDB/TestDB.dbf </b> : the database file with some
101 * predefined fields described in <code>util.DBTools</code>.
102 * The copy of this file is always made in temp directory for
103 * testing purposes.</li>
104 * </ul> <p>
105 * The following parameters in ini-file used by this test:
106 * <ul>
107 * <li><code>test.db.url</code> - URL to MySQL database.
108 * For example: <code>mysql://mercury:3306/api_current</code></li>
109 * <li><code>test.db.user</code> - user for MySQL database</li>
110 * <li><code>test.db.password</code> - password for MySQL database</li>
111 * </ul><p>
113 * @see com.sun.star.sdbc.RowSet
114 * @see com.sun.star.sdbcx.XRowLocate
115 * @see com.sun.star.sdbc.XResultSetUpdate
116 * @see com.sun.star.util.XCancellable
117 * @see com.sun.star.sdbc.XParameters
118 * @see com.sun.star.sdbc.XResultSetMetaDataSupplier
119 * @see com.sun.star.sdbcx.XDeleteRows
120 * @see com.sun.star.sdbc.XCloseable
121 * @see com.sun.star.sdbcx.XColumnsSupplier
122 * @see com.sun.star.sdb.XResultSetAccess
123 * @see com.sun.star.sdbc.XResultSet
124 * @see com.sun.star.sdbc.XColumnLocate
125 * @see com.sun.star.sdbc.XRowSet
126 * @see com.sun.star.sdb.RowSet
127 * @see com.sun.star.sdbc.XRowUpdate
128 * @see com.sun.star.sdb.XRowSetApproveBroadcaster
129 * @see com.sun.star.beans.XPropertySet
130 * @see com.sun.star.sdbc.XRow
131 * @see com.sun.star.sdbc.XWarningsSupplier
132 * @see com.sun.star.lang.XComponent
133 * @see com.sun.star.sdbcx.ResultSet
134 * @see com.sun.star.sdbc.ResultSet
135 * @see ifc.sdbc._RowSet
136 * @see ifc.sdbcx._XRowLocate
137 * @see ifc.sdbc._XResultSetUpdate
138 * @see ifc.util._XCancellable
139 * @see ifc.sdbc._XParameters
140 * @see ifc.sdbc._XResultSetMetaDataSupplier
141 * @see ifc.sdbcx._XDeleteRows
142 * @see ifc.sdbc._XCloseable
143 * @see ifc.sdbcx._XColumnsSupplier
144 * @see ifc.sdb._XResultSetAccess
145 * @see ifc.sdbc._XResultSet
146 * @see ifc.sdbc._XColumnLocate
147 * @see ifc.sdbc._XRowSet
148 * @see ifc.sdb._RowSet
149 * @see ifc.sdbc._XRowUpdate
150 * @see ifc.sdb._XRowSetApproveBroadcaster
151 * @see ifc.beans._XPropertySet
152 * @see ifc.sdbc._XRow
153 * @see ifc.sdbc._XWarningsSupplier
154 * @see ifc.lang._XComponent
155 * @see ifc.sdbcx._ResultSet
156 * @see ifc.sdbc._ResultSet
158 public class ORowSet extends TestCase {
160 private static int uniqueSuffix = 0 ;
161 private DBTools dbTools = null ;
162 private static String origDB = null ;
163 private PrintWriter log = null ;
164 private static String tmpDir = null ;
165 String tableName = null;
166 DBTools.DataSourceInfo srcInf = null;
167 boolean isMySQLDB = false;
168 protected final static String dbSourceName = "ORowSetDataSource";
169 public XConnection conn = null;
170 Object dbSrc = null;
171 String aFile = "";
174 * Initializes some class fields. Then creates DataSource, which serves
175 * as a single source for all tables created in the test.
176 * This DataSource then registered in the global
177 * <code>DatabaseContext</code> service. This data source's URL
178 * points to SOffice temp directory where tables are copied from
179 * <code>TestDocuments</code> directory on every environment
180 * creation.
181 * To create DataSource for MySQL database next parameters required
182 * in ini-file:
183 * <ul>
184 * <li><code>test.db.url</code> - URL to MySQL database.
185 * For example: <code>mysql://mercury:3306/api_current</code></li>
186 * <li><code>test.db.user</code> - user for MySQL database</li>
187 * <li><code>test.db.password</code> - password for MySQL database</li>
188 * </ul>
190 * @throws StatusException if DataSource can not be created or
191 * registered.
193 protected void initialize ( TestParameters Param, PrintWriter log)
194 throws StatusException {
196 this.log = log ;
197 tmpDir = (String) Param.get("TMPURL") ;
198 tmpDir = utils.getOfficeTemp((XMultiServiceFactory)Param.getMSF());
200 origDB = util.utils.getFullTestDocName("TestDB/testDB.dbf");
202 dbTools = new DBTools((XMultiServiceFactory)Param.getMSF()) ;
204 // creating DataSource and registering it in DatabaseContext
205 String dbURL = (String) Param.get("test.db.url");
206 String dbUser = (String) Param.get("test.db.user");
207 String dbPassword = (String) Param.get("test.db.password");
209 log.println("Creating and registering DataSource ...");
210 srcInf = dbTools.newDataSourceInfo();
211 if (dbURL != null && dbUser != null && dbPassword != null) {
212 isMySQLDB = true;
213 log.println("dbURL = " + dbURL);
214 log.println("dbUSER = " + dbUser);
215 log.println("dbPASSWORD = " + dbPassword);
216 //DataSource for mysql db
217 try {
218 tableName = "soffice_test_table";
219 srcInf.URL = "jdbc:" + dbURL;
220 srcInf.IsPasswordRequired = new Boolean(true);
221 srcInf.Password = dbPassword;
222 srcInf.User = dbUser;
223 PropertyValue[] propInfo = new PropertyValue[1];
224 propInfo[0] = new PropertyValue();
225 propInfo[0].Name = "JavaDriverClass";
226 propInfo[0].Value = "org.gjt.mm.mysql.Driver";
227 srcInf.Info = propInfo;
228 dbSrc = srcInf.getDataSourceService() ;
229 if (uniqueSuffix < 1)
230 dbTools.reRegisterDB(dbSourceName, dbSrc);
231 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF ();
232 aFile = utils.getOfficeTemp (xMSF)+dbSourceName+".odb";
233 } catch (com.sun.star.uno.Exception e) {
234 log.println("Error while object test initialization :") ;
235 e.printStackTrace(log) ;
236 throw new StatusException("Error while object test" +
237 " initialization", e);
239 } else {
240 try {
241 srcInf.URL = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir) ;
242 dbSrc = srcInf.getDataSourceService() ;
243 if (uniqueSuffix < 1)
244 dbTools.reRegisterDB(dbSourceName, dbSrc) ;
245 } catch (com.sun.star.uno.Exception e) {
246 log.println("Error while object test initialization :") ;
247 e.printStackTrace(log) ;
248 throw new
249 StatusException("Error while object test initialization",e) ;
255 * Creating a Testenvironment for the interfaces to be tested.
256 * The database (DBF) file is copied from test document directory
257 * into SOffice temp dir with unique name for each enviroment
258 * creation. If the file cann't be copied (is not released)
259 * then another unique name is used (file name suffix incremented
260 * by 1).<p>
262 * <code>com.sun.star.sdb.RowSet</code> service created and its
263 * source is all rows from the current copy of the table. Then
264 * row set command ("select all rows from a table") is executed
265 * and cursor is positioned to the first row. <p>
267 * Object relations created :
268 * <ul>
269 * <li> <code>'ORowSet.Connection'</code> for
270 * internal component test usage. Is used for
271 * closing connection when cleaning up environment. </li>
272 * <li> <code>'XRowSetApproveBroadcaster.ApproveChecker'</code> for
273 * {@link ifc.sdb._XRowSetApproveBroadcaster} interface
274 * implementation which made actions required </li>
275 * <li> <code>'CurrentRowData'</code> for
276 * {@link ifc.sdbc._XRow}, {@link ifc.sdbc._XRowUpdate} :
277 * exports types and values of the current row data.</li>
278 * <li> <code>'XColumnLocate.ColumnName'</code> for
279 * {@link ifc.sdbc._XColumnLocate} :
280 * the name of the first column of the table.</li>
281 * <li> <code>'XParameters.ParamValues'</code> for
282 * {@link ifc.sdbc._XParameters} :
283 * Collection of parameter types presented in the query. </li>
284 * <li> <code>'XRowUpdate.XRow'</code> for
285 * {@link ifc.sdbc._XRowUpdate} :
286 * <code>XRow</code> interface of the current component.</li>
287 * <li> <code>'XResultSetUpdate.UpdateTester'</code> for
288 * {@link ifc.sdbc._XResultSetUpdate} </li>
289 * </ul>
291 * @see com.sun.star.sdb.DatabaseContext
292 * @see com.sun.star.sdb.DataSource
294 protected TestEnvironment createTestEnvironment(TestParameters Param,
295 PrintWriter log) {
297 XInterface oObj = null;
298 Object oInterface = null;
299 XMultiServiceFactory xMSF = null ;
300 uniqueSuffix++;
301 boolean envCreatedOK = false ;
303 //initialize test table
304 if (isMySQLDB) {
305 try {
306 dbTools.initTestTableUsingJDBC(tableName, srcInf);
307 } catch(java.sql.SQLException e) {
308 e.printStackTrace(log);
309 throw new StatusException(Status.failed("Couldn't " +
310 " init test table. SQLException..."));
311 } catch(java.lang.ClassNotFoundException e) {
312 throw new StatusException(Status.failed("Couldn't " +
313 "register mysql driver"));
315 } else {
316 String oldF = null ;
317 String newF = null ;
318 do {
319 tableName = "ORowSet_tmp" + uniqueSuffix ;
320 oldF = utils.getFullURL(origDB);
321 newF = utils.getOfficeTemp((XMultiServiceFactory)Param.getMSF())+tableName+".dbf";
322 } while (!utils.overwriteFile((XMultiServiceFactory)Param.getMSF(),oldF,newF) &&
323 uniqueSuffix++ < 50);
326 XConnection connection = null ;
328 try {
329 xMSF = (XMultiServiceFactory)Param.getMSF();
331 Object oRowSet = xMSF.createInstance("com.sun.star.sdb.RowSet") ;
333 XPropertySet xSetProp = (XPropertySet) UnoRuntime.queryInterface
334 (XPropertySet.class, oRowSet) ;
336 log.println("Trying to open: " + tableName);
338 xSetProp.setPropertyValue("DataSourceName", dbSourceName) ;
339 xSetProp.setPropertyValue("Command", tableName) ;
340 xSetProp.setPropertyValue("CommandType",
341 new Integer(CommandType.TABLE)) ;
343 com.sun.star.sdbc.XRowSet xORowSet = (com.sun.star.sdbc.XRowSet)
344 UnoRuntime.queryInterface(com.sun.star.sdbc.XRowSet.class,
345 oRowSet) ;
347 xORowSet.execute() ;
349 connection = null;
351 try {
352 connection = (XConnection) AnyConverter.toObject(
353 new Type(XConnection.class),
354 xSetProp.getPropertyValue("ActiveConnection"));
355 } catch (com.sun.star.lang.IllegalArgumentException iae) {
356 throw new StatusException("couldn't convert Any",iae);
359 oInterface = oRowSet ;
361 XResultSet xRes = (XResultSet) UnoRuntime.queryInterface
362 (XResultSet.class, oRowSet) ;
364 xRes.first() ;
366 if (oInterface == null) {
367 log.println("Service wasn't created") ;
368 throw new StatusException("Service wasn't created",
369 new NullPointerException()) ;
372 oObj = (XInterface) oInterface;
374 log.println( " creating a new environment for object" );
375 TestEnvironment tEnv = new TestEnvironment( oObj );
377 // Adding relations for disposing object
378 tEnv.addObjRelation("ORowSet.Connection", connection) ;
379 this.conn = (XConnection) tEnv.getObjRelation("ORowSet.Connection");
382 // Adding obj relation for XRowSetApproveBroadcaster test
384 final XResultSet xResSet = (XResultSet)
385 UnoRuntime.queryInterface(XResultSet.class, oObj) ;
386 final XResultSetUpdate xResSetUpdate = (XResultSetUpdate)
387 UnoRuntime.queryInterface(XResultSetUpdate.class, oObj) ;
388 final XRowSet xRowSet = (XRowSet) UnoRuntime.queryInterface
389 (XRowSet.class, oObj) ;
390 final XRowUpdate xRowUpdate = (XRowUpdate)
391 UnoRuntime.queryInterface(XRowUpdate.class, oObj) ;
392 final PrintWriter logF = log ;
393 tEnv.addObjRelation("XRowSetApproveBroadcaster.ApproveChecker",
394 new ifc.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker() {
395 public void moveCursor() {
396 try {
397 xResSet.beforeFirst() ;
398 xResSet.afterLast() ;
399 xResSet.first() ;
400 } catch (com.sun.star.sdbc.SQLException e) {
401 logF.println("### _XRowSetApproveBroadcaster." +
402 "RowSetApproveChecker.moveCursor() :") ;
403 e.printStackTrace(logF) ;
406 public RowChangeEvent changeRow() {
407 try {
408 xResSet.first() ;
409 xRowUpdate.updateString(1, "ORowSetTest2") ;
410 xResSetUpdate.updateRow() ;
411 } catch (com.sun.star.sdbc.SQLException e) {
412 logF.println("### _XRowSetApproveBroadcaster." +
413 "RowSetApproveChecker.changeRow() :") ;
414 e.printStackTrace(logF) ;
416 RowChangeEvent ev = new RowChangeEvent() ;
417 ev.Action = com.sun.star.sdb.RowChangeAction.UPDATE ;
418 ev.Rows = 1 ;
420 return ev ;
422 public void changeRowSet() {
423 try {
424 xRowSet.execute() ;
425 xResSet.first() ;
426 } catch (com.sun.star.sdbc.SQLException e) {
427 logF.println("### _XRowSetApproveBroadcaster."+
428 "RowSetApproveChecker.changeRowSet() :") ;
429 e.printStackTrace(logF) ;
432 }) ;
434 // Adding relations for XRow as a Vector with all data
435 // of current row of RowSet.
437 Vector rowData = new Vector() ;
439 for (int i = 0; i < DBTools.TST_TABLE_VALUES[0].length; i++) {
440 rowData.add(DBTools.TST_TABLE_VALUES[0][i]) ;
443 // here XRef must be added
444 // here XBlob must be added
445 // here XClob must be added
446 // here XArray must be added
448 tEnv.addObjRelation("CurrentRowData", rowData) ;
450 // Adding relation for XColumnLocate ifc test
451 tEnv.addObjRelation("XColumnLocate.ColumnName",
452 DBTools.TST_STRING_F) ;
454 // Adding relation for XCompletedExecution
455 tEnv.addObjRelation("InteractionHandlerChecker", new InteractionHandlerImpl());
456 XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oObj) ;
457 try {
458 xProp.setPropertyValue("DataSourceName", dbSourceName) ;
459 if(isMySQLDB) {
460 xProp.setPropertyValue("Command", "SELECT Column0 FROM soffice_test_table WHERE ( ( Column0 = :param1 ) )");
462 else {
463 xProp.setPropertyValue("Command", "SELECT \"_TEXT\" FROM \"ORowSet_tmp" + uniqueSuffix + "\" WHERE ( ( \"_TEXT\" = :param1 ) )");
466 xProp.setPropertyValue("CommandType", new Integer(CommandType.COMMAND)) ;
468 catch(Exception e) {
475 // Adding relation for XParameters ifc test
476 Vector params = new Vector() ;
479 tEnv.addObjRelation("XParameters.ParamValues", params) ;
481 // Adding relation for XRowUpdate
482 XRow row = (XRow) UnoRuntime.queryInterface (XRow.class, oObj) ;
483 tEnv.addObjRelation("XRowUpdate.XRow", row) ;
485 // Adding relation for XResultSetUpdate
487 final XResultSet xResSet = (XResultSet)
488 UnoRuntime.queryInterface(XResultSet.class, oObj) ;
489 final XRowUpdate xRowUpdate = (XRowUpdate)
490 UnoRuntime.queryInterface(XRowUpdate.class, oObj) ;
491 final XRow xRow = (XRow) UnoRuntime.queryInterface
492 (XRow.class, oObj) ;
494 tEnv.addObjRelation("XResultSetUpdate.UpdateTester",
495 new ifc.sdbc._XResultSetUpdate.UpdateTester() {
496 String lastUpdate = null ;
498 public int rowCount() throws SQLException {
499 int prevPos = xResSet.getRow() ;
500 xResSet.last() ;
501 int count = xResSet.getRow() ;
502 xResSet.absolute(prevPos) ;
504 return count ;
507 public void update() throws SQLException {
508 lastUpdate = xRow.getString(1) ;
509 lastUpdate += "_" ;
510 xRowUpdate.updateString(1, lastUpdate) ;
513 public boolean wasUpdated() throws SQLException {
514 String getStr = xRow.getString(1) ;
515 return lastUpdate.equals(getStr) ;
518 public int currentRow() throws SQLException {
519 return xResSet.getRow() ;
521 }) ;
524 envCreatedOK = true ;
525 return tEnv;
527 } catch(com.sun.star.uno.Exception e) {
528 log.println("Can't create object" );
529 e.printStackTrace(log) ;
530 try {
531 connection.close() ;
532 } catch(Exception ex) {}
533 throw new StatusException("Can't create object", e) ;
534 } finally {
535 if (!envCreatedOK) {
536 try {
537 connection.close() ;
538 } catch(Exception ex) {}
542 } // finish method getTestEnvironment
545 * Closes connection of <code>RowSet</code> instance created.
547 protected void cleanup( TestParameters Param, PrintWriter log) {
548 try {
549 conn.close() ;
550 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF ();
551 Object sfa = xMSF.createInstance ("com.sun.star.comp.ucb.SimpleFileAccess");
552 XSimpleFileAccess xSFA = (XSimpleFileAccess) UnoRuntime.queryInterface (XSimpleFileAccess.class, sfa);
553 log.println ("deleting database file");
554 xSFA.kill (aFile);
555 log.println ("Could delete file "+aFile+": "+!xSFA.exists (aFile));
556 } catch (com.sun.star.uno.Exception e) {
557 log.println("Can't close the connection") ;
558 e.printStackTrace(log) ;
559 } catch (com.sun.star.lang.DisposedException e) {
560 log.println("Connection was already closed. It's OK.") ;
562 // try {
563 // dbTools.revokeDB(dbSourceName) ;
564 // XComponent db = (XComponent) UnoRuntime.queryInterface(XComponent.class,dbSrc);
565 // db.dispose();
566 // } catch (com.sun.star.uno.Exception e) {
567 // log.println("Error while object test cleaning up :") ;
568 // e.printStackTrace(log) ;
569 // throw new StatusException("Error while object test cleaning up",e) ;
570 // }
574 * Implementation of interface _XCompletedExecution.CheckInteractionHandler
575 * for the XCompletedExecution test
576 * @see ifc.sdb._XCompletedExecution
578 public class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler {
579 private boolean handlerWasUsed = false;
580 private PrintWriter log = new PrintWriter(System.out);
582 public boolean checkInteractionHandler() {
583 return handlerWasUsed;
586 public void handle(XInteractionRequest xInteractionRequest) {
587 log.println("### _XCompletedExecution.InteractionHandlerImpl: handle called.");
588 ParametersRequest req = null;
589 boolean abort = false;
591 Object o = xInteractionRequest.getRequest();
592 if (o instanceof ParametersRequest) {
593 req = (ParametersRequest)o;
595 else if (o instanceof AuthenticationRequest) {
596 log.println("### The request in XCompletedExecution is of type 'AuthenticationRequest'");
597 log.println("### This is not implemented in ORowSet.InteractionHandlerImpl test -> abort.");
598 abort = true;
600 else {
601 log.println("### Unknown request:" + o.toString());
602 log.println("### This is not implemented in ORowSet.InteractionHandlerImpl test -> abort.");
603 abort = true;
606 XInteractionContinuation[]xCont = xInteractionRequest.getContinuations();
607 XInteractionSupplyParameters xParamCallback = null;
608 for(int i=0; i<xCont.length; i++) {
609 if (abort) {
610 XInteractionAbort xAbort = null;
611 xAbort = (XInteractionAbort)UnoRuntime.queryInterface(XInteractionAbort.class, xCont[i]);
612 if (xAbort != null)
613 xAbort.select();
614 return;
616 else {
617 xParamCallback = (XInteractionSupplyParameters)
618 UnoRuntime.queryInterface(XInteractionSupplyParameters.class, xCont[i]);
619 if (xParamCallback != null)
620 break;
623 if (xParamCallback != null) {
624 log.println("### _XCompletedExecution.InteractionHandlerImpl: supplying parameters.");
625 handlerWasUsed = true;
626 PropertyValue[] prop = new PropertyValue[1];
627 prop[0] = new PropertyValue();
628 prop[0].Name = "param1";
629 prop[0].Value = "Hi.";
631 xParamCallback.setParameters(prop);
632 xParamCallback.select();
634 else { // we should never reach this: abort has to be true first.
635 log.println("### _XCompletedExecution.InteractionHandlerImpl: Got no " +
636 "'XInteractionSupplyParameters' and no 'XInteractionAbort'.");
640 public void setLog(PrintWriter log) {
641 this.log = log;