String phase = (requiredClassMode.name().startsWith("BEFORE") ? "Before" : "After"); logger.debug(String.format("%s test method: context %s, class annotated with @DirtiesContext [%s] " + "with mode [%s], method annotated with @DirtiesContext [%s] with mode [%s].", phase, testContext,
String phase = (requiredClassMode.name().startsWith("BEFORE") ? "Before" : "After"); logger.debug(String.format("%s test method: context %s, class annotated with @DirtiesContext [%s] " + "with mode [%s], method annotated with @DirtiesContext [%s] with mode [%s].", phase, testContext,
String phase = (requiredClassMode.name().startsWith("BEFORE") ? "Before" : "After"); logger.debug(String.format("%s test method: context %s, class annotated with @DirtiesContext [%s] " + "with mode [%s], method annotated with @DirtiesContext [%s] with mode [%s].", phase, testContext,
/** * Perform the actual work for {@link #beforeTestClass} and {@link #afterTestClass} * by dirtying the context if appropriate (i.e., according to the required mode). * @param testContext the test context whose application context should * potentially be marked as dirty; never {@code null} * @param requiredClassMode the class mode required for a context to * be marked dirty in the current phase; never {@code null} * @throws Exception allows any exception to propagate * @since 4.2 * @see #dirtyContext */ protected void beforeOrAfterTestClass(TestContext testContext, ClassMode requiredClassMode) throws Exception { Assert.notNull(testContext, "TestContext must not be null"); Assert.notNull(requiredClassMode, "requiredClassMode must not be null"); Class<?> testClass = testContext.getTestClass(); Assert.notNull(testClass, "The test class of the supplied TestContext must not be null"); DirtiesContext dirtiesContext = AnnotatedElementUtils.findMergedAnnotation(testClass, DirtiesContext.class); boolean classAnnotated = (dirtiesContext != null); ClassMode classMode = (classAnnotated ? dirtiesContext.classMode() : null); if (logger.isDebugEnabled()) { String phase = (requiredClassMode.name().startsWith("BEFORE") ? "Before" : "After"); logger.debug(String.format( "%s test class: context %s, class annotated with @DirtiesContext [%s] with mode [%s].", phase, testContext, classAnnotated, classMode)); } if (classMode == requiredClassMode) { dirtyContext(testContext, dirtiesContext.hierarchyMode()); } }
/** * Perform the actual work for {@link #beforeTestClass} and {@link #afterTestClass} * by dirtying the context if appropriate (i.e., according to the required mode). * @param testContext the test context whose application context should * potentially be marked as dirty; never {@code null} * @param requiredClassMode the class mode required for a context to * be marked dirty in the current phase; never {@code null} * @throws Exception allows any exception to propagate * @since 4.2 * @see #dirtyContext */ protected void beforeOrAfterTestClass(TestContext testContext, ClassMode requiredClassMode) throws Exception { Assert.notNull(testContext, "TestContext must not be null"); Assert.notNull(requiredClassMode, "requiredClassMode must not be null"); Class<?> testClass = testContext.getTestClass(); Assert.notNull(testClass, "The test class of the supplied TestContext must not be null"); DirtiesContext dirtiesContext = AnnotatedElementUtils.findMergedAnnotation(testClass, DirtiesContext.class); boolean classAnnotated = (dirtiesContext != null); ClassMode classMode = (classAnnotated ? dirtiesContext.classMode() : null); if (logger.isDebugEnabled()) { String phase = (requiredClassMode.name().startsWith("BEFORE") ? "Before" : "After"); logger.debug(String.format( "%s test class: context %s, class annotated with @DirtiesContext [%s] with mode [%s].", phase, testContext, classAnnotated, classMode)); } if (classMode == requiredClassMode) { dirtyContext(testContext, dirtiesContext.hierarchyMode()); } }
/** * Perform the actual work for {@link #beforeTestClass} and {@link #afterTestClass} * by dirtying the context if appropriate (i.e., according to the required mode). * @param testContext the test context whose application context should * potentially be marked as dirty; never {@code null} * @param requiredClassMode the class mode required for a context to * be marked dirty in the current phase; never {@code null} * @throws Exception allows any exception to propagate * @since 4.2 * @see #dirtyContext */ protected void beforeOrAfterTestClass(TestContext testContext, ClassMode requiredClassMode) throws Exception { Assert.notNull(testContext, "TestContext must not be null"); Assert.notNull(requiredClassMode, "requiredClassMode must not be null"); Class<?> testClass = testContext.getTestClass(); Assert.notNull(testClass, "The test class of the supplied TestContext must not be null"); DirtiesContext dirtiesContext = AnnotatedElementUtils.findMergedAnnotation(testClass, DirtiesContext.class); boolean classAnnotated = (dirtiesContext != null); ClassMode classMode = (classAnnotated ? dirtiesContext.classMode() : null); if (logger.isDebugEnabled()) { String phase = (requiredClassMode.name().startsWith("BEFORE") ? "Before" : "After"); logger.debug(String.format( "%s test class: context %s, class annotated with @DirtiesContext [%s] with mode [%s].", phase, testContext, classAnnotated, classMode)); } if (classMode == requiredClassMode) { dirtyContext(testContext, dirtiesContext.hierarchyMode()); } }