Skip to content

Commit d6135b0

Browse files
DATAMONGO-2130 - Add rule for MongoDB version and replica set.
1 parent 87d20ec commit d6135b0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepositoryTests.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import java.util.UUID;
2929

3030
import org.junit.Before;
31+
import org.junit.Rule;
3132
import org.junit.Test;
33+
import org.junit.rules.TestRule;
3234
import org.junit.runner.RunWith;
3335
import org.springframework.beans.factory.annotation.Autowired;
3436
import org.springframework.data.domain.Example;
@@ -45,6 +47,10 @@
4547
import org.springframework.data.mongodb.repository.Person.Sex;
4648
import org.springframework.data.mongodb.repository.User;
4749
import org.springframework.data.mongodb.repository.query.MongoEntityInformation;
50+
import org.springframework.data.mongodb.test.util.MongoVersion;
51+
import org.springframework.data.mongodb.test.util.MongoVersionRule;
52+
import org.springframework.data.mongodb.test.util.ReplicaSet;
53+
import org.springframework.test.annotation.IfProfileValue;
4854
import org.springframework.test.context.ContextConfiguration;
4955
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
5056
import org.springframework.test.util.ReflectionTestUtils;
@@ -61,6 +67,8 @@
6167
public class SimpleMongoRepositoryTests {
6268

6369
@Autowired private MongoTemplate template;
70+
public @Rule MongoVersionRule mongoVersion = MongoVersionRule.any();
71+
public @Rule TestRule replSet = ReplicaSet.none();
6472

6573
private Person oliver, dave, carter, boyd, stefan, leroi, alicia;
6674
private List<Person> all;
@@ -386,6 +394,8 @@ public void saveAllUsesEntityCollection() {
386394
}
387395

388396
@Test // DATAMONGO-2130
397+
@MongoVersion(asOf = "4.0")
398+
@IfProfileValue(name = "replSet", value = "true")
389399
public void countShouldBePossibleInTransaction() {
390400

391401
MongoTransactionManager txmgr = new MongoTransactionManager(template.getMongoDbFactory());
@@ -404,7 +414,7 @@ public void countShouldBePossibleInTransaction() {
404414
return repository.count();
405415
});
406416

407-
assertThat(count).isEqualTo(countPreTx+1);
417+
assertThat(count).isEqualTo(countPreTx + 1);
408418
}
409419

410420
private void assertThatAllReferencePersonsWereStoredCorrectly(Map<String, Person> references, List<Person> saved) {

0 commit comments

Comments
 (0)