|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AssertNotSameTagHandler.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 <assertnotsame> nodes.
|
|
13 |
* Insures that the actual and expected objects are not the same.
|
|
14 |
*
|
|
15 |
* <H3>Summary</H3>
|
|
16 |
* <assertnotsame [message="message text"] actualrefid="id"|actualobject="value"
|
|
17 |
* expectedrefid="id expectedobject="value">
|
|
18 |
*
|
|
19 |
* <H3>One of the following attributes is required:</H3>
|
|
20 |
* actualrefid id of the object to be compared.<br>
|
|
21 |
* actualobject value of the object to be compared.
|
|
22 |
*
|
|
23 |
* <H3>One of the following attributes is required:</H3>
|
|
24 |
* expectedrefid id of the object to be compared.<br>
|
|
25 |
* expectedobject value of the object to be compared.
|
|
26 |
*
|
|
27 |
* <H3>Optional Attributes:</H3>
|
|
28 |
* message Optional message text to be specified.
|
|
29 |
*
|
|
30 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
31 |
*/
|
|
32 |
public class AssertNotSameTagHandler extends AbstractAssertTagHandler { |
|
33 |
/**
|
|
34 |
* Constructor for AssertEqualsTagHandler.
|
|
35 |
*
|
|
36 |
* @param element The element to be processed
|
|
37 |
* @param testCase The IXMLTestCase that uses this element
|
|
38 |
*/
|
|
39 | 3 |
public AssertNotSameTagHandler(final Element element,
|
40 |
final IXMLTestCase testCase) { |
|
41 | 3 |
super(element, testCase);
|
42 |
} |
|
43 |
|
|
44 |
/**
|
|
45 |
* Obtain the expected and actual values. Then assert
|
|
46 |
* that they are not the same.
|
|
47 |
*
|
|
48 |
* @throws XMLException when asserting.
|
|
49 |
*/
|
|
50 | 2 |
public void processElement() throws XMLException { |
51 | 2 |
validateElement(); |
52 | 2 |
Assert.assertNotSame( |
53 |
getMessage(), |
|
54 |
getExpectedObject(), |
|
55 |
getActualObject()); |
|
56 |
} |
|
57 |
|
|
58 |
/**
|
|
59 |
* Insure that a actual and expected attributes are
|
|
60 |
* specified.
|
|
61 |
*
|
|
62 |
* @throws XMLException if one of the required
|
|
63 |
* attributes are missing.
|
|
64 |
*/
|
|
65 | 2 |
public void validateElement() throws XMLException { |
66 |
// do the default validations from the super class
|
|
67 | 2 |
super.validateElement();
|
68 |
|
|
69 |
// reqd attribute: at least one of expected or expectedrefid
|
|
70 | 2 |
checkExpected(); |
71 | 2 |
checkActual(); |
72 |
} |
|
73 |
} |
|
74 |
|
|