|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AssertNotEqualsTagHandler.java | - | 100% | 100% | 100% |
|
1 |
package junit.extensions.xml.elements;
|
|
2 |
|
|
3 |
import junit.extensions.xml.IXMLTestCase;
|
|
4 |
import junit.extensions.xml.XMLException;
|
|
5 |
|
|
6 |
import junit.framework.Assert;
|
|
7 |
|
|
8 |
import org.w3c.dom.Element;
|
|
9 |
|
|
10 |
|
|
11 |
/**
|
|
12 |
* This class will handle the processing of <assertnotequal> nodes.
|
|
13 |
* Insures that the actual and expected objects are not equal.
|
|
14 |
*
|
|
15 |
* <H3>Summary</H3>
|
|
16 |
* assertnotequal [message="message text"] actualrefid="id"|actualobject="value"
|
|
17 |
* expectedrefid="id expectedobject="value"
|
|
18 |
*<H3>One of the following attributes is required:</H3>
|
|
19 |
* actualrefid id of the object to be compared.<p>
|
|
20 |
* actualobject value of the object to be compared.<p>
|
|
21 |
*
|
|
22 |
* <H3>One of the following attributes is required:</H3>
|
|
23 |
* expectedrefid id of the object to be compared.<p>
|
|
24 |
* expectedobject value of the object to be compared.<p>
|
|
25 |
*
|
|
26 |
* <H3>Optional Attributes:</H3>
|
|
27 |
* message Optional message text to be specified.
|
|
28 |
*
|
|
29 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
30 |
*/
|
|
31 |
public class AssertNotEqualsTagHandler extends AbstractAssertTagHandler { |
|
32 |
/**
|
|
33 |
* Constructor for AssertEqualsTagHandler.
|
|
34 |
*
|
|
35 |
* @param element The element to be processed
|
|
36 |
* @param testCase The IXMLTestCase that uses this element
|
|
37 |
*/
|
|
38 | 11 |
public AssertNotEqualsTagHandler(final Element element,
|
39 |
final IXMLTestCase testCase) { |
|
40 | 11 |
super(element, testCase);
|
41 |
} |
|
42 |
|
|
43 |
/**
|
|
44 |
* Obtain the expected and actual values. If the
|
|
45 |
* compared values are not equal then assert.
|
|
46 |
*
|
|
47 |
* @throws XMLException when exception is thrown.
|
|
48 |
*/
|
|
49 | 10 |
public void processElement() throws XMLException { |
50 | 10 |
validateElement(); |
51 |
|
|
52 | 10 |
boolean assrt = false; |
53 |
|
|
54 | 10 |
try {
|
55 | 10 |
Assert.assertEquals( |
56 |
getExpectedObject(), |
|
57 |
getActualObject()); |
|
58 |
} catch (Throwable t) {
|
|
59 | 6 |
assrt = true;
|
60 |
} |
|
61 |
|
|
62 | 10 |
Assert.assertTrue( |
63 |
getMessage(), |
|
64 |
assrt); |
|
65 |
} |
|
66 |
|
|
67 |
/**
|
|
68 |
* Insure that the expected and actual attributes are
|
|
69 |
* specified.
|
|
70 |
* @throws XMLException thrown if the expected or actual
|
|
71 |
* values are not specified.
|
|
72 |
*/
|
|
73 | 10 |
public void validateElement() throws XMLException { |
74 |
// do the default validations from the super class
|
|
75 | 10 |
super.validateElement();
|
76 |
|
|
77 |
// reqd attribute: at least one of expected or expectedrefid
|
|
78 | 10 |
checkExpected(); |
79 | 10 |
checkActual(); |
80 |
} |
|
81 |
} |
|
82 |
|
|