|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AssertSameTagHandler.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 <assertsame> nodes.
|
|
| 13 |
* Insures that the actual and expected objects are the same.
|
|
| 14 |
*
|
|
| 15 |
* <H3>Summary</H3>
|
|
| 16 |
* <assertsame [message="message text"]
|
|
| 17 |
* actualrefid="id"|actualobject="value"
|
|
| 18 |
* expectedrefid="id"|expectedobject="value"/><br>
|
|
| 19 |
*
|
|
| 20 |
* <H3>One of the following attributes are required:</H3>
|
|
| 21 |
* actualrefid id of the object to be compared.<br>
|
|
| 22 |
* actualobject value of the object to be compared.<br>
|
|
| 23 |
*
|
|
| 24 |
* <H3>One of the following attributes are required:</H3>
|
|
| 25 |
* expectedrefid id of the object to be compared.<br>
|
|
| 26 |
* expectedobject value of the object to be compared.<br>
|
|
| 27 |
*
|
|
| 28 |
* <H3>Optional Attributes:</H3>
|
|
| 29 |
* message Optional message text to be specified.
|
|
| 30 |
*
|
|
| 31 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
| 32 |
*/
|
|
| 33 |
public class AssertSameTagHandler extends AbstractAssertTagHandler { |
|
| 34 |
/**
|
|
| 35 |
* Constructor for AssertEqualsTagHandler.
|
|
| 36 |
*
|
|
| 37 |
* @param element The element to be processed
|
|
| 38 |
* @param testCase The IXMLTestCase that uses this element
|
|
| 39 |
*/
|
|
| 40 | 3 |
public AssertSameTagHandler(final Element element,
|
| 41 |
final IXMLTestCase testCase) {
|
|
| 42 | 3 |
super(element, testCase);
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
/**
|
|
| 46 |
* Obtain the expected and actual values. Insure that the
|
|
| 47 |
* values are refrenced to the same object. If not then
|
|
| 48 |
* throw an assertion error.
|
|
| 49 |
* @throws XMLException when the values do not reflect the
|
|
| 50 |
* same object.
|
|
| 51 |
*/
|
|
| 52 | 2 |
public void processElement() throws XMLException { |
| 53 | 2 |
validateElement(); |
| 54 |
|
|
| 55 | 2 |
Assert.assertSame( |
| 56 |
getMessage(), |
|
| 57 |
getExpectedObject(), |
|
| 58 |
getActualObject()); |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
/**
|
|
| 62 |
* Insure that a actual and expected value are specified.
|
|
| 63 |
* @throws XMLException when one of the required 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 |
|
|
||||||||||