Skip to content

Instantly share code, notes, and snippets.

@trishagee
Created July 5, 2013 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trishagee/5935904 to your computer and use it in GitHub Desktop.
Save trishagee/5935904 to your computer and use it in GitHub Desktop.
class MongoClientURISpecification extends Specification {
def 'should correctly parse different write concerns'() {
expect:
uri.getOptions().getWriteConcern() == writeConcern;
where:
uri | writeConcern
new MongoClientURI('mongodb://localhost') | WriteConcern.ACKNOWLEDGED
new MongoClientURI('mongodb://localhost/?safe=true') | WriteConcern.ACKNOWLEDGED
new MongoClientURI('mongodb://localhost/?safe=false') | WriteConcern.UNACKNOWLEDGED
new MongoClientURI('mongodb://localhost/?wTimeout=5') | new WriteConcern(1, 5, false, false)
new MongoClientURI('mongodb://localhost/?fsync=true') | new WriteConcern(1, 0, true, false)
new MongoClientURI('mongodb://localhost/?j=true') | new WriteConcern(1, 0, false, true)
new MongoClientURI('mongodb://localhost/?w=2&wtimeout=5&fsync=true&j=true') | new WriteConcern(2, 5, true, true)
new MongoClientURI('mongodb://localhost/?w=majority&wtimeout=5&fsync=true&j=true') | new WriteConcern('majority', 5, true, true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment