KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jelly > tags > junit > FailTag


1 /*
2  * Copyright 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc message;
31
32     public FailTag() {
33     }
34
35     // Tag interface
36
//-------------------------------------------------------------------------
37
public void doTag(XMLOutput output) throws JellyTagException {
38         String JavaDoc 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 JavaDoc getMessage() {
52         return message;
53     }
54
55
56     /**
57      * Sets the failure message. If this attribute is not specified then the
58      * body of this tag will be used instead.
59      */

60     public void setMessage(String JavaDoc message) {
61         this.message = message;
62     }
63 }
64
Popular Tags