merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / form / _XDatabaseParameterBroadcaster.java
blob85faac33c368eae723f873e6e43b7d9e2a7266a6
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: _XDatabaseParameterBroadcaster.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
30 package ifc.form;
32 import com.sun.star.form.XDatabaseParameterBroadcaster;
33 import com.sun.star.form.XDatabaseParameterListener;
34 import com.sun.star.sdbc.XRowSet;
35 import com.sun.star.uno.UnoRuntime;
36 import java.io.PrintWriter;
37 import lib.MultiMethodTest;
39 /**
42 public class _XDatabaseParameterBroadcaster extends MultiMethodTest {
44 // oObj filled by MultiMethodTest
45 public XDatabaseParameterBroadcaster oObj = null ;
46 private CheckParameterListener listenerChecker = null;
48 /**
49 * Interface to implement so the call of the listener can be checked.
51 public static interface CheckParameterListener extends XDatabaseParameterListener {
52 /**
53 * Set a log of the listener, so messages of the listener get printed
54 * into the file of the interface
56 public void setLog(PrintWriter log);
57 /**
58 * Return True, when the listener was called correctly.
60 public boolean checkListener();
63 /**
64 * Get the object relation 'ParameterListenerChecker' and
65 * set the log inside of the implementation.
67 protected void before() {
68 listenerChecker = (CheckParameterListener)
69 tEnv.getObjRelation("ParameterListenerChecker");
70 listenerChecker.setLog((PrintWriter)log);
73 /**
75 public void _addParameterListener() {
76 oObj.addParameterListener(listenerChecker);
77 tRes.tested("addParameterListener()", true);
80 /**
82 public void _removeParameterListener() {
83 requiredMethod("addParameterListener()");
85 // trigger the action.
86 try {
87 XRowSet xRowSet = (XRowSet)UnoRuntime.queryInterface(XRowSet.class, oObj);
88 xRowSet.execute();
90 catch(com.sun.star.sdbc.SQLException e) {
91 log.println("Exception in XDatabaseParameterBroadcaster test.");
92 log.println("This does not let the test fail, but should be inquired.");
93 e.printStackTrace((PrintWriter)log);
95 // was the listener called?
96 oObj.removeParameterListener(listenerChecker);
97 tRes.tested("removeParameterListener()", listenerChecker.checkListener());
100 protected void after() {
101 disposeEnvironment();