Search in sources :

Example 1 with MongoClientImpl

use of com.mongodb.client.internal.MongoClientImpl in project spring-boot by spring-projects.

the class MongoAutoConfigurationTests method getSettings.

private MongoClientSettings getSettings(AssertableApplicationContext context) {
    assertThat(context).hasSingleBean(MongoClient.class);
    MongoClientImpl client = (MongoClientImpl) context.getBean(MongoClient.class);
    return client.getSettings();
}
Also used : MongoClient(com.mongodb.client.MongoClient) MongoClientImpl(com.mongodb.client.internal.MongoClientImpl)

Example 2 with MongoClientImpl

use of com.mongodb.client.internal.MongoClientImpl in project brave by openzipkin.

the class ITMongoDBTracing method getClusterId.

@Before
public void getClusterId() throws Exception {
    // TODO: Figure out an easier way to get this!
    Field clusterIdField = Class.forName("com.mongodb.internal.connection.BaseCluster").getDeclaredField("clusterId");
    clusterIdField.setAccessible(true);
    ClusterId clusterId = (ClusterId) clusterIdField.get(((MongoClientImpl) mongoClient).getCluster());
    this.clusterId = clusterId.getValue();
}
Also used : Field(java.lang.reflect.Field) MongoClientImpl(com.mongodb.client.internal.MongoClientImpl) ClusterId(com.mongodb.connection.ClusterId) Before(org.junit.Before)

Example 3 with MongoClientImpl

use of com.mongodb.client.internal.MongoClientImpl in project drill by apache.

the class TestMongoStoragePluginUsesCredentialsStore method test.

private void test(String expectedUserName, String expectedPassword, String connection, String name) throws ExecutionSetupException {
    MongoStoragePlugin plugin = new MongoStoragePlugin(new MongoStoragePluginConfig(connection, null, 100, false, PlainCredentialsProvider.EMPTY_CREDENTIALS_PROVIDER), null, name);
    MongoClientImpl client = (MongoClientImpl) plugin.getClient();
    MongoCredential cred = client.getSettings().getCredential();
    if (expectedUserName == null) {
        assertNull(cred);
    } else {
        assertNotNull(cred);
        assertEquals(expectedUserName, cred.getUserName());
        assertEquals(expectedPassword, new String(cred.getPassword()));
    }
}
Also used : MongoClientImpl(com.mongodb.client.internal.MongoClientImpl) MongoCredential(com.mongodb.MongoCredential)

Aggregations

MongoClientImpl (com.mongodb.client.internal.MongoClientImpl)3 MongoCredential (com.mongodb.MongoCredential)1 MongoClient (com.mongodb.client.MongoClient)1 ClusterId (com.mongodb.connection.ClusterId)1 Field (java.lang.reflect.Field)1 Before (org.junit.Before)1