Package org.mongolink.test.factory

Examples of org.mongolink.test.factory.FakeDbFactory


    @Test
    public void canCreateDbFactory() {
        Settings settings = Settings.defaultInstance().withPort(1234).withHost("localhost").withDbFactory(FakeDbFactory.class).withReadPreference(ReadPreference.nearest());

        FakeDbFactory dbFactory = (FakeDbFactory) settings.createDbFactory();

        assertThat(dbFactory.addresses.size(), is(1));
        ServerAddress serverAddress = dbFactory.addresses.get(0);
        assertThat(serverAddress.getHost(), is("localhost"));
        assertThat(serverAddress.getPort(), is(1234));
        assertThat(settings.authenticationRequired(), is(false));
        assertThat(dbFactory.getReadPreference(), is(ReadPreference.nearest()));
    }
View Full Code Here


    @Test
    public void canCreateDbFactoryWithMultipleAddresses() throws UnknownHostException {
        Settings settings = Settings.defaultInstance().withAddresses(Lists.newArrayList(new ServerAddress("localhost:1234"), new ServerAddress("localhost:1235"))).withDbFactory(FakeDbFactory.class);

        FakeDbFactory dbFactory = (FakeDbFactory) settings.createDbFactory();

        assertThat(dbFactory.addresses.size(), is(2));
    }
View Full Code Here

    @Test
    public void canDefineReadPreference() {
        Settings settings = Settings.defaultInstance().withReadPreference(ReadPreference.secondary()).withDbFactory(FakeDbFactory.class);

        FakeDbFactory dbFactory = (FakeDbFactory) settings.createDbFactory();

        assertThat(dbFactory.getReadPreference(), is(ReadPreference.secondary()));
    }
View Full Code Here

TOP

Related Classes of org.mongolink.test.factory.FakeDbFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.