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 .
18 package ifc
.form
.submission
;
20 import com
.sun
.star
.form
.submission
.XSubmission
;
21 import com
.sun
.star
.form
.submission
.XSubmissionVetoListener
;
23 import lib
.MultiMethodTest
;
26 public class _XSubmission
extends MultiMethodTest
{
27 public XSubmission oObj
= null;
28 public boolean HandlerWasCalled
= false;
30 public void _addSubmissionVetoListener() {
32 "submitting with VetoListener ... exception should appear");
35 XSubmissionVetoListener aListener
= new MyListener();
38 oObj
.addSubmissionVetoListener(aListener
);
42 "the expected exception wasn't thrown ... FAILED");
43 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
45 "Expected exception was thrown while calling submit() "
46 + e
.getMessage() + "FAILED");
48 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
50 "NoSupportExpected exception was thrown while calling submit() "
51 + e
.getMessage() + "FAILED");
53 } catch (com
.sun
.star
.util
.VetoException e
) {
55 "VetoException was thrown while calling submit() "
56 + e
.getMessage() + "OK");
60 oObj
.removeSubmissionVetoListener(aListener
);
61 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
63 "NoSupportExpected exception was thrown while removing the listener) "
64 + e
.getMessage() + "FAILED");
68 tRes
.tested("addSubmissionVetoListener()", res
);
71 public void _removeSubmissionVetoListener() {
73 "submitting with VetoListener ... exception should appear");
76 XSubmissionVetoListener aListener
= new MyListener();
79 oObj
.addSubmissionVetoListener(aListener
);
83 "the expected exception wasn't thrown ... FAILED");
84 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
86 "WrappedTargetException exception was thrown while calling submit() "
87 + e
.getMessage() + "FAILED");
89 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
91 "NoSupportExpected exception was thrown while calling submit() "
92 + e
.getMessage() + "FAILED");
94 } catch (com
.sun
.star
.util
.VetoException e
) {
96 "VetoException was thrown while calling submit() "
97 + e
.getMessage() + "OK");
100 log
.println("removing the listener");
103 oObj
.removeSubmissionVetoListener(aListener
);
104 } catch (com
.sun
.star
.lang
.NoSupportException e
) {
106 "NoSupportExpected exception was thrown while removing the listener) "
107 + e
.getMessage() + "FAILED");
111 log
.println("Sleeping 2s");
113 util
.utils
.pause(2000);
115 log
.println("... done");
118 "submitting after VetoListener has been removed... no exception should appear");
122 log
.println("No Exception ... OK");
123 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
125 "WrappedTargetException was thrown while calling submit() "
126 + e
.getMessage() + "FAILED");
128 } catch (com
.sun
.star
.util
.VetoException e
) {
130 "VetoException was thrown while calling submit() "
131 + e
.getMessage() + "FAILED");
135 tRes
.tested("removeSubmissionVetoListener()", res
);
138 /** Calls submit and returns true if no exception was thrown
139 * then adds a SubmissionVetoListener and checks if the
140 * exception is thrown in case of a veto of this listener.
142 public void _submit() {
145 "submitting without VetoListener ... no exception should appear");
149 log
.println("No Exception ... OK");
150 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
152 "Exception was thrown while calling submit() "
153 + e
.getMessage() + "FAILED");
155 } catch (com
.sun
.star
.util
.VetoException e
) {
157 "VetoException was thrown while calling submit() "
158 + e
.getMessage() + "FAILED");
162 tRes
.tested("submit()", res
);
165 public class MyListener
implements XSubmissionVetoListener
{
166 public void disposing(
167 com
.sun
.star
.lang
.EventObject eventObject
) {
170 public void submitting(
171 com
.sun
.star
.lang
.EventObject eventObject
)
172 throws com
.sun
.star
.util
.VetoException
{
173 log
.println("MyVetoListener was called");
174 throw new com
.sun
.star
.util
.VetoException(
175 "submission isn't allowed ...");