Test that @TestConstructor can be used as a meta-annotation

This commit is contained in:
Sam Brannen 2020-04-17 13:29:33 +02:00
parent df291a39b1
commit 0017256968
1 changed files with 20 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@ -16,6 +16,10 @@
package org.springframework.test.context.support;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import org.junit.jupiter.api.AfterEach;
@ -57,6 +61,11 @@ class TestConstructorUtilsTests {
assertAutowirable(TestConstructorAnnotationTestCase.class);
}
@Test
void testConstructorAsMetaAnnotation() throws Exception {
assertAutowirable(TestConstructorAsMetaAnnotationTestCase.class);
}
@Test
void automaticallyAutowired() throws Exception {
setGlobalFlag();
@ -125,6 +134,16 @@ class TestConstructorUtilsTests {
static class TestConstructorAnnotationTestCase {
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@TestConstructor(autowireMode = ALL)
@interface AutowireConstructor {
}
@AutowireConstructor
static class TestConstructorAsMetaAnnotationTestCase {
}
static class AutomaticallyAutowiredTestCase {
}