Skip to content

Instantly share code, notes, and snippets.

@josephtaylor
Created December 12, 2018 02:17
Show Gist options
  • Save josephtaylor/a5ee426ef4754de1a58343b29e11adbf to your computer and use it in GitHub Desktop.
Save josephtaylor/a5ee426ef4754de1a58343b29e11adbf to your computer and use it in GitHub Desktop.
embedded-mysql-5
package com.singlemusic.example;
import com.wix.mysql.EmbeddedMysql;
import com.wix.mysql.config.MysqldConfig;
import com.wix.mysql.config.SchemaConfig;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import java.time.ZoneId;
import java.util.TimeZone;
import static com.wix.mysql.distribution.Version.v5_7_19;
@RunWith(Suite.class)
@Suite.SuiteClasses({
DatabaseTest.class
})
public class TestSuite {
private static EmbeddedMysql embeddedMysql;
@BeforeClass
public static void _setupBeforeClass() {
MysqldConfig config = MysqldConfig.aMysqldConfig(v5_7_19)
.withPort(3307)
.withTimeZone(TimeZone.getTimeZone(ZoneId.of("UTC")))
.withUser("test", "test")
.build();
SchemaConfig schemaConfig = SchemaConfig.aSchemaConfig("test_database")
.build();
embeddedMysql = EmbeddedMysql.anEmbeddedMysql(config)
.addSchema(schemaConfig)
.start();
}
@AfterClass
public static void _tearDownAfterClass() {
if (null != embeddedMysql) {
embeddedMysql.stop();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment