Skip to content

Commit f5a1d79

Browse files
committed
XWIKI-23463: Errors with DocumentTreeMacroIT with Mysql UTF-8
1 parent 8b2ecb6 commit f5a1d79

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-docker/src/test/it/org/xwiki/index/test/ui/docker/DynamicTestConfigurationExtension.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
*/
2020
package org.xwiki.index.test.ui.docker;
2121

22+
import java.util.Objects;
2223
import java.util.Properties;
2324

25+
import org.jetbrains.annotations.NotNull;
2426
import org.junit.jupiter.api.extension.BeforeAllCallback;
2527
import org.junit.jupiter.api.extension.ExtensionContext;
2628
import 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

Comments
 (0)