1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package ifc.sdb;
29 
30 import lib.MultiMethodTest;
31 import lib.StatusException;
32 
33 import com.sun.star.sdb.XCompletedConnection;
34 import com.sun.star.sdbc.XConnection;
35 import com.sun.star.task.XInteractionHandler;
36 
37 /**
38  * Testing <code>com.sun.star.sdb.XCompletedConnection</code>
39  * interface methods :
40  * <ul>
41  *  <li><code> connectWithCompletion()</code></li>
42  * </ul> <p>
43 *    The following object relations required :
44 * <ul>
45 * <li> <code>'XCompletedConnection.Handler'</code> : passed as parameter
46 * to <code>connectWithCompletion</code> method. </li>
47 * </ul>
48 * @see com.sun.star.sdb.XCompletedConnection
49 * @see com.sun.star.task.XInteractionHandler
50 * @see com.sun.star.sdbc.XConnection
51 */
52 public class _XCompletedConnection extends MultiMethodTest {
53 
54     // oObj filled by MultiMethodTest
55     public XCompletedConnection oObj = null ;
56 
57     /**
58     * Test call the method with handler passed as object relation.
59     * Then value returned is checked.<p>
60     * Has OK status if not null value returned. <&nbsp>
61     * FAILED if exception occured, null value returned or object
62     * relation was not found.
63     */
64     public void _connectWithCompletion() throws StatusException {
65         XInteractionHandler handler = (XInteractionHandler)
66             tEnv.getObjRelation("XCompletedConnection.Handler") ;
67 
68         if (handler == null) {
69             log.println("Required object relation not found !") ;
70             tRes.tested("connectWithCompletion()", false) ;
71             return ;
72         }
73 
74         XConnection con = null ;
75         try {
76             con = oObj.connectWithCompletion(handler) ;
77         } catch (com.sun.star.sdbc.SQLException e) {
78             throw new StatusException("Exception while method calling", e) ;
79         }
80 
81         tRes.tested("connectWithCompletion()", con != null) ;
82     }
83 }  // finish class _XCompletedConnection
84 
85