01: /*
02: * Copyright 2002,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.jelly.tags.junit;
17:
18: import org.apache.commons.jelly.JellyTagException;
19: import org.apache.commons.jelly.XMLOutput;
20:
21: /**
22: * This tag causes a failure message. The message can either
23: * be specified in the tags body or via the message attribute.
24: *
25: * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
26: * @version $Revision: 155420 $
27: */
28: public class FailTag extends AssertTagSupport {
29:
30: private String message;
31:
32: public FailTag() {
33: }
34:
35: // Tag interface
36: //-------------------------------------------------------------------------
37: public void doTag(XMLOutput output) throws JellyTagException {
38: String message = getMessage();
39: if (message == null) {
40: message = getBodyText();
41: }
42: fail(message);
43: }
44:
45: // Properties
46: //-------------------------------------------------------------------------
47:
48: /**
49: * @return the failure message
50: */
51: public String getMessage() {
52: return message;
53: }
54:
55: /**
56: * Sets the failure message. If this attribute is not specified then the
57: * body of this tag will be used instead.
58: */
59: public void setMessage(String message) {
60: this.message = message;
61: }
62: }
|