Skip to content

Commit

Permalink
Update per review - Generate tests in admin-client-tests from admin-c…
Browse files Browse the repository at this point in the history
…lient-jee-tests

Signed-off-by: mposolda <[email protected]>
  • Loading branch information
mposolda committed Aug 5, 2024
1 parent 1301b5e commit cec8cb3
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 44 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions testsuite/admin-client-jee-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client-testsuite</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client-jee</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <a href="mailto:[email protected]">Marek Posolda</a>
*/
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";
}
}

This file was deleted.

This file was deleted.

57 changes: 50 additions & 7 deletions testsuite/admin-client-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@

<artifactId>keycloak-admin-client-testsuite</artifactId>

<properties>
<!-- Tests from this directory will be copied from "admin-client-jee-tests" -->
<admin-client-tests-root-dir>src/test/java/org/keycloak/client/testsuite/adminclient</admin-client-tests-root-dir>

<jakarta-transformer-sources>${project.basedir}/../admin-client-jee-tests/${admin-client-tests-root-dir}</jakarta-transformer-sources>
<jakarta-transformer-target>${project.basedir}/${admin-client-tests-root-dir}</jakarta-transformer-target>
</properties>

<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
Expand All @@ -24,21 +32,56 @@
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<filesets>
<fileset>
<!-- delete the files created by the transformer -->
<directory>${admin-client-tests-root-dir}</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>transform</id>
<phase>initialize</phase>
<goals>
<goal>test-jar</goal>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<delete dir="${jakarta-transformer-target}"/>
<java classname="org.eclipse.transformer.cli.JakartaTransformerCLI" fork="true">
<arg value="${jakarta-transformer-sources}"/>
<arg value="${jakarta-transformer-target}"/>
<classpath>
<pathelement path="${plugin_classpath}"/>
</classpath>
</java>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.transformer</groupId>
<artifactId>org.eclipse.transformer.cli</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.14</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.keycloak.client.testsuite.adminclient;
package org.keycloak.client.testsuite;

import java.lang.reflect.Field;

Expand All @@ -14,7 +14,7 @@
*
* @author <a href="mailto:[email protected]">Marek Posolda</a>
*/
public class ClasspathTest {
public class ClasspathJakartaTest {

@Test
public void testCorrectResteasyClient() throws Exception {
Expand Down

0 comments on commit cec8cb3

Please sign in to comment.