diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOs.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOs.java index a6c3ee499b..d691eac3a8 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOs.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOs.java @@ -17,7 +17,6 @@ package org.springframework.boot.testsupport.junit; import java.lang.annotation.ElementType; -import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -27,7 +26,7 @@ import org.junit.jupiter.api.extension.ExtendWith; /** * Improves JUnit5's {@link org.junit.jupiter.api.condition.DisabledOnOs} by adding an - * architecture check and making it repeatable. + * architecture check. * * @author Moritz Halbritter * @since 2.5.11 @@ -35,7 +34,6 @@ import org.junit.jupiter.api.extension.ExtendWith; @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @ExtendWith(DisabledOnOsCondition.class) -@Repeatable(DisabledOnOsRepeatable.class) public @interface DisabledOnOs { /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsCondition.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsCondition.java index bd14d9b235..3b644b2006 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsCondition.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsCondition.java @@ -16,7 +16,7 @@ package org.springframework.boot.testsupport.junit; -import java.util.List; +import java.util.Optional; import org.junit.jupiter.api.extension.ConditionEvaluationResult; import org.junit.jupiter.api.extension.ExecutionCondition; @@ -32,24 +32,21 @@ class DisabledOnOsCondition implements ExecutionCondition { @Override public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { - List annotations = AnnotationUtils.findRepeatableAnnotations(context.getElement(), - DisabledOnOs.class); - if (annotations.isEmpty()) { + Optional annotation = AnnotationUtils.findAnnotation(context.getElement(), DisabledOnOs.class); + if (!annotation.isPresent()) { return ConditionEvaluationResult.enabled("No @DisabledOnOs found"); } - return evaluate(annotations); + return evaluate(annotation.get()); } - private ConditionEvaluationResult evaluate(List annotations) { + private ConditionEvaluationResult evaluate(DisabledOnOs annotation) { String architecture = System.getProperty("os.arch"); String os = System.getProperty("os.name"); - for (DisabledOnOs annotation : annotations) { - if (annotation.os().isCurrentOs() && annotation.architecture().equals(architecture)) { - String reason = annotation.disabledReason().isEmpty() - ? String.format("Disabled on OS = %s, architecture = %s", os, architecture) - : annotation.disabledReason(); - return ConditionEvaluationResult.disabled(reason); - } + if (annotation.os().isCurrentOs() && annotation.architecture().equals(architecture)) { + String reason = annotation.disabledReason().isEmpty() + ? String.format("Disabled on OS = %s, architecture = %s", os, architecture) + : annotation.disabledReason(); + return ConditionEvaluationResult.disabled(reason); } return ConditionEvaluationResult .enabled(String.format("Enabled on OS = %s, architecture = %s", os, architecture)); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsRepeatable.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsRepeatable.java deleted file mode 100644 index 1c52f5afe7..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsRepeatable.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012-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.boot.testsupport.junit; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.api.extension.ExtendWith; - -/** - * Repeatable container for {@link DisabledOnOs}. - * - * @author Moritz Halbritter - * @since 2.5.10 - */ -@Target({ ElementType.TYPE, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -@ExtendWith(DisabledOnOsCondition.class) -public @interface DisabledOnOsRepeatable { - - DisabledOnOs[] value(); - -}