From 0017256968d02f19ce03282db2c6dbd7267d2539 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 17 Apr 2020 13:29:33 +0200 Subject: [PATCH] Test that @TestConstructor can be used as a meta-annotation --- .../support/TestConstructorUtilsTests.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spring-test/src/test/java/org/springframework/test/context/support/TestConstructorUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/TestConstructorUtilsTests.java index 860001b4a9..5bcf5767ea 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/TestConstructorUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/TestConstructorUtilsTests.java @@ -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 { }