All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.test.context.event.annotation.AfterTestClass Maven / Gradle / Ivy

There is a newer version: 6.1.13
Show newest version
/*
 * Copyright 2002-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.test.context.event.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.AliasFor;
import org.springframework.test.context.event.AfterTestClassEvent;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * {@link EventListener @EventListener} annotation used to consume an
 * {@link AfterTestClassEvent} published by the
 * {@link org.springframework.test.context.event.EventPublishingTestExecutionListener
 * EventPublishingTestExecutionListener}.
 *
 * 

This annotation may be used on {@code @EventListener}-compliant methods within * a Spring test {@link org.springframework.context.ApplicationContext ApplicationContext} * — for example, on methods in a * {@link org.springframework.context.annotation.Configuration @Configuration} * class. A method annotated with this annotation will be invoked as part of the * {@link org.springframework.test.context.TestExecutionListener#afterTestClass} * lifecycle. * *

Event processing can optionally be made {@linkplain #value conditional} via * a SpEL expression — for example, * {@code @AfterTestClass("event.testContext.testClass.name matches '.+IntegrationTests'")}. * *

The {@code EventPublishingTestExecutionListener} must be registered in order * for this annotation to have an effect — for example, via * {@link org.springframework.test.context.TestExecutionListeners @TestExecutionListeners}. * Note, however, that the {@code EventPublishingTestExecutionListener} is registered * by default. * * @author Frank Scheffler * @author Sam Brannen * @since 5.2 * @see AfterTestClassEvent */ @Retention(RUNTIME) @Target({ METHOD, ANNOTATION_TYPE }) @Documented @EventListener(AfterTestClassEvent.class) public @interface AfterTestClass { /** * Alias for {@link EventListener#condition}. */ @AliasFor(annotation = EventListener.class, attribute = "condition") String value() default ""; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy