package com.mydreamjob.messaging; import org.springframework.test.context.*; import org.testcontainers.containers.MySQLContainer; import org.testcontainers.junit.jupiter.*; @Testcontainers @org.springframework.test.annotation.DirtiesContext(classMode=org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_CLASS) class ChatAttachmentMySqlIntegrationTest extends ChatAttachmentIntegrationTest { @Container static final MySQLContainer MYSQL=new MySQLContainer<>(System.getProperty("attachment.mysql.image","mysql:8.4")) .withDatabaseName("chat_files").withUsername("chatfiles").withPassword("synthetic-only") .withCommand("--character-set-server=utf8mb4","--collation-server=utf8mb4_unicode_ci","--max-allowed-packet=32M") .withUrlParam("characterEncoding","UTF-8").withCreateContainerCmdModifier(c->c.getHostConfig().withMemory(768L*1024*1024)); @DynamicPropertySource static void properties(DynamicPropertyRegistry r) { r.add("spring.datasource.url",MYSQL::getJdbcUrl);r.add("spring.datasource.username",MYSQL::getUsername);r.add("spring.datasource.password",MYSQL::getPassword); r.add("spring.datasource.driver-class-name",()->"com.mysql.cj.jdbc.Driver"); r.add("spring.jpa.properties.hibernate.dialect",()->"org.hibernate.dialect.MySQLDialect"); } }