This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
name: "Trisha", | |
twitter: "@trisha_gee", | |
address: [ | |
{ line1: "not telling", | |
line2: "no really", | |
town: "London" } | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID: 63537 | |
Name: Trisha | |
Twitter: @trisha_gee | |
Location: London |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void shouldEncodeListOfStrings() { | |
final List<String> stringList = asList("Uno", "Dos", "Tres"); | |
context.checking(new Expectations() {{ | |
oneOf(bsonWriter).writeStartArray(); | |
oneOf(bsonWriter).writeString("Uno"); | |
oneOf(bsonWriter).writeString("Dos"); | |
oneOf(bsonWriter).writeString("Tres"); | |
oneOf(bsonWriter).writeEndArray(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IterableCodecTest { | |
//CHECKSTYLE:OFF | |
@Rule | |
public final JUnitRuleMockery context = new JUnitRuleMockery(); | |
//CHECKSTYLE:ON | |
// Mocks | |
private BSONWriter bsonWriter; | |
// Under test | |
private final IterableCodec iterableCodec = new IterableCodec(Codecs.createDefault()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IterableCodecSpecification extends Specification { | |
private BSONWriter bsonWriter = Mock(); | |
@Subject | |
private final IterableCodec iterableCodec = new IterableCodec(Codecs.createDefault()); | |
public void 'should encode list of strings'() { | |
setup: | |
List<String> stringList = ['Uno', 'Dos', 'Tres']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DBCollectionSpecification extends Specification { | |
private final Mongo mongo = Mock() | |
private final ServerSelectingSession session = Mock() | |
private final DB database = new DB(mongo, 'myDatabase', new DocumentCodec()) | |
@Subject | |
private final DBCollection collection = new DBCollection('collectionName', database, new DocumentCodec()) | |
def setup() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static class TestAsyncConnectionFactory implements AsyncConnectionFactory { | |
@Override | |
public AsyncConnection create(final ServerAddress serverAddress) { | |
return new AsyncConnection() { | |
@Override | |
public void sendMessage(final List<ByteBuf> byteBuffers, final SingleResultCallback<Void> callback) { | |
throw new UnsupportedOperationException(); | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MongoClientURITest { | |
@Test() | |
public void testWriteConcern() { | |
MongoClientURI uri = new MongoClientURI("mongodb://localhost"); | |
assertEquals(WriteConcern.ACKNOWLEDGED, uri.getOptions().getWriteConcern()); | |
uri = new MongoClientURI("mongodb://localhost/?wTimeout=5"); | |
assertEquals(new WriteConcern(1, 5, false, false), uri.getOptions().getWriteConcern()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project> | |
... | |
<dependencies> | |
<dependency> | |
<groupId>org.mongodb</groupId> | |
<artifactId>mongo-java-driver</artifactId> | |
<version>3.0.0-SNAPSHOT</version> | |
</dependency> | |
... |
OlderNewer