Package org.junit

Examples of org.junit.ComparisonFailure$ComparisonCompactor$DiffExtractor


    }

    public static void assertNotInstanceOf(String message, Class expectedClass, Object actualInstance) {
        if (expectedClass.isInstance(actualInstance)) {
            String cleanMessage = message == null ? "" : message;
            throw new ComparisonFailure(cleanMessage, "not " + expectedClass.getName(),
                    actualInstance == null ? "null" : actualInstance.getClass().getName());
        }
    }
View Full Code Here


      return;
    }
    if (expected.getClass() != actual.getClass()) {
      //One is an Exception and the other one isn't. these's no way these should
      //ever be treated as equivalent!
      throw new ComparisonFailure(null, expected.toString(), actual.toString());
    }
    if (expected instanceof Result) {
      assertEqualResults((Result) expected, (Result) actual);
    } else if (expected instanceof ResultException) {
      assertEqualExceptions((ResultException) expected, (ResultException) actual);
    } else {
      //I don't what it is?? There are only two implementations of the interface
      throw new ComparisonFailure(null, expected.toString(), actual.toString());
    }
  }
View Full Code Here

  /**
   * This method gets called to compare two ResultExceptions, but only when the standard equals method returned false. Subclasses
   * may override this to relax the equality check.
   */
  protected void assertEqualExceptions(ResultException expected, ResultException actual) {
    throw new ComparisonFailure(null, expected.toString(), actual.toString());
  }
View Full Code Here

  /**
   * This method gets called to compare two Results, but only when the standard equals method returned false. Subclasses may
   * override this to relax the equality check.
   */
  protected void assertEqualResults(Result expected, Result actual) {
    throw new ComparisonFailure(null, expected.toString(), actual.toString());
  }
View Full Code Here

        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()).toString());
                    }
                } 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().toString(),
                                            sourceTag.getText().toString());
            }
        }
        return true;
View Full Code Here

                throw new AssertionError("Attribute: " + attr.getKey()
                                         + " is missing in "
                                         + element);               
            }
            if (!found.equals(attr.getValue())) {
                throw new ComparisonFailure("Attribute not equal: ",
                                            attr.getKey() + ":" + attr.getValue(),
                                            attr.getKey() + ":" + found);
            }
        }
    }
View Full Code Here

    protected void assertTagEquals(Tag expected, Tag source,
                                   final List<String> ignoreAttr,
                                   final List<String> ignoreTag) {
        if (!expected.getName().equals(source.getName())) {
            throw new ComparisonFailure("Tags not equal: ",
                                        expected.getName().toString(),
                                        source.getName().toString());
        }

        assertAttributesEquals(expected.getName(),
                               expected.getAttributes(), source.getAttributes(), ignoreAttr);
        assertAttributesEquals(expected.getName(),
                               source.getAttributes(), expected.getAttributes(), ignoreAttr);

        if (!StringUtils.isEmpty(expected.getText())
                && !expected.getText().equals(source.getText())) {
            throw new ComparisonFailure("Text not equal: ",
                                        expected.getText().toString(),
                                        source.getText().toString());
        }

        if (!expected.getTags().isEmpty()) {
View Full Code Here

                            if(diff.identical()) {
                                reportTestResult(testName, "pass", null);
                                break;
                            } else {
                                if(oi == lastoi) {
                                    String errmsg = new ComparisonFailure("[Text comparison]", expectedStr, resString).getMessage();
                                    reportTestResult(testName, "fail", errmsg);
                                    Assert.assertEquals("[Text comparison]", expectedStr, resString);
                                }
                            }
                        }
View Full Code Here

        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()).toString());
                    }
                } 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().toString(),
                                            sourceTag.getText().toString());
            }
        }
        return true;
View Full Code Here

            String found = q2.get(attr.getKey());
            if (found == null) {
                throw new AssertionError("Attribute: " + attr.getKey() + " is missing.");               
            }
            if (!found.equals(attr.getValue())) {
                throw new ComparisonFailure("Attribute not equal: ",
                                            attr.getKey() + ":" + attr.getValue(),
                                            attr.getKey() + ":" + found);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.junit.ComparisonFailure$ComparisonCompactor$DiffExtractor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.