Upgrade tests to Junit5

See gh-14737
This commit is contained in:
Madhura Bhave
2018-12-05 13:56:29 -08:00
parent 4c96c76f11
commit 59d2b0a3fb
804 changed files with 1976 additions and 2238 deletions

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -18,7 +18,7 @@ package org.springframework.boot.test.context;
import javax.servlet.ServletContext;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.test.context.example.ExampleConfig;

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
@ContextConfiguration(classes = ConfigFileApplicationContextInitializerTests.Config.class, initializers = ConfigFileApplicationContextInitializer.class)
public class ConfigFileApplicationContextInitializerTests {

View File

@@ -18,7 +18,7 @@ package org.springframework.boot.test.context;
import java.net.URL;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,9 +25,10 @@ import org.springframework.boot.test.context.ImportsContextCustomizerFactoryInte
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Integration tests for {@link ImportsContextCustomizerFactory} and
@@ -35,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@Import(ImportedBean.class)
public class ImportsContextCustomizerFactoryIntegrationTests {
@@ -50,9 +51,10 @@ public class ImportsContextCustomizerFactoryIntegrationTests {
assertThat(this.bean).isNotNull();
}
@Test(expected = NoSuchBeanDefinitionException.class)
@Test
public void testItselfIsNotABean() {
this.context.getBean(getClass());
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(getClass()));
}
@Component

View File

@@ -19,7 +19,7 @@ package org.springframework.boot.test.context;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

View File

@@ -22,7 +22,7 @@ import java.util.Collections;
import java.util.Set;
import kotlin.Metadata;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.spockframework.runtime.model.SpecMetadata;
import spock.lang.Issue;
import spock.lang.Stepwise;

View File

@@ -18,15 +18,15 @@ package org.springframework.boot.test.context;
import javax.servlet.ServletContext;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
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.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -46,7 +46,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
*
* @author Stephane Nicoll
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
@ContextConfiguration(loader = SpringBootContextLoader.class)
@WebAppConfiguration
@@ -60,7 +60,7 @@ public class SpringBootContextLoaderMockMvcTests {
private MockMvc mvc;
@Before
@BeforeEach
public void setUp() {
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
}

View File

@@ -18,8 +18,8 @@ package org.springframework.boot.test.context;
import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
@@ -81,7 +81,7 @@ public class SpringBootContextLoaderTests {
}
@Test
@Ignore
@Disabled
public void environmentPropertiesNewLineInValue() {
// gh-4384
Map<String, Object> config = getEnvironmentProperties(NewLineInValue.class);

View File

@@ -16,15 +16,13 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@DirtiesContext
@SpringBootTest("spring.config.name=enableother")
@ActiveProfiles("override")

View File

@@ -16,8 +16,7 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTestContextHierarchyTests.ChildConfiguration;
import org.springframework.boot.test.context.SpringBootTestContextHierarchyTests.ParentConfiguration;
@@ -25,7 +24,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Tests for {@link SpringBootTest} and {@link ContextHierarchy}.
@@ -35,7 +33,6 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest
@ContextHierarchy({ @ContextConfiguration(classes = ParentConfiguration.class),
@ContextConfiguration(classes = ChildConfiguration.class) })
@RunWith(SpringRunner.class)
public class SpringBootTestContextHierarchyTests {
@Test

View File

@@ -16,13 +16,11 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -31,7 +29,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@SpringBootTest(properties = "spring.config.name=custom-config-name")
public class SpringBootTestCustomConfigNameTests {

View File

@@ -16,13 +16,11 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -32,7 +30,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
*/
@RunWith(SpringRunner.class)
@SpringBootTest(properties = "server.port=12345")
public class SpringBootTestCustomPortTests {

View File

@@ -16,13 +16,13 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
public class SpringBootTestDefaultConfigurationTests {

View File

@@ -16,13 +16,11 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -31,7 +29,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@DirtiesContext
@SpringBootTest
@ContextConfiguration(locations = "classpath:test.groovy")

View File

@@ -16,12 +16,10 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -30,7 +28,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@DirtiesContext
public class SpringBootTestGroovyConventionConfigurationTests {

View File

@@ -16,15 +16,13 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@DirtiesContext
@SpringBootTest
public class SpringBootTestJmxTests {

View File

@@ -16,15 +16,13 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTestMixedConfigurationTests.Config;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@DirtiesContext
@SpringBootTest
@ContextConfiguration(classes = Config.class, locations = "classpath:test.groovy")

View File

@@ -16,12 +16,9 @@
package org.springframework.boot.test.context;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.config.EnableWebFlux;
@@ -31,7 +28,6 @@ import org.springframework.web.reactive.config.EnableWebFlux;
*
* @author Stephane Nicoll
*/
@RunWith(SpringRunner.class)
@DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, properties = {
"spring.main.web-application-type=reactive", "server.port=0", "value=123" })

View File

@@ -16,12 +16,9 @@
package org.springframework.boot.test.context;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.config.EnableWebFlux;
@@ -31,7 +28,6 @@ import org.springframework.web.reactive.config.EnableWebFlux;
*
* @author Stephane Nicoll
*/
@RunWith(SpringRunner.class)
@DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"spring.main.webApplicationType=reactive", "value=123" })

View File

@@ -16,14 +16,12 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.config.EnableWebFlux;
@@ -36,7 +34,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Madhura Bhave
*/
@RunWith(SpringRunner.class)
@DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"spring.main.web-application-type=reactive", "value=123" })

View File

@@ -16,14 +16,12 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@@ -37,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "value=123" })
public class SpringBootTestUserDefinedTestRestTemplateTests

View File

@@ -16,8 +16,7 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.AbstractSpringBootTestWebServerWebEnvironmentTests.AbstractConfig;
@@ -29,7 +28,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@@ -42,7 +40,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, properties = {
"server.port=0", "value=123" })

View File

@@ -16,12 +16,12 @@
package org.springframework.boot.test.context;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@@ -31,7 +31,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, properties = {
"server.port=0", "value=123" })

