1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
27 package ifc
.form
.submission
;
29 import com
.sun
.star
.form
.submission
.XSubmission
;
30 import com
.sun
.star
.form
.submission
.XSubmissionVetoListener
;
32 import lib
.MultiMethodTest
;
35 public class _XSubmission
extends MultiMethodTest
{
36 public XSubmission oObj
= null;
37 public boolean HandlerWasCalled
= false;
39 public void _addSubmissionVetoListener() {
41 "submitting with VetoListener ... exception should appear");
44 XSubmissionVetoListener aListener
= new MyListener();
47 oObj
.addSubmissionVetoListener(aListener
);
51 "the expected exception wasn't thrown ... FAILED");
52 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
54 "Expected exception was thrown while calling submit() "
55 + e
.getMessage() + "FAILED");
57 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
59 "NoSupportExpected exception was thrown while calling submit() "
60 + e
.getMessage() + "FAILED");
62 } catch (com
.sun
.star
.util
.VetoException e
) {
64 "VetoException was thrown while calling submit() "
65 + e
.getMessage() + "OK");
69 oObj
.removeSubmissionVetoListener(aListener
);
70 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
72 "NoSupportExpected exception was thrown while removing the listener) "
73 + e
.getMessage() + "FAILED");
77 tRes
.tested("addSubmissionVetoListener()", res
);
80 public void _removeSubmissionVetoListener() {
82 "submitting with VetoListener ... exception should appear");
85 XSubmissionVetoListener aListener
= new MyListener();
88 oObj
.addSubmissionVetoListener(aListener
);
92 "the expected exception wasn't thrown ... FAILED");
93 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
95 "WrappedTargetException exception was thrown while calling submit() "
96 + e
.getMessage() + "FAILED");
98 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
100 "NoSupportExpected exception was thrown while calling submit() "
101 + e
.getMessage() + "FAILED");
103 } catch (com
.sun
.star
.util
.VetoException e
) {
105 "VetoException was thrown while calling submit() "
106 + e
.getMessage() + "OK");
109 log
.println("removing the listener");
112 oObj
.removeSubmissionVetoListener(aListener
);
113 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
115 "NoSupportExpected exception was thrown while removing the listener) "
116 + e
.getMessage() + "FAILED");
120 log
.println("Sleeping 2s");
124 } catch (InterruptedException e
) {
125 // sleeping didn't work
128 log
.println("... done");
131 "submitting after VetoListener has been removed... no exception should appear");
135 log
.println("No Exception ... OK");
136 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
138 "WrappedTargetException was thrown while calling submit() "
139 + e
.getMessage() + "FAILED");
141 } catch (com
.sun
.star
.util
.VetoException e
) {
143 "VetoException was thrown while calling submit() "
144 + e
.getMessage() + "FAILED");
148 tRes
.tested("removeSubmissionVetoListener()", res
);
151 /** Calls submit and returns true if no exception was thrown
152 * then adds a SubmissionVetoListener and checks if the
153 * exception is thrown in case of a veto of this listener.
155 public void _submit() {
158 "submitting without VetoListener ... no exception should appear");
162 log
.println("No Exception ... OK");
163 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
165 "Exception was thrown while calling submit() "
166 + e
.getMessage() + "FAILED");
168 } catch (com
.sun
.star
.util
.VetoException e
) {
170 "VetoException was thrown while calling submit() "
171 + e
.getMessage() + "FAILED");
175 tRes
.tested("submit()", res
);
178 public class MyListener
implements XSubmissionVetoListener
{
179 public void disposing(
180 com
.sun
.star
.lang
.EventObject eventObject
) {
183 public void submitting(
184 com
.sun
.star
.lang
.EventObject eventObject
)
185 throws com
.sun
.star
.util
.VetoException
{
186 log
.println("MyVetoListener was called");
187 throw new com
.sun
.star
.util
.VetoException(
188 "submission isn't allowed ...");