本文整理汇总了Java中org.custommonkey.xmlunit.DifferenceConstants.HAS_CHILD_NODES_ID属性的典型用法代码示例。如果您正苦于以下问题:Java DifferenceConstants.HAS_CHILD_NODES_ID属性的具体用法?Java DifferenceConstants.HAS_CHILD_NODES_ID怎么用?Java DifferenceConstants.HAS_CHILD_NODES_ID使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.custommonkey.xmlunit.DifferenceConstants
的用法示例。
在下文中一共展示了DifferenceConstants.HAS_CHILD_NODES_ID属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCausedByAttribute
protected boolean isCausedByAttribute(Difference difference, boolean isOptional) {
if (difference.getId() != DifferenceConstants.ATTR_NAME_NOT_FOUND_ID
&& difference.getId() != DifferenceConstants.ELEMENT_NUM_ATTRIBUTES_ID
&& difference.getId() != DifferenceConstants.HAS_CHILD_NODES_ID
&& difference.getId() != DifferenceConstants.ATTR_VALUE_ID) {
return false;
}
// get the nodes that are different
// don't use 'difference.getControlNodeDetail().getNode()' because it
// returns a node that is not even equal to ones returned by the xPath
// parser
Set<String> attributeSet;
Node node;
for (XmlDiffDocumentType type : XmlDiffDocumentType.values()) {// test whether one of
// the document
// nodes contains an
// ignored attribute
// optional attributes must have same value, if they are set
if (!isOptional && difference.getId() == DifferenceConstants.ATTR_VALUE_ID) {
// xpath originally points to the actual attribute node ->
// remove attribute reference from xpath
node = helper.getDocumentNode(difference, type, true);
if (node != null){
// String attributeName = difference.getControlNodeDetail().getNode().getNodeName();
String attributeName = XPathUtil.getAttributeNameFromXPath(difference.getControlNodeDetail().getXpathLocation());
if (getAttributeSetForNode(node, ignoredAttributesMap)
.contains(attributeName)) {
return true;
}
}
}
node = helper.getDocumentNode(difference, type, false);
if (node == null) {
continue;
}
if (isOptional) {
attributeSet = getAttributeSetForNode(node,
optionalAttributesMap);
} else {
attributeSet = getAttributeSetForNode(node,
ignoredAttributesMap);
}
switch (difference.getId()) {
case DifferenceConstants.ATTR_NAME_NOT_FOUND_ID:
String attrName = difference.getControlNodeDetail().getValue();
if (attrName == null || attrName.equals(ATTR_NULL)){
attrName = difference.getTestNodeDetail().getValue();
attrName = helper.addNamespacePrefixToAttribute(attrName, difference.getTestNodeDetail().getNode());
}else{
attrName = helper.addNamespacePrefixToAttribute(attrName, difference.getControlNodeDetail().getNode());
}
if (attributeSet.contains(attrName)) {
return true;
}
break;
case DifferenceConstants.ELEMENT_NUM_ATTRIBUTES_ID:
case DifferenceConstants.HAS_CHILD_NODES_ID:
if (attributeSet.size() > 0) {
return true;
}
if (containsAttributesOfIgnoredNamespaces(node)) {
return true;
}
if (containsIgnorableAttributeValues(node)) {
return true;
}
break;
}
}
return false;
}
示例2: differenceFound
@Override
public int differenceFound(Difference difference) {
/*
* if (!isChildOf(difference.getTestNodeDetail().getNode(), testRoot) ||
* !isChildOf(difference.getControlNodeDetail().getNode(), refRoot)) {
* return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; }
*/
switch (difference.getId()) {
case DifferenceConstants.TEXT_VALUE_ID:
String controlString = WhitespaceUtil
.normalizeWhitespace(difference.getControlNodeDetail()
.getValue());
String testString = WhitespaceUtil.normalizeWhitespace(difference
.getTestNodeDetail().getValue());
if (controlString.equals(testString)) // Text nodes only differ
// in whitespaces
return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
else
return RETURN_ACCEPT_DIFFERENCE;
case DifferenceConstants.ATTR_SEQUENCE_ID:
case DifferenceConstants.CHILD_NODELIST_LENGTH_ID:
case DifferenceConstants.CHILD_NODELIST_SEQUENCE_ID:
return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
case DifferenceConstants.CHILD_NODE_NOT_FOUND_ID:
// Something has been added in the test document
// return RETURN_ACCEPT_DIFFERENCE;
if (difference.getControlNodeDetail().getNode() == null)
return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
else
return RETURN_ACCEPT_DIFFERENCE;
case DifferenceConstants.HAS_CHILD_NODES_ID:
// The reference has no child nodes
if (difference.getControlNodeDetail().getNode().hasChildNodes() == false)
return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
else
return RETURN_ACCEPT_DIFFERENCE;
default:
return RETURN_ACCEPT_DIFFERENCE;
}
}