mirror of
https://github.com/keycloak/keycloak.git
synced 2025-12-21 06:20:05 -06:00
Sort test classes by server config (#38215)
Signed-off-by: stianst <stianst@gmail.com>
This commit is contained in:
@@ -39,6 +39,12 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<artifactId>keycloak-test-framework-junit5-config</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<artifactId>keycloak-test-framework-ui</artifactId>
|
||||
|
||||
@@ -43,6 +43,12 @@
|
||||
<dependency>
|
||||
<groupId>org.keycloak</groupId>
|
||||
<artifactId>keycloak-junit5</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-junit5-config</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<artifactId>keycloak-test-framework-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<artifactId>keycloak-test-framework-junit5-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<artifactId>keycloak-test-framework-db-mariadb</artifactId>
|
||||
|
||||
42
test-framework/junit5-config/pom.xml
Executable file
42
test-framework/junit5-config/pom.xml
Executable file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||
~ and other contributors as indicated by the @author tags.
|
||||
~
|
||||
~ 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
|
||||
~
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<artifactId>keycloak-test-framework-parent</artifactId>
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<version>999.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>keycloak-test-framework-junit5-config</artifactId>
|
||||
<name>Keycloak Test Framework</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Default test framework config for JUnit 5</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<artifactId>keycloak-test-framework-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.keycloak.testframework;
|
||||
|
||||
import org.infinispan.util.function.SerializableComparator;
|
||||
import org.junit.jupiter.api.ClassDescriptor;
|
||||
import org.junit.jupiter.api.ClassOrderer;
|
||||
import org.junit.jupiter.api.ClassOrdererContext;
|
||||
import org.keycloak.testframework.annotations.KeycloakIntegrationTest;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class ServerConfigClassOrderer implements ClassOrderer {
|
||||
|
||||
@Override
|
||||
public void orderClasses(ClassOrdererContext classOrdererContext) {
|
||||
classOrdererContext.getClassDescriptors().sort(new ServerConfigComparator());
|
||||
}
|
||||
|
||||
static class ServerConfigComparator implements SerializableComparator<ClassDescriptor> {
|
||||
|
||||
@Override
|
||||
public int compare(ClassDescriptor o1, ClassDescriptor o2) {
|
||||
Optional<KeycloakIntegrationTest> a1 = o1.findAnnotation(KeycloakIntegrationTest.class);
|
||||
Optional<KeycloakIntegrationTest> a2 = o2.findAnnotation(KeycloakIntegrationTest.class);
|
||||
|
||||
if (a1.isPresent() && a2.isPresent()) {
|
||||
return a1.get().config().getName().compareTo(a2.get().config().getName());
|
||||
} else if (a1.isPresent()) {
|
||||
return 1;
|
||||
} else if (a2.isPresent()) {
|
||||
return 2;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
junit.jupiter.extensions.autodetection.enabled=true
|
||||
junit.jupiter.testclass.order.default=org.keycloak.testframework.ServerConfigClassOrderer
|
||||
@@ -35,6 +35,7 @@
|
||||
<modules>
|
||||
<module>bom</module>
|
||||
<module>core</module>
|
||||
<module>junit5-config</module>
|
||||
<module>db-mariadb</module>
|
||||
<module>db-mssql</module>
|
||||
<module>db-mysql</module>
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<artifactId>keycloak-test-framework-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<artifactId>keycloak-test-framework-junit5-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.testframework</groupId>
|
||||
<artifactId>keycloak-test-framework-ui</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user