diff --git a/spring-core-test/src/main/java/org/springframework/aot/test/agent/EnabledIfRuntimeHintsAgent.java b/spring-core-test/src/main/java/org/springframework/aot/test/agent/EnabledIfRuntimeHintsAgent.java index 36ef2803b43..b89c4ed3289 100644 --- a/spring-core-test/src/main/java/org/springframework/aot/test/agent/EnabledIfRuntimeHintsAgent.java +++ b/spring-core-test/src/main/java/org/springframework/aot/test/agent/EnabledIfRuntimeHintsAgent.java @@ -22,8 +22,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.condition.EnabledIf; import org.springframework.aot.agent.RuntimeHintsAgent; @@ -51,13 +50,13 @@ import org.springframework.aot.agent.RuntimeHintsAgent; * * * @author Brian Clozel + * @author Sam Brannen * @since 6.0 */ @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Documented -@ExtendWith(RuntimeHintsAgentCondition.class) -@Tag("RuntimeHintsTests") +@EnabledIf(value = "org.springframework.aot.agent.RuntimeHintsAgent#isLoaded", + disabledReason = "RuntimeHintsAgent is not loaded on the current JVM") public @interface EnabledIfRuntimeHintsAgent { - } diff --git a/spring-core-test/src/main/java/org/springframework/aot/test/agent/RuntimeHintsAgentCondition.java b/spring-core-test/src/main/java/org/springframework/aot/test/agent/RuntimeHintsAgentCondition.java deleted file mode 100644 index 9276acdef1d..00000000000 --- a/spring-core-test/src/main/java/org/springframework/aot/test/agent/RuntimeHintsAgentCondition.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.aot.test.agent; - -import org.junit.jupiter.api.extension.ConditionEvaluationResult; -import org.junit.jupiter.api.extension.ExecutionCondition; -import org.junit.jupiter.api.extension.ExtensionContext; - -import org.springframework.aot.agent.RuntimeHintsAgent; - -import static org.junit.platform.commons.support.AnnotationSupport.findAnnotation; - -/** - * {@link ExecutionCondition} for {@link EnabledIfRuntimeHintsAgent @EnabledIfRuntimeHintsAgent}. - * - * @author Brian Clozel - * @since 6.0 - */ -class RuntimeHintsAgentCondition implements ExecutionCondition { - - @Override - public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { - return findAnnotation(context.getElement(), EnabledIfRuntimeHintsAgent.class) - .map(annotation -> checkRuntimeHintsAgentPresence()) - .orElse(ConditionEvaluationResult.enabled("@EnabledIfRuntimeHintsAgent is not present")); - } - - static ConditionEvaluationResult checkRuntimeHintsAgentPresence() { - return RuntimeHintsAgent.isLoaded() ? ConditionEvaluationResult.enabled("RuntimeHintsAgent is loaded") - : ConditionEvaluationResult.disabled("RuntimeHintsAgent is not loaded on the current JVM"); - } - -}