Java Code Examples for io.r2dbc.spi.ConnectionFactoryOptions#getRequiredValue()

The following examples show how to use io.r2dbc.spi.ConnectionFactoryOptions#getRequiredValue() . 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: Hidden.java    From testcontainers-java with MIT License 6 votes vote down vote up
private ConnectionFactoryOptions removeProxying(ConnectionFactoryOptions options) {
    // To delegate to the next factory provider, inspect the PROTOCOL and convert it to the next DRIVER and PROTOCOL values.
    //
    // example:
    //   | Property | Input           | Output       |
    //   |----------|-----------------|--------------|
    //   | DRIVER   | tc              | postgres     |
    //   | PROTOCOL | postgres        | <empty>      |

    String protocol = options.getRequiredValue(ConnectionFactoryOptions.PROTOCOL);
    if (protocol.trim().length() == 0) {
        throw new IllegalArgumentException("Invalid protocol: " + protocol);
    }
    String[] protocols = protocol.split(":", 2);
    String driverDelegate = protocols[0];

    // when protocol does NOT contain COLON, the length becomes 1
    String protocolDelegate = protocols.length == 2 ? protocols[1] : "";

    return ConnectionFactoryOptions.builder()
        .from(options)
        .option(ConnectionFactoryOptions.DRIVER, driverDelegate)
        .option(ConnectionFactoryOptions.PROTOCOL, protocolDelegate)
        .build();
}
 
Example 2
Source File: MSSQLR2DBCDatabaseContainerProvider.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Override
public R2DBCDatabaseContainer createContainer(ConnectionFactoryOptions options) {
    String image = MSSQLServerContainer.IMAGE + ":" + options.getRequiredValue(IMAGE_TAG_OPTION);
    MSSQLServerContainer<?> container = new MSSQLServerContainer<>(image);

    if (Boolean.TRUE.equals(options.getValue(REUSABLE_OPTION))) {
        container.withReuse(true);
    }
    return new MSSQLR2DBCDatabaseContainer(container);
}
 
Example 3
Source File: PostgreSQLR2DBCDatabaseContainerProvider.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Override
public R2DBCDatabaseContainer createContainer(ConnectionFactoryOptions options) {
    String image = PostgreSQLContainer.IMAGE + ":" + options.getRequiredValue(IMAGE_TAG_OPTION);
    PostgreSQLContainer<?> container = new PostgreSQLContainer<>(image)
        .withDatabaseName(options.getRequiredValue(ConnectionFactoryOptions.DATABASE));

    if (Boolean.TRUE.equals(options.getValue(REUSABLE_OPTION))) {
        container.withReuse(true);
    }
    return new PostgreSQLR2DBCDatabaseContainer(container);
}
 
Example 4
Source File: MySQLR2DBCDatabaseContainerProvider.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Override
public R2DBCDatabaseContainer createContainer(ConnectionFactoryOptions options) {
    String image = MySQLContainer.IMAGE + ":" + options.getRequiredValue(IMAGE_TAG_OPTION);
    MySQLContainer<?> container = new MySQLContainer<>(image)
        .withDatabaseName(options.getRequiredValue(ConnectionFactoryOptions.DATABASE));

    if (Boolean.TRUE.equals(options.getValue(REUSABLE_OPTION))) {
        container.withReuse(true);
    }
    return new MySQLR2DBCDatabaseContainer(container);
}
 
Example 5
Source File: MariaDBR2DBCDatabaseContainerProvider.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Override
public R2DBCDatabaseContainer createContainer(ConnectionFactoryOptions options) {
    String image = MariaDBContainer.IMAGE + ":" + options.getRequiredValue(IMAGE_TAG_OPTION);
    MariaDBContainer<?> container = new MariaDBContainer<>(image)
        .withDatabaseName(options.getRequiredValue(ConnectionFactoryOptions.DATABASE));

    if (Boolean.TRUE.equals(options.getValue(REUSABLE_OPTION))) {
        container.withReuse(true);
    }
    return new MariaDBR2DBCDatabaseContainer(container);
}