Migrate tests to JUnit 5

Resolves: #1033
This commit is contained in:
Vedran Pavic
2019-06-06 20:57:45 +02:00
parent 35f09d0da7
commit a4ff3682f6
108 changed files with 577 additions and 528 deletions

View File

@@ -25,8 +25,8 @@ import java.util.function.Supplier;
import javax.sql.DataSource;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@@ -63,7 +63,7 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests {
private SecurityContext changedContext;
@Before
@BeforeEach
public void setUp() {
this.context = SecurityContextHolder.createEmptyContext();
this.context.setAuthentication(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -24,7 +24,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
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 Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class DerbyJdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -24,7 +24,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
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 Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class H2JdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -24,7 +24,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
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 Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class HsqldbJdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,14 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.MariaDBContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
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 Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class MariaDb10JdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,14 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.MariaDBContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
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 Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class MariaDb5JdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,14 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.MySQLContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
/**
@@ -31,7 +31,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
*
* @author Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class MySql5JdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,14 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.MySQLContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
/**
@@ -31,7 +31,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
*
* @author Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class MySql8JdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
package org.springframework.session.jdbc;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.OracleContainer;
import org.testcontainers.utility.TestcontainersConfiguration;
@@ -26,7 +26,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.util.ClassUtils;
@@ -38,19 +38,20 @@ import org.springframework.util.ClassUtils;
*
* @author Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class OracleJdbcOperationsSessionRepositoryITests
extends AbstractContainerJdbcOperationsSessionRepositoryITests {
@BeforeClass
@BeforeAll
public static void setUpClass() {
Assume.assumeTrue("Oracle JDBC driver is present on the classpath",
ClassUtils.isPresent("oracle.jdbc.OracleDriver", null));
Assume.assumeTrue("Testcontainers property `oracle.container.image` is set",
Assumptions.assumeTrue(ClassUtils.isPresent("oracle.jdbc.OracleDriver", null),
"Oracle JDBC driver is present on the classpath");
Assumptions.assumeTrue(
TestcontainersConfiguration.getInstance().getProperties()
.getProperty("oracle.container.image") != null);
.getProperty("oracle.container.image") != null,
"Testcontainers property `oracle.container.image` is set");
}
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,14 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.PostgreSQLContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
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 Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class PostgreSql10JdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,14 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.PostgreSQLContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
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 Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class PostgreSql11JdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,14 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.PostgreSQLContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
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 Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class PostgreSql9JdbcOperationsSessionRepositoryITests

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,14 @@
package org.springframework.session.jdbc;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.MSSQLServerContainer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
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 Vedran Pavic
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class SqlServerJdbcOperationsSessionRepositoryITests

View File

@@ -23,8 +23,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
@@ -74,7 +74,7 @@ public class JdbcOperationsSessionRepositoryTests {
private JdbcOperationsSessionRepository repository;
@Before
@BeforeEach
public void setUp() {
this.repository = new JdbcOperationsSessionRepository(this.jdbcOperations,
this.transactionManager);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@ package org.springframework.session.jdbc.config.annotation.web.http;
import javax.sql.DataSource;
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.BeanCreationException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -57,7 +57,7 @@ public class JdbcHttpSessionConfigurationTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@After
@AfterEach
public void closeContext() {
if (this.context != null) {
this.context.close();