|
26 | 26 | public class MongoClientTest { |
27 | 27 | @Test |
28 | 28 | public void testConstructors() throws UnknownHostException { |
| 29 | + MongoClientOptions customClientOptions = new MongoClientOptions.Builder().connectionsPerHost(500).build(); |
| 30 | + MongoOptions customOptions = new MongoOptions(customClientOptions); |
| 31 | + MongoOptions defaultOptions = new MongoOptions(new MongoClientOptions.Builder().build()); |
29 | 32 | MongoClient mc; |
30 | 33 |
|
31 | 34 | mc = new MongoClient(); |
32 | | - Assert.assertEquals(WriteConcern.ACKNOWLEDGED, mc.getWriteConcern()); |
| 35 | + Assert.assertEquals(new ServerAddress(), mc.getAddress()); |
| 36 | + Assert.assertEquals(defaultOptions, mc.getMongoOptions()); |
33 | 37 | mc.close(); |
34 | 38 |
|
35 | | - mc = new MongoClient("localhost"); |
36 | | - Assert.assertEquals(WriteConcern.ACKNOWLEDGED, mc.getWriteConcern()); |
| 39 | + mc = new MongoClient("127.0.0.1"); |
| 40 | + Assert.assertEquals(new ServerAddress("127.0.0.1"), mc.getAddress()); |
| 41 | + Assert.assertEquals(defaultOptions, mc.getMongoOptions()); |
37 | 42 | mc.close(); |
38 | 43 |
|
39 | | - mc = new MongoClient("localhost", new MongoClientOptions.Builder().build()); |
40 | | - Assert.assertEquals(WriteConcern.ACKNOWLEDGED, mc.getWriteConcern()); |
| 44 | + mc = new MongoClient("127.0.0.1", customClientOptions); |
| 45 | + Assert.assertEquals(new ServerAddress("127.0.0.1"), mc.getAddress()); |
| 46 | + Assert.assertEquals(customOptions, mc.getMongoOptions()); |
41 | 47 | mc.close(); |
42 | 48 |
|
43 | | - mc = new MongoClient("localhost", 27017); |
44 | | - Assert.assertEquals(WriteConcern.ACKNOWLEDGED, mc.getWriteConcern()); |
| 49 | + mc = new MongoClient("127.0.0.1", 27018); |
| 50 | + Assert.assertEquals(new ServerAddress("127.0.0.1", 27018), mc.getAddress()); |
| 51 | + Assert.assertEquals(defaultOptions, mc.getMongoOptions()); |
45 | 52 | mc.close(); |
46 | 53 |
|
47 | | - mc = new MongoClient(new ServerAddress("localhost")); |
48 | | - Assert.assertEquals(WriteConcern.ACKNOWLEDGED, mc.getWriteConcern()); |
| 54 | + mc = new MongoClient(new ServerAddress("127.0.0.1")); |
| 55 | + Assert.assertEquals(new ServerAddress("127.0.0.1"), mc.getAddress()); |
| 56 | + Assert.assertEquals(defaultOptions, mc.getMongoOptions()); |
49 | 57 | mc.close(); |
50 | 58 |
|
51 | | - mc = new MongoClient(new ServerAddress("localhost"), new MongoClientOptions.Builder().build()); |
52 | | - Assert.assertEquals(WriteConcern.ACKNOWLEDGED, mc.getWriteConcern()); |
| 59 | + mc = new MongoClient(new ServerAddress("127.0.0.1"), customClientOptions); |
| 60 | + Assert.assertEquals(new ServerAddress("127.0.0.1"), mc.getAddress()); |
| 61 | + Assert.assertEquals(customOptions, mc.getMongoOptions()); |
53 | 62 | mc.close(); |
54 | 63 |
|
55 | | - mc = new MongoClient(Arrays.asList(new ServerAddress("localhost"))); |
56 | | - Assert.assertEquals(WriteConcern.ACKNOWLEDGED, mc.getWriteConcern()); |
| 64 | + mc = new MongoClient(Arrays.asList(new ServerAddress("localhost", 27017), new ServerAddress("127.0.0.1", 27018))); |
| 65 | + Assert.assertEquals(Arrays.asList(new ServerAddress("localhost", 27017), new ServerAddress("127.0.0.1", 27018)), mc.getAllAddress()); |
| 66 | + Assert.assertEquals(defaultOptions, mc.getMongoOptions()); |
57 | 67 | mc.close(); |
58 | 68 |
|
59 | | - mc = new MongoClient(Arrays.asList(new ServerAddress("localhost")), new MongoClientOptions.Builder().build()); |
60 | | - Assert.assertEquals(WriteConcern.ACKNOWLEDGED, mc.getWriteConcern()); |
| 69 | + mc = new MongoClient(Arrays.asList(new ServerAddress("localhost", 27017), new ServerAddress("127.0.0.1", 27018)), customClientOptions); |
| 70 | + Assert.assertEquals(Arrays.asList(new ServerAddress("localhost", 27017), new ServerAddress("127.0.0.1", 27018)), mc.getAllAddress()); |
| 71 | + Assert.assertEquals(customOptions, mc.getMongoOptions()); |
61 | 72 | mc.close(); |
62 | 73 |
|
63 | | - mc = new MongoClient(new MongoClientURI("mongodb://localhost")); |
64 | | - Assert.assertEquals(WriteConcern.ACKNOWLEDGED, mc.getWriteConcern()); |
| 74 | + mc = new MongoClient(new MongoClientURI("mongodb://127.0.0.1")); |
| 75 | + Assert.assertEquals(new ServerAddress("127.0.0.1"), mc.getAddress()); |
| 76 | + Assert.assertEquals(defaultOptions, mc.getMongoOptions()); |
65 | 77 | mc.close(); |
66 | 78 | } |
67 | 79 | } |
0 commit comments