Skip to content

Commit

Permalink
Fixed tests for 2.8 server
Browse files Browse the repository at this point in the history
  • Loading branch information
trishagee committed Dec 11, 2014
1 parent 737ae93 commit 57781f4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 5 additions & 1 deletion morphia/src/test/java/org/mongodb/morphia/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ public void setUp() {

protected void cleanup() {
for (final MappedClass mc : getMorphia().getMapper().getMappedClasses()) {
getDb().getCollection(mc.getCollectionName()).drop();
String collectionName = mc.getCollectionName();
if (collectionName != null && collectionName.length() > 0) {
getDb().getCollection(collectionName).drop();
}
}
getDb().dropDatabase();
}

@After
Expand Down
16 changes: 15 additions & 1 deletion morphia/src/test/java/org/mongodb/morphia/TestQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@ public void maxScan() {
}

@Test
public void testExplainPlanIsReturnedAndContainsCorrectValueForN() {
public void testExplainPlanIsReturnedAndContainsCorrectValueForNForServersPriorTo27() {
checkMaxServerVersion(2.7);
// Given
getDs().save(new Pic("pic1"), new Pic("pic2"), new Pic("pic3"), new Pic("pic4"));

Expand All @@ -1094,6 +1095,19 @@ public void testExplainPlanIsReturnedAndContainsCorrectValueForN() {
Assert.assertEquals(4, explainResult.get("n"));
}

@Test
public void testExplainPlanIsReturnedAndContainsCorrectValueForN() {
checkMinServerVersion(2.7);
// Given
getDs().save(new Pic("pic1"), new Pic("pic2"), new Pic("pic3"), new Pic("pic4"));

// When
Map<String, Object> explainResult = getDs().createQuery(Pic.class).explain();

// Then
Assert.assertEquals(4, ((Map) explainResult.get("executionStats")).get("nReturned"));
}

@Test
public void testSettingACommentInsertsCommentIntoProfileCollectionWhenProfilingIsTurnedOn() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public void add(final WebTemplateType type, final List<WebTemplate> templates) {

@Test
public void testEnumMapping() throws Exception {
getDs().getDB().dropDatabase();

getMorphia().map(ContainsEnum.class);

getDs().save(new ContainsEnum());
Expand Down

0 comments on commit 57781f4

Please sign in to comment.