Skip to content

Commit 7142e84

Browse files
committed
Switch to JUnit 5.
Issue #2075.
1 parent 1acab9d commit 7142e84

File tree

123 files changed

+1586
-1532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1586
-1532
lines changed

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/AbstractIntegrationTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@
1515
*/
1616
package org.springframework.data.rest.core;
1717

18-
import org.junit.Before;
19-
import org.junit.runner.RunWith;
18+
import org.junit.jupiter.api.BeforeEach;
19+
import org.junit.jupiter.api.extension.ExtendWith;
2020
import org.springframework.beans.factory.annotation.Autowired;
2121
import org.springframework.data.rest.core.domain.Person;
2222
import org.springframework.data.rest.core.domain.PersonRepository;
2323
import org.springframework.test.context.ContextConfiguration;
24-
import org.springframework.test.context.junit4.SpringRunner;
24+
import org.springframework.test.context.junit.jupiter.SpringExtension;
2525

2626
/**
2727
* Base class for integration tests loading {@link RepositoryTestsConfig} and populating the {@link PersonRepository}
2828
* with a {@link Person}.
2929
*
3030
* @author Oliver Gierke
3131
*/
32-
@RunWith(SpringRunner.class)
32+
@ExtendWith(SpringExtension.class)
3333
@ContextConfiguration(classes = RepositoryTestsConfig.class)
3434
public abstract class AbstractIntegrationTests {
3535

3636
@Autowired PersonRepository repository;
3737

38-
@Before
39-
public void populateDatabase() {
38+
@BeforeEach
39+
void populateDatabase() {
4040
repository.save(new Person("John", "Doe"));
4141
}
4242
}

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/PathUnitTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,63 +17,63 @@
1717

1818
import static org.assertj.core.api.Assertions.*;
1919

20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
2121

2222
/**
2323
* Unit tests for {@link Path}.
2424
*
2525
* @author Oliver Gierke
2626
*/
27-
public class PathUnitTests {
27+
class PathUnitTests {
2828

2929
@Test
30-
public void combinesSimplePaths() {
30+
void combinesSimplePaths() {
3131

3232
Path builder = new Path("foo").slash("bar");
3333
assertThat(builder.toString()).isEqualTo("/foo/bar");
3434
}
3535

3636
@Test
37-
public void removesLeadingAndTrailingSlashes() {
37+
void removesLeadingAndTrailingSlashes() {
3838

3939
Path builder = new Path("foo/").slash("/bar").slash("//foobar///");
4040
assertThat(builder.toString()).isEqualTo("/foo/bar/foobar");
4141
}
4242

4343
@Test
44-
public void removesWhitespace() {
44+
void removesWhitespace() {
4545

4646
Path builder = new Path("foo/ ").slash("/ b a r").slash(" //foobar/// ");
4747
assertThat(builder.toString()).isEqualTo("/foo/bar/foobar");
4848
}
4949

5050
@Test
51-
public void matchesWithLeadingSlash() {
51+
void matchesWithLeadingSlash() {
5252
assertThat(new Path("/foobar").matches("/foobar")).isTrue();
5353
}
5454

5555
@Test
56-
public void matchesWithoutLeadingSlash() {
56+
void matchesWithoutLeadingSlash() {
5757
assertThat(new Path("/foobar").matches("foobar")).isTrue();
5858
}
5959

6060
@Test
61-
public void doesNotMatchIfDifferent() {
61+
void doesNotMatchIfDifferent() {
6262
assertThat(new Path("/foobar").matches("barfoo")).isFalse();
6363
}
6464

6565
@Test
66-
public void doesNotPrefixAbsoluteUris() {
66+
void doesNotPrefixAbsoluteUris() {
6767
assertThat(new Path("http://localhost").toString()).isEqualTo("http://localhost");
6868
}
6969

7070
@Test // DATAREST-222
71-
public void doesNotMatchIfReferenceContainsReservedCharacters() {
71+
void doesNotMatchIfReferenceContainsReservedCharacters() {
7272
assertThat(new Path("/foobar").matches("barfoo{?foo}")).isFalse();
7373
}
7474

7575
@Test // DATAREST-222
76-
public void doesNotMatchNullReference() {
76+
void doesNotMatchNullReference() {
7777
assertThat(new Path("/foobar").matches(null)).isFalse();
7878
}
7979
}

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/RepositoryRestConfigurationIntegrationTests.java

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

1818
import static org.assertj.core.api.Assertions.*;
1919

20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
2121
import org.springframework.beans.factory.annotation.Autowired;
2222
import org.springframework.data.repository.support.Repositories;
2323
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
@@ -36,13 +36,13 @@
3636
* @author Oliver Gierke
3737
*/
3838
@SuppressWarnings("deprecation")
39-
public class RepositoryRestConfigurationIntegrationTests extends AbstractIntegrationTests {
39+
class RepositoryRestConfigurationIntegrationTests extends AbstractIntegrationTests {
4040

4141
@Autowired RepositoryRestConfiguration config;
4242
@Autowired Repositories repositories;
4343

4444
@Test
45-
public void shouldProvideResourceMappingForConfiguredRepository() throws Exception {
45+
void shouldProvideResourceMappingForConfiguredRepository() throws Exception {
4646

4747
ResourceMapping mapping = config.getResourceMappingForRepository(ConfiguredPersonRepository.class);
4848

@@ -54,7 +54,7 @@ public void shouldProvideResourceMappingForConfiguredRepository() throws Excepti
5454

5555
@Test // DATAREST-1304
5656
@DirtiesContext
57-
public void exposesLookupPropertyFromLambda() {
57+
void exposesLookupPropertyFromLambda() {
5858

5959
config.withEntityLookup() //
6060
.forRepository(ProfileRepository.class) //

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/RepositoryRestConfigurationUnitTests.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import static org.assertj.core.api.Assertions.*;
1919
import static org.mockito.Mockito.*;
2020

21-
import org.junit.Before;
22-
import org.junit.Test;
21+
import org.junit.jupiter.api.BeforeEach;
22+
import org.junit.jupiter.api.Test;
2323
import org.springframework.data.rest.core.config.EnumTranslationConfiguration;
2424
import org.springframework.data.rest.core.config.MetadataConfiguration;
2525
import org.springframework.data.rest.core.config.ProjectionDefinitionConfiguration;
@@ -37,40 +37,40 @@
3737
* @author Mark Paluch
3838
* @soundtrack Adam F - Circles (Colors)
3939
*/
40-
public class RepositoryRestConfigurationUnitTests {
40+
class RepositoryRestConfigurationUnitTests {
4141

4242
RepositoryRestConfiguration configuration;
4343

44-
@Before
45-
public void setUp() {
44+
@BeforeEach
45+
void setUp() {
4646

4747
this.configuration = new RepositoryRestConfiguration(new ProjectionDefinitionConfiguration(),
4848
new MetadataConfiguration(), mock(EnumTranslationConfiguration.class));
4949
}
5050

5151
@Test // DATAREST-34
52-
public void returnsBodiesIfAcceptHeaderPresentByDefault() {
52+
void returnsBodiesIfAcceptHeaderPresentByDefault() {
5353

5454
assertThat(configuration.returnBodyOnCreate(MediaType.APPLICATION_JSON_VALUE)).isTrue();
5555
assertThat(configuration.returnBodyOnUpdate(MediaType.APPLICATION_JSON_VALUE)).isTrue();
5656
}
5757

5858
@Test // DATAREST-34
59-
public void doesNotReturnBodiesIfNoAcceptHeaderPresentByDefault() {
59+
void doesNotReturnBodiesIfNoAcceptHeaderPresentByDefault() {
6060

6161
assertThat(configuration.returnBodyOnCreate(null)).isFalse();
6262
assertThat(configuration.returnBodyOnUpdate(null)).isFalse();
6363
}
6464

6565
@Test // DATAREST-34
66-
public void doesNotReturnBodiesIfEmptyAcceptHeaderPresentByDefault() {
66+
void doesNotReturnBodiesIfEmptyAcceptHeaderPresentByDefault() {
6767

6868
assertThat(configuration.returnBodyOnCreate("")).isFalse();
6969
assertThat(configuration.returnBodyOnUpdate("")).isFalse();
7070
}
7171

7272
@Test // DATAREST-34
73-
public void doesNotReturnBodyForUpdateIfExplicitlyDeactivated() {
73+
void doesNotReturnBodyForUpdateIfExplicitlyDeactivated() {
7474

7575
configuration.setReturnBodyOnUpdate(false);
7676

@@ -80,7 +80,7 @@ public void doesNotReturnBodyForUpdateIfExplicitlyDeactivated() {
8080
}
8181

8282
@Test // DATAREST-34
83-
public void doesNotReturnBodyForCreateIfExplicitlyDeactivated() {
83+
void doesNotReturnBodyForCreateIfExplicitlyDeactivated() {
8484

8585
configuration.setReturnBodyOnCreate(false);
8686

@@ -90,7 +90,7 @@ public void doesNotReturnBodyForCreateIfExplicitlyDeactivated() {
9090
}
9191

9292
@Test // DATAREST-34
93-
public void returnsBodyForUpdateIfExplicitlyActivated() {
93+
void returnsBodyForUpdateIfExplicitlyActivated() {
9494

9595
configuration.setReturnBodyOnUpdate(true);
9696

@@ -100,7 +100,7 @@ public void returnsBodyForUpdateIfExplicitlyActivated() {
100100
}
101101

102102
@Test // DATAREST-34
103-
public void returnsBodyForCreateIfExplicitlyActivated() {
103+
void returnsBodyForCreateIfExplicitlyActivated() {
104104

105105
configuration.setReturnBodyOnCreate(true);
106106

@@ -110,7 +110,7 @@ public void returnsBodyForCreateIfExplicitlyActivated() {
110110
}
111111

112112
@Test // DATAREST-776
113-
public void considersDomainTypeOfValueRepositoryLookupTypes() {
113+
void considersDomainTypeOfValueRepositoryLookupTypes() {
114114

115115
configuration.withEntityLookup().forLookupRepository(ProfileRepository.class);
116116

spring-data-rest-core/src/test/java/org/springframework/data/rest/core/StringToLdapNameConverterUnitTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@
2121
import javax.naming.Name;
2222
import javax.naming.ldap.LdapName;
2323

24-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2525
import org.springframework.core.convert.support.DefaultConversionService;
2626

2727
/**
2828
* Unit tests for {@link StringToLdapNameConverter}.
2929
*
3030
* @author Mark Paluch
3131
*/
32-
public class StringToLdapNameConverterUnitTests {
32+
class StringToLdapNameConverterUnitTests {
3333

3434
@Test // DATAREST-1198
35-
public void shouldCreateLdapName() throws InvalidNameException {
35+
void shouldCreateLdapName() throws InvalidNameException {
3636

3737
LdapName converted = StringToLdapNameConverter.INSTANCE.convert("dc=foo");
3838

3939
assertThat(converted).isEqualTo(new LdapName("dc=foo"));
4040
}
4141

4242
@Test // DATAREST-1198
43-
public void failedConversionShouldThrowIAE() {
43+
void failedConversionShouldThrowIAE() {
4444

4545
assertThatThrownBy(() -> StringToLdapNameConverter.INSTANCE.convert("foo"))
4646
.isInstanceOf(IllegalArgumentException.class);
4747
}
4848

4949
@Test // DATAREST-1198
50-
public void shouldConvertStringInNameViaConversionService() {
50+
void shouldConvertStringInNameViaConversionService() {
5151

5252
DefaultConversionService conversionService = new DefaultConversionService();
5353
conversionService.addConverter(StringToLdapNameConverter.INSTANCE);

0 commit comments

Comments
 (0)