%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.junit.AssertTagSupport |
|
|
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.xpath.XPathTagSupport; |
|
19 | ||
20 | /** |
|
21 | * The abstract base class of any assertion tag which is |
|
22 | * useful for implementation inheritence. |
|
23 | * |
|
24 | * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> |
|
25 | * @version $Revision: 1.4 $ |
|
26 | */ |
|
27 | public abstract class AssertTagSupport extends XPathTagSupport { |
|
28 | ||
29 | 29 | public AssertTagSupport() { |
30 | 29 | } |
31 | ||
32 | // Implementation methods |
|
33 | //------------------------------------------------------------------------- |
|
34 | ||
35 | /** |
|
36 | * Produces a failure assertion with the given message |
|
37 | */ |
|
38 | protected void fail(String message) throws JellyAssertionFailedError { |
|
39 | 10 | throw new JellyAssertionFailedError(message); |
40 | } |
|
41 | ||
42 | /** |
|
43 | * Produces a failure assertion with the given message and added detail. |
|
44 | */ |
|
45 | protected void fail(String message, String detail) throws JellyAssertionFailedError { |
|
46 | 1 | if (message == null || message.length() == 0) { |
47 | 0 | fail(detail); |
48 | } |
|
49 | else { |
|
50 | 1 | fail(message + ". Assertion failed while " + detail); |
51 | } |
|
52 | 0 | } |
53 | ||
54 | /** |
|
55 | * Produces a failure if the actual value was not equal to the expected value |
|
56 | */ |
|
57 | protected void failNotEquals(String message, Object expected, Object actual, String expressions) throws JellyAssertionFailedError { |
|
58 | 1 | String formatted= ""; |
59 | 1 | if (message != null) { |
60 | 1 | formatted = message +" "; |
61 | } |
|
62 | 1 | fail(formatted + "expected:[" + expected + "] but was:[" + actual + "]" + expressions); |
63 | 0 | } |
64 | ||
65 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |