package io.quarkus.it.extension;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class ClasspathTestCase {

    private static final String CLASS_FILE = "io/quarkus/it/extension/ClasspathTestEndpoint.class";
    private static final String RESOURCE_FILE = "some-resource-for-classpath-test.txt";

    @Test
    public void testAugmentationMainClassNoDuplicate() {
        given().param("resourceName", CLASS_FILE)
                .param("phase", "augmentation")
                .when().get("/core/classpath").then()
                .body(is("OK"));
    }

    @Test
    public void testAugmentationMainResourceNoDuplicate() {
        given().param("resourceName", RESOURCE_FILE)
                .param("phase", "augmentation")
                .when().get("/core/classpath").then()
                .body(is("OK"));
    }

    @Test
    public void testStaticInitMainClassNoDuplicate() {
        given().param("resourceName", CLASS_FILE)
                .param("phase", "static_init")
                .when().get("/core/classpath").then()
                .body(is("OK"));
    }

    @Test
    public void testStaticInitMainResourceNoDuplicate() {
        given().param("resourceName", RESOURCE_FILE)
                .param("phase", "static_init")
                .when().get("/core/classpath").then()
                .body(is("OK"));
    }

    @Test
    @Disabled("For some reason, class files are not accessible as resources through the runtime init classloader;"
            + " that's beside the point of this PR though, so we'll ignore that.")
    public void testRuntimeInitMainClassNoDuplicate() {
        given().param("resourceName", CLASS_FILE)
                .param("phase", "runtime_init")
                .when().get("/core/classpath").then()
                .body(is("OK"));
    }

    @Test
    public void testRuntimeInitMainResourceNoDuplicate() {
        given().param("resourceName", RESOURCE_FILE)
                .param("phase", "runtime_init")
                .when().get("/core/classpath").then()
                .body(is("OK"));
    }

}

@@ -191,16 +191,68 @@
 .Test;%0A%0A
+import io.quarkus.test.junit.DisabledOnNativeImage;%0A
 import i
@@ -1048,32 +1048,199 @@
    %7D%0A%0A    @Test%0A
+    // Static init may happen in a container when testing a native image,%0A    // in which case we don't have any classpath record to check.%0A    @DisabledOnNativeImage%0A
     public void 
@@ -1471,32 +1471,199 @@
    %7D%0A%0A    @Test%0A
+    // Static init may happen in a container when testing a native image,%0A    // in which case we don't have any classpath record to check.%0A    @DisabledOnNativeImage%0A
     public void 

Disable static init classpath checks in native image tests