微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.junit.ComparisonFailure的实例源码

项目:sonar-analyzer-commons    文件MultiFiLeverifierTest.java   
@Test
public void code_js_with_one_issue() throws Exception {
  Path path = Paths.get("src/test/resources/code.js");
  MultiFiLeverifier verifier = MultiFiLeverifier.create(path,UTF_8);

  verifier.addComment(path,4,19,"// Noncompliant",2,0);
  verifier.reportIssue(path,"issue").onLine(4);

  verifier.assertOneOrMoreIssues();

  try {
    verifier.assertNoIssues();
    Assert.fail("Should raise ComparisonFailure.");
  } catch (ComparisonFailure failure) {
    assertthat(failure.getExpected()).contains("ERROR: 'assertNoIssues()' is called but there's some 'Noncompliant' comments.");
  }
}
项目:n4js    文件XpectCompareCommandHandler.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

    IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
    try {
        view = (N4IDEXpectView) windows[0].getActivePage().showView(
                N4IDEXpectView.ID);
    } catch (PartinitException e) {
        N4IDEXpectUIPlugin.logError("cannot refresh test view window",e);
    }

    Description desc = (Description) selection.getFirstElement();
    if (desc.istest() && view.testsExecutionStatus.hasFailed(desc)) {
        Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();

        if (failureException instanceof ComparisonFailure) {
            ComparisonFailure cf = (ComparisonFailure) failureException;
            // display comparison view
            displayComparisonView(cf,desc);
        }
    }
    return null;
}
项目:n4js    文件XpectCompareCommandHandler.java   
/**
 * display comparison view of test file with expected and actual xpect expectation
 */
