Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / form / submission / _XSubmission.java
blob14c8b37be71deb6d657a8591ca77568ae4d793d7
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() {
40 log.println(
41 "submitting with VetoListener ... exception should appear");
43 boolean res = true;
44 XSubmissionVetoListener aListener = new MyListener();
46 try {
47 oObj.addSubmissionVetoListener(aListener);
48 oObj.submit();
49 res = false;
50 log.println(
51 "the expected exception wasn't thrown ... FAILED");
52 } catch (com.sun.star.lang.WrappedTargetException e) {
53 log.println(
54 "Expected exception was thrown while calling submit() "
55 + e.getMessage() + "FAILED");
56 res = false;
57 } catch (com.sun.star.lang.NoSupportException e) {
58 log.println(
59 "NoSupportExpected exception was thrown while calling submit() "
60 + e.getMessage() + "FAILED");
61 res = false;
62 } catch (com.sun.star.util.VetoException e) {
63 log.println(
64 "VetoException was thrown while calling submit() "
65 + e.getMessage() + "OK");
68 try {
69 oObj.removeSubmissionVetoListener(aListener);
70 } catch (com.sun.star.lang.NoSupportException e) {
71 log.println(
72 "NoSupportExpected exception was thrown while removing the listener) "
73 + e.getMessage() + "FAILED");
74 res = false;
77 tRes.tested("addSubmissionVetoListener()", res);
80 public void _removeSubmissionVetoListener() {
81 log.println(
82 "submitting with VetoListener ... exception should appear");
84 boolean res = true;
85 XSubmissionVetoListener aListener = new MyListener();
87 try {
88 oObj.addSubmissionVetoListener(aListener);
89 oObj.submit();
90 res = false;
91 log.println(
92 "the expected exception wasn't thrown ... FAILED");
93 } catch (com.sun.star.lang.WrappedTargetException e) {
94 log.println(
95 "WrappedTargetException exception was thrown while calling submit() "
96 + e.getMessage() + "FAILED");
97 res = false;
98 } catch (com.sun.star.lang.NoSupportException e) {
99 log.println(
100 "NoSupportExpected exception was thrown while calling submit() "
101 + e.getMessage() + "FAILED");
102 res = false;
103 } catch (com.sun.star.util.VetoException e) {
104 log.println(
105 "VetoException was thrown while calling submit() "
106 + e.getMessage() + "OK");
109 log.println("removing the listener");
111 try {
112 oObj.removeSubmissionVetoListener(aListener);
113 } catch (com.sun.star.lang.NoSupportException e) {
114 log.println(
115 "NoSupportExpected exception was thrown while removing the listener) "
116 + e.getMessage() + "FAILED");
117 res = false;
120 log.println("Sleeping 2s");
122 try {
123 Thread.sleep(2000);
124 } catch (InterruptedException e) {
125 // sleeping didn't work
128 log.println("... done");
130 log.println(
131 "submitting after VetoListener has been removed... no exception should appear");
133 try {
134 oObj.submit();
135 log.println("No Exception ... OK");
136 } catch (com.sun.star.lang.WrappedTargetException e) {
137 log.println(
138 "WrappedTargetException was thrown while calling submit() "
139 + e.getMessage() + "FAILED");
140 res = false;
141 } catch (com.sun.star.util.VetoException e) {
142 log.println(
143 "VetoException was thrown while calling submit() "
144 + e.getMessage() + "FAILED");
145 res = false;
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() {
156 boolean res = true;
157 log.println(
158 "submitting without VetoListener ... no exception should appear");
160 try {
161 oObj.submit();
162 log.println("No Exception ... OK");
163 } catch (com.sun.star.lang.WrappedTargetException e) {
164 log.println(
165 "Exception was thrown while calling submit() "
166 + e.getMessage() + "FAILED");
167 res = false;
168 } catch (com.sun.star.util.VetoException e) {
169 log.println(
170 "VetoException was thrown while calling submit() "
171 + e.getMessage() + "FAILED");
172 res = false;
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 ...");