Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _dbaccess / OInteractionHandler.java
blob0d2fbb06c329d6a98d8b780d8a1c6b72908a36a2
1 /*
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;
23 import lib.Status;
24 import lib.StatusException;
25 import lib.TestCase;
26 import lib.TestEnvironment;
27 import lib.TestParameters;
29 import com.sun.star.sdbc.SQLException;
30 import com.sun.star.task.XInteractionContinuation;
31 import com.sun.star.task.XInteractionRequest;
32 import com.sun.star.uno.XInterface;
34 /**
35 * Test for object which is represented by service
36 * <code>com.sun.star.sdb.InteractionHandler</code>. <p>
37 * Object implements the following interfaces :
38 * <ul>
39 * <li> <code>com::sun::star::task::XInteractionHandler</code></li>
40 * </ul>
41 * This object test <b> is NOT </b> designed to be run in several
42 * threads concurently.
43 * @see com.sun.star.task.XInteractionHandler
44 * @see com.sun.star.sdb.InteractionHandler
45 * @see ifc.task._XInteractionHandler
47 public class OInteractionHandler extends TestCase {
50 private static class TestRequest implements XInteractionRequest {
51 public Object getRequest() {
52 return new SQLException("Test exception") ;
55 public XInteractionContinuation[] getContinuations() {
56 return new XInteractionContinuation[0] ;
61 /**
62 * Creating a Testenvironment for the interfaces to be tested.
63 * Creates an instance of the service
64 * <code>com.sun.star.sdb.InteractionHandler</code>.
65 * Object relations created :
66 * <ul>
67 * <li> <code>'XInteractionHandler.Request'</code> for
68 * {@link ifc.task._XInteractionHandler} : this relation
69 * is <code>com.sun.star.task.XInteractionRequest</code>
70 * interface implementation which depends on the component
71 * tested. In this case it emulates SQL error by returning
72 * <code>SQLException</code> object. </li>
73 * </ul>
75 @Override
76 public TestEnvironment createTestEnvironment( TestParameters Param,
77 PrintWriter log )
78 throws StatusException {
79 XInterface oObj = null;
80 Object oInterface = null;
82 try {
83 oInterface = 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()) ;
104 return tEnv;
105 } // finish method getTestEnvironment