28
28
import java .util .UUID ;
29
29
30
30
import org .junit .Before ;
31
+ import org .junit .Rule ;
31
32
import org .junit .Test ;
33
+ import org .junit .rules .TestRule ;
32
34
import org .junit .runner .RunWith ;
33
35
import org .springframework .beans .factory .annotation .Autowired ;
34
36
import org .springframework .data .domain .Example ;
45
47
import org .springframework .data .mongodb .repository .Person .Sex ;
46
48
import org .springframework .data .mongodb .repository .User ;
47
49
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 ;
48
54
import org .springframework .test .context .ContextConfiguration ;
49
55
import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
50
56
import org .springframework .test .util .ReflectionTestUtils ;
61
67
public class SimpleMongoRepositoryTests {
62
68
63
69
@ Autowired private MongoTemplate template ;
70
+ public @ Rule MongoVersionRule mongoVersion = MongoVersionRule .any ();
71
+ public @ Rule TestRule replSet = ReplicaSet .none ();
64
72
65
73
private Person oliver , dave , carter , boyd , stefan , leroi , alicia ;
66
74
private List <Person > all ;
@@ -386,6 +394,8 @@ public void saveAllUsesEntityCollection() {
386
394
}
387
395
388
396
@ Test // DATAMONGO-2130
397
+ @ MongoVersion (asOf = "4.0" )
398
+ @ IfProfileValue (name = "replSet" , value = "true" )
389
399
public void countShouldBePossibleInTransaction () {
390
400
391
401
MongoTransactionManager txmgr = new MongoTransactionManager (template .getMongoDbFactory ());
@@ -404,7 +414,7 @@ public void countShouldBePossibleInTransaction() {
404
414
return repository .count ();
405
415
});
406
416
407
- assertThat (count ).isEqualTo (countPreTx + 1 );
417
+ assertThat (count ).isEqualTo (countPreTx + 1 );
408
418
}
409
419
410
420
private void assertThatAllReferencePersonsWereStoredCorrectly (Map <String , Person > references , List <Person > saved ) {
0 commit comments