1919 */
2020package org .xwiki .index .test .ui .docker ;
2121
22+ import java .util .Objects ;
2223import java .util .Properties ;
2324
25+ import org .jetbrains .annotations .NotNull ;
2426import org .junit .jupiter .api .extension .BeforeAllCallback ;
2527import org .junit .jupiter .api .extension .ExtensionContext ;
2628import org .xwiki .test .docker .internal .junit5 .DockerTestUtils ;
@@ -38,13 +40,14 @@ public class DynamicTestConfigurationExtension implements BeforeAllCallback
3840 @ Override
3941 public void beforeAll (ExtensionContext extensionContext )
4042 {
43+
4144 // Get the already loaded configuration to get the used database engine.
4245 TestConfiguration loadedConfiguration = DockerTestUtils .getTestConfiguration (extensionContext );
4346
4447 // Collations to test. They were chosen such that they offer sorting for German umlauts that differs from the
4548 // default "binary" sorting.
4649 String collation = switch (loadedConfiguration .getDatabase ()) {
47- case MYSQL , MARIADB -> "utf8mb4_german2_ci" ;
50+ case MYSQL , MARIADB -> computeMysqlCollation ( loadedConfiguration ) ;
4851 case HSQLDB_EMBEDDED -> "de_DE" ;
4952 case POSTGRESQL -> "unicode" ;
5053 case ORACLE -> "GENERIC_M_CI" ;
@@ -59,4 +62,17 @@ public void beforeAll(ExtensionContext extensionContext)
5962 configuration .setProperties (properties );
6063 globalStore .put (TestConfiguration .class , configuration );
6164 }
65+
66+ private static String computeMysqlCollation (TestConfiguration loadedConfiguration )
67+ {
68+ String mysqlCollation ;
69+ // Replace the collation with utf8mb3 when the collation is explicitly set to utf8. This is for instance the
70+ // case when running the docker-all configuration on the CI.
71+ if (Objects .equals (loadedConfiguration .getDatabaseCommands ().getProperty ("collation-server" ), "utf8_bin" )) {
72+ mysqlCollation = "utf8mb3_german2_ci" ;
73+ } else {
74+ mysqlCollation = "utf8mb4_german2_ci" ;
75+ }
76+ return mysqlCollation ;
77+ }
6278}
0 commit comments