当前位置: 首页>>代码示例>>Java>>正文


Java AssertionFailedError.initCause方法代码示例

本文整理汇总了Java中junit.framework.AssertionFailedError.initCause方法的典型用法代码示例。如果您正苦于以下问题:Java AssertionFailedError.initCause方法的具体用法?Java AssertionFailedError.initCause怎么用?Java AssertionFailedError.initCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在junit.framework.AssertionFailedError的用法示例。


在下文中一共展示了AssertionFailedError.initCause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertThrows

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
public void assertThrows(Class<? extends Throwable> expectedExceptionClass,
                         Runnable... throwingActions) {
    for (Runnable throwingAction : throwingActions) {
        boolean threw = false;
        try { throwingAction.run(); }
        catch (Throwable t) {
            threw = true;
            if (!expectedExceptionClass.isInstance(t)) {
                AssertionFailedError afe =
                    new AssertionFailedError
                    ("Expected " + expectedExceptionClass.getName() +
                     ", got " + t.getClass().getName());
                afe.initCause(t);
                threadUnexpectedException(afe);
            }
        }
        if (!threw)
            shouldThrow(expectedExceptionClass.getName());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:JSR166TestCase.java

示例2: testStaticEvaluation

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
public void testStaticEvaluation () throws Exception {
    try {
        List<Method> methods = getMethods(true);
        AssertionFailedError te = null;
        AssertionFailedError ex = null;
        for (Method m : methods) {
            try {
                checkEval (m);
            } catch (AssertionFailedError e) {
                if (te == null) {
                    te = ex = e;
                } else {
                    ex.initCause(e);
                    ex = e;
                }
            }
        }
        if (te != null) {
            throw te;
        }
        //checkEvalFails ("this");
        checkEvalFails ("NoSuchClass.class");
    } finally {
        support.doFinish ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:EvaluatorTest.java

示例3: tearDown

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
/**
 * Extra checks that get done for all test cases.
 *
 * Triggers test case failure if any thread assertions have failed,
 * by rethrowing, in the test harness thread, any exception recorded
 * earlier by threadRecordFailure.
 *
 * Triggers test case failure if interrupt status is set in the main thread.
 */
public void tearDown() throws Exception {
    Throwable t = threadFailure.getAndSet(null);
    if (t != null) {
        if (t instanceof Error)
            throw (Error) t;
        else if (t instanceof RuntimeException)
            throw (RuntimeException) t;
        else if (t instanceof Exception)
            throw (Exception) t;
        else {
            AssertionFailedError afe =
                new AssertionFailedError(t.toString());
            afe.initCause(t);
            throw afe;
        }
    }

    if (Thread.interrupted())
        throw new AssertionFailedError("interrupt status set in main thread");
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:30,代码来源:JSR166TestCase.java

示例4: findStackFrame

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
private static int findStackFrame(
    ExecutionException e, String clazz, String method) {
  StackTraceElement[] elements = e.getStackTrace();
  for (int i = 0; i < elements.length; i++) {
    StackTraceElement element = elements[i];
    if (element.getClassName().equals(clazz)
        && element.getMethodName().equals(method)) {
      return i;
    }
  }
  AssertionFailedError failure =
      new AssertionFailedError("Expected element " + clazz + "." + method
          + " not found in stack trace");
  failure.initCause(e);
  throw failure;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:AbstractFutureTest.java

示例5: threadUnexpectedException

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
/**
 * Records the given exception using {@link #threadRecordFailure},
 * then rethrows the exception, wrapping it in an
 * AssertionFailedError if necessary.
 */
public void threadUnexpectedException(Throwable t) {
    threadRecordFailure(t);
    t.printStackTrace();
    if (t instanceof RuntimeException)
        throw (RuntimeException) t;
    else if (t instanceof Error)
        throw (Error) t;
    else {
        AssertionFailedError afe =
            new AssertionFailedError("unexpected exception: " + t);
        afe.initCause(t);
        throw afe;
    }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:20,代码来源:JSR166TestCase.java

示例6: sleep

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
/**
 * Sleeps until the given time has elapsed.
 * Throws AssertionFailedError if interrupted.
 */
static void sleep(long millis) {
    try {
        delay(millis);
    } catch (InterruptedException fail) {
        AssertionFailedError afe =
            new AssertionFailedError("Unexpected InterruptedException");
        afe.initCause(fail);
        throw afe;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:JSR166TestCase.java

示例7: await

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
public int await() {
    try {
        return super.await(2 * LONG_DELAY_MS, MILLISECONDS);
    } catch (TimeoutException timedOut) {
        throw new AssertionFailedError("timed out");
    } catch (Exception fail) {
        AssertionFailedError afe =
            new AssertionFailedError("Unexpected exception: " + fail);
        afe.initCause(fail);
        throw afe;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:JSR166TestCase.java

示例8: assertFile

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
private void assertFile(FileObject primaryFile) {
    if (!primaryFile.equals(file)) {
        AssertionFailedError afe = new AssertionFailedError("Files shall be the same:\nExpected:" + primaryFile + "\nReal    :" + file);
        afe.initCause(who);
        throw afe;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:FileEncodingQueryDataEditorSupportTest.java

示例9: assertAccess

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
public static void assertAccess(String msg, int expectURL, int expectFO) {
    try {
        DataShadow.waitUpdatesProcessed();
        assertEquals(msg + " file object check", expectFO, toFOCnt);
        assertEquals(msg + " to url check", expectURL, toURLCnt);
        toFOCnt = 0;
        toURLCnt = 0;
    } catch (AssertionFailedError ex) {
        if (lastAccess != null) ex.initCause(lastAccess);
        throw ex;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:DataShadowBrokenAreNotTestedTest.java

示例10: sleep

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
/**
 * Sleeps until the given time has elapsed.
 * Throws AssertionFailedError if interrupted.
 */
void sleep(long millis) {
    try {
        delay(millis);
    } catch (InterruptedException ie) {
        AssertionFailedError afe =
            new AssertionFailedError("Unexpected InterruptedException");
        afe.initCause(ie);
        throw afe;
    }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:15,代码来源:JSR166TestCase.java

示例11: runTest

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
protected void runTest () throws Throwable {
    try {
        super.runTest();
    } catch (Error err) {
        AssertionFailedError newErr = new AssertionFailedError (err.getMessage () + "\n" + ErrManager.messages);
        newErr.initCause (err);
        throw newErr;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:AddRemoveNotifyRaceConditionTest.java

示例12: runInstanceEvaluation

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
private void runInstanceEvaluation(int bpNo) throws Exception {
    try {
        Utils.BreakPositions bp = Utils.getBreakPositions(System.getProperty ("test.dir.src")+
                                  "org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java");
        LineBreakpoint lb = bp.getLineBreakpoints().get(bpNo);
        DebuggerManager.getDebuggerManager ().addBreakpoint (lb);
        support.doContinue();
        support.waitState (JPDADebugger.STATE_STOPPED);
        
        List<Method> methods = getMethods(false);
        AssertionFailedError te = null;
        AssertionFailedError ex = null;
        for (Method m : methods) {
            try {
                checkEval (m);
            } catch (AssertionFailedError e) {
                if (te == null) {
                    te = ex = e;
                } else {
                    ex.initCause(e);
                    ex = e;
                }
            }
        }
        if (te != null) {
            throw te;
        }
    } finally {
        support.doFinish ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:EvaluatorTest.java

示例13: sanityError

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
private static AssertionFailedError sanityError(
    Class<?> cls, List<String> explicitTestNames, String description, Throwable e) {
  String message = String.format(Locale.ROOT,
      "Error in automated %s of %s\n"
          + "If the class is better tested explicitly, you can add %s() to %sTest",
      description, cls, explicitTestNames.get(0), cls.getName());
  AssertionFailedError error = new AssertionFailedError(message);
  error.initCause(e);
  return error;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:AbstractPackageSanityTests.java

示例14: getDoneFromTimeoutOverload

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
/**
 * Retrieves the result of a {@code Future} known to be done but uses the {@code get(long,
 * TimeUnit)} overload in order to test that method.
 */
static <V> V getDoneFromTimeoutOverload(Future<V> future) throws ExecutionException {
  checkState(future.isDone(), "Future was expected to be done: %s", future);
  try {
    return getUninterruptibly(future, 0, SECONDS);
  } catch (TimeoutException e) {
    AssertionFailedError error = new AssertionFailedError(e.getMessage());
    error.initCause(e);
    throw error;
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:15,代码来源:TestPlatform.java

示例15: failureWithCause

import junit.framework.AssertionFailedError; //导入方法依赖的package包/类
static AssertionFailedError failureWithCause(Throwable cause, String message) {
  AssertionFailedError failure = new AssertionFailedError(message);
  failure.initCause(cause);
  return failure;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:6,代码来源:FuturesTest.java


注:本文中的junit.framework.AssertionFailedError.initCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。