org.testcontainers.containers.MariaDBContainer Java Examples

The following examples show how to use org.testcontainers.containers.MariaDBContainer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleMariaDBTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void testWithAdditionalUrlParamInJdbcUrl() {
    MariaDBContainer mariaDBContainer = (MariaDBContainer) new MariaDBContainer()
        .withUrlParam("connectTimeout", "40000")
        .withUrlParam("rewriteBatchedStatements", "true");

    try {
        mariaDBContainer.start();
        String jdbcUrl = mariaDBContainer.getJdbcUrl();
        assertThat(jdbcUrl, containsString("?"));
        assertThat(jdbcUrl, containsString("&"));
        assertThat(jdbcUrl, containsString("rewriteBatchedStatements=true"));
        assertThat(jdbcUrl, containsString("connectTimeout=40000"));
    } finally {
        mariaDBContainer.stop();
    }
}
 
Example #2
Source File: SqlMetaDataITCase.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("resource")
@Parameters
public static Collection<Object> databaseContainerImages() {
    return Arrays.asList(
            //new DerbyContainer(),  //
            new PostgreSQLContainer<>(),
            new MariaDBContainer<>()
            );
}
 
Example #3
Source File: MariaDBDataSourceFactory.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
@Override
protected DataSource createDataSource() {
    try {
        final MariaDBContainer container = mariaDBContainer();
        final MariaDbDataSource dataSource = new MariaDbDataSource();
        dataSource.setUrl(container.getJdbcUrl());
        dataSource.setUser(container.getUsername());
        dataSource.setPassword(container.getPassword());
        dataSource.setDatabaseName(container.getDatabaseName());
        return dataSource;
    } catch (SQLException e) {
        throw new RuntimeException("Unable to create MariaDB DataSource", e);
    }
}
 
Example #4
Source File: SimpleMariaDBTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testSimple() throws SQLException {
    try (MariaDBContainer<?> mariadb = new MariaDBContainer<>()) {

        mariadb.start();

        ResultSet resultSet = performQuery(mariadb, "SELECT 1");
        int resultSetInt = resultSet.getInt(1);

        assertEquals("A basic SELECT query succeeds", 1, resultSetInt);
    }
}
 
Example #5
Source File: SimpleMariaDBTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testSpecificVersion() throws SQLException {
    try (MariaDBContainer<?> mariadbOldVersion = new MariaDBContainer<>("mariadb:5.5.51")) {

        mariadbOldVersion.start();

        ResultSet resultSet = performQuery(mariadbOldVersion, "SELECT VERSION()");
        String resultSetString = resultSet.getString(1);

        assertTrue("The database version can be set using a container rule parameter", resultSetString.startsWith("5.5.51"));
    }
}
 
Example #6
Source File: SimpleMariaDBTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testMariaDBWithCustomIniFile() throws SQLException {
    assumeFalse(SystemUtils.IS_OS_WINDOWS);

    try (MariaDBContainer<?> mariadbCustomConfig = new MariaDBContainer<>("mariadb:10.1.16")
        .withConfigurationOverride("somepath/mariadb_conf_override")) {
        mariadbCustomConfig.start();

        ResultSet resultSet = performQuery(mariadbCustomConfig, "SELECT @@GLOBAL.innodb_file_format");
        String result = resultSet.getString(1);

        assertEquals("The InnoDB file format has been set by the ini file content", "Barracuda", result);
    }
}
 
Example #7
Source File: SimpleMariaDBTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testMariaDBWithCommandOverride() throws SQLException {

    try (MariaDBContainer<?> mariadbCustomConfig = new MariaDBContainer<>("mariadb:10.1.16")
        .withCommand("mysqld --auto_increment_increment=10")) {
        mariadbCustomConfig.start();
        ResultSet resultSet = performQuery(mariadbCustomConfig, "show variables like 'auto_increment_increment'");
        String result = resultSet.getString("Value");

        assertEquals("Auto increment increment should be overriden by command line", "10", result);
    }
}
 
Example #8
Source File: MariaDB10_2DataSourceFactory.java    From nifi-registry with Apache License 2.0 4 votes vote down vote up
@Override
protected MariaDBContainer mariaDBContainer() {
    return MARIA_DB_CONTAINER;
}
 
Example #9
Source File: MariaDB10DataSourceFactory.java    From nifi-registry with Apache License 2.0 4 votes vote down vote up
@Override
protected MariaDBContainer mariaDBContainer() {
    return MARIA_DB_CONTAINER;
}
 
Example #10
Source File: MariaDB10_3DataSourceFactory.java    From nifi-registry with Apache License 2.0 4 votes vote down vote up
@Override
protected MariaDBContainer mariaDBContainer() {
    return MARIA_DB_CONTAINER;
}
 
Example #11
Source File: DatabaseContainers.java    From spring-session with Apache License 2.0 4 votes vote down vote up
static MariaDBContainer mariaDb5() {
	return new MariaDb5Container();
}
 
Example #12
Source File: DatabaseContainers.java    From spring-session with Apache License 2.0 4 votes vote down vote up
static MariaDBContainer mariaDb10() {
	return new MariaDb10Container();
}
 
Example #13
Source File: MariaDBDataSourceFactory.java    From nifi-registry with Apache License 2.0 votes vote down vote up
protected abstract MariaDBContainer mariaDBContainer();