View File

@@ -18,8 +18,8 @@ package org.springframework.boot.test.context;
import javax.servlet.ServletContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -28,7 +28,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest("value=123")
@DirtiesContext
public class SpringBootTestWebEnvironmentMockTests {

View File

@@ -18,8 +18,8 @@ package org.springframework.boot.test.context;
import javax.servlet.ServletContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.test.annotation.DirtiesContext;
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.web.servlet.config.annotation.EnableWebMvc;
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest
@DirtiesContext
@WebAppConfiguration("src/mymain/mywebapp")

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.AbstractSpringBootTestWebServerWebEnvironmentTests.AbstractConfig;
@@ -25,7 +25,7 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"server.port=12345" })

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.client.RestTemplateBuilder;
@@ -25,7 +25,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "value=123" })
public class SpringBootTestWebEnvironmentRandomPortTests

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
@SpringBootTest(classes = SpringBootTestWithClassesIntegrationTests.Config.class)
public class SpringBootTestWithClassesIntegrationTests {

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,7 +25,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
@SpringBootTest
@ContextConfiguration(classes = SpringBootTestWithContextConfigurationIntegrationTests.Config.class)

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
@SpringBootTest(webEnvironment = WebEnvironment.NONE, properties = {
"boot-test-inlined=foo", "b=boot-test-inlined", "c=boot-test-inlined" })

View File

@@ -16,12 +16,12 @@
package org.springframework.boot.test.context;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext
@SpringBootTest
public class SpringBootTestXmlConventionConfigurationTests {

View File

@@ -18,8 +18,8 @@ package org.springframework.boot.test.context.assertj;
import java.util.function.Supplier;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -49,7 +49,7 @@ public class ApplicationContextAssertProviderTests {
private Supplier<ApplicationContext> startupFailureSupplier;
@Before
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
this.startupFailure = new RuntimeException();

View File

@@ -16,9 +16,9 @@
package org.springframework.boot.test.context.assertj;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.assertj.ApplicationContextAssert.Scope;
import org.springframework.context.ConfigurableApplicationContext;
@@ -46,14 +46,14 @@ public class ApplicationContextAssertTests {
private RuntimeException failure = new RuntimeException();
@Before
@BeforeEach
public void setup() {
this.parent = new StaticApplicationContext();
this.context = new StaticApplicationContext();
this.context.setParent(this.parent);
}
@After
@AfterEach
public void cleanup() {
this.context.close();
this.parent.close();

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.context.assertj;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.ConfigurableApplicationContext;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.context.assertj;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.boot.web.reactive.context.ConfigurableReactiveWebApplicationContext;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.context.assertj;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.web.context.ConfigurableWebApplicationContext;

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.context.bootstrap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
@@ -25,7 +25,7 @@ import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@BootstrapWith(SpringBootTestContextBootstrapper.class)
public class SpringBootTestContextBootstrapperIntegrationTests {

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.context.bootstrap;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.context.bootstrap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@BootstrapWith(SpringBootTestContextBootstrapper.class)
@ContextConfiguration
public class SpringBootTestContextBootstrapperWithContextConfigurationTests {

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.context.bootstrap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
@@ -27,7 +27,7 @@ import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@BootstrapWith(SpringBootTestContextBootstrapper.class)
@ContextConfiguration(initializers = CustomInitializer.class)
public class SpringBootTestContextBootstrapperWithInitializersTests {

View File

@@ -16,10 +16,10 @@
package org.springframework.boot.test.context.filter;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Abstract test with nest {@code @Configuration} and {@code @RunWith} used by
@@ -27,7 +27,7 @@ import org.springframework.test.context.junit4.SpringRunner;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public abstract class AbstractTestWithConfigAndRunWith {
@Configuration

View File

@@ -18,7 +18,7 @@ package org.springframework.boot.test.context.filter;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.type.classreading.MetadataReader;

View File

@@ -21,7 +21,7 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import com.google.gson.Gson;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.boot.context.annotation.UserConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.context.runner;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
import org.springframework.mock.web.MockServletContext;

View File

@@ -22,14 +22,15 @@ import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.nio.file.Path;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.support.io.TempDirectory;
import org.springframework.core.ResolvableType;
import org.springframework.core.io.ByteArrayResource;
@@ -45,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Phillip Webb
*/
@ExtendWith(TempDirectory.class)
public abstract class AbstractJsonMarshalTesterTests {
private static final String JSON = "{\"name\":\"Spring\",\"age\":123}";
@@ -58,9 +60,6 @@ public abstract class AbstractJsonMarshalTesterTests {
private static final ResolvableType TYPE = ResolvableType
.forClass(ExampleObject.class);
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@Test
public void writeShouldReturnJsonContent() throws Exception {
JsonContent<Object> content = createTester(TYPE).write(OBJECT);
@@ -125,8 +124,9 @@ public abstract class AbstractJsonMarshalTesterTests {
}
@Test
public void readFileShouldReturnObject() throws Exception {
File file = this.temp.newFile("example.json");
public void readFileShouldReturnObject(@TempDirectory.TempDir Path temp)
throws Exception {
File file = new File(temp.toFile(), "example.json");
FileCopyUtils.copy(JSON.getBytes(), file);
AbstractJsonMarshalTester<Object> tester = createTester(TYPE);
assertThat(tester.read(file)).isEqualTo(OBJECT);

View File

@@ -19,10 +19,11 @@ package org.springframework.boot.test.json;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Path;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.support.io.TempDirectory;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
@@ -36,13 +37,11 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Phillip Webb
*/
@ExtendWith(TempDirectory.class)
public class BasicJsonTesterTests {
private static final String JSON = "{\"spring\":[\"boot\",\"framework\"]}";
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
private BasicJsonTester json = new BasicJsonTester(getClass());
@Test
@@ -72,8 +71,9 @@ public class BasicJsonTesterTests {
}
@Test
public void fromFileShouldReturnJsonContent() throws Exception {
File file = this.tempFolder.newFile("file.json");
public void fromFileShouldReturnJsonContent(@TempDirectory.TempDir Path temp)
throws Exception {
File file = new File(temp.toFile(), "file.json");
FileCopyUtils.copy(JSON.getBytes(), file);
assertThat(this.json.from(file)).isEqualToJson("source.json");
}

View File

@@ -20,7 +20,7 @@ import java.util.List;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.ResolvableType;

View File

@@ -24,8 +24,8 @@ import java.util.Map;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ByteArrayResource;
@@ -51,7 +51,7 @@ public class JacksonTesterIntegrationTests {
private static final String JSON = "{\"name\":\"Spring\",\"age\":123}";
@Before
@BeforeEach
public void setup() {
this.objectMapper = new ObjectMapper();
JacksonTester.initFields(this, this.objectMapper);

View File

@@ -19,7 +19,7 @@ package org.springframework.boot.test.json;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.ResolvableType;

View File

@@ -20,11 +20,12 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import org.assertj.core.api.AssertProvider;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.support.io.TempDirectory;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.skyscreamer.jsonassert.comparator.DefaultComparator;
import org.skyscreamer.jsonassert.comparator.JSONComparator;
@@ -45,6 +46,7 @@ import static org.assertj.core.api.Assertions.entry;
*
* @author Phillip Webb
*/
@ExtendWith(TempDirectory.class)
public class JsonContentAssertTests {
private static final String SOURCE = loadJson("source.json");
@@ -60,22 +62,27 @@ public class JsonContentAssertTests {
private static JSONComparator COMPARATOR = new DefaultComparator(
JSONCompareMode.LENIENT);
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
private final File temp;
public JsonContentAssertTests(@TempDirectory.TempDir Path temp) throws IOException {
this.temp = new File(temp.toFile(), "file.json");
}
@Test
public void isEqualToWhenStringIsMatchingShouldPass() {
assertThat(forJson(SOURCE)).isEqualTo(LENIENT_SAME);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToWhenNullActualShouldFail() {
assertThat(forJson(null)).isEqualTo(SOURCE);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(null)).isEqualTo(SOURCE));
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToWhenStringIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT));
}
@Test
@@ -83,9 +90,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualTo("lenient-same.json");
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToWhenResourcePathIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualTo("different.json");
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualTo("different.json"));
}
@Test
@@ -93,9 +101,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualTo(LENIENT_SAME.getBytes());
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToWhenBytesAreNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT.getBytes());
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT.getBytes()));
}
@Test
@@ -103,9 +112,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualTo(createFile(LENIENT_SAME));
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToWhenFileIsNotMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isEqualTo(createFile(DIFFERENT));
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualTo(createFile(DIFFERENT)));
}
@Test
@@ -113,9 +123,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualTo(createInputStream(LENIENT_SAME));
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToWhenInputStreamIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualTo(createInputStream(DIFFERENT));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualTo(createInputStream(DIFFERENT)));
}
@Test
@@ -123,9 +135,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualTo(createResource(LENIENT_SAME));
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToWhenResourceIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualTo(createResource(DIFFERENT));
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualTo(createResource(DIFFERENT)));
}
@Test
@@ -133,14 +146,16 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenNullActualShouldFail() {
assertThat(forJson(null)).isEqualToJson(SOURCE);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(null)).isEqualToJson(SOURCE));
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenStringIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT));
}
@Test
@@ -148,9 +163,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json");
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenResourcePathIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json");
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json"));
}
@Test
@@ -158,9 +174,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json", getClass());
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass());
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson("different.json", getClass()));
}
@Test
@@ -168,9 +186,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME.getBytes());
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenBytesAreNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes());
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes()));
}
@Test
@@ -178,9 +197,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson(createFile(LENIENT_SAME));
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenFileIsNotMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT));
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT)));
}
@Test
@@ -188,9 +208,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(LENIENT_SAME));
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenInputStreamIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson(createInputStream(DIFFERENT)));
}
@Test
@@ -198,9 +220,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson(createResource(LENIENT_SAME));
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenResourceIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson(createResource(DIFFERENT)));
}
@Test
@@ -208,9 +232,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(SOURCE);
}
@Test(expected = AssertionError.class)
@Test
public void isStrictlyEqualToJsonWhenStringIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME);
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME));
}
@Test
@@ -218,9 +243,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson("source.json");
}
@Test(expected = AssertionError.class)
@Test
public void isStrictlyEqualToJsonWhenResourcePathIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json");
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isStrictlyEqualToJson("lenient-same.json"));
}
@Test
@@ -228,10 +255,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson("source.json", getClass());
}
@Test(expected = AssertionError.class)
@Test
public void isStrictlyEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json",
getClass());
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isStrictlyEqualToJson("lenient-same.json", getClass()));
}
@Test
@@ -239,9 +267,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(SOURCE.getBytes());
}
@Test(expected = AssertionError.class)
@Test
public void isStrictlyEqualToJsonWhenBytesAreNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME.getBytes());
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isStrictlyEqualToJson(LENIENT_SAME.getBytes()));
}
@Test
@@ -249,9 +279,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createFile(SOURCE));
}
@Test(expected = AssertionError.class)
@Test
public void isStrictlyEqualToJsonWhenFileIsNotMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createFile(LENIENT_SAME));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isStrictlyEqualToJson(createFile(LENIENT_SAME)));
}
@Test
@@ -259,10 +291,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createInputStream(SOURCE));
}
@Test(expected = AssertionError.class)
@Test
public void isStrictlyEqualToJsonWhenInputStreamIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE))
.isStrictlyEqualToJson(createInputStream(LENIENT_SAME));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isStrictlyEqualToJson(createInputStream(LENIENT_SAME)));
}
@Test
@@ -270,9 +303,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createResource(SOURCE));
}
@Test(expected = AssertionError.class)
@Test
public void isStrictlyEqualToJsonWhenResourceIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createResource(LENIENT_SAME));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isStrictlyEqualToJson(createResource(LENIENT_SAME)));
}
@Test
@@ -280,9 +315,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME, JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenStringIsNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT,
JSONCompareMode.LENIENT));
}
@Test
@@ -291,10 +328,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenResourcePathIsNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json",
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson("different.json", JSONCompareMode.LENIENT));
}
@Test
@@ -303,10 +341,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenResourcePathAndClassIsNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(),
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json",
getClass(), JSONCompareMode.LENIENT));
}
@Test
@@ -315,10 +354,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenBytesAreNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(),
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson(DIFFERENT.getBytes(), JSONCompareMode.LENIENT));
}
@Test
@@ -327,11 +367,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenFileIsNotMatchingAndLenientShouldFail()
throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT),
JSONCompareMode.LENIENT);
@Test
public void isEqualToJsonWhenFileIsNotMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson(createFile(DIFFERENT), JSONCompareMode.LENIENT));
}
@Test
@@ -340,10 +380,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenInputStreamIsNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT),
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(
createInputStream(DIFFERENT), JSONCompareMode.LENIENT));
}
@Test
@@ -352,10 +393,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenResourceIsNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT),
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT),
JSONCompareMode.LENIENT));
}
@Test
@@ -363,9 +405,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME, COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, COMPARATOR);
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, COMPARATOR));
}
@Test
@@ -373,9 +416,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json", COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson("different.json", COMPARATOR));
}
@Test
@@ -384,10 +429,11 @@ public class JsonContentAssertTests {
COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenResourcePathAndClassAreNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(),
COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson("different.json", getClass(), COMPARATOR));
}
@Test
@@ -395,9 +441,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME.getBytes(), COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson(DIFFERENT.getBytes(), COMPARATOR));
}
@Test
@@ -406,10 +454,12 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isEqualToJson(createFile(LENIENT_SAME), COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail()
throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT), COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson(createFile(DIFFERENT), COMPARATOR));
}
@Test
@@ -418,10 +468,11 @@ public class JsonContentAssertTests {
COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenInputStreamIsNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT),
COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson(createInputStream(DIFFERENT), COMPARATOR));
}
@Test
@@ -430,14 +481,17 @@ public class JsonContentAssertTests {
COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToJsonWhenResourceIsNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT), COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isEqualToJson(createResource(DIFFERENT), COMPARATOR));
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToWhenStringIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME));
}
@Test
@@ -450,9 +504,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualTo(DIFFERENT);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToWhenResourcePathIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualTo("lenient-same.json");
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotEqualTo("lenient-same.json"));
}
@Test
@@ -460,9 +515,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualTo("different.json");
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToWhenBytesAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME.getBytes());
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME.getBytes()));
}
@Test
@@ -470,9 +526,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualTo(DIFFERENT.getBytes());
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToWhenFileIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME));
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME)));
}
@Test
@@ -480,9 +537,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualTo(createFile(DIFFERENT));
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToWhenInputStreamIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(LENIENT_SAME));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualTo(createInputStream(LENIENT_SAME)));
}
@Test
@@ -490,9 +549,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(DIFFERENT));
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToWhenResourceIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualTo(createResource(LENIENT_SAME));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualTo(createResource(LENIENT_SAME)));
}
@Test
@@ -500,9 +561,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualTo(createResource(DIFFERENT));
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenStringIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME);
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME));
}
@Test
@@ -515,9 +577,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenResourcePathIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json");
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json"));
}
@Test
@@ -525,9 +588,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json");
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass());
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson("lenient-same.json", getClass()));
}
@Test
@@ -535,9 +600,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass());
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenBytesAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes());
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(LENIENT_SAME.getBytes()));
}
@Test
@@ -545,9 +612,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes());
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenFileIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(createFile(LENIENT_SAME)));
}
@Test
@@ -555,9 +624,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(DIFFERENT));
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenInputStreamIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(createInputStream(LENIENT_SAME)));
}
@Test
@@ -565,9 +636,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(DIFFERENT));
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenResourceIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(createResource(LENIENT_SAME)));
}
@Test
@@ -575,9 +648,10 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(DIFFERENT));
}
@Test(expected = AssertionError.class)
@Test
public void isNotStrictlyEqualToJsonWhenStringIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE);
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE));
}
@Test
@@ -585,9 +659,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(LENIENT_SAME);
}
@Test(expected = AssertionError.class)
@Test
public void isNotStrictlyEqualToJsonWhenResourcePathIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json");
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotStrictlyEqualToJson("source.json"));
}
@Test
@@ -595,9 +671,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("lenient-same.json");
}
@Test(expected = AssertionError.class)
@Test
public void isNotStrictlyEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json", getClass());
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotStrictlyEqualToJson("source.json", getClass()));
}
@Test
@@ -606,9 +684,11 @@ public class JsonContentAssertTests {
getClass());
}
@Test(expected = AssertionError.class)
@Test
public void isNotStrictlyEqualToJsonWhenBytesAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE.getBytes());
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotStrictlyEqualToJson(SOURCE.getBytes()));
}
@Test
@@ -616,9 +696,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(LENIENT_SAME.getBytes());
}
@Test(expected = AssertionError.class)
@Test
public void isNotStrictlyEqualToJsonWhenFileIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotStrictlyEqualToJson(createFile(SOURCE)));
}
@Test
@@ -627,9 +709,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(LENIENT_SAME));
}
@Test(expected = AssertionError.class)
@Test
public void isNotStrictlyEqualToJsonWhenInputStreamIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createInputStream(SOURCE));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotStrictlyEqualToJson(createInputStream(SOURCE)));
}
@Test
@@ -638,9 +722,11 @@ public class JsonContentAssertTests {
.isNotStrictlyEqualToJson(createInputStream(LENIENT_SAME));
}
@Test(expected = AssertionError.class)
@Test
public void isNotStrictlyEqualToJsonWhenResourceIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createResource(SOURCE));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotStrictlyEqualToJson(createResource(SOURCE)));
}
@Test
@@ -649,10 +735,11 @@ public class JsonContentAssertTests {
.isNotStrictlyEqualToJson(createResource(LENIENT_SAME));
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenStringIsMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME,
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(LENIENT_SAME, JSONCompareMode.LENIENT));
}
@Test
@@ -660,10 +747,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT, JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenResourcePathIsMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json",
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson("lenient-same.json", JSONCompareMode.LENIENT));
}
@Test
@@ -672,10 +760,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass(),
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json",
getClass(), JSONCompareMode.LENIENT));
}
@Test
@@ -684,10 +773,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenBytesAreMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(),
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(
LENIENT_SAME.getBytes(), JSONCompareMode.LENIENT));
}
@Test
@@ -696,11 +786,12 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenFileIsMatchingAndLenientShouldFail()
throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME),
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(
createFile(LENIENT_SAME), JSONCompareMode.LENIENT));
}
@Test
@@ -710,10 +801,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenInputStreamIsMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME),
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(
createInputStream(LENIENT_SAME), JSONCompareMode.LENIENT));
}
@Test
@@ -722,10 +814,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenResourceIsMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME),
JSONCompareMode.LENIENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(
createResource(LENIENT_SAME), JSONCompareMode.LENIENT));
}
@Test
@@ -734,9 +827,11 @@ public class JsonContentAssertTests {
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenStringIsMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(LENIENT_SAME, COMPARATOR));
}
@Test
@@ -744,9 +839,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT, COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson("lenient-same.json", COMPARATOR));
}
@Test
@@ -754,10 +851,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass(),
COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson("lenient-same.json", getClass(), COMPARATOR));
}
@Test
@@ -766,9 +864,11 @@ public class JsonContentAssertTests {
COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenBytesAreMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(), COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(LENIENT_SAME.getBytes(), COMPARATOR));
}
@Test
@@ -776,11 +876,12 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes(), COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenFileIsMatchingAndComparatorShouldFail()
throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME),
COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(createFile(LENIENT_SAME), COMPARATOR));
}
@Test
@@ -789,10 +890,11 @@ public class JsonContentAssertTests {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(DIFFERENT), COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenInputStreamIsMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME),
COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(createInputStream(LENIENT_SAME), COMPARATOR));
}
@Test
@@ -801,10 +903,11 @@ public class JsonContentAssertTests {
COMPARATOR);
}
@Test(expected = AssertionError.class)
@Test
public void isNotEqualToJsonWhenResourceIsMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME),
COMPARATOR);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(createResource(LENIENT_SAME), COMPARATOR));
}
@Test
@@ -1210,7 +1313,7 @@ public class JsonContentAssertTests {
}
private File createFile(String content) throws IOException {
File file = this.tempFolder.newFile("file.json");
File file = this.temp;
FileCopyUtils.copy(content.getBytes(), file);
return file;
}

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.json;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.ResolvableType;

