Upgrade to JUnit 5.
This commit is contained in:
34
pom.xml
34
pom.xml
@@ -74,7 +74,7 @@
|
||||
<hamcrest.version>1.3</hamcrest.version>
|
||||
<jackson-bom.version>2.9.9.20190727</jackson-bom.version>
|
||||
<jsr305.version>3.0.2</jsr305.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<junit-bom.version>5.5.1</junit-bom.version>
|
||||
<lombok.version>1.18.6</lombok.version>
|
||||
<mockito.version>2.25.1</mockito.version>
|
||||
<mongo.version>3.11.0-rc0</mongo.version>
|
||||
@@ -462,6 +462,14 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit-bom</artifactId>
|
||||
<version>${junit-bom.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@@ -560,9 +568,20 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -579,6 +598,13 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.session.data.mongo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextImpl;
|
||||
|
||||
|
||||
@@ -21,9 +21,10 @@ import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.bson.Document;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -84,10 +85,12 @@ public class JacksonMongoSessionConverterTest extends AbstractMongoSessionConver
|
||||
assertThat(converterMapper).isEqualTo(myMapper);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotAllowNullObjectMapperToBeInjected() {
|
||||
|
||||
new JacksonMongoSessionConverter((ObjectMapper) null);
|
||||
Assertions.assertThatIllegalArgumentException().isThrownBy(() -> {
|
||||
new JacksonMongoSessionConverter((ObjectMapper) null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
*/
|
||||
package org.springframework.session.data.mongo;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.serializer.support.DeserializingConverter;
|
||||
import org.springframework.core.serializer.support.SerializingConverter;
|
||||
|
||||
@@ -36,13 +38,17 @@ public class JdkMongoSessionConverterTest extends AbstractMongoSessionConverterT
|
||||
return this.mongoSessionConverter;
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void constructorNullSerializer() {
|
||||
new JdkMongoSessionConverter(null, new DeserializingConverter(), inactiveInterval);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> {
|
||||
new JdkMongoSessionConverter(null, new DeserializingConverter(), inactiveInterval);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void constructorNullDeserializer() {
|
||||
new JdkMongoSessionConverter(new SerializingConverter(), null, inactiveInterval);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> {
|
||||
new JdkMongoSessionConverter(new SerializingConverter(), null, inactiveInterval);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.data.mongodb.core.MongoOperations;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
@@ -49,7 +49,7 @@ import com.mongodb.DBObject;
|
||||
* @author Vedran Pavic
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class MongoOperationsSessionRepositoryTest {
|
||||
|
||||
@Mock private AbstractMongoSessionConverter converter;
|
||||
@@ -58,7 +58,7 @@ public class MongoOperationsSessionRepositoryTest {
|
||||
|
||||
private MongoOperationsSessionRepository repository;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
|
||||
this.repository = new MongoOperationsSessionRepository(this.mongoOperations);
|
||||
|
||||
@@ -21,7 +21,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
|
||||
@@ -27,11 +27,11 @@ import static org.mockito.Mockito.verify;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
@@ -52,7 +52,7 @@ import com.mongodb.client.result.DeleteResult;
|
||||
* @author Vedran Pavic
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class ReactiveMongoOperationsSessionRepositoryTest {
|
||||
|
||||
@Mock private AbstractMongoSessionConverter converter;
|
||||
@@ -63,7 +63,7 @@ public class ReactiveMongoOperationsSessionRepositoryTest {
|
||||
|
||||
private ReactiveMongoOperationsSessionRepository repository;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
|
||||
this.repository = new ReactiveMongoOperationsSessionRepository(this.mongoOperations);
|
||||
|
||||
@@ -21,10 +21,8 @@ import static org.mockito.BDDMockito.*;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -50,11 +48,9 @@ public class MongoHttpSessionConfigurationTest {
|
||||
|
||||
private static final int MAX_INACTIVE_INTERVAL_IN_SECONDS = 600;
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void after() {
|
||||
|
||||
if (this.context != null) {
|
||||
@@ -65,10 +61,9 @@ public class MongoHttpSessionConfigurationTest {
|
||||
@Test
|
||||
public void noMongoOperationsConfiguration() {
|
||||
|
||||
this.thrown.expect(UnsatisfiedDependencyException.class);
|
||||
this.thrown.expectMessage("mongoSessionRepository");
|
||||
|
||||
registerAndRefresh(EmptyConfiguration.class);
|
||||
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() -> {
|
||||
registerAndRefresh(EmptyConfiguration.class);
|
||||
}).withMessageContaining("mongoSessionRepository");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,8 +25,8 @@ import static org.mockito.Mockito.mock;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -53,7 +53,7 @@ public class ReactiveMongoWebSessionConfigurationTest {
|
||||
|
||||
private AnnotationConfigApplicationContext context;
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
|
||||
if (this.context != null) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.serializer.DefaultDeserializer;
|
||||
|
||||
@@ -17,14 +17,14 @@ package org.springframework.session.data.mongo.integration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
*
|
||||
* @author Jakub Kubrynski
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@WebAppConfiguration
|
||||
public abstract class AbstractITest {
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class AbstractITest {
|
||||
|
||||
@Autowired(required = false) protected SessionEventRegistry registry;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
|
||||
if (this.registry != null) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import de.flapdoodle.embed.mongo.MongodExecutable;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.geo.GeoModule;
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
|
||||
|
||||
Reference in New Issue
Block a user