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
apply plugin: 'java' | |
repositories { | |
maven { | |
url "https://oss.sonatype.org/content/repositories/snapshots/" | |
} | |
} | |
dependencies { | |
compile 'org.mongodb:mongo-java-driver:3.0.0-SNAPSHOT' |
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> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.mongodb.test</groupId> | |
<artifactId>3.0-test</artifactId> | |
<version>1</version> | |
<dependencies> | |
<dependency> | |
<groupId>org.mongodb</groupId> | |
<artifactId>mongodb-driver</artifactId> |
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
apply plugin: 'java' | |
repositories { | |
maven { | |
url "https://oss.sonatype.org/content/repositories/snapshots/" | |
} | |
} | |
dependencies { | |
compile 'org.mongodb:mongodb-driver:3.0.0-SNAPSHOT' |
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
10 PRINT "HELLO" | |
20 GOTO 10 |
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
Document query = new Document(theKey, type); | |
MongoView<MyThing> results = myCollection.find(query); | |
return results.into(new ArrayList<MyThing>()); |
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 testSingleServer() { | |
MongoClientURI u = new MongoClientURI("mongodb://db.example.com"); | |
assertEquals(1, u.getHosts().size()); | |
assertEquals("db.example.com", u.getHosts().get(0)); | |
assertNull(u.getDatabase()); | |
assertNull(u.getCollection()); | |
assertNull( u.getUsername()); | |
assertEquals(null, u.getPassword()); | |
} |
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
@Unroll | |
def 'should parse #uri into correct components'() { | |
expect: | |
uri.getHosts().size() == num; | |
uri.getHosts() == hosts; | |
uri.getDatabase() == database; | |
uri.getCollection() == collection; | |
uri.getUsername() == username; | |
uri.getPassword() == password; |
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 testGetLastErrorCommand() { | |
assertEquals(new BasicDBObject("getlasterror", 1), WriteConcern.UNACKNOWLEDGED.getCommand()); | |
assertEquals(new BasicDBObject("getlasterror", 1), WriteConcern.ACKNOWLEDGED.getCommand()); | |
assertEquals(new BasicDBObject("getlasterror", 1).append("w", 2), WriteConcern.REPLICA_ACKNOWLEDGED.getCommand()); | |
assertEquals(new BasicDBObject("getlasterror", 1).append("j", true), WriteConcern.JOURNALED.getCommand()); | |
assertEquals(new BasicDBObject("getlasterror", 1).append("fsync", true), WriteConcern.FSYNCED.getCommand()); | |
assertEquals(new BasicDBObject("getlasterror", 1).append("w", "majority"), new WriteConcern("majority").getCommand()); | |
assertEquals(new BasicDBObject("getlasterror", 1).append("wtimeout", 100), new WriteConcern(1, 100).getCommand()); | |
} |
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
@Unroll | |
def '#wc should return getlasterror document #commandDocument'() { | |
expect: | |
wc.asDocument() == commandDocument; | |
where: | |
wc | commandDocument | |
WriteConcern.UNACKNOWLEDGED | ['getlasterror': 0] | |
WriteConcern.ACKNOWLEDGED | ['getlasterror': 1] | |
WriteConcern.REPLICA_ACKNOWLEDGED | ['getlasterror': 1, 'w': 2] |
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 shouldGenerateIndexNameForSimpleKey() { | |
final Index index = new Index("x"); | |
assertEquals("x_1", index.getName()); | |
} | |
@Test | |
public void shouldGenerateIndexNameForKeyOrderedAscending() { | |
final Index index = new Index("x", OrderBy.ASC); | |
assertEquals("x_1", index.getName()); |