2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod
._dbaccess
;
21 import java
.io
.PrintWriter
;
24 import lib
.StatusException
;
26 import lib
.TestEnvironment
;
27 import lib
.TestParameters
;
29 import com
.sun
.star
.lang
.XMultiServiceFactory
;
30 import com
.sun
.star
.sdbc
.SQLException
;
31 import com
.sun
.star
.task
.XInteractionContinuation
;
32 import com
.sun
.star
.task
.XInteractionRequest
;
33 import com
.sun
.star
.uno
.XInterface
;
36 * Test for object which is represented by service
37 * <code>com.sun.star.sdb.InteractionHandler</code>. <p>
38 * Object implements the following interfaces :
40 * <li> <code>com::sun::star::task::XInteractionHandler</code></li>
42 * This object test <b> is NOT </b> designed to be run in several
43 * threads concurently.
44 * @see com.sun.star.task.XInteractionHandler
45 * @see com.sun.star.sdb.InteractionHandler
46 * @see ifc.task._XInteractionHandler
48 public class OInteractionHandler
extends TestCase
{
51 private static class TestRequest
implements XInteractionRequest
{
52 public Object
getRequest() {
53 return new SQLException("Test exception") ;
56 public XInteractionContinuation
[] getContinuations() {
57 return new XInteractionContinuation
[0] ;
63 * Creating a Testenvironment for the interfaces to be tested.
64 * Creates an instance of the service
65 * <code>com.sun.star.sdb.InteractionHandler</code>.
66 * Object relations created :
68 * <li> <code>'XInteractionHandler.Request'</code> for
69 * {@link ifc.task._XInteractionHandler} : this realtion
70 * is <code>com.sun.star.task.XInteractionRequest</code>
71 * interface implementation which depends on the component
72 * tested. In this case it emulates SQL error by returning
73 * <code>SQLException</code> object. </li>
76 public TestEnvironment
createTestEnvironment( TestParameters Param
,
78 throws StatusException
{
79 XInterface oObj
= null;
80 Object oInterface
= null;
83 oInterface
= ((XMultiServiceFactory
)Param
.getMSF()).createInstance(
84 "com.sun.star.sdb.InteractionHandler" );
87 catch( com
.sun
.star
.uno
.Exception e
) {
88 log
.println("Service not available" );
89 throw new StatusException("Service not available", e
) ;
92 if (oInterface
== null) {
93 log
.println("Service wasn't created") ;
94 throw new StatusException(Status
.failed("Service wasn't created")) ;
97 oObj
= (XInterface
) oInterface
;
99 log
.println( " creating a new environment for object" );
100 TestEnvironment tEnv
= new TestEnvironment( oObj
);
102 tEnv
.addObjRelation("XInteractionHandler.Request", new TestRequest()) ;
105 } // finish method getTestEnvironment