Examples of ExpectedException


Examples of org.springframework.test.annotation.ExpectedException

  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) {
      String msg = "Test method [" + frameworkMethod.getMethod()
          + "] has been configured with Spring's @ExpectedException(" + springExpectedException.getName()
          + ".class) and JUnit's @Test(expected=" + junitExpectedException.getName()
View Full Code Here

Examples of org.springframework.test.annotation.ExpectedException

   * @throws Throwable if any exception is thrown
   * @see ExpectedException
   * @see Repeat
   */
  private void runTest(TestExecutionCallback tec, Method testMethod) throws Throwable {
    ExpectedException expectedExceptionAnnotation = testMethod.getAnnotation(ExpectedException.class);
    boolean exceptionIsExpected = (expectedExceptionAnnotation != null && expectedExceptionAnnotation.value() != null);
    Class<? extends Throwable> expectedException = (exceptionIsExpected ? expectedExceptionAnnotation.value()
        : null);

    Repeat repeat = testMethod.getAnnotation(Repeat.class);
    int runs = ((repeat != null) && (repeat.value() > 1)) ? repeat.value() : 1;

View Full Code Here

Examples of org.springframework.test.annotation.ExpectedException

  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) {
      String msg = "Test method [" + frameworkMethod.getMethod()
          + "] has been configured with Spring's @ExpectedException(" + springExpectedException.getName()
          + ".class) and JUnit's @Test(expected=" + junitExpectedException.getName()
View Full Code Here

Examples of org.springframework.test.annotation.ExpectedException

   * @throws Throwable if any exception is thrown
   * @see ExpectedException
   * @see Repeat
   */
  private void runTest(TestExecutionCallback tec, Method testMethod) throws Throwable {
    ExpectedException expectedExceptionAnnotation = testMethod.getAnnotation(ExpectedException.class);
    boolean exceptionIsExpected = (expectedExceptionAnnotation != null && expectedExceptionAnnotation.value() != null);
    Class<? extends Throwable> expectedException = (exceptionIsExpected ? expectedExceptionAnnotation.value()
        : null);

    Repeat repeat = testMethod.getAnnotation(Repeat.class);
    int runs = ((repeat != null) && (repeat.value() > 1)) ? repeat.value() : 1;

View Full Code Here

Examples of org.springframework.test.annotation.ExpectedException

   * @param testContext
   * @return <code>true</code> if the <code>Exception</code> thrown by the
   *         test was expected, <code>false</code> otherwise.
   */
  protected boolean isExpectedException(final TestContext testContext) {
    final ExpectedException expectedAnnotiation = testContext
        .getTestMethod().getAnnotation(ExpectedException.class);
    if ((expectedAnnotiation != null)
        && expectedAnnotiation.value().isInstance(
            testContext.getTestException())) {
      return true;
    }
    return false;
  }
View Full Code Here

Examples of org.springframework.test.annotation.ExpectedException

   * and JUnit's {@link Test#expected() @Test(expected=...)} annotations, but
   * not both simultaneously.
   * @return the expected exception, or <code>null</code> if none was specified
   */
  public Class<? extends Throwable> getExpectedException() throws IllegalStateException {
    ExpectedException expectedExAnn = getMethod().getAnnotation(ExpectedException.class);
    Test testAnnotation = getMethod().getAnnotation(Test.class);

    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(" +
View Full Code Here

Examples of org.springframework.test.annotation.ExpectedException

   * @throws Throwable if any exception is thrown
   * @see ExpectedException
   * @see Repeat
   */
  private void runTest(TestExecutionCallback tec, Method testMethod) throws Throwable {
    ExpectedException expectedExceptionAnnotation = testMethod.getAnnotation(ExpectedException.class);
    boolean exceptionIsExpected = (expectedExceptionAnnotation != null &&
        expectedExceptionAnnotation.value() != null);
    Class<? extends Throwable> expectedException =
        (exceptionIsExpected ? expectedExceptionAnnotation.value() : null);

    Repeat repeat = testMethod.getAnnotation(Repeat.class);
    int runs = ((repeat != null) && (repeat.value() > 1)) ? repeat.value() : 1;

    for (int i = 0; i < runs; i++) {
View Full Code Here

Examples of org.springframework.test.annotation.ExpectedException

   * and JUnit's {@link Test#expected() @Test(expected=...)} annotations, but
   * not both simultaneously.
   * @return the expected exception, or <code>null</code> if none was specified
   */
  public Class<? extends Throwable> getExpectedException() throws IllegalStateException {
    ExpectedException expectedExAnn = getMethod().getAnnotation(ExpectedException.class);
    Test testAnnotation = getMethod().getAnnotation(Test.class);

    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(" +
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.