private void displayComparisonView(ComparisonFailure cf,Description desc) {
    IXpectURIProvider uriProfider = XpectRunner.INSTANCE.getUriProvider();
    IFile fileTest = null;
    if (uriProfider instanceof N4IDEXpectTestURIProvider) {
        N4IDEXpectTestURIProvider fileCollector = (N4IDEXpectTestURIProvider) uriProfider;
        fileTest = ResourcesPlugin.getWorkspace().getRoot()
                .getFileForLocation(new Path(fileCollector.findRawLocation(desc)));
    }

    if (fileTest != null && fileTest.isAccessible()) {
        N4IDEXpectCompareEditorInput inp = new N4IDEXpectCompareEditorInput(fileTest,cf);
        CompareUI.openCompareEditor(inp);
    } else {
        throw new RuntimeException("paths in descriptions changed!");
    }
}
项目:JRediClients    文件AssertUtil.java   
public static void assertByteArraySetEquals(Set<byte[]> expected,Set<byte[]> actual) {
  assertEquals(expected.size(),actual.size());
  Iterator<byte[]> e = expected.iterator();
  while (e.hasNext()) {
    byte[] next = e.next();
    boolean contained = false;
    for (byte[] element : expected) {
      if (Arrays.equals(next,element)) {
        contained = true;
      }
    }
    if (!contained) {
      throw new ComparisonFailure("element is missing",Arrays.toString(next),actual.toString());
    }
  }
}
项目:pact-spring-mvc    文件JsonResponseBodyMatcher.java   
@Override
public void match(MvcResult result) throws Exception {
    String content = result.getResponse().getContentAsstring();

    final JsonParser parser = new JsonParser();
    final JsonElement actual = parser.parse(content);

    if (actual.isJsonPrimitive()) {
        final JsonElement expected = parser.parse(expectedJsonResponse);
        assertthat(actual,is(expected));
    } else {
        try {
            JSONAssert.assertEquals(expectedJsonResponse,content,false);
        } catch (AssertionError e) {
            throw new ComparisonFailure(e.getMessage(),expectedJsonResponse,content);
        }
    }
}
项目:educational-plugin    文件CCTestCase.java   
public void checkByFile(TaskFile taskFile,String fileName,boolean useLength) {
  Pair<Document,List<AnswerPlaceholder>> placeholders = getPlaceholders(fileName,useLength,true);
  String message = "Placeholders don't match";
  if (taskFile.getActivePlaceholders().size() != placeholders.second.size()) {
    throw new ComparisonFailure(message,CCTestsUtil.getPlaceholdersPresentation(taskFile.getActivePlaceholders()),CCTestsUtil.getPlaceholdersPresentation(placeholders.second));
  }
  for (AnswerPlaceholder answerPlaceholder : placeholders.getSecond()) {
    AnswerPlaceholder placeholder = taskFile.getAnswerPlaceholder(answerPlaceholder.getoffset());
    if (!CCTestsUtil.comparePlaceholders(placeholder,answerPlaceholder)) {
      throw new ComparisonFailure(message,CCTestsUtil.getPlaceholdersPresentation(placeholders.second));
    }
  }
}
项目:aws-sdk-java-v2    文件PoetMatchers.java   
public static Matcher<Classspec> generatesTo(String expectedTestFile) {
    return new TypeSafeMatcher<Classspec>() {
        @Override
        protected boolean matchesSafely(Classspec spec) {
            String expectedClass = getExpectedClass(spec,expectedTestFile);
            String actualClass = generateClass(spec);
            try {
                assertthat(actualClass,equalToIgnoringWhiteSpace(expectedClass));
            } catch (AssertionError e) {
                //Unfortunately for string comparisons Hamcrest doesn't really give us a nice diff. On the other hand
                //IDEs kNow how to nicely display JUnit's ComparisonFailure - makes debugging tests much easier
                throw new ComparisonFailure(String.format("Output class does not match expected [test-file: %s]",expectedTestFile),expectedClass,actualClass);
            }
            return true;
        }

        @Override
        public void describeto(Description description) {
            //Since we bubble an exception this will never actually get called
        }
    };
}
项目:twig4j-core    文件HashTests.java   
@Test
public void canCompile() throws LoaderException,Twig4jRuntimeException {
    ClassCompiler compiler = new ClassCompiler(new Environment());

    Hash hash = new Hash(1);
    hash.putAttribute("foo",new Constant("Foo",1));
    hash.putAttribute("bar",new Constant("Bar",1));

    hash.compile(compiler);

    // Since it's a hashmap we're not sure of the order of the attributes so just try both
    try {
        Assert.assertEquals(
                "Compiled source code should be valid java array","((new org.twig4j.core.util.HashMap()).put(\"foo\",\"Foo\").put(\"bar\",\"Bar\"))",compiler.getSourceCode()
        );
    } catch (ComparisonFailure e) {
        Assert.assertEquals(
                "Compiled source code should be valid java array","((new org.twig4j.core.util.HashMap()).put(\"bar\",\"Bar\").put(\"foo\",\"Foo\"))",compiler.getSourceCode()
        );
    }
}
项目:4mila-1.0    文件IOF300CourseImporterTest.java   
private void assertCourseVariants(List<List<CourseControlRowData>> variantList,String[][] codes) throws ComparisonFailure {
  int successCounter = 0;
  ComparisonFailure lastException = null;
  for (List<CourseControlRowData> course : variantList) {
    for (String[] codeList : codes) {
      try {
        assertCourse(course,codeList);
        successCounter++;
      }
      catch (ComparisonFailure e) {
        lastException = e;
      }
    }
  }
  if (successCounter != variantList.size()) {
    throw lastException;
  }
}
项目:cachecloud    文件JedisCommandTestBase.java   
protected void assertEquals(Set<byte[]> expected,actual.toString());
    }
  }
}
项目:strategy-spring-security-acl    文件MultithreadCustomerRepositoryTest.java   
private void prepareTaskAs(Runnable runnable,String lastName) {
    range(0,TIMES).forEach(i -> {
        tasks.add(() -> {
            Session.login(lastName);
            try {
                runnable.run();
            } catch (ComparisonFailure failure) {
                throw new ComparisonFailure(lastName + ": " + failure.getMessage(),failure.getExpected(),failure.getActual());
            } finally {
                Session.logout();
            }
            return lastName;
        });
    });
}
项目:xtext-core    文件PartialParsingProcessor.java   
@Override
public String processFile(String completeData,String data,int offset,int len,String change) throws Exception {
    IParseResult initialParseResult = parser.parse(new StringReader(data));
    String newData = applyDelta(data,offset,len,change);
    ReplaceRegion replaceRegion = new ReplaceRegion(offset,change);
    try {
        IParseResult reparsed = parser.reparse(initialParseResult,replaceRegion);

        IParseResult parsedFromScratch = parser.parse(new StringReader(newData));
        assertEqual(data,newData,parsedFromScratch,reparsed);
        return newData;
    } catch(Throwable e) {
        ComparisonFailure throwMe = new ComparisonFailure(e.getMessage(),replaceRegion + DELIM + data);
        throwMe.initCause(e);
        throw throwMe;
    }
}
项目:Jedis    文件JedisCommandTestBase.java   
protected void assertEquals(Set<byte[]> expected,actual.toString());
    }
  }
}
项目:idea-multimarkdown    文件OrderedComparisonCriteria.java   
private int assertArraysAreSameLength(Object expecteds,Object actuals,String header) {
    if (expecteds == null) {
        Assert.fail(header + "expected array was null");
    }

    if (actuals == null) {
        Assert.fail(header + "actual array was null");
    }

    int actualsLength = Array.getLength(actuals);
    int expectedsLength = Array.getLength(expecteds);
    if (actualsLength != expectedsLength) {
        throw new ComparisonFailure(header + "array lengths differed,expected.length=" + expectedsLength + " actual.length=" + actualsLength,TestUtils.arrayAsstring(expecteds),TestUtils.arrayAsstring(actuals));
    }

    return expectedsLength;
}
项目:idea-multimarkdown    文件UnorderedComparisonCriteria.java   
private int assertArraysAreSameLength(Object expecteds,TestUtils.arrayAsstring(actuals));
    }

    return expectedsLength;
}
项目:streamflyer    文件RegexModifierUnitTest.java   
/**
 * See <a href="http://www.regular-expressions.info/continue.html>Continuing at The End of The PrevIoUs Match</a>
 * 
 * @throws Exception
 */
