Ejemplo n.º 1
0
 public void assertWsdlEquals(
     final InputStream expected, final InputStream source, List<String> attr, List<String> tag)
     throws Exception {
   Tag expectedTag = ToolsStaxUtils.getTagTree(expected, attr);
   Tag sourceTag = ToolsStaxUtils.getTagTree(source, attr);
   assertTagEquals(expectedTag, sourceTag, attr, tag);
 }
Ejemplo n.º 2
0
  public boolean assertXmlEquals(
      final File expected, final File source, final List<String> ignoreAttr) throws Exception {
    List<Tag> expectedTags = ToolsStaxUtils.getTags(expected);
    List<Tag> sourceTags = ToolsStaxUtils.getTags(source);

    Iterator<Tag> iterator = sourceTags.iterator();

    for (Tag expectedTag : expectedTags) {
      Tag sourceTag = iterator.next();
      if (!expectedTag.getName().equals(sourceTag.getName())) {
        throw new ComparisonFailure(
            "Tags not equal: ", expectedTag.getName().toString(), sourceTag.getName().toString());
      }
      for (Map.Entry<QName, String> attr : expectedTag.getAttributes().entrySet()) {
        if (ignoreAttr.contains(attr.getKey().getLocalPart())) {
          continue;
        }

        if (sourceTag.getAttributes().containsKey(attr.getKey())) {
          if (!sourceTag.getAttributes().get(attr.getKey()).equals(attr.getValue())) {
            throw new ComparisonFailure(
                "Attributes not equal: ",
                attr.getKey() + ":" + attr.getValue(),
                attr.getKey() + ":" + sourceTag.getAttributes().get(attr.getKey()));
          }
        } else {
          throw new AssertionError("Attribute: " + attr + " is missing in the source file.");
        }
      }

      if (!StringUtils.isEmpty(expectedTag.getText())
          && !expectedTag.getText().equals(sourceTag.getText())) {
        throw new ComparisonFailure("Text not equal: ", expectedTag.getText(), sourceTag.getText());
      }
    }
    return true;
  }