Skip to content

Commit 95e38c1

Browse files
committed
JAVA-682: Added more assertions to testWriteConcern
1 parent e012113 commit 95e38c1

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/test/com/mongodb/MongoClientURITest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,25 @@ public void testUserPassAndMultipleHostsWithPort() {
8282

8383
@Test()
8484
public void testWriteConcern() {
85-
MongoClientURI uri = new MongoClientURI("mongodb://localhost/?safe=true");
85+
MongoClientURI uri = new MongoClientURI("mongodb://localhost");
86+
assertEquals(WriteConcern.ACKNOWLEDGED, uri.getOptions().getWriteConcern());
87+
88+
uri = new MongoClientURI("mongodb://localhost/?wTimeout=5");
89+
assertEquals(new WriteConcern(1, 5, false, false), uri.getOptions().getWriteConcern());
90+
91+
uri = new MongoClientURI("mongodb://localhost/?fsync=true");
92+
assertEquals(new WriteConcern(1, 0, true, false), uri.getOptions().getWriteConcern());
93+
94+
uri = new MongoClientURI("mongodb://localhost/?j=true");
95+
assertEquals(new WriteConcern(1, 0, false, true), uri.getOptions().getWriteConcern());
96+
97+
uri = new MongoClientURI("mongodb://localhost/?w=2&wtimeout=5&fsync=true&j=true");
98+
assertEquals(new WriteConcern(2, 5, true, true), uri.getOptions().getWriteConcern());
99+
100+
uri = new MongoClientURI("mongodb://localhost/?w=majority&wtimeout=5&fsync=true&j=true");
101+
assertEquals(new WriteConcern("majority", 5, true, true), uri.getOptions().getWriteConcern());
102+
103+
uri = new MongoClientURI("mongodb://localhost/?safe=true");
86104
assertEquals(WriteConcern.ACKNOWLEDGED, uri.getOptions().getWriteConcern());
87105

88106
uri = new MongoClientURI("mongodb://localhost/?safe=false");

0 commit comments

Comments
 (0)