@Test
public void testBoundaryMatchers6_G_TheEndOfThePrevIoUsMatch_MISSING_FEATURE() throws Exception {

    // it's nice that this works here but this is because it matches at
    // EVERY position here
    assertReplacementByReader("yzyz","\\G(y|z)","x",1,1024,"xxxx",0);
    assertReplacementByReader("yzyzyzyzyzyz","xxxxxxxxxxxx",0);

    // there are other cases that are not supported:
    try {
        assertReplacementByReader("azyzazyz","(y)|(\\Gz)","azxxazxx",0);
        fail("ComparisonFailure expected");
    } catch (ComparisonFailure e) {
        assertEquals("expected:<a[zxxaz]xx> but was:<a[xxxax]xx>",e.getMessage());
    }
}
项目:streamflyer    文件XmlVersionModifierTest.java   
@Test
public void testXmlVersion_utf8Bom_withoutByteSkippingReader() throws Exception {

    byte UTF8_BOM_BYTE_1 = (byte) 0xEF;
    byte UTF8_BOM_BYTE_2 = (byte) 0xBB;
    byte UTF8_BOM_BYTE_3 = (byte) 0xBF;

    // version in prolog is 1.0
    String input = "<?xml version='1.0'>";
    byte[] bytes = input.getBytes();
    byte[] bytesWithUtf8Bom = new byte[bytes.length + 3];
    bytesWithUtf8Bom[0] = UTF8_BOM_BYTE_1;
    bytesWithUtf8Bom[1] = UTF8_BOM_BYTE_2;
    bytesWithUtf8Bom[2] = UTF8_BOM_BYTE_3;
    System.arraycopy(bytes,bytesWithUtf8Bom,3,bytes.length);
    String inputWithBom = new String(bytesWithUtf8Bom);
    // System.out.println("inputWithBom: " + inputWithBom);
    try {
        assertXmlVersionInProlog(inputWithBom,"1.1","<?xml version='1.1'>");
        fail("AssertionError expected");
    } catch (ComparisonFailure e) {
        // OK
    }
}
项目:afc    文件AbstractTestCase.java   
/** Assert two iterable objects have the same elements.
 *
 * @param <T> the type of the elements in the iterable objects.
 * @param expected the expected value.
 * @param actual the actual value.
 */
