1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package ifc.form; 24 25 import com.sun.star.form.XDatabaseParameterBroadcaster; 26 import com.sun.star.form.XDatabaseParameterListener; 27 import com.sun.star.sdbc.XRowSet; 28 import com.sun.star.uno.UnoRuntime; 29 import java.io.PrintWriter; 30 import lib.MultiMethodTest; 31 32 /** 33 * 34 */ 35 public class _XDatabaseParameterBroadcaster extends MultiMethodTest { 36 37 // oObj filled by MultiMethodTest 38 public XDatabaseParameterBroadcaster oObj = null ; 39 private CheckParameterListener listenerChecker = null; 40 41 /** 42 * Interface to implement so the call of the listener can be checked. 43 */ 44 public static interface CheckParameterListener extends XDatabaseParameterListener { 45 /** 46 * Set a log of the listener, so messages of the listener get printed 47 * into the file of the interface 48 */ setLog(PrintWriter log)49 public void setLog(PrintWriter log); 50 /** 51 * Return True, when the listener was called correctly. 52 */ checkListener()53 public boolean checkListener(); 54 } 55 56 /** 57 * Get the object relation 'ParameterListenerChecker' and 58 * set the log inside of the implementation. 59 */ before()60 protected void before() { 61 listenerChecker = (CheckParameterListener) 62 tEnv.getObjRelation("ParameterListenerChecker"); 63 listenerChecker.setLog((PrintWriter)log); 64 } 65 66 /** 67 */ _addParameterListener()68 public void _addParameterListener() { 69 oObj.addParameterListener(listenerChecker); 70 tRes.tested("addParameterListener()", true); 71 } 72 73 /** 74 */ _removeParameterListener()75 public void _removeParameterListener() { 76 requiredMethod("addParameterListener()"); 77 78 // trigger the action. 79 try { 80 XRowSet xRowSet = (XRowSet)UnoRuntime.queryInterface(XRowSet.class, oObj); 81 xRowSet.execute(); 82 } 83 catch(com.sun.star.sdbc.SQLException e) { 84 log.println("Exception in XDatabaseParameterBroadcaster test."); 85 log.println("This does not let the test fail, but should be inquired."); 86 e.printStackTrace((PrintWriter)log); 87 } 88 // was the listener called? 89 oObj.removeParameterListener(listenerChecker); 90 tRes.tested("removeParameterListener()", listenerChecker.checkListener()); 91 } 92 after()93 protected void after() { 94 disposeEnvironment(); 95 } 96 } 97