Skip to content

Commit 7c1f8b7

Browse files
DATAMONGO-1158 - Soften exception validation.
We need to soften the exception validation a bit since the message is slightly different when using different storage engines in a MongoDB 3.0 environment.
1 parent d3065ba commit 7c1f8b7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public void throwsExceptionForDuplicateIds() {
237237
template.insert(person);
238238
fail("Expected DataIntegrityViolationException!");
239239
} catch (DataIntegrityViolationException e) {
240-
assertThat(e.getMessage(), containsString("E11000 duplicate key error index: database.person.$_id_"));
240+
assertThat(e.getMessage(), containsString("E11000 duplicate key error"));
241241
}
242242
}
243243

@@ -289,7 +289,7 @@ public void throwsExceptionForIndexViolationIfConfigured() {
289289
template.save(person);
290290
fail("Expected DataIntegrityViolationException!");
291291
} catch (DataIntegrityViolationException e) {
292-
assertThat(e.getMessage(), containsString("E11000 duplicate key error index: database.person.$firstName_-1"));
292+
assertThat(e.getMessage(), containsString("E11000 duplicate key error"));
293293
}
294294
}
295295

@@ -300,7 +300,7 @@ public void throwsExceptionForIndexViolationIfConfigured() {
300300
public void rejectsDuplicateIdInInsertAll() {
301301

302302
thrown.expect(DataIntegrityViolationException.class);
303-
thrown.expectMessage("E11000 duplicate key error index: database.person.$_id_");
303+
thrown.expectMessage("E11000 duplicate key error");
304304

305305
MongoTemplate template = new MongoTemplate(factory);
306306
template.setWriteResultChecking(WriteResultChecking.EXCEPTION);

0 commit comments

Comments
 (0)