Skip to content

Commit 53e866f

Browse files
committed
Migrate tests to JUnit 5.
See #289
1 parent ba44659 commit 53e866f

File tree

4 files changed

+40
-38
lines changed

4 files changed

+40
-38
lines changed

src/test/java/org/springframework/data/envers/repository/support/DefaultRevisionMetadataUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.time.temporal.ChronoUnit;
2424

2525
import org.hibernate.envers.DefaultRevisionEntity;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

2828
/**
2929
* Unit tests for {@link DefaultRevisionMetadata}.
@@ -32,12 +32,12 @@
3232
* @author Jens Schauder
3333
* @author Mark Paluch
3434
*/
35-
public class DefaultRevisionMetadataUnitTests {
35+
class DefaultRevisionMetadataUnitTests {
3636

3737
private static final Instant NOW = Instant.now();;
3838

3939
@Test // #112
40-
public void createsLocalDateTimeFromTimestamp() {
40+
void createsLocalDateTimeFromTimestamp() {
4141

4242
DefaultRevisionEntity entity = new DefaultRevisionEntity();
4343
entity.setTimestamp(NOW.toEpochMilli());

src/test/java/org/springframework/data/envers/repository/support/EnversRevisionRepositoryImplUnitTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import org.hibernate.envers.DefaultRevisionEntity;
2222
import org.hibernate.envers.RevisionType;
23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2424
import org.springframework.data.history.AnnotationRevisionMetadata;
2525
import org.springframework.data.history.RevisionMetadata;
2626

@@ -29,10 +29,10 @@
2929
*
3030
* @author Jens Schauder
3131
*/
32-
public class EnversRevisionRepositoryImplUnitTests {
32+
class EnversRevisionRepositoryImplUnitTests {
3333

3434
@Test // gh-215
35-
public void revisionTypeOfAnnotationRevisionMetadataIsProperlySet() {
35+
void revisionTypeOfAnnotationRevisionMetadataIsProperlySet() {
3636

3737
Object[] data = new Object[] { "a", "some metadata", RevisionType.DEL };
3838

@@ -45,7 +45,7 @@ public void revisionTypeOfAnnotationRevisionMetadataIsProperlySet() {
4545
}
4646

4747
@Test // gh-215
48-
public void revisionTypeOfDefaultRevisionMetadataIsProperlySet() {
48+
void revisionTypeOfDefaultRevisionMetadataIsProperlySet() {
4949

5050
Object[] data = new Object[] { "a", mock(DefaultRevisionEntity.class), RevisionType.DEL };
5151

src/test/java/org/springframework/data/envers/repository/support/QueryDslRepositoryIntegrationTests.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
import java.util.Iterator;
2121

22-
import org.junit.Before;
23-
import org.junit.Test;
24-
import org.junit.runner.RunWith;
22+
import org.junit.jupiter.api.BeforeEach;
23+
import org.junit.jupiter.api.Test;
24+
import org.junit.jupiter.api.extension.ExtendWith;
25+
2526
import org.springframework.beans.factory.annotation.Autowired;
2627
import org.springframework.data.envers.Config;
2728
import org.springframework.data.envers.sample.Country;
@@ -30,7 +31,7 @@
3031
import org.springframework.data.history.Revision;
3132
import org.springframework.data.history.Revisions;
3233
import org.springframework.test.context.ContextConfiguration;
33-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
34+
import org.springframework.test.context.junit.jupiter.SpringExtension;
3435

3536
/**
3637
* Integration tests for repositories with Querydsl support. They make sure that methods provided by both
@@ -39,20 +40,20 @@
3940
* @author Dmytro Iaroslavskyi
4041
* @author Jens Schauder
4142
*/
42-
@RunWith(SpringJUnit4ClassRunner.class)
43+
@ExtendWith(SpringExtension.class)
4344
@ContextConfiguration(classes = Config.class)
44-
public class QueryDslRepositoryIntegrationTests {
45+
class QueryDslRepositoryIntegrationTests {
4546

4647
@Autowired
4748
CountryQueryDslRepository countryRepository;
4849

49-
@Before
50-
public void setUp() {
50+
@BeforeEach
51+
void setUp() {
5152
countryRepository.deleteAll();
5253
}
5354

5455
@Test
55-
public void testWithQueryDsl() {
56+
void testWithQueryDsl() {
5657

5758
Country de = new Country();
5859
de.code = "de";
@@ -67,7 +68,7 @@ public void testWithQueryDsl() {
6768
}
6869

6970
@Test
70-
public void testWithRevisions() {
71+
void testWithRevisions() {
7172

7273
Country de = new Country();
7374
de.code = "de";

src/test/java/org/springframework/data/envers/repository/support/RepositoryIntegrationTests.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
import java.util.Iterator;
2424
import java.util.Optional;
2525

26-
import org.junit.After;
27-
import org.junit.Before;
28-
import org.junit.Test;
29-
import org.junit.runner.RunWith;
26+
import org.junit.jupiter.api.AfterEach;
27+
import org.junit.jupiter.api.BeforeEach;
28+
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.api.extension.ExtendWith;
30+
3031
import org.springframework.beans.factory.annotation.Autowired;
3132
import org.springframework.data.domain.Page;
3233
import org.springframework.data.domain.PageRequest;
@@ -39,39 +40,39 @@
3940
import org.springframework.data.history.RevisionSort;
4041
import org.springframework.data.history.Revisions;
4142
import org.springframework.test.context.ContextConfiguration;
42-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
43+
import org.springframework.test.context.junit.jupiter.SpringExtension;
4344

4445
/**
4546
* Integration tests for repositories.
4647
*
4748
* @author Oliver Gierke
4849
* @author Jens Schauder
4950
*/
50-
@RunWith(SpringJUnit4ClassRunner.class)
51+
@ExtendWith(SpringExtension.class)
5152
@ContextConfiguration(classes = Config.class)
52-
public class RepositoryIntegrationTests {
53+
class RepositoryIntegrationTests {
5354

5455
@Autowired
5556
LicenseRepository licenseRepository;
5657
@Autowired
5758
CountryRepository countryRepository;
5859

59-
@Before
60-
public void setUp() {
60+
@BeforeEach
61+
void setUp() {
6162

6263
licenseRepository.deleteAll();
6364
countryRepository.deleteAll();
6465
}
6566

66-
@After
67-
public void tearDown() {
67+
@AfterEach
68+
void tearDown() {
6869

6970
licenseRepository.deleteAll();
7071
countryRepository.deleteAll();
7172
}
7273

7374
@Test
74-
public void testLifeCycle() {
75+
void testLifeCycle() {
7576

7677
License license = new License();
7778
license.name = "Schnitzel";
@@ -110,22 +111,22 @@ public void testLifeCycle() {
110111
}
111112

112113
@Test // #1
113-
public void returnsEmptyLastRevisionForUnrevisionedEntity() {
114+
void returnsEmptyLastRevisionForUnrevisionedEntity() {
114115
assertThat(countryRepository.findLastChangeRevision(100L)).isEmpty();
115116
}
116117

117118
@Test // #47
118-
public void returnsEmptyRevisionsForUnrevisionedEntity() {
119+
void returnsEmptyRevisionsForUnrevisionedEntity() {
119120
assertThat(countryRepository.findRevisions(100L)).isEmpty();
120121
}
121122

122123
@Test // #47
123-
public void returnsEmptyRevisionForUnrevisionedEntity() {
124+
void returnsEmptyRevisionForUnrevisionedEntity() {
124125
assertThat(countryRepository.findRevision(100L, 23)).isEmpty();
125126
}
126127

127128
@Test // #31
128-
public void returnsParticularRevisionForAnEntity() {
129+
void returnsParticularRevisionForAnEntity() {
129130

130131
Country de = new Country();
131132
de.code = "de";
@@ -153,7 +154,7 @@ public void returnsParticularRevisionForAnEntity() {
153154
}
154155

155156
@Test // #55
156-
public void considersRevisionNumberSortOrder() {
157+
void considersRevisionNumberSortOrder() {
157158

158159
Country de = new Country();
159160
de.code = "de";
@@ -174,7 +175,7 @@ public void considersRevisionNumberSortOrder() {
174175
}
175176

176177
@Test // #21
177-
public void findsDeletedRevisions() {
178+
void findsDeletedRevisions() {
178179

179180
Country de = new Country();
180181
de.code = "de";
@@ -194,7 +195,7 @@ public void findsDeletedRevisions() {
194195
}
195196

196197
@Test // #47
197-
public void includesCorrectRevisionType() {
198+
void includesCorrectRevisionType() {
198199

199200
Country de = new Country();
200201
de.code = "de";
@@ -220,7 +221,7 @@ public void includesCorrectRevisionType() {
220221
}
221222

222223
@Test // #146
223-
public void shortCircuitingWhenOffsetIsToLarge() {
224+
void shortCircuitingWhenOffsetIsToLarge() {
224225

225226
Country de = new Country();
226227
de.code = "de";
@@ -236,7 +237,7 @@ public void shortCircuitingWhenOffsetIsToLarge() {
236237
}
237238

238239
@Test // #47
239-
public void paginationWithEmptyResult() {
240+
void paginationWithEmptyResult() {
240241

241242
check(23L, 0, 0, 0);
242243
}

0 commit comments

Comments
 (0)