This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new e53251caa6 [resolves #5586] Add @DisabledOnQuarkusPlatform annotation
e53251caa6 is described below

commit e53251caa64ee13c1259c770335df2e1fd9b4234
Author: Lukas Lowinger <[email protected]>
AuthorDate: Wed Sep 17 10:09:20 2025 +0200

    [resolves #5586] Add @DisabledOnQuarkusPlatform annotation
---
 integration-test-groups/foundation/core/pom.xml    |  5 +++
 .../org/apache/camel/quarkus/core/CoreTest.java    | 11 +----
 .../quarkus/test/DisabledOnQuarkusPlatform.java    | 35 ++++++++++++++++
 .../test/DisabledOnQuarkusPlatformCondition.java   | 48 ++++++++++++++++++++++
 integration-tests/foundation-grouped/pom.xml       |  5 +++
 .../apache/camel/quarkus/main/CoreMainTest.java    | 13 +-----
 6 files changed, 97 insertions(+), 20 deletions(-)

diff --git a/integration-test-groups/foundation/core/pom.xml 
b/integration-test-groups/foundation/core/pom.xml
index 04154ccf24..ae9b7cbc2d 100644
--- a/integration-test-groups/foundation/core/pom.xml
+++ b/integration-test-groups/foundation/core/pom.xml
@@ -55,6 +55,11 @@
             <artifactId>rest-assured</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-integration-test-support</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <profiles>
diff --git 
a/integration-test-groups/foundation/core/src/test/java/org/apache/camel/quarkus/core/CoreTest.java
 
b/integration-test-groups/foundation/core/src/test/java/org/apache/camel/quarkus/core/CoreTest.java
index dc6c075479..ed5904093f 100644
--- 
a/integration-test-groups/foundation/core/src/test/java/org/apache/camel/quarkus/core/CoreTest.java
+++ 
b/integration-test-groups/foundation/core/src/test/java/org/apache/camel/quarkus/core/CoreTest.java
@@ -17,13 +17,11 @@
 package org.apache.camel.quarkus.core;
 
 import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
+import org.apache.camel.quarkus.test.DisabledOnQuarkusPlatform;
 import org.apache.camel.support.DefaultLRUCacheFactory;
-import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.Matchers.*;
@@ -165,14 +163,9 @@ public class CoreTest {
                 .body(emptyOrNullString());
     }
 
+    @DisabledOnQuarkusPlatform // 
https://github.com/apache/camel-quarkus/issues/7312
     @Test
     void classpathPackageScanDirectoryGlob() {
-        // TODO: Remove this suppression of test execution in the Quarkus 
Platform
-        // https://github.com/apache/camel-quarkus/issues/7312
-        Path moduleDir = Paths.get("").toAbsolutePath().getFileName();
-
-        
Assumptions.assumeFalse(moduleDir.toString().equals("camel-quarkus-integration-test-foundation-grouped"));
-
         RestAssured.given()
                 .queryParam("path", "sub-resources-folder/**")
                 .get("/core/resource/resolve")
diff --git 
a/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnQuarkusPlatform.java
 
b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnQuarkusPlatform.java
new file mode 100644
index 0000000000..122d65fcf8
--- /dev/null
+++ 
b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnQuarkusPlatform.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *      http://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.apache.camel.quarkus.test;
+
+import java.lang.annotation.Documented;
+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;
+
+/**
+ * Skip test on Quarkus Platform.
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@ExtendWith(DisabledOnQuarkusPlatformCondition.class)
+public @interface DisabledOnQuarkusPlatform {
+}
diff --git 
a/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnQuarkusPlatformCondition.java
 
b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnQuarkusPlatformCondition.java
new file mode 100644
index 0000000000..954010096d
--- /dev/null
+++ 
b/integration-tests-support/test-support/src/main/java/org/apache/camel/quarkus/test/DisabledOnQuarkusPlatformCondition.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *      http://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.apache.camel.quarkus.test;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import org.junit.jupiter.api.extension.ConditionEvaluationResult;
+import org.junit.jupiter.api.extension.ExecutionCondition;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+import static 
org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled;
+import static 
org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
+import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation;
+
+public class DisabledOnQuarkusPlatformCondition implements ExecutionCondition {
+    private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = 
enabled(
+            "@DisabledOnQuarkusPlatform: enabled - annotation not present");
+
+    @Override
+    public ConditionEvaluationResult 
evaluateExecutionCondition(ExtensionContext context) {
+        return findAnnotation(context.getElement(), 
DisabledOnQuarkusPlatform.class).isPresent() ? evaluate()
+                : ENABLED_BY_DEFAULT;
+    }
+
+    private ConditionEvaluationResult evaluate() {
+        // There are no .java source files in Quarkus Platform (tests are run 
from test-jars)
+        if (Files.exists(Paths.get("src/main/java"))) {
+            return enabled("@DisabledOnQuarkusPlatform: enabled - Quarkus 
Platform not detected");
+        } else {
+            return disabled("@DisabledOnQuarkusPlatform: disabled - Quarkus 
Platform detected");
+        }
+    }
+}
diff --git a/integration-tests/foundation-grouped/pom.xml 
b/integration-tests/foundation-grouped/pom.xml
index e4ecd43fe2..5f58c39995 100644
--- a/integration-tests/foundation-grouped/pom.xml
+++ b/integration-tests/foundation-grouped/pom.xml
@@ -175,6 +175,11 @@
             <artifactId>rest-assured</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-integration-test-support</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-integration-wiremock-support</artifactId>
diff --git 
a/integration-tests/main/src/test/java/org/apache/camel/quarkus/main/CoreMainTest.java
 
b/integration-tests/main/src/test/java/org/apache/camel/quarkus/main/CoreMainTest.java
index ae35559794..40b023ea50 100644
--- 
a/integration-tests/main/src/test/java/org/apache/camel/quarkus/main/CoreMainTest.java
+++ 
b/integration-tests/main/src/test/java/org/apache/camel/quarkus/main/CoreMainTest.java
@@ -17,10 +17,7 @@
 package org.apache.camel.quarkus.main;
 
 import java.net.HttpURLConnection;
-import java.nio.file.Files;
-import java.nio.file.Paths;
 import java.util.Map;
-import java.util.function.BooleanSupplier;
 
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
@@ -31,7 +28,7 @@ import jakarta.ws.rs.core.MediaType;
 import org.apache.camel.ServiceStatus;
 import org.apache.camel.quarkus.core.DisabledModelToXMLDumper;
 import org.apache.camel.quarkus.core.RegistryRoutesLoaders;
-import org.apache.camel.quarkus.test.EnabledIf;
+import org.apache.camel.quarkus.test.DisabledOnQuarkusPlatform;
 import org.apache.camel.reactive.vertx.VertXReactiveExecutor;
 import org.apache.camel.reactive.vertx.VertXThreadPoolFactory;
 import org.apache.camel.support.DefaultLRUCacheFactory;
@@ -228,7 +225,7 @@ public class CoreMainTest {
     }
 
     // Avoid running in the Quarkus Platform where there are no .java source 
files
-    @EnabledIf(SrcDirectoryExists.class)
+    @DisabledOnQuarkusPlatform
     @Test
     public void routeSourceResource() {
         RestAssured.given()
@@ -238,10 +235,4 @@ public class CoreMainTest {
                 .body(containsString("public class " + 
CamelCdiBeanRoute.class.getSimpleName()));
     }
 
-    public static class SrcDirectoryExists implements BooleanSupplier {
-        @Override
-        public boolean getAsBoolean() {
-            return Files.exists(Paths.get("src/main/java"));
-        }
-    }
 }

Reply via email to