merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _dbaccess / OInteractionHandler.java
blob3c5d27e2f7e16ff1a24c92d9017d1d5aa431da4a
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: OInteractionHandler.java,v $
10 * $Revision: 1.5 $
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;
35 import lib.Status;
36 import lib.StatusException;
37 import lib.TestCase;
38 import lib.TestEnvironment;
39 import lib.TestParameters;
41 import com.sun.star.lang.XMultiServiceFactory;
42 import com.sun.star.sdbc.SQLException;
43 import com.sun.star.task.XInteractionContinuation;
44 import com.sun.star.task.XInteractionRequest;
45 import com.sun.star.uno.XInterface;
47 /**
48 * Test for object which is represented by service
49 * <code>com.sun.star.sdb.InteractionHandler</code>. <p>
50 * Object implements the following interfaces :
51 * <ul>
52 * <li> <code>com::sun::star::task::XInteractionHandler</code></li>
53 * </ul>
54 * This object test <b> is NOT </b> designed to be run in several
55 * threads concurently.
56 * @see com.sun.star.task.XInteractionHandler
57 * @see com.sun.star.sdb.InteractionHandler
58 * @see ifc.task._XInteractionHandler
60 public class OInteractionHandler extends TestCase {
63 private static class TestRequest implements XInteractionRequest {
64 public Object getRequest() {
65 return new SQLException("Test exception") ;
68 public XInteractionContinuation[] getContinuations() {
69 return new XInteractionContinuation[0] ;
74 /**
75 * Creating a Testenvironment for the interfaces to be tested.
76 * Creates an instance of the service
77 * <code>com.sun.star.sdb.InteractionHandler</code>.
78 * Object relations created :
79 * <ul>
80 * <li> <code>'XInteractionHandler.Request'</code> for
81 * {@link ifc.task._XInteractionHandler} : this realtion
82 * is <code>com.sun.star.task.XInteractionRequest</code>
83 * interface implementation which depends on the component
84 * tested. In this case it emulates SQL error by returning
85 * <code>SQLException</code> object. </li>
86 * </ul>
88 public TestEnvironment createTestEnvironment( TestParameters Param,
89 PrintWriter log )
90 throws StatusException {
91 XInterface oObj = null;
92 Object oInterface = null;
94 try {
95 oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance(
96 "com.sun.star.sdb.InteractionHandler" );
99 catch( com.sun.star.uno.Exception e ) {
100 log.println("Service not available" );
101 throw new StatusException("Service not available", e) ;
104 if (oInterface == null) {
105 log.println("Service wasn't created") ;
106 throw new StatusException(Status.failed("Service wasn't created")) ;
109 oObj = (XInterface) oInterface;
111 log.println( " creating a new environment for object" );
112 TestEnvironment tEnv = new TestEnvironment( oObj );
114 tEnv.addObjRelation("XInteractionHandler.Request", new TestRequest()) ;
116 return tEnv;
117 } // finish method getTestEnvironment