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: OInteractionHandler.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 ************************************************************************/
31 package mod
._dbaccess
;
33 import java
.io
.PrintWriter
;
36 import lib
.StatusException
;
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
;
48 * Test for object which is represented by service
49 * <code>com.sun.star.sdb.InteractionHandler</code>. <p>
50 * Object implements the following interfaces :
52 * <li> <code>com::sun::star::task::XInteractionHandler</code></li>
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] ;
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 :
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>
88 public TestEnvironment
createTestEnvironment( TestParameters Param
,
90 throws StatusException
{
91 XInterface oObj
= null;
92 Object oInterface
= null;
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()) ;
117 } // finish method getTestEnvironment