Java Code Examples for io.r2dbc.spi.ConnectionFactory#getMetadata()

The following examples show how to use io.r2dbc.spi.ConnectionFactory#getMetadata() . 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: R2DBCDatabaseContainerProvider.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Nullable
default ConnectionFactoryMetadata getMetadata(ConnectionFactoryOptions options) {
    ConnectionFactoryOptions.Builder builder = options.mutate();
    if (!options.hasOption(ConnectionFactoryOptions.HOST)) {
        builder.option(ConnectionFactoryOptions.HOST, "localhost");
    }
    if (!options.hasOption(ConnectionFactoryOptions.PORT)) {
        builder.option(ConnectionFactoryOptions.PORT, 65535);
    }

    ConnectionFactory connectionFactory = ConnectionFactories.find(builder.build());
    return connectionFactory != null ? connectionFactory.getMetadata() : null;
}
 
Example 2
Source File: AbstractR2DBCDatabaseContainerTest.java    From testcontainers-java with MIT License 4 votes vote down vote up
@Test
public final void testGetMetadata() {
    ConnectionFactory connectionFactory = ConnectionFactories.get(createR2DBCUrl());
    ConnectionFactoryMetadata metadata = connectionFactory.getMetadata();
    assertThat(metadata).isNotNull();
}