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

org.junit.internal.runners.statements.ExpectException的实例源码

项目:sosiefier    文件BlockJUnit4ClassRunner.java   
/**
 * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation
 * has the {@code expecting} attribute,return normally only if {@code next}
 * throws an exception of the correct type,and throw an exception
 * otherwise.
 */
protected Statement possiblyExpectingExceptions(FrameworkMethod method,Object test,Statement next) {
    Test annotation = method.getAnnotation(Test.class);
    return expectsException(annotation) ? new ExpectException(next,getExpectedException(annotation)) : next;
}
项目:tomee    文件JUnit4Runner.java   
protected Statement possiblyExpectingAccessException(final Statement next,final boolean failWithAccessException) {
    if (failWithAccessException) {
        return new ExpectException(next,EJBAccessException.class);
    } else {
        return next;
    }
}
项目:junit-hierarchicalcontextrunner    文件ExpectExceptionStatementBuilderTest.java   
@Test
public void whenTestAnnotationDoesspecifyAnException_returnExpectExceptionStatement() throws Exception {
    TestClass testClass = TestClasspool.forClass(SingleTestWithExpectedAnnotation.class);
    FrameworkMethod method = testClass.getAnnotatedMethods(Test.class).get(0);

    Statement actual = builder.createStatement(testClass,method,target,next,description,notifier);
    assertthat(actual,is(instanceOf(ExpectException.class)));
}
项目:ef-orm    文件JefJUnit4DatabaseTestRunner.java   
@Override
protected Statement methodInvoker(FrameworkMethod method,Object test) {
    boolean isNew = false;
    boolean inject = false;
    if (method instanceof DbFrameworkMethod) {
        DbFrameworkMethod dbCase = (DbFrameworkMethod) method;
        String dbType = dbCase.getDbType();
        Object obj = connections.get(dbType);
        if (obj == null) {
            throw new IllegalArgumentException("Database " + dbType + " is unkNown.");
        }
        DbConnectionHolder holder;
        if (obj instanceof DataSource) {
            holder = createDbClient((DataSource) obj);// CreateDbClient
            isNew = true;
        } else {
            holder = (DbConnectionHolder) obj;
            if (holder.db == null) {
                holder = createDbClient(holder.datasource);// CreateDbClient
            }
        }
        inject(test,holder.db,holder.datasource.field());
        inject=true;
    } else if (isRouting) {
        if (routingDbClient == null) {
            MapDataSourceLookup lookup = new MapDataSourceLookup();
            for (Entry<String,Object> entry : connections.entrySet()) {
                if (entry.getValue() instanceof DataSource) {
                    DataSource ds = (DataSource) entry.getValue();
                    lookup.put(ds.name(),new SimpleDataSource(ds.url(),ds.user(),ds.password()));
                }
            }
            RoutingDataSource rds = new RoutingDataSource(lookup);
            routingDbClient = new DbClient(rds);
            isNew = true;
        }
        inject(test,routingDbClient,"");
        inject=true;
    }
    if (isNew) {
        List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(DatabaseInit.class);
        try {
            for (FrameworkMethod m : methods) {
                printMethod(m,method);
                m.getmethod().invoke(test);
            }
        } catch (Exception e) {
            throw dbutils.toRuntimeException(e);
        }
    }
    printMethod(method,null);
    if(inject){
        return super.methodInvoker(method,test);
    }else{
        System.err.println("数据库未配置,跳过测试:"+super.describeChild(method).getdisplayName());
        return new ExpectException(null,NullPointerException.class);
    }
}
项目:smartassert    文件SoftAssertVerifier.java   
private VerifierStatement(Statement base) {
    this.base = base;
    this.expectsException = ExpectException.class.isAssignableFrom(base.getClass());
}
项目:junit-hierarchicalcontextrunner    文件ExpectExceptionStatementBuilder.java   
public Statement createStatement(final TestClass testClass,final FrameworkMethod method,final Object target,final Statement next,final Description description,final RunNotifier notifier) {
    final Test annotation = method.getAnnotation(Test.class);
    return annotation.expected() == Test.None.class ? next : new ExpectException(next,annotation.expected());
}
项目:kc-rice    文件LoadTimeWeavableTestRunner.java   
/**
 * Returns a {@link org.junit.runners.model.Statement}: if {@code method}'s {@code @Test} annotation
 * has the {@code expecting} attribute,and throw an exception
 * otherwise.
 *
 * @deprecated Will be private soon: use Rules instead
 */
@Deprecated
protected Statement possiblyExpectingExceptions(FrameworkMethod method,getExpectedException(annotation)) : next;
}
项目:lcm    文件BlockJUnit4ClassRunner.java   
/**
 * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation
 * has the {@code expecting} attribute,getExpectedException(annotation)) : next;
}
项目:rice    文件LoadTimeWeavableTestRunner.java   
/**
 * Returns a {@link org.junit.runners.model.Statement}: if {@code method}'s {@code @Test} annotation
 * has the {@code expecting} attribute,getExpectedException(annotation)) : next;
}
项目:junit    文件BlockJUnit4ClassRunner.java   
/**
 * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation
 * has the {@code expecting} attribute,getExpectedException(annotation)) : next;
}
项目:org.openntf.domino    文件BlockJUnit4ClassRunner.java   
/**
 * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation
 * has the {@code expecting} attribute,getExpectedException(annotation)) : next;
}
项目:spring4-understanding    文件SpringJUnit4ClassRunner.java   
/**
 * Perform the same logic as
 * {@link BlockJUnit4ClassRunner#possiblyExpectingExceptions(FrameworkMethod,Object,Statement)}
 * except that the <em>expected exception</em> is retrieved using
 * {@link #getExpectedException(FrameworkMethod)}.
 */
@Override
protected Statement possiblyExpectingExceptions(FrameworkMethod frameworkMethod,Object testInstance,Statement next) {
    Class<? extends Throwable> expectedException = getExpectedException(frameworkMethod);
    return (expectedException != null ? new ExpectException(next,expectedException) : next);
}
项目:class-guard    文件SpringJUnit4ClassRunner.java   
/**
 * Performs the same logic as
 * {@link BlockJUnit4ClassRunner#possiblyExpectingExceptions(FrameworkMethod,Statement next) {
    Class<? extends Throwable> expectedException = getExpectedException(frameworkMethod);
    return expectedException != null ? new ExpectException(next,expectedException) : next;
}

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