public static <T> void assertCollectionEquals(Iterable<? extends T> expected,Iterable<? extends T> actual) {
    final Iterator<? extends T> it1 = expected.iterator();
    final Iterator<? extends T> it2 = actual.iterator();
    while (it1.hasNext()) {
        if (!it2.hasNext()) {
            throw new ComparisonFailure(
                    formatFailMessage(null,"Element is missed",expected,actual),//$NON-NLS-1$
                    toString(expected),toString(actual));
        }
        final T expect = it1.next();
        final T act = it2.next();
        if (!Objects.equals(expect,act)) {
            throw new ComparisonFailure(formatFailMessage(null,"Not same element",toString(actual));
        }
    }
    if (it2.hasNext()) {
        throw new ComparisonFailure(formatFailMessage(null,"Too many elements",//$NON-NLS-1$
                toString(expected),toString(actual));
    }
}
项目:afc    文件AbstractTestCase.java   
/** Test if the two collections contain the same elements without
 * taking into account the order of the elements in the collections.
 *
 * @param <T> the type of the elements in the collections.
 * @param message the error message.
 * @param expected the expected collection.
 * @param actual the actual collection.
 */
public static <T> void assertEpsilonEquals(String message,Collection<? extends T> expected,Collection<? extends T> actual) {
    final List<T> l = new ArrayList<>(actual);
    for (final T e : expected) {
        if (!l.remove(e)) {
            throw new ComparisonFailure(
                    formatFailMessage(message,"not similar collections",//$NON-NLS-1$
                    expected.toString(),actual.toString());
        }
    }
    if (!l.isEmpty()) {
        throw new ComparisonFailure(
                formatFailMessage(message,"not similar collections,not expected elements",//$NON-NLS-1$
                expected.toString(),actual.toString());
    }
}
项目:afc    文件AbstractTestCase.java   
/** Test if the two collections contain the same elements without
 * taking into account the order of the elements in the collections.
 *
 * @param <T> the type of the elements in the collections.
 * @param message the error message.
 * @param expected the expected collection.
 * @param actual the actual collection.
 */
public static <T> void assertEpsilonEquals(String message,T[] expected,T[] actual) {
    final List<T> l = new ArrayList<>(Arrays.asList(actual));
    for (final T e : expected) {
        if (!l.remove(e)) {
            throw new ComparisonFailure(
                    formatFailMessage(message,//$NON-NLS-1$
                    Arrays.toString(expected),Arrays.toString(actual));
        }
    }
    if (!l.isEmpty()) {
        throw new ComparisonFailure(
                formatFailMessage(message,//$NON-NLS-1$
                Arrays.toString(expected),Arrays.toString(actual));
    }
}
项目:afc    文件AbstractShape3fTestCase.java   
/** Test if the actual value is not equal to the expected value with
 * a distance of epsilon.
 * 
 * @param message
 * @param expected
 * @param actual
 */
protected void assertNotEpsilonEquals(String message,Tuple3D<?> expected,Tuple3D<?> actual) {
    if (isEpsilonEquals(expected.getX(),actual.getX(),false)) {
        throw new ComparisonFailure(
                (message==null ? "" : (message+": "))  
                +"not same x value",expected.toString(),actual.toString());
    }
    if (isEpsilonEquals(expected.getY(),actual.getY(),false)) {
        throw new ComparisonFailure(
                (message==null ? "" : (message+": "))  
                +"not same y value",actual.toString());
    }
    if (isEpsilonEquals(expected.getZ(),actual.getZ(),false)) {
        throw new ComparisonFailure(
                (message==null ? "" : (message+": "))  
                +"not same z value",actual.toString());
    }
}
项目:afc    文件AbstractShape3fTestCase.java   
/** Test if the actual value is equal to the expected value with
 * a distance of epsilon.
 * 
 * @param message
 * @param expected
 * @param actual
 */
protected void assertEpsilonEquals(String message,Tuple3D<?> actual) {
    if (!isEpsilonEquals(expected.getX(),actual.getX())) {
        throw new ComparisonFailure(
                (message==null ? "" : (message+": "))  
                +"not same x value",actual.toString());
    }
    if (!isEpsilonEquals(expected.getY(),actual.getY())) {
        throw new ComparisonFailure(
                (message==null ? "" : (message+": "))  
                +"not same y value",actual.toString());
    }
    if (!isEpsilonEquals(expected.getZ(),actual.getZ())) {
        throw new ComparisonFailure(
                (message==null ? "" : (message+": "))  
                +"not same z value",Tuple2D<?> expected,Tuple2D<?> actual) {
    if (!isEpsilonEquals(expected.getX(),actual.toString());
    }
}
项目:afc    文件AbstractShape3fTestCase.java   
/** Test if the actual value is not equal to the expected value with
 * a distance of epsilon.
 * 
 * @param message
 * @param expected
 * @param actual
 */
protected void assertNotEpsilonEquals(String message,Tuple2D<?> actual) {
    if (isEpsilonEquals(expected.getX(),actual.toString());
    }
}
项目:afc    文件AbstractVector3DTest.java   
public final void assertEpsilonEquals(double expectedX,double expectedY,PowerResult<?> actual) {
    if (actual == null) {
        fail("Result is null"); //$NON-NLS-1$
        return;
    }
    if (!actual.isvectorial()) {
        throw new ComparisonFailure("Not same result type","[" + expectedX + ";" + expectedY + "]",//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                actual.toString());
    }
    Vector3D<?,?> vector = actual.getVector();
    assert (vector != null);
    if (!isEpsilonEquals(expectedX,vector.getX())
        || !isEpsilonEquals(expectedY,vector.getY())) {
        throw new ComparisonFailure("Not same result type",//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                actual.toString());
    }
}
项目:afc    文件AbstractVector2DTest.java   
public final void assertEpsilonEquals(double expectedX,//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                actual.toString());
    }
    Vector2D<?,//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                actual.toString());
    }
}
项目:afc    文件AbstractShape2afpTest.java   
/** Assert is the given path iterator has a first element with the
 * given @R_841_4045@ion.
 * 
 * @param pi the path iterator.
 * @param type the expected type.
 * @param coords the expected coordinates.
 */
public void assertElement(PathIterator2afp<?> pi,pathelementType type,double... coords) {
    if (!pi.hasNext()) {
        fail("expected path element but the iterator is empty");  //$NON-NLS-1$
    }
    pathelement2afp pe = pi.next();
    if (!type.equals(pe.getType())) {
        throw new ComparisonFailure("not same element type.",type.name(),pe.getType().name()); //$NON-NLS-1$
    }
    double[] c = new double[coords.length];
    pe.toArray(c);
    if (!isEpsilonEquals(c,coords)) {
        throw new ComparisonFailure("not same coordinates.",//$NON-NLS-1$
                Arrays.toString(coords),Arrays.toString(c));
    }
}
项目:afc    文件AbstractShape3afpTest.java   
/** Assert is the given path iterator has a first element with the
 * given @R_841_4045@ion.
 * 
 * @param pi the path iterator.
 * @param type the expected type.
 * @param coords the expected coordinates.
 */
protected void assertElement(PathIterator3afp<?> pi,double... coords) {
    if (!pi.hasNext()) {
        fail("expected path element but the iterator is empty"); //$NON-NLS-1$
    }
    pathelement3afp pe = pi.next();
    if (!type.equals(pe.getType())) {
        throw new ComparisonFailure("not same element type.",//$NON-NLS-1$ 
                Arrays.toString(coords),Arrays.toString(c));
    }
}
项目:afc    文件AbstractMathTestCase.java   
/** Test if the actual value is equal to the expected value with
 * a distance of epsilon.
 * 
 * @param message the error message.
 * @param expected the expected value.
 * @param actual the actual value.
 */
public void assertEpsilonEquals(String message,actual.getX())) {
        throw new ComparisonFailure(
                formatFailMessage(message,"not same x value",actual.getY())) {
        throw new ComparisonFailure(
                formatFailMessage(message,"not same y value",actual.getZ())) {
        throw new ComparisonFailure(
                formatFailMessage(message,"not same z value",actual.toString());
    }
}
项目:afc    文件AbstractMathTestCase.java   
/** Test if the actual value is not equal to the expected value with
 * a distance of epsilon.
 * 
 * @param message the error message.
 * @param expected the expected value.
 * @param actual the actual value.
 */
public void assertNotEpsilonEquals(String message,false)) {
        throw new ComparisonFailure(
                formatFailMessage(message,actual.toString());
    }
}
项目:afc    文件AbstractMathTestCase.java   
/** Test if the actual matrix is equal to the expected values.
 * 
 * @param expected the expected value. 
 * @param actual the actual value.
 */
public void assertEpsilonEquals(Matrix3d expected,Matrix3d actual) {
    if ((!isEpsilonEquals(expected.getM00(),actual.getM00()))
        ||(!isEpsilonEquals(expected.getM01(),actual.getM01()))
        ||(!isEpsilonEquals(expected.getM02(),actual.getM02()))
        ||(!isEpsilonEquals(expected.getM10(),actual.getM10()))
        ||(!isEpsilonEquals(expected.getM11(),actual.getM11()))
        ||(!isEpsilonEquals(expected.getM12(),actual.getM12()))
        ||(!isEpsilonEquals(expected.getM20(),actual.getM20()))
        ||(!isEpsilonEquals(expected.getM21(),actual.getM21()))
        ||(!isEpsilonEquals(expected.getM22(),actual.getM22()))) {
        throw new ComparisonFailure(
                formatFailMessage(null,"Not same matrices",actual.toString());
    }
}
项目:afc    文件AbstractMathTestCase.java   
/** Test if the actual matrix is different from the expected values.
 * 
 * @param expected the expected value. 
 * @param actual the actual value.
 */
public void assertNotEpsilonEquals(Matrix3d expected,Matrix3d actual) {
    if ((isEpsilonEquals(expected.getM00(),actual.getM00()))
        &&(isEpsilonEquals(expected.getM01(),actual.getM01()))
        &&(isEpsilonEquals(expected.getM02(),actual.getM02()))
        &&(isEpsilonEquals(expected.getM10(),actual.getM10()))
        &&(isEpsilonEquals(expected.getM11(),actual.getM11()))
        &&(isEpsilonEquals(expected.getM12(),actual.getM12()))
        &&(isEpsilonEquals(expected.getM20(),actual.getM20()))
        &&(isEpsilonEquals(expected.getM21(),actual.getM21()))
        &&(isEpsilonEquals(expected.getM22(),actual.toString());
    }
}
项目:afc    文件AbstractMathTestCase.java   
/** Test if the actual matrix is equal to the expected values.
 * 
 * @param expected the expected value. 
 * @param actual the actual value.
 */
public void assertEpsilonEquals(Matrix4d expected,Matrix4d actual) {
    if ((!isEpsilonEquals(expected.getM00(),actual.getM02()))
        ||(!isEpsilonEquals(expected.getM03(),actual.getM03()))
        ||(!isEpsilonEquals(expected.getM10(),actual.getM12()))
        ||(!isEpsilonEquals(expected.getM13(),actual.getM13()))
        ||(!isEpsilonEquals(expected.getM20(),actual.getM22()))
        ||(!isEpsilonEquals(expected.getM23(),actual.getM23()))
        ||(!isEpsilonEquals(expected.getM30(),actual.getM30()))
        ||(!isEpsilonEquals(expected.getM31(),actual.getM31()))
        ||(!isEpsilonEquals(expected.getM32(),actual.getM32()))
        ||(!isEpsilonEquals(expected.getM33(),actual.getM33()))) {
        throw new ComparisonFailure(
                formatFailMessage(null,actual.toString());
    }
}
项目:afc    文件AbstractMathTestCase.java   
/** Test if the actual matrix is different from the expected values.
 * 
 * @param expected the expected value. 
 * @param actual the actual value.
 */
public void assertNotEpsilonEquals(Matrix4d expected,Matrix4d actual) {
    if ((isEpsilonEquals(expected.getM00(),actual.getM02()))
        &&(isEpsilonEquals(expected.getM03(),actual.getM03()))
        &&(isEpsilonEquals(expected.getM10(),actual.getM12()))
        &&(isEpsilonEquals(expected.getM13(),actual.getM13()))
        &&(isEpsilonEquals(expected.getM20(),actual.getM22()))
        &&(isEpsilonEquals(expected.getM23(),actual.getM23()))
        &&(isEpsilonEquals(expected.getM30(),actual.getM30()))
        &&(isEpsilonEquals(expected.getM31(),actual.getM31()))
        &&(isEpsilonEquals(expected.getM32(),actual.getM32()))
        &&(isEpsilonEquals(expected.getM33(),actual.toString());
    }
}
项目:afc    文件ClasspathUtilTest.java   
private void assertClasspathEquals(Iterator<URL> actuals,String... expecteds) {
    assertNotNull(actuals);
    List<URL> list = new ArrayList<>();
    while (actuals.hasNext()) {
        list.add(actuals.next());
    }
    String[] tab = new String[list.size()];
    for (int i = 0; i < tab.length; ++i) {
        tab[i] = toString(list.get(i));
    }
    try {
        assertArrayEquals(expecteds,tab);
    } catch (Throwable exception) {
        throw new ComparisonFailure(exception.getMessage(),Arrays.toString(expecteds).replaceAll(" +","\n"),Arrays.toString(tab).replaceAll(" +","\n")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    }
}
项目:units4j    文件Units4JUtilsTest.java   
@Test
public final void testAssertCauseMessage() {

    // PREPARE
    final Exception second = new RuntimeException("second");
    final Exception first = new RuntimeException("first",second);

    // TEST & VERIFY
    Units4JUtils.assertCauseMessage(first,"second");
    try {
        Units4JUtils.assertCauseMessage(first,"xxx");
        fail();
    } catch (final ComparisonFailure f) {
        // OK
        assertthat(f.getMessage()).isEqualTo(
                "expected:<\"[xxx]\"> but was:<\"[second]\">");
    }

}
项目:units4j    文件Units4JUtilsTest.java   
@Test
public final void testAssertCauseCauseMessage() {

    // PREPARE
    final Exception third = new RuntimeException("third");
    final Exception second = new RuntimeException("second",third);
    final Exception first = new RuntimeException("first",second);

    // TEST & VERIFY
    Units4JUtils.assertCauseCauseMessage(first,"third");
    try {
        Units4JUtils.assertCauseCauseMessage(first,"xxx");
        fail();
    } catch (final ComparisonFailure f) {
        // OK
        assertthat(f.getMessage()).isEqualTo(
                "expected:<\"[xxx]\"> but was:<\"[third]\">");
    }

}
项目:sonar-analyzer-commons    文件MultiFiLeverifierTest.java   
@Test
public void code_js_without_issue() throws Exception {
  Path path = Paths.get("src/test/resources/code.js");
  MultiFiLeverifier verifier = MultiFiLeverifier.create(path,UTF_8);
  // no addComment(...)
  // no reportIssue(...)
  verifier.assertNoIssues();

  try {
    verifier.assertOneOrMoreIssues();
    Assert.fail("Should raise ComparisonFailure.");
  } catch (ComparisonFailure failure) {
    assertthat(failure.getExpected()).contains("ERROR: 'assertOneOrMoreIssues()' is called but there's no 'Noncompliant' comments.");
  }
}
项目:n4js    文件TestEventQueue.java   
/**
 * Asserts the actual events with the expected ones.
 *
 * @param sessionId
 *            the unique ID of the session that has to be checked.
 * @param expectedEvents
 *            the expected events to assert against the actual ones.
 */
public void assertEquals(final String sessionId,final Iterable<String> expectedEvents) {
    assertNotNull("Queue was not initialized. One should call #init(int) before invoking #assertEquals()",latch);
    try {
        latch.await(20L,SECONDS);
        unregistersupplier.get();
    } catch (final InterruptedException e) {
        throw new AssertionError("Time outed while waiting to receive all expected test events.",e);
    }
    final Collection<String> eventsForSession = events.get(sessionId);
    if (size(expectedEvents) != eventsForSession.size()) {
        throw new ComparisonFailure("Expected:",toString(expectedEvents),toString(eventsForSession));
    }
    final Iterator<String> actItr = eventsForSession.iterator();
    final Iterator<String> expItr = expectedEvents.iterator();

    while (expItr.hasNext()) {
        if (!actItr.hasNext()) {
            throw new ComparisonFailure("Expected:",toString(eventsForSession));
        }
        final String expected = expItr.next();
        final String actual = actItr.next();
        if (null == expected || null == actual) {
            if (expected != actual) {
                throw new ComparisonFailure("Expected:",toString(eventsForSession));
            }
        } else {
            if (!expected.equals(actual)) {
                throw new ComparisonFailure("Expected:",toString(eventsForSession));
            }
        }

        Assert.assertEquals(expected,actual);
    }
}
项目:n4js    文件N4IDEXpectCompareEditorInput.java   
/**
 */
public N4IDEXpectCompareEditorInput(IFile file,ComparisonFailure cf) {
    super(createConfiguration(file));
    Preconditions.checkNotNull(file);
    this.file = file;
    this.comparisonFailure = cf;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。