View File

@@ -21,7 +21,7 @@ import java.util.List;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.ResolvableType;

View File

@@ -20,9 +20,10 @@ import java.util.Collections;
import java.util.Map;
import org.assertj.core.api.AssertProvider;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Tests for {@link ObjectContentAssert}.
@@ -45,9 +46,10 @@ public class ObjectContentAssertTests {
assertThat(forObject(SOURCE)).isEqualTo(SOURCE);
}
@Test(expected = AssertionError.class)
@Test
public void isEqualToWhenObjectsAreDifferentShouldFail() {
assertThat(forObject(SOURCE)).isEqualTo(DIFFERENT);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forObject(SOURCE)).isEqualTo(DIFFERENT));
}
@Test
@@ -56,9 +58,10 @@ public class ObjectContentAssertTests {
assertThat(forObject(source)).asArray().containsExactly(SOURCE);
}
@Test(expected = AssertionError.class)
@Test
public void asArrayForNonArrayShouldFail() {
assertThat(forObject(SOURCE)).asArray();
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forObject(SOURCE)).asArray());
}
@Test
@@ -67,9 +70,10 @@ public class ObjectContentAssertTests {
assertThat(forObject(source)).asMap().containsEntry("a", SOURCE);
}
@Test(expected = AssertionError.class)
@Test
public void asMapForNonMapShouldFail() {
assertThat(forObject(SOURCE)).asMap();
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forObject(SOURCE)).asMap());
}
private AssertProvider<ObjectContentAssert<Object>> forObject(Object source) {

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.json;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.ResolvableType;

View File

@@ -19,7 +19,7 @@ package org.springframework.boot.test.mock.mockito;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Answers;
import org.springframework.beans.factory.annotation.Qualifier;

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.mock;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanForBeanFactoryIntegrationTests {
// gh-7439

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
@@ -25,7 +25,7 @@ import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.FailingExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -35,7 +35,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanOnConfigurationClassForExistingBeanIntegrationTests {
@Autowired

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -35,7 +35,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanOnConfigurationClassForNewBeanIntegrationTests {
@Autowired

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
@@ -25,7 +25,7 @@ import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.FailingExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -36,7 +36,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanOnConfigurationFieldForExistingBeanIntegrationTests {
@Autowired

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -35,7 +35,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanOnConfigurationFieldForNewBeanIntegrationTests {
@Autowired

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,7 +30,7 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@ContextHierarchy({ @ContextConfiguration(classes = ParentConfig.class),
@ContextConfiguration(classes = ChildConfig.class) })
public class MockBeanOnContextHierarchyIntegrationTests {

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
@@ -28,7 +28,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -39,7 +39,7 @@ import static org.mockito.BDDMockito.given;
* @author Phillip Webb
* @see <a href="https://github.com/spring-projects/spring-boot/issues/5724">gh-5724</a>
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanOnScopedProxyTests {
@MockBean

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
@@ -25,7 +25,7 @@ import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.FailingExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -35,7 +35,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@MockBean(ExampleService.class)
public class MockBeanOnTestClassForExistingBeanIntegrationTests {

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -34,7 +34,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@MockBean(ExampleService.class)
public class MockBeanOnTestClassForNewBeanIntegrationTests {

View File

@@ -16,14 +16,14 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -37,7 +37,7 @@ import static org.mockito.BDDMockito.given;
* @author Phillip Webb
* @see MockBeanOnTestFieldForExistingBeanIntegrationTests
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = MockBeanOnTestFieldForExistingBeanConfig.class)
public class MockBeanOnTestFieldForExistingBeanCacheIntegrationTests {

View File

@@ -16,14 +16,14 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -34,7 +34,7 @@ import static org.mockito.BDDMockito.given;
* @author Phillip Webb
* @see MockBeanOnTestFieldForExistingBeanCacheIntegrationTests
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = MockBeanOnTestFieldForExistingBeanConfig.class)
public class MockBeanOnTestFieldForExistingBeanIntegrationTests {

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.CustomQualifier;
@@ -28,7 +28,7 @@ import org.springframework.boot.test.mock.mockito.example.RealExampleService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -40,7 +40,7 @@ import static org.mockito.Mockito.verify;
* @author Stephane Nicoll
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests {
@MockBean

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -34,7 +34,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanOnTestFieldForNewBeanIntegrationTests {
@MockBean

View File

@@ -18,8 +18,8 @@ package org.springframework.boot.test.mock.mockito;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.Cacheable;
@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.verify;
* @author Phillip Webb
* @see <a href="https://github.com/spring-projects/spring-boot/issues/5837">5837</a>
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanWithAopProxyTests {
@MockBean

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -34,7 +34,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanWithAsyncInterfaceMethodIntegrationTests {
@MockBean

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
@@ -26,7 +26,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -37,7 +37,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD)
public class MockBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests {

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleGenericService;
import org.springframework.boot.test.mock.mockito.example.ExampleGenericServiceCaller;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -34,7 +34,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanWithGenericsOnTestFieldForNewBeanIntegrationTests {
@MockBean

View File

@@ -18,11 +18,11 @@ package org.springframework.boot.test.mock.mockito;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -32,7 +32,7 @@ import static org.mockito.BDDMockito.given;
*
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class MockBeanWithInjectedFieldIntegrationTests {
@MockBean

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Answers;
import org.mockito.Mockito;
import org.mockito.mock.MockCreationSettings;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.example.ExampleService;

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.MockitoAnnotations;
import org.springframework.test.context.ContextCustomizer;
@@ -33,7 +33,7 @@ public class MockitoContextCustomizerFactoryTests {
private final MockitoContextCustomizerFactory factory = new MockitoContextCustomizerFactory();
@Before
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
}

View File

@@ -21,7 +21,7 @@ import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.FactoryBean;

View File

@@ -19,8 +19,8 @@ package org.springframework.boot.test.mock.mockito;
import java.io.InputStream;
import java.lang.reflect.Field;
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.mockito.Captor;
import org.mockito.Mock;
@@ -56,7 +56,7 @@ public class MockitoTestExecutionListenerTests {
@Captor
private ArgumentCaptor<Field> fieldCaptor;
@Before
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
given(this.applicationContext.getBean(MockitoPostProcessor.class))

View File

@@ -20,8 +20,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;
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.mockito.Captor;
import org.mockito.Mock;
@@ -51,7 +51,7 @@ public class QualifierDefinitionTests {
@Captor
private ArgumentCaptor<DependencyDescriptor> descriptorCaptor;
@Before
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
}

View File

@@ -17,8 +17,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.FactoryBean;
@@ -28,7 +28,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@@ -40,7 +40,7 @@ import static org.mockito.Mockito.mock;
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ResetMocksTestExecutionListenerTests {

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.SimpleExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanOnConfigurationClassForExistingBeanIntegrationTests {
@Autowired

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.SimpleExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanOnConfigurationClassForNewBeanIntegrationTests {
@Autowired

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
@@ -25,7 +25,7 @@ import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.SimpleExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -36,7 +36,7 @@ import static org.mockito.Mockito.verify;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests {
@Autowired

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.SimpleExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanOnConfigurationFieldForNewBeanIntegrationTests {
@Autowired

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,7 +31,7 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@ContextHierarchy({ @ContextConfiguration(classes = ParentConfig.class),
@ContextConfiguration(classes = ChildConfig.class) })
public class SpyBeanOnContextHierarchyIntegrationTests {

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.SimpleExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpyBean(SimpleExampleService.class)
public class SpyBeanOnTestClassForExistingBeanIntegrationTests {

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.SimpleExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpyBean(SimpleExampleService.class)
public class SpyBeanOnTestClassForNewBeanIntegrationTests {

View File

@@ -16,14 +16,14 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.verify;
* @author Phillip Webb
* @see SpyBeanOnTestFieldForExistingBeanIntegrationTests
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = SpyBeanOnTestFieldForExistingBeanConfig.class)
public class SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests {

View File

@@ -16,14 +16,14 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleService;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify;
* @author Phillip Webb
* @see SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = SpyBeanOnTestFieldForExistingBeanConfig.class)
public class SpyBeanOnTestFieldForExistingBeanIntegrationTests {

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.CustomQualifier;
@@ -28,7 +28,7 @@ import org.springframework.boot.test.mock.mockito.example.RealExampleService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -39,7 +39,7 @@ import static org.mockito.Mockito.verify;
*
* @author Andreas Neiser
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests {
@SpyBean

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleGenericService;
@@ -27,7 +27,7 @@ import org.springframework.boot.test.mock.mockito.example.SimpleExampleStringGen
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify;
* @author Phillip Webb
* @see SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests {
// gh-7625

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests {
@SpyBean

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
import org.springframework.boot.test.mock.mockito.example.SimpleExampleService;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify;
*
* @author Phillip Webb
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanOnTestFieldForNewBeanIntegrationTests {
@SpyBean

View File

@@ -18,8 +18,8 @@ package org.springframework.boot.test.mock.mockito;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.exceptions.misusing.UnfinishedVerificationException;
import org.springframework.cache.CacheManager;
@@ -32,10 +32,9 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -46,19 +45,18 @@ import static org.mockito.Mockito.verify;
* @author Phillip Webb
* @see <a href="https://github.com/spring-projects/spring-boot/issues/5837">5837</a>
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanWithAopProxyAndNotProxyTargetAwareTests {
@SpyBean(proxyTargetAware = false)
private DateService dateService;
@Test(expected = UnfinishedVerificationException.class)
@Test
public void verifyShouldUseProxyTarget() {
this.dateService.getDate(false);
verify(this.dateService, times(1)).getDate(false);
verify(this.dateService, times(1)).getDate(eq(false));
verify(this.dateService, times(1)).getDate(anyBoolean());
reset(this.dateService);
assertThatExceptionOfType(UnfinishedVerificationException.class)
.isThrownBy(() -> reset(this.dateService));
}
@Configuration

View File

@@ -19,8 +19,8 @@ package org.springframework.boot.test.mock.mockito;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentMatchers;
import org.springframework.cache.CacheManager;
@@ -33,7 +33,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Service;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
@@ -47,7 +47,7 @@ import static org.mockito.Mockito.verify;
* @author Phillip Webb
* @see <a href="https://github.com/spring-projects/spring-boot/issues/5837">5837</a>
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanWithAopProxyTests {
@SpyBean

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.example.ExampleServiceCaller;
@@ -26,7 +26,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.mockito.Mockito.verify;
@@ -36,7 +36,7 @@ import static org.mockito.Mockito.verify;
*
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD)
public class SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests {

View File

@@ -16,15 +16,15 @@
package org.springframework.boot.test.mock.mockito;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockingDetails;
import org.mockito.Mockito;
import org.springframework.boot.test.mock.mockito.example.SimpleExampleStringGenericService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class SpyBeanWithNameOnTestFieldForMultipleExistingBeansTests {
@SpyBean(name = "two")

Some files were not shown because too many files have changed in this diff Show More