Support ContextLoader config in @SpringJUnit[Web]Config
Prior to this commit, @SpringJUnitConfig and @SpringJUnitWebConfig did not declare `loader` attributes that alias @ContextConfiguration's `loader` attribute. Consequently, it was not possible to configure a custom ContextLoader via those annotations. The lack of those `loader` attributes was an oversight, and this commit introduces them to support custom ContextLoader configuration directly via the @SpringJUnitConfig and @SpringJUnitWebConfig annotations. Closes gh-31498
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -28,6 +28,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.ContextLoader;
|
||||
|
||||
/**
|
||||
* {@code @SpringJUnitConfig} is a <em>composed annotation</em> that combines
|
||||
@@ -91,6 +92,13 @@ public @interface SpringJUnitConfig {
|
||||
@AliasFor(annotation = ContextConfiguration.class)
|
||||
boolean inheritInitializers() default true;
|
||||
|
||||
/**
|
||||
* Alias for {@link ContextConfiguration#loader}.
|
||||
* @since 6.1
|
||||
*/
|
||||
@AliasFor(annotation = ContextConfiguration.class)
|
||||
Class<? extends ContextLoader> loader() default ContextLoader.class;
|
||||
|
||||
/**
|
||||
* Alias for {@link ContextConfiguration#name}.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
@@ -28,6 +28,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.ContextLoader;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@@ -96,6 +97,13 @@ public @interface SpringJUnitWebConfig {
|
||||
@AliasFor(annotation = ContextConfiguration.class)
|
||||
boolean inheritInitializers() default true;
|
||||
|
||||
/**
|
||||
* Alias for {@link ContextConfiguration#loader}.
|
||||
* @since 6.1
|
||||
*/
|
||||
@AliasFor(annotation = ContextConfiguration.class)
|
||||
Class<? extends ContextLoader> loader() default ContextLoader.class;
|
||||
|
||||
/**
|
||||
* Alias for {@link ContextConfiguration#name}.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user