Package org.junit

Examples of org.junit.Test.expected()


   * @return the expected exception, or <code>null</code> if none was specified
   */
  protected Class<? extends Throwable> getExpectedException(FrameworkMethod frameworkMethod) {
    Test testAnnotation = frameworkMethod.getAnnotation(Test.class);
    Class<? extends Throwable> junitExpectedException = (testAnnotation != null
        && testAnnotation.expected() != Test.None.class ? testAnnotation.expected() : null);

    ExpectedException expectedExAnn = frameworkMethod.getAnnotation(ExpectedException.class);
    Class<? extends Throwable> springExpectedException = (expectedExAnn != null ? expectedExAnn.value() : null);

    if (springExpectedException != null && junitExpectedException != null) {
View Full Code Here


   * @return the expected exception, or <code>null</code> if none was specified
   */
  protected Class<? extends Throwable> getExpectedException(FrameworkMethod frameworkMethod) {
    Test testAnnotation = frameworkMethod.getAnnotation(Test.class);
    Class<? extends Throwable> junitExpectedException = (testAnnotation != null
        && testAnnotation.expected() != Test.None.class ? testAnnotation.expected() : null);

    ExpectedException expectedExAnn = frameworkMethod.getAnnotation(ExpectedException.class);
    Class<? extends Throwable> springExpectedException = (expectedExAnn != null ? expectedExAnn.value() : null);

    if (springExpectedException != null && junitExpectedException != null) {
View Full Code Here

public abstract class Junit4Utils {

  public static boolean isExpectedException(final Method method,
      final Throwable ex) {
    final Test testAnnotation = method.getAnnotation(Test.class);
    if ((testAnnotation != null) && (testAnnotation.expected() != null)
        && testAnnotation.expected().isInstance(ex)) {
      return true;
    }
    return false;
  }
View Full Code Here

  public static boolean isExpectedException(final Method method,
      final Throwable ex) {
    final Test testAnnotation = method.getAnnotation(Test.class);
    if ((testAnnotation != null) && (testAnnotation.expected() != null)
        && testAnnotation.expected().isInstance(ex)) {
      return true;
    }
    return false;
  }
View Full Code Here

    Class<? extends Throwable> expectedException = null;
    Class<? extends Throwable> springExpectedException =
        (expectedExAnn != null && expectedExAnn.value() != null ? expectedExAnn.value() : null);
    Class<? extends Throwable> junitExpectedException =
        (testAnnotation != null && testAnnotation.expected() != None.class ? testAnnotation.expected() : null);

    if (springExpectedException != null && junitExpectedException != null) {
      String msg = "Test method [" + getMethod() + "] has been configured with Spring's @ExpectedException(" +
          springExpectedException.getName() + ".class) and JUnit's @Test(expected=" +
          junitExpectedException.getName() + ".class) annotations. " +
View Full Code Here

    Class<? extends Throwable> expectedException = null;
    Class<? extends Throwable> springExpectedException =
        (expectedExAnn != null && expectedExAnn.value() != null ? expectedExAnn.value() : null);
    Class<? extends Throwable> junitExpectedException =
        (testAnnotation != null && testAnnotation.expected() != None.class ? testAnnotation.expected() : null);

    if (springExpectedException != null && junitExpectedException != null) {
      String msg = "Test method [" + getMethod() + "] has been configured with Spring's @ExpectedException(" +
          springExpectedException.getName() + ".class) and JUnit's @Test(expected=" +
          junitExpectedException.getName() + ".class) annotations. " +
View Full Code Here

            if (getJunit4()){
                Class<? extends Throwable> expectedException = None.class;
                long timeout = 0;
                Test annotation = m.getAnnotation(Test.class);
                if(null != annotation) {
                    expectedException = annotation.expected();
                    timeout = annotation.timeout();
                }
                final AnnotatedTestCase at = new AnnotatedTestCase(m, expectedException, timeout);
                testCase = at;
                protectable = new Protectable() {
View Full Code Here

    if (ann == null) {
      return s;
    }
   
    // If there's no expected class, don't wrap. Eh, None is package-private...
    final Class<? extends Throwable> expectedClass = ann.expected();
    if (expectedClass.getName().equals("org.junit.Test$None")) {
      return s;
    }

    return new Statement() {
View Full Code Here

      Statement containerTestRunnerStatement = new ContainerTestRunnerStatement(method, description);
     
      // Handle expected exception. We need to handle this explicitly as it is implemented
      // using a statement that we will discard here (as we don't use base)
      Test t = method.getAnnotation(Test.class);
      if (t != null && t.expected() != None.class) {
        testStatement = new ExpectException(containerTestRunnerStatement, t.expected());
      } else {
        testStatement = containerTestRunnerStatement;
      }
    } else {
View Full Code Here

     
      // Handle expected exception. We need to handle this explicitly as it is implemented
      // using a statement that we will discard here (as we don't use base)
      Test t = method.getAnnotation(Test.class);
      if (t != null && t.expected() != None.class) {
        testStatement = new ExpectException(containerTestRunnerStatement, t.expected());
      } else {
        testStatement = containerTestRunnerStatement;
      }
    } else {
      // With LOCAL_TEST, just run the original statement locally.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.