From cec8cb377c37da55840f557758417ea47e37996d Mon Sep 17 00:00:00 2001 From: mposolda Date: Mon, 5 Aug 2024 13:23:47 +0200 Subject: [PATCH] Update per review - Generate tests in admin-client-tests from admin-client-jee-tests Signed-off-by: mposolda --- .gitignore | 4 +- testsuite/admin-client-jee-tests/pom.xml | 13 ----- .../client/testsuite/ClasspathJEETest.java | 33 +++++++++++ .../adminclient/AbstractAdminClientTest.java | 0 .../testsuite/adminclient/RealmsTest.java | 0 .../adminclientjee/ClasspathJEETest.java | 12 ---- .../adminclientjee/RealmsJEETest.java | 7 --- testsuite/admin-client-tests/pom.xml | 57 ++++++++++++++++--- ...athTest.java => ClasspathJakartaTest.java} | 4 +- 9 files changed, 86 insertions(+), 44 deletions(-) create mode 100644 testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/ClasspathJEETest.java rename testsuite/{admin-client-tests => admin-client-jee-tests}/src/test/java/org/keycloak/client/testsuite/adminclient/AbstractAdminClientTest.java (100%) rename testsuite/{admin-client-tests => admin-client-jee-tests}/src/test/java/org/keycloak/client/testsuite/adminclient/RealmsTest.java (100%) delete mode 100644 testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/ClasspathJEETest.java delete mode 100644 testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/RealmsJEETest.java rename testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/{adminclient/ClasspathTest.java => ClasspathJakartaTest.java} (93%) diff --git a/.gitignore b/.gitignore index a732d8e..0fcf598 100644 --- a/.gitignore +++ b/.gitignore @@ -81,9 +81,7 @@ quarkus/data/*.db # Jakarta transformed sources # ############################### -/integration/admin-client/src/ -/adapters/saml/jakarta-servlet-filter/src/ -/adapters/oidc/jakarta-servlet-filter/src/ +/testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/ /.metadata/ # Git ephemeral files diff --git a/testsuite/admin-client-jee-tests/pom.xml b/testsuite/admin-client-jee-tests/pom.xml index 07d02ec..75c0643 100644 --- a/testsuite/admin-client-jee-tests/pom.xml +++ b/testsuite/admin-client-jee-tests/pom.xml @@ -29,19 +29,6 @@ - - org.keycloak - keycloak-admin-client-testsuite - ${project.version} - test - test-jar - - - * - * - - - org.keycloak keycloak-admin-client-jee diff --git a/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/ClasspathJEETest.java b/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/ClasspathJEETest.java new file mode 100644 index 0000000..6312fb5 --- /dev/null +++ b/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/ClasspathJEETest.java @@ -0,0 +1,33 @@ +package org.keycloak.client.testsuite; + +import java.lang.reflect.Field; + +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.junit.jupiter.api.Test; +import org.keycloak.admin.client.Keycloak; +import org.testcontainers.shaded.org.hamcrest.MatcherAssert; + +import static org.testcontainers.shaded.org.hamcrest.Matchers.equalTo; + +/** + * @author Marek Posolda + */ +public class ClasspathJEETest { + + @Test + public void testCorrectResteasyClient() throws Exception { + Field clientField = Keycloak.class.getDeclaredField("client"); + Class clientFieldClass = clientField.getType(); + MatcherAssert.assertThat(getExpectedClientFieldClass(), equalTo(clientFieldClass.getName())); + } + + @Test + public void testResteasyVersion() throws Exception { + Class resteasyClientSuperclass = ResteasyClient.class.getInterfaces()[0]; + MatcherAssert.assertThat(getExpectedClientFieldClass(), equalTo(resteasyClientSuperclass.getName())); + } + + protected String getExpectedClientFieldClass() { + return "javax.ws.rs.client.Client"; + } +} diff --git a/testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/AbstractAdminClientTest.java b/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclient/AbstractAdminClientTest.java similarity index 100% rename from testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/AbstractAdminClientTest.java rename to testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclient/AbstractAdminClientTest.java diff --git a/testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/RealmsTest.java b/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclient/RealmsTest.java similarity index 100% rename from testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/RealmsTest.java rename to testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclient/RealmsTest.java diff --git a/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/ClasspathJEETest.java b/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/ClasspathJEETest.java deleted file mode 100644 index cf9274e..0000000 --- a/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/ClasspathJEETest.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.keycloak.client.testsuite.adminclientjee; - -/** - * @author Marek Posolda - */ -public class ClasspathJEETest extends org.keycloak.client.testsuite.adminclient.ClasspathTest { - - @Override - protected String getExpectedClientFieldClass() { - return "javax.ws.rs.client.Client"; - } -} diff --git a/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/RealmsJEETest.java b/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/RealmsJEETest.java deleted file mode 100644 index 1d7341e..0000000 --- a/testsuite/admin-client-jee-tests/src/test/java/org/keycloak/client/testsuite/adminclientjee/RealmsJEETest.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.keycloak.client.testsuite.adminclientjee; - -/** - * @author Marek Posolda - */ -public class RealmsJEETest extends org.keycloak.client.testsuite.adminclient.RealmsTest { -} diff --git a/testsuite/admin-client-tests/pom.xml b/testsuite/admin-client-tests/pom.xml index 892ca1a..a67e4c1 100644 --- a/testsuite/admin-client-tests/pom.xml +++ b/testsuite/admin-client-tests/pom.xml @@ -12,6 +12,14 @@ keycloak-admin-client-testsuite + + + src/test/java/org/keycloak/client/testsuite/adminclient + + ${project.basedir}/../admin-client-jee-tests/${admin-client-tests-root-dir} + ${project.basedir}/${admin-client-tests-root-dir} + + org.keycloak @@ -24,21 +32,56 @@ - maven-jar-plugin + maven-clean-plugin - - - true - - + + + + ${admin-client-tests-root-dir} + + **/*.java + + + + + + maven-antrun-plugin + 3.0.0 + transform + initialize - test-jar + run + + + + + + + + + + + + + + + + org.eclipse.transformer + org.eclipse.transformer.cli + 0.5.0 + + + org.apache.ant + ant + 1.10.14 + + diff --git a/testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/ClasspathTest.java b/testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/ClasspathJakartaTest.java similarity index 93% rename from testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/ClasspathTest.java rename to testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/ClasspathJakartaTest.java index 2796b9f..a693d9e 100644 --- a/testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/adminclient/ClasspathTest.java +++ b/testsuite/admin-client-tests/src/test/java/org/keycloak/client/testsuite/ClasspathJakartaTest.java @@ -1,4 +1,4 @@ -package org.keycloak.client.testsuite.adminclient; +package org.keycloak.client.testsuite; import java.lang.reflect.Field; @@ -14,7 +14,7 @@ * * @author Marek Posolda */ -public class ClasspathTest { +public class ClasspathJakartaTest { @Test public void testCorrectResteasyClient() throws Exception {