Reformat code following spring-javaformat upgrade
This commit is contained in:
@@ -212,7 +212,7 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
}
|
||||
initializers.addAll(application.getInitializers());
|
||||
for (Class<? extends ApplicationContextInitializer<?>> initializerClass : config
|
||||
.getContextInitializerClasses()) {
|
||||
.getContextInitializerClasses()) {
|
||||
initializers.add(BeanUtils.instantiateClass(initializerClass));
|
||||
}
|
||||
if (config.getParent() != null) {
|
||||
@@ -222,8 +222,11 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
}
|
||||
|
||||
private boolean isEmbeddedWebEnvironment(MergedContextConfiguration config) {
|
||||
return MergedAnnotations.from(config.getTestClass(), SearchStrategy.TYPE_HIERARCHY).get(SpringBootTest.class)
|
||||
.getValue("webEnvironment", WebEnvironment.class).orElse(WebEnvironment.NONE).isEmbedded();
|
||||
return MergedAnnotations.from(config.getTestClass(), SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(SpringBootTest.class)
|
||||
.getValue("webEnvironment", WebEnvironment.class)
|
||||
.orElse(WebEnvironment.NONE)
|
||||
.isEmbedded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,9 @@ class SpringBootTestArgs implements ContextCustomizer {
|
||||
|
||||
SpringBootTestArgs(Class<?> testClass) {
|
||||
this.args = MergedAnnotations.from(testClass, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(SpringBootTest.class).getValue("args", String[].class).orElse(NO_ARGS);
|
||||
.get(SpringBootTest.class)
|
||||
.getValue("args", String[].class)
|
||||
.orElse(NO_ARGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -115,7 +115,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
protected Set<Class<? extends TestExecutionListener>> getDefaultTestExecutionListenerClasses() {
|
||||
Set<Class<? extends TestExecutionListener>> listeners = super.getDefaultTestExecutionListenerClasses();
|
||||
List<DefaultTestExecutionListenersPostProcessor> postProcessors = SpringFactoriesLoader
|
||||
.loadFactories(DefaultTestExecutionListenersPostProcessor.class, getClass().getClassLoader());
|
||||
.loadFactories(DefaultTestExecutionListenersPostProcessor.class, getClass().getClassLoader());
|
||||
for (DefaultTestExecutionListenersPostProcessor postProcessor : postProcessors) {
|
||||
listeners = postProcessor.postProcessDefaultTestExecutionListeners(listeners);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
TestPropertySourceUtils.convertInlinedPropertiesToMap(configuration.getPropertySourceProperties()));
|
||||
Binder binder = new Binder(source);
|
||||
return binder.bind("spring.main.web-application-type", Bindable.of(WebApplicationType.class))
|
||||
.orElseGet(this::deduceWebApplicationType);
|
||||
.orElseGet(this::deduceWebApplicationType);
|
||||
}
|
||||
|
||||
private WebApplicationType deduceWebApplicationType() {
|
||||
@@ -199,8 +199,9 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
*/
|
||||
protected String determineResourceBasePath(MergedContextConfiguration configuration) {
|
||||
return MergedAnnotations.from(configuration.getTestClass(), SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(WebAppConfiguration.class).getValue(MergedAnnotation.VALUE, String.class)
|
||||
.orElse("src/main/webapp");
|
||||
.get(WebAppConfiguration.class)
|
||||
.getValue(MergedAnnotation.VALUE, String.class)
|
||||
.orElse("src/main/webapp");
|
||||
}
|
||||
|
||||
private boolean isWebEnvironmentSupported(MergedContextConfiguration mergedConfig) {
|
||||
@@ -232,7 +233,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
return classes;
|
||||
}
|
||||
Class<?> found = new AnnotatedClassFinder(SpringBootConfiguration.class)
|
||||
.findFromClass(mergedConfig.getTestClass());
|
||||
.findFromClass(mergedConfig.getTestClass());
|
||||
Assert.state(found != null, "Unable to find a @SpringBootConfiguration, you need to use "
|
||||
+ "@ContextConfiguration or @SpringBootTest(classes=...) with your test");
|
||||
logger.info("Found @SpringBootConfiguration " + found.getName() + " for test " + mergedConfig.getTestClass());
|
||||
@@ -242,7 +243,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
private boolean containsNonTestComponent(Class<?>[] classes) {
|
||||
for (Class<?> candidate : classes) {
|
||||
if (!MergedAnnotations.from(candidate, SearchStrategy.INHERITED_ANNOTATIONS)
|
||||
.isPresent(TestConfiguration.class)) {
|
||||
.isPresent(TestConfiguration.class)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -328,8 +329,9 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
|
||||
|
||||
protected void verifyConfiguration(Class<?> testClass) {
|
||||
SpringBootTest springBootTest = getAnnotation(testClass);
|
||||
if (springBootTest != null && isListeningOnPort(springBootTest.webEnvironment()) && MergedAnnotations
|
||||
.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS).isPresent(WebAppConfiguration.class)) {
|
||||
if (springBootTest != null && isListeningOnPort(springBootTest.webEnvironment())
|
||||
&& MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS)
|
||||
.isPresent(WebAppConfiguration.class)) {
|
||||
throw new IllegalStateException("@WebAppConfiguration should only be used "
|
||||
+ "with @SpringBootTest when @SpringBootTest is configured with a "
|
||||
+ "mock web environment. Please remove @WebAppConfiguration or reconfigure @SpringBootTest.");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -223,7 +223,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
throwAssertionError(contextFailedToStartWhenExpecting("to get beans names with type:%n <%s>", type));
|
||||
}
|
||||
return Assertions.assertThat(getApplicationContext().getBeanNamesForType(type))
|
||||
.as("Bean names of type <%s> from <%s>", type, getApplicationContext());
|
||||
.as("Bean names of type <%s> from <%s>", type, getApplicationContext());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,8 +359,8 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
"%nExpecting:%n <%s>%nto contain a bean of name:%n <%s> (%s)%nbut found:%n <%s> of type <%s>",
|
||||
getApplicationContext(), name, type, bean, bean.getClass()));
|
||||
}
|
||||
return Assertions.assertThat((T) bean).as("Bean of name <%s> and type <%s> from <%s>", name, type,
|
||||
getApplicationContext());
|
||||
return Assertions.assertThat((T) bean)
|
||||
.as("Bean of name <%s> and type <%s> from <%s>", name, type, getApplicationContext());
|
||||
}
|
||||
|
||||
private Object findBean(String name) {
|
||||
@@ -411,7 +411,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
throwAssertionError(contextFailedToStartWhenExpecting("to get beans of type:%n <%s>", type));
|
||||
}
|
||||
return Assertions.assertThat(scope.getBeansOfType(getApplicationContext(), type))
|
||||
.as("Beans of type <%s> from <%s>", type, getApplicationContext());
|
||||
.as("Beans of type <%s> from <%s>", type, getApplicationContext());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,9 +96,9 @@ class AssertProviderApplicationContextInvocationHandler implements InvocationHan
|
||||
+ this.startupFailure.getClass().getName() + "]";
|
||||
}
|
||||
ToStringCreator builder = new ToStringCreator(this.applicationContext)
|
||||
.append("id", this.applicationContext.getId())
|
||||
.append("applicationName", this.applicationContext.getApplicationName())
|
||||
.append("beanDefinitionCount", this.applicationContext.getBeanDefinitionCount());
|
||||
.append("id", this.applicationContext.getId())
|
||||
.append("applicationName", this.applicationContext.getApplicationName())
|
||||
.append("beanDefinitionCount", this.applicationContext.getBeanDefinitionCount());
|
||||
return "Started application " + builder;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -441,10 +441,10 @@ public abstract class AbstractApplicationContextRunner<SELF extends AbstractAppl
|
||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||
if (beanFactory instanceof AbstractAutowireCapableBeanFactory) {
|
||||
((AbstractAutowireCapableBeanFactory) beanFactory)
|
||||
.setAllowCircularReferences(this.runnerConfiguration.allowCircularReferences);
|
||||
.setAllowCircularReferences(this.runnerConfiguration.allowCircularReferences);
|
||||
if (beanFactory instanceof DefaultListableBeanFactory) {
|
||||
((DefaultListableBeanFactory) beanFactory)
|
||||
.setAllowBeanDefinitionOverriding(this.runnerConfiguration.allowBeanDefinitionOverriding);
|
||||
.setAllowBeanDefinitionOverriding(this.runnerConfiguration.allowBeanDefinitionOverriding);
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2022 the original author or authors.
|
||||
* Copyright 2020-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -204,7 +204,7 @@ class HttpGraphQlTesterContextCustomizer implements ContextCustomizer {
|
||||
private boolean isSslEnabled(ApplicationContext context) {
|
||||
try {
|
||||
AbstractConfigurableWebServerFactory webServerFactory = context
|
||||
.getBean(AbstractConfigurableWebServerFactory.class);
|
||||
.getBean(AbstractConfigurableWebServerFactory.class);
|
||||
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,8 +96,10 @@ public class JacksonTester<T> extends AbstractJsonMarshalTester<T> {
|
||||
|
||||
@Override
|
||||
protected JsonContent<T> getJsonContent(String json) {
|
||||
Configuration configuration = Configuration.builder().jsonProvider(new JacksonJsonProvider(this.objectMapper))
|
||||
.mappingProvider(new JacksonMappingProvider(this.objectMapper)).build();
|
||||
Configuration configuration = Configuration.builder()
|
||||
.jsonProvider(new JacksonJsonProvider(this.objectMapper))
|
||||
.mappingProvider(new JacksonMappingProvider(this.objectMapper))
|
||||
.build();
|
||||
return new JsonContent<>(getResourceLoadClass(), getType(), json, configuration);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,10 +67,12 @@ class DefinitionsParser {
|
||||
|
||||
private void parseElement(AnnotatedElement element, Class<?> source) {
|
||||
MergedAnnotations annotations = MergedAnnotations.from(element, SearchStrategy.SUPERCLASS);
|
||||
annotations.stream(MockBean.class).map(MergedAnnotation::synthesize)
|
||||
.forEach((annotation) -> parseMockBeanAnnotation(annotation, element, source));
|
||||
annotations.stream(SpyBean.class).map(MergedAnnotation::synthesize)
|
||||
.forEach((annotation) -> parseSpyBeanAnnotation(annotation, element, source));
|
||||
annotations.stream(MockBean.class)
|
||||
.map(MergedAnnotation::synthesize)
|
||||
.forEach((annotation) -> parseMockBeanAnnotation(annotation, element, source));
|
||||
annotations.stream(SpyBean.class)
|
||||
.map(MergedAnnotation::synthesize)
|
||||
.forEach((annotation) -> parseSpyBeanAnnotation(annotation, element, source));
|
||||
}
|
||||
|
||||
private void parseMockBeanAnnotation(MockBean annotation, AnnotatedElement element, Class<?> source) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -129,9 +129,13 @@ class MockDefinition extends Definition {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("name", getName()).append("typeToMock", this.typeToMock)
|
||||
.append("extraInterfaces", this.extraInterfaces).append("answer", this.answer)
|
||||
.append("serializable", this.serializable).append("reset", getReset()).toString();
|
||||
return new ToStringCreator(this).append("name", getName())
|
||||
.append("typeToMock", this.typeToMock)
|
||||
.append("extraInterfaces", this.extraInterfaces)
|
||||
.append("answer", this.answer)
|
||||
.append("serializable", this.serializable)
|
||||
.append("reset", getReset())
|
||||
.toString();
|
||||
}
|
||||
|
||||
<T> T createMock() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -83,7 +83,7 @@ public class MockitoPostProcessor implements InstantiationAwareBeanPostProcessor
|
||||
private static final String BEAN_NAME = MockitoPostProcessor.class.getName();
|
||||
|
||||
private static final String CONFIGURATION_CLASS_ATTRIBUTE = Conventions
|
||||
.getQualifiedAttributeName(ConfigurationClassPostProcessor.class, "configurationClass");
|
||||
.getQualifiedAttributeName(ConfigurationClassPostProcessor.class, "configurationClass");
|
||||
|
||||
private static final BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -108,7 +108,7 @@ public class MockitoTestExecutionListener extends AbstractTestExecutionListener
|
||||
parser.parse(testContext.getTestClass());
|
||||
if (!parser.getDefinitions().isEmpty()) {
|
||||
MockitoPostProcessor postProcessor = testContext.getApplicationContext()
|
||||
.getBean(MockitoPostProcessor.class);
|
||||
.getBean(MockitoPostProcessor.class);
|
||||
for (Definition definition : parser.getDefinitions()) {
|
||||
Field field = parser.getField(definition);
|
||||
if (field != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -79,8 +79,10 @@ class SpyDefinition extends Definition {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("name", getName()).append("typeToSpy", this.typeToSpy)
|
||||
.append("reset", getReset()).toString();
|
||||
return new ToStringCreator(this).append("name", getName())
|
||||
.append("typeToSpy", this.typeToSpy)
|
||||
.append("reset", getReset())
|
||||
.toString();
|
||||
}
|
||||
|
||||
<T> T createSpy(Object instance) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessor implements EnvironmentPos
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
MapPropertySource source = (MapPropertySource) environment.getPropertySources()
|
||||
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
if (source == null || isTestServerPortFixed(source, environment) || isTestManagementPortConfigured(source)) {
|
||||
return;
|
||||
}
|
||||
@@ -70,10 +70,14 @@ class SpringBootTestRandomPortEnvironmentPostProcessor implements EnvironmentPos
|
||||
}
|
||||
|
||||
private Integer getPropertyAsInteger(ConfigurableEnvironment environment, String property, Integer defaultValue) {
|
||||
return environment.getPropertySources().stream().filter(
|
||||
(source) -> !source.getName().equals(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME))
|
||||
.map((source) -> getPropertyAsInteger(source, property, environment)).filter(Objects::nonNull)
|
||||
.findFirst().orElse(defaultValue);
|
||||
return environment.getPropertySources()
|
||||
.stream()
|
||||
.filter((source) -> !source.getName()
|
||||
.equals(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME))
|
||||
.map((source) -> getPropertyAsInteger(source, property, environment))
|
||||
.filter(Objects::nonNull)
|
||||
.findFirst()
|
||||
.orElse(defaultValue);
|
||||
}
|
||||
|
||||
private Integer getPropertyAsInteger(PropertySource<?> source, String property,
|
||||
|
||||
@@ -135,7 +135,7 @@ public class TestRestTemplate {
|
||||
ClientHttpRequestFactory requestFactory = builder.buildRequestFactory();
|
||||
if (requestFactory instanceof HttpComponentsClientHttpRequestFactory) {
|
||||
builder = builder
|
||||
.requestFactory(() -> new CustomHttpComponentsClientHttpRequestFactory(httpClientOptions));
|
||||
.requestFactory(() -> new CustomHttpComponentsClientHttpRequestFactory(httpClientOptions));
|
||||
}
|
||||
}
|
||||
if (username != null || password != null) {
|
||||
@@ -952,12 +952,12 @@ public class TestRestTemplate {
|
||||
if (entity instanceof UriTemplateRequestEntity) {
|
||||
UriTemplateRequestEntity<?> templatedUriEntity = (UriTemplateRequestEntity<?>) entity;
|
||||
if (templatedUriEntity.getVars() != null) {
|
||||
return this.restTemplate.getUriTemplateHandler().expand(templatedUriEntity.getUriTemplate(),
|
||||
templatedUriEntity.getVars());
|
||||
return this.restTemplate.getUriTemplateHandler()
|
||||
.expand(templatedUriEntity.getUriTemplate(), templatedUriEntity.getVars());
|
||||
}
|
||||
else if (templatedUriEntity.getVarsMap() != null) {
|
||||
return this.restTemplate.getUriTemplateHandler().expand(templatedUriEntity.getUriTemplate(),
|
||||
templatedUriEntity.getVarsMap());
|
||||
return this.restTemplate.getUriTemplateHandler()
|
||||
.expand(templatedUriEntity.getUriTemplate(), templatedUriEntity.getVarsMap());
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"No variables specified for URI template: " + templatedUriEntity.getUriTemplate());
|
||||
@@ -1025,8 +1025,10 @@ public class TestRestTemplate {
|
||||
}
|
||||
|
||||
protected RequestConfig getRequestConfig() {
|
||||
Builder builder = RequestConfig.custom().setCookieSpec(this.cookieSpec).setAuthenticationEnabled(false)
|
||||
.setRedirectsEnabled(this.enableRedirects);
|
||||
Builder builder = RequestConfig.custom()
|
||||
.setCookieSpec(this.cookieSpec)
|
||||
.setAuthenticationEnabled(false)
|
||||
.setRedirectsEnabled(this.enableRedirects);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,7 +53,7 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer {
|
||||
public void customizeContext(ConfigurableApplicationContext context,
|
||||
MergedContextConfiguration mergedContextConfiguration) {
|
||||
SpringBootTest springBootTest = TestContextAnnotationUtils
|
||||
.findMergedAnnotation(mergedContextConfiguration.getTestClass(), SpringBootTest.class);
|
||||
.findMergedAnnotation(mergedContextConfiguration.getTestClass(), SpringBootTest.class);
|
||||
if (springBootTest.webEnvironment().isEmbedded()) {
|
||||
registerTestRestTemplate(context);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer {
|
||||
private boolean isSslEnabled(ApplicationContext context) {
|
||||
try {
|
||||
AbstractServletWebServerFactory webServerFactory = context
|
||||
.getBean(AbstractServletWebServerFactory.class);
|
||||
.getBean(AbstractServletWebServerFactory.class);
|
||||
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -208,7 +208,7 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
|
||||
private boolean isSslEnabled(ApplicationContext context) {
|
||||
try {
|
||||
AbstractReactiveWebServerFactory webServerFactory = context
|
||||
.getBean(AbstractReactiveWebServerFactory.class);
|
||||
.getBean(AbstractReactiveWebServerFactory.class);
|
||||
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
@@ -218,7 +218,8 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
|
||||
|
||||
private void customizeWebTestClientBuilder(WebTestClient.Builder clientBuilder, ApplicationContext context) {
|
||||
for (WebTestClientBuilderCustomizer customizer : context
|
||||
.getBeansOfType(WebTestClientBuilderCustomizer.class).values()) {
|
||||
.getBeansOfType(WebTestClientBuilderCustomizer.class)
|
||||
.values()) {
|
||||
customizer.customize(clientBuilder);
|
||||
}
|
||||
}
|
||||
@@ -226,9 +227,10 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
|
||||
private void customizeWebTestClientCodecs(WebTestClient.Builder clientBuilder, ApplicationContext context) {
|
||||
Collection<CodecCustomizer> codecCustomizers = context.getBeansOfType(CodecCustomizer.class).values();
|
||||
if (!CollectionUtils.isEmpty(codecCustomizers)) {
|
||||
clientBuilder.exchangeStrategies(ExchangeStrategies.builder().codecs(
|
||||
(codecs) -> codecCustomizers.forEach((codecCustomizer) -> codecCustomizer.customize(codecs)))
|
||||
.build());
|
||||
clientBuilder.exchangeStrategies(ExchangeStrategies.builder()
|
||||
.codecs((codecs) -> codecCustomizers
|
||||
.forEach((codecCustomizer) -> codecCustomizer.customize(codecs)))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ class WebTestClientContextCustomizerFactory implements ContextCustomizerFactory
|
||||
reactorClientPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
|
||||
jettyClientPresent = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
|
||||
httpComponentsClientPresent = ClassUtils
|
||||
.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader)
|
||||
.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader)
|
||||
&& ClassUtils.isPresent("org.apache.hc.core5.reactive.ReactiveDataConsumer", loader);
|
||||
webClientPresent = ClassUtils.isPresent("org.springframework.web.reactive.function.client.WebClient", loader);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,8 +69,15 @@ abstract class AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests {
|
||||
@Test
|
||||
void runAndTestHttpEndpoint() {
|
||||
assertThat(this.port).isNotEqualTo(8080).isNotEqualTo(0);
|
||||
WebTestClient.bindToServer().baseUrl("http://localhost:" + this.port).responseTimeout(Duration.ofMinutes(5))
|
||||
.build().get().uri("/").exchange().expectBody(String.class).isEqualTo("Hello World");
|
||||
WebTestClient.bindToServer()
|
||||
.baseUrl("http://localhost:" + this.port)
|
||||
.responseTimeout(Duration.ofMinutes(5))
|
||||
.build()
|
||||
.get()
|
||||
.uri("/")
|
||||
.exchange()
|
||||
.expectBody(String.class)
|
||||
.isEqualTo("Hello World");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,13 +37,13 @@ class AnnotatedClassFinderTests {
|
||||
@Test
|
||||
void findFromClassWhenSourceIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.finder.findFromClass((Class<?>) null))
|
||||
.withMessageContaining("Source must not be null");
|
||||
.withMessageContaining("Source must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void findFromPackageWhenSourceIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.finder.findFromPackage((String) null))
|
||||
.withMessageContaining("Source must not be null");
|
||||
.withMessageContaining("Source must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,7 @@ class FilteredClassLoaderTests {
|
||||
try (FilteredClassLoader classLoader = new FilteredClassLoader(
|
||||
FilteredClassLoaderTests.class.getPackage().getName())) {
|
||||
assertThatExceptionOfType(ClassNotFoundException.class)
|
||||
.isThrownBy(() -> Class.forName(getClass().getName(), false, classLoader));
|
||||
.isThrownBy(() -> Class.forName(getClass().getName(), false, classLoader));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class FilteredClassLoaderTests {
|
||||
void loadClassWhenFilteredOnClassShouldThrowClassNotFound() throws Exception {
|
||||
try (FilteredClassLoader classLoader = new FilteredClassLoader(FilteredClassLoaderTests.class)) {
|
||||
assertThatExceptionOfType(ClassNotFoundException.class)
|
||||
.isThrownBy(() -> Class.forName(getClass().getName(), false, classLoader));
|
||||
.isThrownBy(() -> Class.forName(getClass().getName(), false, classLoader));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class FilteredClassLoaderTests {
|
||||
Class<FilteredClassLoaderTests> hiddenClass = FilteredClassLoaderTests.class;
|
||||
try (FilteredClassLoader classLoader = new FilteredClassLoader(hiddenClass)) {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> classLoader.publicDefineClass(hiddenClass.getName(), new byte[] {}, null));
|
||||
.isThrownBy(() -> classLoader.publicDefineClass(hiddenClass.getName(), new byte[] {}, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,7 @@ class ImportsContextCustomizerFactoryIntegrationTests {
|
||||
@Test
|
||||
void testItselfIsNotABean() {
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
|
||||
.isThrownBy(() -> this.context.getBean(getClass()));
|
||||
.isThrownBy(() -> this.context.getBean(getClass()));
|
||||
}
|
||||
|
||||
@Component
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,8 +77,8 @@ class ImportsContextCustomizerFactoryTests {
|
||||
@Test
|
||||
void getContextCustomizerWhenClassHasBeanMethodsShouldThrowException() {
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> this.factory.createContextCustomizer(TestWithImportAndBeanMethod.class, null))
|
||||
.withMessageContaining("Test classes cannot include @Bean methods");
|
||||
.isThrownBy(() -> this.factory.createContextCustomizer(TestWithImportAndBeanMethod.class, null))
|
||||
.withMessageContaining("Test classes cannot include @Bean methods");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,7 +93,7 @@ class ImportsContextCustomizerFactoryTests {
|
||||
@Test
|
||||
void selfAnnotatingAnnotationDoesNotCauseStackOverflow() {
|
||||
assertThat(this.factory.createContextCustomizer(TestWithImportAndSelfAnnotatingAnnotation.class, null))
|
||||
.isNotNull();
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
static class TestWithNoImport {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,37 +47,37 @@ class ImportsContextCustomizerTests {
|
||||
@Test
|
||||
void importSelectorsCouldUseAnyAnnotations() {
|
||||
assertThat(new ImportsContextCustomizer(FirstImportSelectorAnnotatedClass.class))
|
||||
.isNotEqualTo(new ImportsContextCustomizer(SecondImportSelectorAnnotatedClass.class));
|
||||
.isNotEqualTo(new ImportsContextCustomizer(SecondImportSelectorAnnotatedClass.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void determinableImportSelector() {
|
||||
assertThat(new ImportsContextCustomizer(FirstDeterminableImportSelectorAnnotatedClass.class))
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondDeterminableImportSelectorAnnotatedClass.class));
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondDeterminableImportSelectorAnnotatedClass.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customizersForTestClassesWithDifferentKotlinMetadataAreEqual() {
|
||||
assertThat(new ImportsContextCustomizer(FirstKotlinAnnotatedTestClass.class))
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondKotlinAnnotatedTestClass.class));
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondKotlinAnnotatedTestClass.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customizersForTestClassesWithDifferentSpockFrameworkAnnotationsAreEqual() {
|
||||
assertThat(new ImportsContextCustomizer(FirstSpockFrameworkAnnotatedTestClass.class))
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondSpockFrameworkAnnotatedTestClass.class));
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondSpockFrameworkAnnotatedTestClass.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customizersForTestClassesWithDifferentSpockLangAnnotationsAreEqual() {
|
||||
assertThat(new ImportsContextCustomizer(FirstSpockLangAnnotatedTestClass.class))
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondSpockLangAnnotatedTestClass.class));
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondSpockLangAnnotatedTestClass.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customizersForTestClassesWithDifferentJUnitAnnotationsAreEqual() {
|
||||
assertThat(new ImportsContextCustomizer(FirstJUnitAnnotatedTestClass.class))
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondJUnitAnnotatedTestClass.class));
|
||||
.isEqualTo(new ImportsContextCustomizer(SecondJUnitAnnotatedTestClass.class));
|
||||
}
|
||||
|
||||
@Import(TestImportSelector.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -127,7 +127,7 @@ class SpringBootContextLoaderTests {
|
||||
@Test
|
||||
void testPropertyValuesShouldTakePrecedenceWhenInlinedPropertiesPresentAndProfilesActive() {
|
||||
TestContext context = new ExposedTestContextManager(ActiveProfileWithInlinedProperties.class)
|
||||
.getExposedTestContext();
|
||||
.getExposedTestContext();
|
||||
StandardEnvironment environment = (StandardEnvironment) context.getApplicationContext().getEnvironment();
|
||||
TestPropertyValues.of("key=thisValue").applyTo(environment);
|
||||
assertThat(environment.getProperty("key")).isEqualTo("thisValue");
|
||||
@@ -138,9 +138,11 @@ class SpringBootContextLoaderTests {
|
||||
void propertySourceOrdering() {
|
||||
TestContext context = new ExposedTestContextManager(PropertySourceOrdering.class).getExposedTestContext();
|
||||
ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getApplicationContext()
|
||||
.getEnvironment();
|
||||
List<String> names = environment.getPropertySources().stream().map(PropertySource::getName)
|
||||
.collect(Collectors.toList());
|
||||
.getEnvironment();
|
||||
List<String> names = environment.getPropertySources()
|
||||
.stream()
|
||||
.map(PropertySource::getName)
|
||||
.collect(Collectors.toList());
|
||||
String last = names.remove(names.size() - 1);
|
||||
assertThat(names).containsExactly("configurationProperties", "Inlined Test Properties", "commandLineArgs",
|
||||
"servletConfigInitParams", "servletContextInitParams", "systemProperties", "systemEnvironment",
|
||||
@@ -151,14 +153,14 @@ class SpringBootContextLoaderTests {
|
||||
@Test
|
||||
void whenEnvironmentChangesWebApplicationTypeToNoneThenContextTypeChangesAccordingly() {
|
||||
TestContext context = new ExposedTestContextManager(ChangingWebApplicationTypeToNone.class)
|
||||
.getExposedTestContext();
|
||||
.getExposedTestContext();
|
||||
assertThat(context.getApplicationContext()).isNotInstanceOf(WebApplicationContext.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenEnvironmentChangesWebApplicationTypeToReactiveThenContextTypeChangesAccordingly() {
|
||||
TestContext context = new ExposedTestContextManager(ChangingWebApplicationTypeToReactive.class)
|
||||
.getExposedTestContext();
|
||||
.getExposedTestContext();
|
||||
assertThat(context.getApplicationContext()).isInstanceOf(GenericReactiveWebApplicationContext.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,7 +63,7 @@ class SpringBootTestWebEnvironmentMockTests {
|
||||
@Test
|
||||
void validateWebApplicationContextIsSet() {
|
||||
WebApplicationContext fromServletContext = WebApplicationContextUtils
|
||||
.getWebApplicationContext(this.servletContext);
|
||||
.getWebApplicationContext(this.servletContext);
|
||||
assertThat(fromServletContext).isSameAs(this.context);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ class SpringBootTestWebEnvironmentRandomPortTests extends AbstractSpringBootTest
|
||||
@Test
|
||||
void testRestTemplateShouldUseBuilder() {
|
||||
assertThat(getRestTemplate().getRestTemplate().getMessageConverters())
|
||||
.hasAtLeastOneElementOfType(MyConverter.class);
|
||||
.hasAtLeastOneElementOfType(MyConverter.class);
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ class SpringBootTestWithClassesIntegrationTests {
|
||||
void injectsOnlyConfig() {
|
||||
assertThat(this.context.getBean(Config.class)).isNotNull();
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
|
||||
.isThrownBy(() -> this.context.getBean(AdditionalConfig.class));
|
||||
.isThrownBy(() -> this.context.getBean(AdditionalConfig.class));
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ class SpringBootTestWithContextConfigurationIntegrationTests {
|
||||
void injectsOnlyConfig() {
|
||||
assertThat(this.context.getBean(Config.class)).isNotNull();
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
|
||||
.isThrownBy(() -> this.context.getBean(AdditionalConfig.class));
|
||||
.isThrownBy(() -> this.context.getBean(AdditionalConfig.class));
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ class SpringBootTestWithTestPropertySourceTests {
|
||||
@Test
|
||||
void propertyFromPropertySourcePropertiesOverridesPropertyFromPropertySourceLocations() {
|
||||
assertThat(this.config.propertySourceInlinedOverridesPropertySourceLocation)
|
||||
.isEqualTo("property-source-inlined");
|
||||
.isEqualTo("property-source-inlined");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,14 +34,14 @@ class TestConfigurationTests {
|
||||
@Test
|
||||
void proxyBeanMethodsIsEnabledByDefault() {
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils
|
||||
.getMergedAnnotationAttributes(DefaultTestConfiguration.class, Configuration.class);
|
||||
.getMergedAnnotationAttributes(DefaultTestConfiguration.class, Configuration.class);
|
||||
assertThat(attributes.get("proxyBeanMethods")).isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void proxyBeanMethodsCanBeDisabled() {
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils
|
||||
.getMergedAnnotationAttributes(NoBeanMethodProxyingTestConfiguration.class, Configuration.class);
|
||||
.getMergedAnnotationAttributes(NoBeanMethodProxyingTestConfiguration.class, Configuration.class);
|
||||
assertThat(attributes.get("proxyBeanMethods")).isEqualTo(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,37 +64,38 @@ class ApplicationContextAssertProviderTests {
|
||||
void getWhenTypeIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
() -> ApplicationContextAssertProvider.get(null, ApplicationContext.class, this.mockContextSupplier))
|
||||
.withMessageContaining("Type must not be null");
|
||||
.withMessageContaining("Type must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWhenTypeIsClassShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
() -> ApplicationContextAssertProvider.get(null, ApplicationContext.class, this.mockContextSupplier))
|
||||
.withMessageContaining("Type must not be null");
|
||||
.withMessageContaining("Type must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWhenContextTypeIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContextClass.class,
|
||||
ApplicationContext.class, this.mockContextSupplier))
|
||||
.withMessageContaining("Type must be an interface");
|
||||
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContextClass.class,
|
||||
ApplicationContext.class, this.mockContextSupplier))
|
||||
.withMessageContaining("Type must be an interface");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWhenContextTypeIsClassShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ApplicationContextAssertProvider
|
||||
.get(TestAssertProviderApplicationContext.class, null, this.mockContextSupplier))
|
||||
.withMessageContaining("ContextType must not be null");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContext.class, null,
|
||||
this.mockContextSupplier))
|
||||
.withMessageContaining("ContextType must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWhenSupplierIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContext.class,
|
||||
StaticApplicationContext.class, this.mockContextSupplier))
|
||||
.withMessageContaining("ContextType must be an interface");
|
||||
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContext.class,
|
||||
StaticApplicationContext.class, this.mockContextSupplier))
|
||||
.withMessageContaining("ContextType must be an interface");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,8 +110,9 @@ class ApplicationContextAssertProviderTests {
|
||||
void getWhenContextFailsShouldReturnProxyThatThrowsExceptions() {
|
||||
ApplicationContextAssertProvider<ApplicationContext> context = get(this.startupFailureSupplier);
|
||||
assertThat((Object) context).isNotNull();
|
||||
assertThatIllegalStateException().isThrownBy(() -> context.getBean("foo")).withCause(this.startupFailure)
|
||||
.withMessageContaining("failed to start");
|
||||
assertThatIllegalStateException().isThrownBy(() -> context.getBean("foo"))
|
||||
.withCause(this.startupFailure)
|
||||
.withMessageContaining("failed to start");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,7 +125,8 @@ class ApplicationContextAssertProviderTests {
|
||||
void getSourceContextWhenContextFailsShouldThrowException() {
|
||||
ApplicationContextAssertProvider<ApplicationContext> context = get(this.startupFailureSupplier);
|
||||
assertThatIllegalStateException().isThrownBy(context::getSourceApplicationContext)
|
||||
.withCause(this.startupFailure).withMessageContaining("failed to start");
|
||||
.withCause(this.startupFailure)
|
||||
.withMessageContaining("failed to start");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,8 +139,9 @@ class ApplicationContextAssertProviderTests {
|
||||
void getSourceContextOfTypeWhenContextFailsToStartShouldThrowException() {
|
||||
ApplicationContextAssertProvider<ApplicationContext> context = get(this.startupFailureSupplier);
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> context.getSourceApplicationContext(ApplicationContext.class))
|
||||
.withCause(this.startupFailure).withMessageContaining("failed to start");
|
||||
.isThrownBy(() -> context.getSourceApplicationContext(ApplicationContext.class))
|
||||
.withCause(this.startupFailure)
|
||||
.withMessageContaining("failed to start");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -172,7 +176,7 @@ class ApplicationContextAssertProviderTests {
|
||||
void toStringWhenContextStartsShouldReturnSimpleString() {
|
||||
ApplicationContextAssertProvider<ApplicationContext> context = get(this.mockContextSupplier);
|
||||
assertThat(context.toString()).startsWith("Started application [ConfigurableApplicationContext.MockitoMock")
|
||||
.endsWith("id = [null], applicationName = [null], beanDefinitionCount = 0]");
|
||||
.endsWith("id = [null], applicationName = [null], beanDefinitionCount = 0]");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,7 +62,7 @@ class ApplicationContextAssertTests {
|
||||
@Test
|
||||
void createWhenApplicationContextIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ApplicationContextAssert<>(null, null))
|
||||
.withMessageContaining("ApplicationContext must not be null");
|
||||
.withMessageContaining("ApplicationContext must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,15 +84,15 @@ class ApplicationContextAssertTests {
|
||||
@Test
|
||||
void hasBeanWhenHasNoBeanShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasBean("foo"))
|
||||
.withMessageContaining("no such bean");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasBean("foo"))
|
||||
.withMessageContaining("no such bean");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasBeanWhenNotStartedShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasBean("foo"))
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasBean("foo"))
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,8 +104,8 @@ class ApplicationContextAssertTests {
|
||||
@Test
|
||||
void hasSingleBeanWhenHasNoBeansShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
|
||||
.withMessageContaining("to have a single bean of type");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
|
||||
.withMessageContaining("to have a single bean of type");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,16 +113,16 @@ class ApplicationContextAssertTests {
|
||||
this.context.registerSingleton("foo", Foo.class);
|
||||
this.context.registerSingleton("bar", Foo.class);
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
|
||||
.withMessageContaining("but found:");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
|
||||
.withMessageContaining("but found:");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasSingleBeanWhenFailedToStartShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasSingleBean(Foo.class))
|
||||
.withMessageContaining("to have a single bean of type")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasSingleBean(Foo.class))
|
||||
.withMessageContaining("to have a single bean of type")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,8 +130,8 @@ class ApplicationContextAssertTests {
|
||||
this.parent.registerSingleton("foo", Foo.class);
|
||||
this.context.registerSingleton("bar", Foo.class);
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
|
||||
.withMessageContaining("but found:");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
|
||||
.withMessageContaining("but found:");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,24 +150,24 @@ class ApplicationContextAssertTests {
|
||||
void doesNotHaveBeanOfTypeWhenHasBeanOfTypeShouldFail() {
|
||||
this.context.registerSingleton("foo", Foo.class);
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean(Foo.class))
|
||||
.withMessageContaining("but found");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean(Foo.class))
|
||||
.withMessageContaining("but found");
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotHaveBeanOfTypeWhenFailedToStartShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean(Foo.class))
|
||||
.withMessageContaining("not to have any beans of type")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean(Foo.class))
|
||||
.withMessageContaining("not to have any beans of type")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotHaveBeanOfTypeWhenInParentShouldFail() {
|
||||
this.parent.registerSingleton("foo", Foo.class);
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean(Foo.class))
|
||||
.withMessageContaining("but found");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean(Foo.class))
|
||||
.withMessageContaining("but found");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -185,15 +185,16 @@ class ApplicationContextAssertTests {
|
||||
void doesNotHaveBeanOfNameWhenHasBeanOfTypeShouldFail() {
|
||||
this.context.registerSingleton("foo", Foo.class);
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean("foo"))
|
||||
.withMessageContaining("but found");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean("foo"))
|
||||
.withMessageContaining("but found");
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotHaveBeanOfNameWhenFailedToStartShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean("foo"))
|
||||
.withMessageContaining("not to have any beans of name").withMessageContaining("failed to start");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean("foo"))
|
||||
.withMessageContaining("not to have any beans of name")
|
||||
.withMessageContaining("failed to start");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -211,9 +212,9 @@ class ApplicationContextAssertTests {
|
||||
@Test
|
||||
void getBeanNamesWhenFailedToStartShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean("foo"))
|
||||
.withMessageContaining("not to have any beans of name")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean("foo"))
|
||||
.withMessageContaining("not to have any beans of name")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -232,8 +233,8 @@ class ApplicationContextAssertTests {
|
||||
this.context.registerSingleton("foo", Foo.class);
|
||||
this.context.registerSingleton("bar", Foo.class);
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean(Foo.class))
|
||||
.withMessageContaining("but found");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean(Foo.class))
|
||||
.withMessageContaining("but found");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -246,9 +247,9 @@ class ApplicationContextAssertTests {
|
||||
@Test
|
||||
void getBeanOfTypeWhenFailedToStartShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean(Foo.class))
|
||||
.withMessageContaining("to contain bean of type")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean(Foo.class))
|
||||
.withMessageContaining("to contain bean of type")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -268,8 +269,8 @@ class ApplicationContextAssertTests {
|
||||
this.parent.registerSingleton("foo", Foo.class);
|
||||
this.context.registerSingleton("bar", Foo.class);
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean(Foo.class))
|
||||
.withMessageContaining("but found");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean(Foo.class))
|
||||
.withMessageContaining("but found");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -293,9 +294,9 @@ class ApplicationContextAssertTests {
|
||||
@Test
|
||||
void getBeanOfNameWhenFailedToStartShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean("foo"))
|
||||
.withMessageContaining("to contain a bean of name")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean("foo"))
|
||||
.withMessageContaining("to contain a bean of name")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -313,16 +314,16 @@ class ApplicationContextAssertTests {
|
||||
void getBeanOfNameAndTypeWhenHasNoBeanOfNameButDifferentTypeShouldFail() {
|
||||
this.context.registerSingleton("foo", Foo.class);
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean("foo", String.class))
|
||||
.withMessageContaining("of type");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean("foo", String.class))
|
||||
.withMessageContaining("of type");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBeanOfNameAndTypeWhenFailedToStartShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean("foo", Foo.class))
|
||||
.withMessageContaining("to contain a bean of name")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean("foo", Foo.class))
|
||||
.withMessageContaining("to contain a bean of name")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -340,9 +341,9 @@ class ApplicationContextAssertTests {
|
||||
@Test
|
||||
void getBeansWhenFailedToStartShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBeans(Foo.class))
|
||||
.withMessageContaining("to get beans of type")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBeans(Foo.class))
|
||||
.withMessageContaining("to get beans of type")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -367,8 +368,8 @@ class ApplicationContextAssertTests {
|
||||
@Test
|
||||
void getFailureWhenDidNotFailShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).getFailure())
|
||||
.withMessageContaining("context started");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).getFailure())
|
||||
.withMessageContaining("context started");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -379,16 +380,16 @@ class ApplicationContextAssertTests {
|
||||
@Test
|
||||
void hasFailedWhenNotFailedShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasFailed())
|
||||
.withMessageContaining("to have failed");
|
||||
.isThrownBy(() -> assertThat(getAssert(this.context)).hasFailed())
|
||||
.withMessageContaining("to have failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasNotFailedWhenFailedShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasNotFailed())
|
||||
.withMessageContaining("to have not failed")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasNotFailed())
|
||||
.withMessageContaining("to have not failed")
|
||||
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ class AssertableApplicationContextTests {
|
||||
@Test
|
||||
void getShouldReturnProxy() {
|
||||
AssertableApplicationContext context = AssertableApplicationContext
|
||||
.get(() -> mock(ConfigurableApplicationContext.class));
|
||||
.get(() -> mock(ConfigurableApplicationContext.class));
|
||||
assertThat(context).isInstanceOf(ConfigurableApplicationContext.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ class AssertableReactiveWebApplicationContextTests {
|
||||
@Test
|
||||
void getShouldReturnProxy() {
|
||||
AssertableReactiveWebApplicationContext context = AssertableReactiveWebApplicationContext
|
||||
.get(() -> mock(ConfigurableReactiveWebApplicationContext.class));
|
||||
.get(() -> mock(ConfigurableReactiveWebApplicationContext.class));
|
||||
assertThat(context).isInstanceOf(ConfigurableReactiveWebApplicationContext.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ class AssertableWebApplicationContextTests {
|
||||
@Test
|
||||
void getShouldReturnProxy() {
|
||||
AssertableWebApplicationContext context = AssertableWebApplicationContext
|
||||
.get(() -> mock(ConfigurableWebApplicationContext.class));
|
||||
.get(() -> mock(ConfigurableWebApplicationContext.class));
|
||||
assertThat(context).isInstanceOf(ConfigurableWebApplicationContext.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,10 +43,10 @@ class SpringBootTestContextBootstrapperTests {
|
||||
@Test
|
||||
void springBootTestWithANonMockWebEnvironmentAndWebAppConfigurationFailsFast() {
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> buildTestContext(SpringBootTestNonMockWebEnvironmentAndWebAppConfiguration.class))
|
||||
.withMessageContaining("@WebAppConfiguration should only be used with "
|
||||
+ "@SpringBootTest when @SpringBootTest is configured with a mock web "
|
||||
+ "environment. Please remove @WebAppConfiguration or reconfigure @SpringBootTest.");
|
||||
.isThrownBy(() -> buildTestContext(SpringBootTestNonMockWebEnvironmentAndWebAppConfiguration.class))
|
||||
.withMessageContaining("@WebAppConfiguration should only be used with "
|
||||
+ "@SpringBootTest when @SpringBootTest is configured with a mock web "
|
||||
+ "environment. Please remove @WebAppConfiguration or reconfigure @SpringBootTest.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,7 @@ class TestTypeExcludeFilterTests {
|
||||
@Test
|
||||
void matchesJUnit4TestClass() throws Exception {
|
||||
assertThat(this.filter.match(getMetadataReader(TestTypeExcludeFilterTests.class), this.metadataReaderFactory))
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,13 +53,13 @@ class TestTypeExcludeFilterTests {
|
||||
@Test
|
||||
void matchesJUnitJupiterRepeatedTestClass() throws Exception {
|
||||
assertThat(this.filter.match(getMetadataReader(JupiterRepeatedTestExample.class), this.metadataReaderFactory))
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesJUnitJupiterTestFactoryClass() throws Exception {
|
||||
assertThat(this.filter.match(getMetadataReader(JupiterTestFactoryExample.class), this.metadataReaderFactory))
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,19 +70,22 @@ class TestTypeExcludeFilterTests {
|
||||
@Test
|
||||
void matchesNestedConfigurationClassWithoutTestMethodsIfItHasRunWith() throws Exception {
|
||||
assertThat(this.filter.match(getMetadataReader(AbstractTestWithConfigAndRunWith.Config.class),
|
||||
this.metadataReaderFactory)).isTrue();
|
||||
this.metadataReaderFactory))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesNestedConfigurationClassWithoutTestMethodsIfItHasExtendWith() throws Exception {
|
||||
assertThat(this.filter.match(getMetadataReader(AbstractJupiterTestWithConfigAndExtendWith.Config.class),
|
||||
this.metadataReaderFactory)).isTrue();
|
||||
this.metadataReaderFactory))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesNestedConfigurationClassWithoutTestMethodsIfItHasTestable() throws Exception {
|
||||
assertThat(this.filter.match(getMetadataReader(AbstractJupiterTestWithConfigAndTestable.Config.class),
|
||||
this.metadataReaderFactory)).isTrue();
|
||||
this.metadataReaderFactory))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,7 +101,8 @@ class TestTypeExcludeFilterTests {
|
||||
@Test
|
||||
void matchesNestedConfigurationClassWithoutTestNgAnnotation() throws Exception {
|
||||
assertThat(this.filter.match(getMetadataReader(AbstractTestNgTestWithConfig.Config.class),
|
||||
this.metadataReaderFactory)).isTrue();
|
||||
this.metadataReaderFactory))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
private MetadataReader getMetadataReader(Class<?> source) throws IOException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -71,7 +71,7 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
|
||||
String key = "test." + UUID.randomUUID();
|
||||
assertThat(System.getProperties().containsKey(key)).isFalse();
|
||||
get().withSystemProperties(key + "=value")
|
||||
.run((context) -> assertThat(System.getProperties()).containsEntry(key, "value"));
|
||||
.run((context) -> assertThat(System.getProperties()).containsEntry(key, "value"));
|
||||
assertThat(System.getProperties().containsKey(key)).isFalse();
|
||||
}
|
||||
|
||||
@@ -79,8 +79,9 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
|
||||
void runWithSystemPropertiesWhenContextFailsShouldRemoveProperties() {
|
||||
String key = "test." + UUID.randomUUID();
|
||||
assertThat(System.getProperties().containsKey(key)).isFalse();
|
||||
get().withSystemProperties(key + "=value").withUserConfiguration(FailingConfig.class)
|
||||
.run((context) -> assertThat(context).hasFailed());
|
||||
get().withSystemProperties(key + "=value")
|
||||
.withUserConfiguration(FailingConfig.class)
|
||||
.run((context) -> assertThat(context).hasFailed());
|
||||
assertThat(System.getProperties().containsKey(key)).isFalse();
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
|
||||
try {
|
||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||
get().withSystemProperties(key + "=newValue")
|
||||
.run((context) -> assertThat(System.getProperties()).containsEntry(key, "newValue"));
|
||||
.run((context) -> assertThat(System.getProperties()).containsEntry(key, "newValue"));
|
||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||
}
|
||||
finally {
|
||||
@@ -106,7 +107,7 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
|
||||
try {
|
||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||
get().withSystemProperties(key + "=")
|
||||
.run((context) -> assertThat(System.getProperties()).doesNotContainKey(key));
|
||||
.run((context) -> assertThat(System.getProperties()).doesNotContainKey(key));
|
||||
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
|
||||
}
|
||||
finally {
|
||||
@@ -148,8 +149,9 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
|
||||
|
||||
@Test
|
||||
void runWithMultipleConfigurationsShouldRegisterAllConfigurations() {
|
||||
get().withUserConfiguration(FooConfig.class).withConfiguration(UserConfigurations.of(BarConfig.class))
|
||||
.run((context) -> assertThat(context).hasBean("foo").hasBean("bar"));
|
||||
get().withUserConfiguration(FooConfig.class)
|
||||
.withConfiguration(UserConfigurations.of(BarConfig.class))
|
||||
.run((context) -> assertThat(context).hasBean("foo").hasBean("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,30 +162,32 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
|
||||
@Test
|
||||
void runWithClassLoaderShouldSetClassLoaderOnContext() {
|
||||
get().withClassLoader(new FilteredClassLoader(Gson.class.getPackage().getName()))
|
||||
.run((context) -> assertThatExceptionOfType(ClassNotFoundException.class)
|
||||
.isThrownBy(() -> ClassUtils.forName(Gson.class.getName(), context.getClassLoader())));
|
||||
.run((context) -> assertThatExceptionOfType(ClassNotFoundException.class)
|
||||
.isThrownBy(() -> ClassUtils.forName(Gson.class.getName(), context.getClassLoader())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithClassLoaderShouldSetClassLoaderOnConditionContext() {
|
||||
get().withClassLoader(new FilteredClassLoader(Gson.class.getPackage().getName()))
|
||||
.withUserConfiguration(ConditionalConfig.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(ConditionalConfig.class));
|
||||
.withUserConfiguration(ConditionalConfig.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(ConditionalConfig.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void consecutiveRunWithFilteredClassLoaderShouldHaveBeanWithLazyProperties() {
|
||||
get().withClassLoader(new FilteredClassLoader(Gson.class)).withUserConfiguration(LazyConfig.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(ExampleBeanWithLazyProperties.class));
|
||||
get().withClassLoader(new FilteredClassLoader(Gson.class))
|
||||
.withUserConfiguration(LazyConfig.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(ExampleBeanWithLazyProperties.class));
|
||||
|
||||
get().withClassLoader(new FilteredClassLoader(Gson.class)).withUserConfiguration(LazyConfig.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(ExampleBeanWithLazyProperties.class));
|
||||
get().withClassLoader(new FilteredClassLoader(Gson.class))
|
||||
.withUserConfiguration(LazyConfig.class)
|
||||
.run((context) -> assertThat(context).hasSingleBean(ExampleBeanWithLazyProperties.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void thrownRuleWorksWithCheckedException() {
|
||||
get().run((context) -> assertThatIOException().isThrownBy(() -> throwCheckedException("Expected message"))
|
||||
.withMessageContaining("Expected message"));
|
||||
.withMessageContaining("Expected message"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -191,43 +195,48 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
|
||||
get().withUserConfiguration(FooConfig.class).withBean("foo", Integer.class, () -> 42).run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure()).isInstanceOf(BeanDefinitionStoreException.class)
|
||||
.hasMessageContaining("Invalid bean definition with name 'foo'")
|
||||
.hasMessageContaining("@Bean definition illegally overridden by existing bean definition");
|
||||
.hasMessageContaining("Invalid bean definition with name 'foo'")
|
||||
.hasMessageContaining("@Bean definition illegally overridden by existing bean definition");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void runDisablesCircularReferencesByDefault() {
|
||||
get().withUserConfiguration(ExampleConsumerConfiguration.class, ExampleProducerConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context).getFailure().hasRootCauseInstanceOf(BeanCurrentlyInCreationException.class);
|
||||
});
|
||||
.run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context).getFailure().hasRootCauseInstanceOf(BeanCurrentlyInCreationException.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void circularReferencesCanBeAllowed() {
|
||||
get().withAllowCircularReferences(true)
|
||||
.withUserConfiguration(ExampleConsumerConfiguration.class, ExampleProducerConfiguration.class)
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
.withUserConfiguration(ExampleConsumerConfiguration.class, ExampleProducerConfiguration.class)
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithUserBeanShouldBeRegisteredInOrder() {
|
||||
get().withAllowBeanDefinitionOverriding(true).withBean(String.class, () -> "one")
|
||||
.withBean(String.class, () -> "two").withBean(String.class, () -> "three").run((context) -> {
|
||||
assertThat(context).hasBean("string");
|
||||
assertThat(context.getBean("string")).isEqualTo("three");
|
||||
});
|
||||
get().withAllowBeanDefinitionOverriding(true)
|
||||
.withBean(String.class, () -> "one")
|
||||
.withBean(String.class, () -> "two")
|
||||
.withBean(String.class, () -> "three")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasBean("string");
|
||||
assertThat(context.getBean("string")).isEqualTo("three");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithConfigurationsAndUserBeanShouldRegisterUserBeanLast() {
|
||||
get().withAllowBeanDefinitionOverriding(true).withUserConfiguration(FooConfig.class)
|
||||
.withBean("foo", String.class, () -> "overridden").run((context) -> {
|
||||
assertThat(context).hasBean("foo");
|
||||
assertThat(context.getBean("foo")).isEqualTo("overridden");
|
||||
});
|
||||
get().withAllowBeanDefinitionOverriding(true)
|
||||
.withUserConfiguration(FooConfig.class)
|
||||
.withBean("foo", String.class, () -> "overridden")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasBean("foo");
|
||||
assertThat(context.getBean("foo")).isEqualTo("overridden");
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract T get();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,7 +60,7 @@ class ContextConsumerTests {
|
||||
ContextConsumer<ApplicationContext> firstConsumer = (context) -> assertThat(predicate.test(42)).isFalse();
|
||||
ContextConsumer<ApplicationContext> secondConsumer = (context) -> assertThat(predicate.test(24)).isFalse();
|
||||
assertThatThrownBy(() -> firstConsumer.andThen(secondConsumer).accept(mock(ApplicationContext.class)))
|
||||
.isInstanceOf(AssertionError.class);
|
||||
.isInstanceOf(AssertionError.class);
|
||||
then(predicate).should().test(42);
|
||||
then(predicate).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class ContextConsumerTests {
|
||||
ContextConsumer<?> consumer = (context) -> {
|
||||
};
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> consumer.andThen(null))
|
||||
.withMessage("After must not be null");
|
||||
.withMessage("After must not be null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -91,14 +91,14 @@ abstract class AbstractJsonMarshalTesterTests {
|
||||
@Test
|
||||
void createWhenResourceLoadClassIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> createTester(null, ResolvableType.forClass(ExampleObject.class)))
|
||||
.withMessageContaining("ResourceLoadClass must not be null");
|
||||
.isThrownBy(() -> createTester(null, ResolvableType.forClass(ExampleObject.class)))
|
||||
.withMessageContaining("ResourceLoadClass must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenTypeIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> createTester(getClass(), null))
|
||||
.withMessageContaining("Type must not be null");
|
||||
.withMessageContaining("Type must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,7 +45,7 @@ class BasicJsonTesterTests {
|
||||
@Test
|
||||
void createWhenResourceLoadClassIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new BasicJsonTester(null))
|
||||
.withMessageContaining("ResourceLoadClass must not be null");
|
||||
.withMessageContaining("ResourceLoadClass must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,8 +44,8 @@ class DuplicateJsonObjectContextCustomizerFactoryTests {
|
||||
|
||||
@Test
|
||||
void warningForMultipleVersions() {
|
||||
new DuplicateJsonObjectContextCustomizerFactory().createContextCustomizer(null, null).customizeContext(null,
|
||||
null);
|
||||
new DuplicateJsonObjectContextCustomizerFactory().createContextCustomizer(null, null)
|
||||
.customizeContext(null, null);
|
||||
assertThat(this.output).contains("Found multiple occurrences of org.json.JSONObject on the class path:");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,7 +77,7 @@ class GsonTesterIntegrationTests {
|
||||
void stringLiteral() throws Exception {
|
||||
String stringWithSpecialCharacters = "myString";
|
||||
assertThat(this.stringJson.write(stringWithSpecialCharacters)).extractingJsonPathStringValue("@")
|
||||
.isEqualTo(stringWithSpecialCharacters);
|
||||
.isEqualTo(stringWithSpecialCharacters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,14 +37,14 @@ class GsonTesterTests extends AbstractJsonMarshalTesterTests {
|
||||
@Test
|
||||
void initFieldsWhenTestIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> GsonTester.initFields(null, new GsonBuilder().create()))
|
||||
.withMessageContaining("TestInstance must not be null");
|
||||
.withMessageContaining("TestInstance must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void initFieldsWhenMarshallerIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> GsonTester.initFields(new InitFieldsTestClass(), (Gson) null))
|
||||
.withMessageContaining("Marshaller must not be null");
|
||||
.isThrownBy(() -> GsonTester.initFields(new InitFieldsTestClass(), (Gson) null))
|
||||
.withMessageContaining("Marshaller must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -81,7 +81,7 @@ class JacksonTesterIntegrationTests {
|
||||
JacksonTester.initFields(this, new ObjectMapper());
|
||||
String stringWithSpecialCharacters = "myString";
|
||||
assertThat(this.stringJson.write(stringWithSpecialCharacters)).extractingJsonPathStringValue("@")
|
||||
.isEqualTo(stringWithSpecialCharacters);
|
||||
.isEqualTo(stringWithSpecialCharacters);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,7 +95,7 @@ class JacksonTesterIntegrationTests {
|
||||
// restores the symmetry. See gh-15727
|
||||
String stringWithSpecialCharacters = "\u0006\u007F";
|
||||
assertThat(this.stringJson.write(stringWithSpecialCharacters)).extractingJsonPathStringValue("@")
|
||||
.isEqualTo(stringWithSpecialCharacters);
|
||||
.isEqualTo(stringWithSpecialCharacters);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,7 +105,7 @@ class JacksonTesterIntegrationTests {
|
||||
object.setName("Spring");
|
||||
object.setAge(123);
|
||||
JsonContent<ExampleObjectWithView> content = this.jsonWithView.forView(ExampleObjectWithView.TestView.class)
|
||||
.write(object);
|
||||
.write(object);
|
||||
assertThat(content).extractingJsonPathStringValue("@.name").isEqualTo("Spring");
|
||||
assertThat(content).doesNotHaveJsonPathValue("age");
|
||||
}
|
||||
@@ -115,7 +115,7 @@ class JacksonTesterIntegrationTests {
|
||||
JacksonTester.initFields(this, JsonMapper.builder().disable(MapperFeature.DEFAULT_VIEW_INCLUSION).build());
|
||||
ByteArrayResource resource = new ByteArrayResource(JSON.getBytes());
|
||||
ObjectContent<ExampleObjectWithView> content = this.jsonWithView.forView(ExampleObjectWithView.TestView.class)
|
||||
.read(resource);
|
||||
.read(resource);
|
||||
assertThat(content.getObject().getName()).isEqualTo("Spring");
|
||||
assertThat(content.getObject().getAge()).isEqualTo(0);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class JacksonTesterIntegrationTests {
|
||||
JacksonTester.initFields(this, JsonMapper.builder().disable(MapperFeature.DEFAULT_VIEW_INCLUSION).build());
|
||||
Reader reader = new StringReader(JSON);
|
||||
ObjectContent<ExampleObjectWithView> content = this.jsonWithView.forView(ExampleObjectWithView.TestView.class)
|
||||
.read(reader);
|
||||
.read(reader);
|
||||
assertThat(content.getObject().getName()).isEqualTo("Spring");
|
||||
assertThat(content.getObject().getAge()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,14 +36,14 @@ class JacksonTesterTests extends AbstractJsonMarshalTesterTests {
|
||||
@Test
|
||||
void initFieldsWhenTestIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> JacksonTester.initFields(null, new ObjectMapper()))
|
||||
.withMessageContaining("TestInstance must not be null");
|
||||
.withMessageContaining("TestInstance must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void initFieldsWhenMarshallerIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> JacksonTester.initFields(new InitFieldsTestClass(), (ObjectMapper) null))
|
||||
.withMessageContaining("Marshaller must not be null");
|
||||
.isThrownBy(() -> JacksonTester.initFields(new InitFieldsTestClass(), (ObjectMapper) null))
|
||||
.withMessageContaining("Marshaller must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,7 +85,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToWhenStringIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,7 +96,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToWhenResourcePathIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo("different.json"));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo("different.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -107,7 +107,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToWhenBytesAreNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT.getBytes()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT.getBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,7 +118,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToWhenFileIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createFile(DIFFERENT)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createFile(DIFFERENT)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,7 +129,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToWhenInputStreamIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createInputStream(DIFFERENT)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createInputStream(DIFFERENT)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,7 +140,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToWhenResourceIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createResource(DIFFERENT)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createResource(DIFFERENT)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,13 +151,13 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenNullActualShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(null)).isEqualToJson(SOURCE));
|
||||
.isThrownBy(() -> assertThat(forJson(null)).isEqualToJson(SOURCE));
|
||||
}
|
||||
|
||||
@Test
|
||||
void isEqualToJsonWhenStringIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -168,7 +168,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenResourcePathIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json"));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,7 +179,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -190,7 +190,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenBytesAreNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,7 +201,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenFileIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -212,7 +212,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenInputStreamIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -223,7 +223,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenResourceIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,7 +234,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isStrictlyEqualToJsonWhenStringIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,7 +245,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isStrictlyEqualToJsonWhenResourcePathIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json"));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -256,7 +256,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isStrictlyEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json", getClass()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json", getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -267,7 +267,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isStrictlyEqualToJsonWhenBytesAreNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME.getBytes()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME.getBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -278,7 +278,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isStrictlyEqualToJsonWhenFileIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createFile(LENIENT_SAME)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createFile(LENIENT_SAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -289,7 +289,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isStrictlyEqualToJsonWhenInputStreamIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createInputStream(LENIENT_SAME)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createInputStream(LENIENT_SAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -300,7 +300,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isStrictlyEqualToJsonWhenResourceIsNotMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createResource(LENIENT_SAME)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createResource(LENIENT_SAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -311,7 +311,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenStringIsNotMatchingAndLenientShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, JSONCompareMode.LENIENT));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, JSONCompareMode.LENIENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -322,7 +322,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenResourcePathIsNotMatchingAndLenientShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", JSONCompareMode.LENIENT));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", JSONCompareMode.LENIENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -343,8 +343,8 @@ class JsonContentAssertTests {
|
||||
|
||||
@Test
|
||||
void isEqualToJsonWhenBytesAreNotMatchingAndLenientShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class).isThrownBy(
|
||||
() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), JSONCompareMode.LENIENT));
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), JSONCompareMode.LENIENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -388,7 +388,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -399,7 +399,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -410,7 +410,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenResourcePathAndClassAreNotMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(), COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(), COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -421,7 +421,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -432,7 +432,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT), COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT), COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -443,7 +443,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenInputStreamIsNotMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT), COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT), COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -454,13 +454,13 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isEqualToJsonWhenResourceIsNotMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT), COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT), COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
void isNotEqualToWhenStringIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -476,7 +476,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToWhenResourcePathIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo("lenient-same.json"));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo("lenient-same.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -487,7 +487,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToWhenBytesAreMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME.getBytes()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME.getBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -498,7 +498,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToWhenFileIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -509,7 +509,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToWhenInputStreamIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(LENIENT_SAME)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(LENIENT_SAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -520,7 +520,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToWhenResourceIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createResource(LENIENT_SAME)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createResource(LENIENT_SAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -531,7 +531,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenStringIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -547,7 +547,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenResourcePathIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json"));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -558,7 +558,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -569,7 +569,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenBytesAreMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -580,7 +580,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenFileIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -591,7 +591,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenInputStreamIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -602,7 +602,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenResourceIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -613,7 +613,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotStrictlyEqualToJsonWhenStringIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -624,7 +624,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotStrictlyEqualToJsonWhenResourcePathIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json"));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -635,7 +635,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotStrictlyEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json", getClass()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json", getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -646,7 +646,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotStrictlyEqualToJsonWhenBytesAreMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE.getBytes()));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE.getBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -657,7 +657,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotStrictlyEqualToJsonWhenFileIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -668,7 +668,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotStrictlyEqualToJsonWhenInputStreamIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createInputStream(SOURCE)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createInputStream(SOURCE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -679,7 +679,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotStrictlyEqualToJsonWhenResourceIsMatchingShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createResource(SOURCE)));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createResource(SOURCE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -690,7 +690,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenStringIsMatchingAndLenientShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, JSONCompareMode.LENIENT));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, JSONCompareMode.LENIENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -712,7 +712,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndLenientShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> assertThat(forJson(SOURCE))
|
||||
.isNotEqualToJson("lenient-same.json", getClass(), JSONCompareMode.LENIENT));
|
||||
.isNotEqualToJson("lenient-same.json", getClass(), JSONCompareMode.LENIENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -745,7 +745,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenInputStreamIsMatchingAndLenientShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> assertThat(forJson(SOURCE))
|
||||
.isNotEqualToJson(createInputStream(LENIENT_SAME), JSONCompareMode.LENIENT));
|
||||
.isNotEqualToJson(createInputStream(LENIENT_SAME), JSONCompareMode.LENIENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -756,7 +756,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenResourceIsMatchingAndLenientShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> assertThat(forJson(SOURCE))
|
||||
.isNotEqualToJson(createResource(LENIENT_SAME), JSONCompareMode.LENIENT));
|
||||
.isNotEqualToJson(createResource(LENIENT_SAME), JSONCompareMode.LENIENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -767,7 +767,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenStringIsMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -778,7 +778,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -800,7 +800,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenBytesAreMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(), COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(), COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -811,7 +811,7 @@ class JsonContentAssertTests {
|
||||
@Test
|
||||
void isNotEqualToJsonWhenFileIsMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), COMPARATOR));
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -832,8 +832,8 @@ class JsonContentAssertTests {
|
||||
|
||||
@Test
|
||||
void isNotEqualToJsonWhenResourceIsMatchingAndComparatorShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class).isThrownBy(
|
||||
() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME), COMPARATOR));
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME), COMPARATOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -855,8 +855,8 @@ class JsonContentAssertTests {
|
||||
void hasJsonPathForNotPresent() {
|
||||
String expression = "missing";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPath(expression))
|
||||
.withMessageContaining("No JSON path \"" + expression + "\" found");
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPath(expression))
|
||||
.withMessageContaining("No JSON path \"" + expression + "\" found");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -878,16 +878,16 @@ class JsonContentAssertTests {
|
||||
void hasJsonPathValueForANullValue() {
|
||||
String expression = "nullname";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPathValue(expression))
|
||||
.withMessageContaining("No value at JSON path \"" + expression + "\"");
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPathValue(expression))
|
||||
.withMessageContaining("No value at JSON path \"" + expression + "\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasJsonPathValueForMissingValue() {
|
||||
String expression = "missing";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPathValue(expression))
|
||||
.withMessageContaining("No value at JSON path \"" + expression + "\"");
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPathValue(expression))
|
||||
.withMessageContaining("No value at JSON path \"" + expression + "\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -899,8 +899,8 @@ class JsonContentAssertTests {
|
||||
void hasJsonPathValueForIndefinitePathWithEmptyResults() {
|
||||
String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).hasJsonPathValue(expression))
|
||||
.withMessageContaining("No value at JSON path \"" + expression + "\"");
|
||||
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).hasJsonPathValue(expression))
|
||||
.withMessageContaining("No value at JSON path \"" + expression + "\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -912,16 +912,16 @@ class JsonContentAssertTests {
|
||||
void doesNotHaveJsonPathForNull() {
|
||||
String expression = "nullname";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).doesNotHaveJsonPath(expression))
|
||||
.withMessageContaining("Expecting no JSON path \"" + expression + "\"");
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).doesNotHaveJsonPath(expression))
|
||||
.withMessageContaining("Expecting no JSON path \"" + expression + "\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotHaveJsonPathForPresent() {
|
||||
String expression = "valuename";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).doesNotHaveJsonPath(expression))
|
||||
.withMessageContaining("Expecting no JSON path \"" + expression + "\"");
|
||||
.isThrownBy(() -> assertThat(forJson(NULLS)).doesNotHaveJsonPath(expression))
|
||||
.withMessageContaining("Expecting no JSON path \"" + expression + "\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -933,25 +933,25 @@ class JsonContentAssertTests {
|
||||
void doesNotHaveJsonPathValueForAnEmptyArray() {
|
||||
String expression = "$.emptyArray";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveJsonPathValue(expression))
|
||||
.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: []");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveJsonPathValue(expression))
|
||||
.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: []");
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotHaveJsonPathValueForAnEmptyMap() {
|
||||
String expression = "$.emptyMap";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveJsonPathValue(expression))
|
||||
.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: {}");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveJsonPathValue(expression))
|
||||
.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: {}");
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotHaveJsonPathValueForIndefinitePathWithResults() {
|
||||
String expression = "$.familyMembers[?(@.name == 'Bart')]";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).doesNotHaveJsonPathValue(expression))
|
||||
.withMessageContaining(
|
||||
"Expected no value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
|
||||
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).doesNotHaveJsonPathValue(expression))
|
||||
.withMessageContaining(
|
||||
"Expected no value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -988,17 +988,17 @@ class JsonContentAssertTests {
|
||||
void hasEmptyJsonPathValueForIndefinitePathWithResults() {
|
||||
String expression = "$.familyMembers[?(@.name == 'Bart')]";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).hasEmptyJsonPathValue(expression))
|
||||
.withMessageContaining(
|
||||
"Expected an empty value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
|
||||
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).hasEmptyJsonPathValue(expression))
|
||||
.withMessageContaining(
|
||||
"Expected an empty value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasEmptyJsonPathValueForWhitespace() {
|
||||
String expression = "$.whitespace";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected an empty value at JSON path \"" + expression + "\" but found: ' '");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected an empty value at JSON path \"" + expression + "\" but found: ' '");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1035,32 +1035,32 @@ class JsonContentAssertTests {
|
||||
void doesNotHaveEmptyJsonPathValueForIndefinitePathWithEmptyResults() {
|
||||
String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).doesNotHaveEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
|
||||
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).doesNotHaveEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotHaveEmptyJsonPathValueForAnEmptyString() {
|
||||
String expression = "$.emptyString";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: ''");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: ''");
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotHaveEmptyJsonPathValueForForAnEmptyArray() {
|
||||
String expression = "$.emptyArray";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotHaveEmptyJsonPathValueForAnEmptyMap() {
|
||||
String expression = "$.emptyMap";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: {}");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
|
||||
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: {}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1077,8 +1077,8 @@ class JsonContentAssertTests {
|
||||
void hasJsonPathStringValueForNonString() {
|
||||
String expression = "$.bool";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathStringValue(expression))
|
||||
.withMessageContaining("Expected a string at JSON path \"" + expression + "\" but found: true");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathStringValue(expression))
|
||||
.withMessageContaining("Expected a string at JSON path \"" + expression + "\" but found: true");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1090,8 +1090,8 @@ class JsonContentAssertTests {
|
||||
void hasJsonPathNumberValueForNonNumber() {
|
||||
String expression = "$.bool";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathNumberValue(expression))
|
||||
.withMessageContaining("Expected a number at JSON path \"" + expression + "\" but found: true");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathNumberValue(expression))
|
||||
.withMessageContaining("Expected a number at JSON path \"" + expression + "\" but found: true");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1103,8 +1103,8 @@ class JsonContentAssertTests {
|
||||
void hasJsonPathBooleanValueForNonBoolean() {
|
||||
String expression = "$.num";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathBooleanValue(expression))
|
||||
.withMessageContaining("Expected a boolean at JSON path \"" + expression + "\" but found: 5");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathBooleanValue(expression))
|
||||
.withMessageContaining("Expected a boolean at JSON path \"" + expression + "\" but found: 5");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1121,8 +1121,8 @@ class JsonContentAssertTests {
|
||||
void hasJsonPathArrayValueForNonArray() {
|
||||
String expression = "$.str";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathArrayValue(expression))
|
||||
.withMessageContaining("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathArrayValue(expression))
|
||||
.withMessageContaining("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1139,8 +1139,8 @@ class JsonContentAssertTests {
|
||||
void hasJsonPathMapValueForNonMap() {
|
||||
String expression = "$.str";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathMapValue(expression))
|
||||
.withMessageContaining("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathMapValue(expression))
|
||||
.withMessageContaining("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1172,8 +1172,8 @@ class JsonContentAssertTests {
|
||||
void extractingJsonPathStringValueForWrongType() {
|
||||
String expression = "$.num";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathStringValue(expression))
|
||||
.withMessageContaining("Expected a string at JSON path \"" + expression + "\" but found: 5");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathStringValue(expression))
|
||||
.withMessageContaining("Expected a string at JSON path \"" + expression + "\" but found: 5");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1190,8 +1190,8 @@ class JsonContentAssertTests {
|
||||
void extractingJsonPathNumberValueForWrongType() {
|
||||
String expression = "$.str";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathNumberValue(expression))
|
||||
.withMessageContaining("Expected a number at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathNumberValue(expression))
|
||||
.withMessageContaining("Expected a number at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1208,8 +1208,8 @@ class JsonContentAssertTests {
|
||||
void extractingJsonPathBooleanValueForWrongType() {
|
||||
String expression = "$.str";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathBooleanValue(expression))
|
||||
.withMessageContaining("Expected a boolean at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathBooleanValue(expression))
|
||||
.withMessageContaining("Expected a boolean at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1231,8 +1231,8 @@ class JsonContentAssertTests {
|
||||
void extractingJsonPathArrayValueForWrongType() {
|
||||
String expression = "$.str";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathArrayValue(expression))
|
||||
.withMessageContaining("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathArrayValue(expression))
|
||||
.withMessageContaining("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1254,8 +1254,8 @@ class JsonContentAssertTests {
|
||||
void extractingJsonPathMapValueForWrongType() {
|
||||
String expression = "$.str";
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathMapValue(expression))
|
||||
.withMessageContaining("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathMapValue(expression))
|
||||
.withMessageContaining("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,23 +38,23 @@ class JsonContentTests {
|
||||
@Test
|
||||
void createWhenResourceLoadClassIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(
|
||||
() -> new JsonContent<ExampleObject>(null, TYPE, JSON, Configuration.defaultConfiguration()))
|
||||
.withMessageContaining("ResourceLoadClass must not be null");
|
||||
.isThrownBy(() -> new JsonContent<ExampleObject>(null, TYPE, JSON, Configuration.defaultConfiguration()))
|
||||
.withMessageContaining("ResourceLoadClass must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenJsonIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
() -> new JsonContent<ExampleObject>(getClass(), TYPE, null, Configuration.defaultConfiguration()))
|
||||
.withMessageContaining("JSON must not be null");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(
|
||||
() -> new JsonContent<ExampleObject>(getClass(), TYPE, null, Configuration.defaultConfiguration()))
|
||||
.withMessageContaining("JSON must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenConfigurationIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new JsonContent<ExampleObject>(getClass(), TYPE, JSON, null))
|
||||
.withMessageContaining("Configuration must not be null");
|
||||
.isThrownBy(() -> new JsonContent<ExampleObject>(getClass(), TYPE, JSON, null))
|
||||
.withMessageContaining("Configuration must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,14 +38,14 @@ class JsonbTesterTests extends AbstractJsonMarshalTesterTests {
|
||||
@Test
|
||||
void initFieldsWhenTestIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> JsonbTester.initFields(null, JsonbBuilder.create()))
|
||||
.withMessageContaining("TestInstance must not be null");
|
||||
.withMessageContaining("TestInstance must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void initFieldsWhenMarshallerIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> JsonbTester.initFields(new InitFieldsTestClass(), (Jsonb) null))
|
||||
.withMessageContaining("Marshaller must not be null");
|
||||
.isThrownBy(() -> JsonbTester.initFields(new InitFieldsTestClass(), (Jsonb) null))
|
||||
.withMessageContaining("Marshaller must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,7 +49,7 @@ class ObjectContentAssertTests {
|
||||
@Test
|
||||
void isEqualToWhenObjectsAreDifferentShouldFail() {
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertThat(forObject(SOURCE)).isEqualTo(DIFFERENT));
|
||||
.isThrownBy(() -> assertThat(forObject(SOURCE)).isEqualTo(DIFFERENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ class ObjectContentTests {
|
||||
@Test
|
||||
void createWhenObjectIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ObjectContent<ExampleObject>(TYPE, null))
|
||||
.withMessageContaining("Object must not be null");
|
||||
.withMessageContaining("Object must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,7 +80,7 @@ class DefinitionsParserTests {
|
||||
MockDefinition fieldDefinition = getMockDefinition(1);
|
||||
assertThat(fieldDefinition.getTypeToMock().resolve()).isEqualTo(ExampleServiceCaller.class);
|
||||
QualifierDefinition qualifier = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(MockBeanOnClassAndField.class, "caller"));
|
||||
.forElement(ReflectionUtils.findField(MockBeanOnClassAndField.class, "caller"));
|
||||
assertThat(fieldDefinition.getQualifier()).isNotNull().isEqualTo(qualifier);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class DefinitionsParserTests {
|
||||
@Test
|
||||
void parseMockBeanMissingClassToMock() {
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.parser.parse(MockBeanMissingClassToMock.class))
|
||||
.withMessageContaining("Unable to deduce type to mock");
|
||||
.withMessageContaining("Unable to deduce type to mock");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,7 +108,7 @@ class DefinitionsParserTests {
|
||||
@Test
|
||||
void parseMockBeanMultipleClassesWithName() {
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.parser.parse(MockBeanMultipleClassesWithName.class))
|
||||
.withMessageContaining("The name attribute can only be used when mocking a single class");
|
||||
.withMessageContaining("The name attribute can only be used when mocking a single class");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,7 +146,7 @@ class DefinitionsParserTests {
|
||||
assertThat(classDefinition.getTypeToSpy().resolve()).isEqualTo(RealExampleService.class);
|
||||
SpyDefinition fieldDefinition = getSpyDefinition(1);
|
||||
QualifierDefinition qualifier = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(SpyBeanOnClassAndField.class, "caller"));
|
||||
.forElement(ReflectionUtils.findField(SpyBeanOnClassAndField.class, "caller"));
|
||||
assertThat(fieldDefinition.getQualifier()).isNotNull().isEqualTo(qualifier);
|
||||
assertThat(fieldDefinition.getTypeToSpy().resolve()).isEqualTo(ExampleServiceCaller.class);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ class DefinitionsParserTests {
|
||||
@Test
|
||||
void parseSpyBeanMissingClassToMock() {
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.parser.parse(SpyBeanMissingClassToMock.class))
|
||||
.withMessageContaining("Unable to deduce type to spy");
|
||||
.withMessageContaining("Unable to deduce type to spy");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,7 +175,7 @@ class DefinitionsParserTests {
|
||||
@Test
|
||||
void parseSpyBeanMultipleClassesWithName() {
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.parser.parse(SpyBeanMultipleClassesWithName.class))
|
||||
.withMessageContaining("The name attribute can only be used when spying a single class");
|
||||
.withMessageContaining("The name attribute can only be used when spying a single class");
|
||||
}
|
||||
|
||||
private MockDefinition getMockDefinition(int index) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,7 @@ class MockBeanContextCachingTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
void clearCache() {
|
||||
Map<MergedContextConfiguration, ApplicationContext> contexts = (Map<MergedContextConfiguration, ApplicationContext>) ReflectionTestUtils
|
||||
.getField(this.contextCache, "contextMap");
|
||||
.getField(this.contextCache, "contextMap");
|
||||
for (ApplicationContext context : contexts.values()) {
|
||||
if (context instanceof ConfigurableApplicationContext) {
|
||||
((ConfigurableApplicationContext) context).close();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,8 +41,8 @@ class MockDefinitionTests {
|
||||
@Test
|
||||
void classToMockMustNotBeNull() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new MockDefinition(null, null, null, null, false, null, null))
|
||||
.withMessageContaining("TypeToMock must not be null");
|
||||
.isThrownBy(() -> new MockDefinition(null, null, null, null, false, null, null))
|
||||
.withMessageContaining("TypeToMock must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,8 +58,8 @@ class MockitoPostProcessorTests {
|
||||
MockitoPostProcessor.register(context);
|
||||
context.register(MultipleBeans.class);
|
||||
assertThatIllegalStateException().isThrownBy(context::refresh)
|
||||
.withMessageContaining("Unable to register mock bean " + ExampleService.class.getName()
|
||||
+ " expected a single matching bean to replace but found [example1, example2]");
|
||||
.withMessageContaining("Unable to register mock bean " + ExampleService.class.getName()
|
||||
+ " expected a single matching bean to replace but found [example1, example2]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,8 +68,8 @@ class MockitoPostProcessorTests {
|
||||
MockitoPostProcessor.register(context);
|
||||
context.register(MultipleQualifiedBeans.class);
|
||||
assertThatIllegalStateException().isThrownBy(context::refresh)
|
||||
.withMessageContaining("Unable to register mock bean " + ExampleService.class.getName()
|
||||
+ " expected a single matching bean to replace but found [example1, example3]");
|
||||
.withMessageContaining("Unable to register mock bean " + ExampleService.class.getName()
|
||||
+ " expected a single matching bean to replace but found [example1, example3]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,7 +94,7 @@ class MockitoPostProcessorTests {
|
||||
assertThat(Mockito.mockingDetails(context.getBean(ExampleService.class)).isMock()).isTrue();
|
||||
assertThat(Mockito.mockingDetails(context.getBean("examplePrimary", ExampleService.class)).isMock()).isTrue();
|
||||
assertThat(Mockito.mockingDetails(context.getBean("exampleQualified", ExampleService.class)).isMock())
|
||||
.isFalse();
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -88,7 +88,7 @@ class MockitoTestExecutionListenerTests {
|
||||
TestContext mockTestContext = mockTestContext(instance);
|
||||
given(mockTestContext.getApplicationContext()).willReturn(this.applicationContext);
|
||||
given(mockTestContext.getAttribute(DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE))
|
||||
.willReturn(Boolean.TRUE);
|
||||
.willReturn(Boolean.TRUE);
|
||||
this.listener.beforeTestMethod(mockTestContext);
|
||||
then(this.postProcessor).should().inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class));
|
||||
assertThat(this.fieldCaptor.getValue().getName()).isEqualTo("mockBean");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,14 +65,14 @@ class QualifierDefinitionTests {
|
||||
@Test
|
||||
void forElementWhenElementIsFieldWithNoQualifiersShouldReturnNull() {
|
||||
QualifierDefinition definition = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "noQualifier"));
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "noQualifier"));
|
||||
assertThat(definition).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void forElementWhenElementIsFieldWithQualifierShouldReturnDefinition() {
|
||||
QualifierDefinition definition = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
|
||||
assertThat(definition).isNotNull();
|
||||
}
|
||||
|
||||
@@ -97,26 +97,29 @@ class QualifierDefinitionTests {
|
||||
@Test
|
||||
void hashCodeAndEqualsShouldWorkOnDifferentClasses() {
|
||||
QualifierDefinition directQualifier1 = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
|
||||
QualifierDefinition directQualifier2 = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(ConfigB.class, "directQualifier"));
|
||||
.forElement(ReflectionUtils.findField(ConfigB.class, "directQualifier"));
|
||||
QualifierDefinition differentDirectQualifier1 = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "differentDirectQualifier"));
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "differentDirectQualifier"));
|
||||
QualifierDefinition differentDirectQualifier2 = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(ConfigB.class, "differentDirectQualifier"));
|
||||
.forElement(ReflectionUtils.findField(ConfigB.class, "differentDirectQualifier"));
|
||||
QualifierDefinition customQualifier1 = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "customQualifier"));
|
||||
.forElement(ReflectionUtils.findField(ConfigA.class, "customQualifier"));
|
||||
QualifierDefinition customQualifier2 = QualifierDefinition
|
||||
.forElement(ReflectionUtils.findField(ConfigB.class, "customQualifier"));
|
||||
.forElement(ReflectionUtils.findField(ConfigB.class, "customQualifier"));
|
||||
assertThat(directQualifier1.hashCode()).isEqualTo(directQualifier2.hashCode());
|
||||
assertThat(differentDirectQualifier1.hashCode()).isEqualTo(differentDirectQualifier2.hashCode());
|
||||
assertThat(customQualifier1.hashCode()).isEqualTo(customQualifier2.hashCode());
|
||||
assertThat(differentDirectQualifier1).isEqualTo(differentDirectQualifier1).isEqualTo(differentDirectQualifier2)
|
||||
.isNotEqualTo(directQualifier2);
|
||||
assertThat(directQualifier1).isEqualTo(directQualifier1).isEqualTo(directQualifier2)
|
||||
.isNotEqualTo(differentDirectQualifier1);
|
||||
assertThat(customQualifier1).isEqualTo(customQualifier1).isEqualTo(customQualifier2)
|
||||
.isNotEqualTo(differentDirectQualifier1);
|
||||
assertThat(differentDirectQualifier1).isEqualTo(differentDirectQualifier1)
|
||||
.isEqualTo(differentDirectQualifier2)
|
||||
.isNotEqualTo(directQualifier2);
|
||||
assertThat(directQualifier1).isEqualTo(directQualifier1)
|
||||
.isEqualTo(directQualifier2)
|
||||
.isNotEqualTo(differentDirectQualifier1);
|
||||
assertThat(customQualifier1).isEqualTo(customQualifier1)
|
||||
.isEqualTo(customQualifier2)
|
||||
.isNotEqualTo(differentDirectQualifier1);
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,7 @@ class SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests {
|
||||
void testSpying() {
|
||||
assertThat(this.caller.sayGreeting()).isEqualTo("I say two");
|
||||
assertThat(Mockito.mockingDetails(this.spy).getMockCreationSettings().getMockName().toString())
|
||||
.isEqualTo("two");
|
||||
.isEqualTo("two");
|
||||
then(this.spy).should().greeting();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,7 @@ class SpyDefinitionTests {
|
||||
@Test
|
||||
void classToSpyMustNotBeNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new SpyDefinition(null, null, null, true, null))
|
||||
.withMessageContaining("TypeToSpy must not be null");
|
||||
.withMessageContaining("TypeToSpy must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,14 +81,14 @@ class SpyDefinitionTests {
|
||||
void createSpyWhenNullInstanceShouldThrowException() {
|
||||
SpyDefinition definition = new SpyDefinition("name", REAL_SERVICE_TYPE, MockReset.BEFORE, true, null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> definition.createSpy(null))
|
||||
.withMessageContaining("Instance must not be null");
|
||||
.withMessageContaining("Instance must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createSpyWhenWrongInstanceShouldThrowException() {
|
||||
SpyDefinition definition = new SpyDefinition("name", REAL_SERVICE_TYPE, MockReset.BEFORE, true, null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> definition.createSpy(new ExampleServiceCaller(null)))
|
||||
.withMessageContaining("must be an instance of");
|
||||
.withMessageContaining("must be an instance of");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -103,7 +103,7 @@ class TestPropertyValuesTests {
|
||||
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment, Type.SYSTEM_ENVIRONMENT);
|
||||
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("BAZ");
|
||||
assertThat(this.environment.getPropertySources()
|
||||
.contains("test-" + StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)).isTrue();
|
||||
.contains("test-" + StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,7 +118,7 @@ class TestPropertyValuesTests {
|
||||
TestPropertyValues.of("foo.bar=baz", "hello.world=hi").applyTo(this.environment, Type.MAP, "other");
|
||||
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment, Type.SYSTEM_ENVIRONMENT, "other");
|
||||
assertThat(this.environment.getPropertySources().get("other"))
|
||||
.isInstanceOf(SystemEnvironmentPropertySource.class);
|
||||
.isInstanceOf(SystemEnvironmentPropertySource.class);
|
||||
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("BAZ");
|
||||
assertThat(this.environment.getProperty("hello.world")).isNull();
|
||||
}
|
||||
@@ -133,8 +133,10 @@ class TestPropertyValuesTests {
|
||||
|
||||
@Test
|
||||
void andShouldChainAndAddSingleKeyValue() {
|
||||
TestPropertyValues.of("foo.bar=baz").and("hello.world=hi").and("bling.blah=bing").applyTo(this.environment,
|
||||
Type.MAP);
|
||||
TestPropertyValues.of("foo.bar=baz")
|
||||
.and("hello.world=hi")
|
||||
.and("bling.blah=bing")
|
||||
.applyTo(this.environment, Type.MAP);
|
||||
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("baz");
|
||||
assertThat(this.environment.getProperty("hello.world")).isEqualTo("hi");
|
||||
assertThat(this.environment.getProperty("bling.blah")).isEqualTo("bing");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -115,7 +115,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
||||
// is null in app properties
|
||||
addTestPropertySource("0", null);
|
||||
this.propertySources
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "8080")));
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "8080")));
|
||||
this.postProcessor.postProcessEnvironment(this.environment, null);
|
||||
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
|
||||
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("");
|
||||
@@ -125,7 +125,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
||||
void postProcessWhenTestServerPortIsZeroAndManagementPortIsNotNullAndDifferentInProduction() {
|
||||
addTestPropertySource("0", null);
|
||||
this.propertySources
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "8081")));
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "8081")));
|
||||
this.postProcessor.postProcessEnvironment(this.environment, null);
|
||||
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
|
||||
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0");
|
||||
@@ -135,7 +135,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
||||
void postProcessWhenTestServerPortIsZeroAndManagementPortMinusOne() {
|
||||
addTestPropertySource("0", null);
|
||||
this.propertySources
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "-1")));
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "-1")));
|
||||
this.postProcessor.postProcessEnvironment(this.environment, null);
|
||||
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
|
||||
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("-1");
|
||||
@@ -145,7 +145,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
||||
void postProcessWhenTestServerPortIsZeroAndManagementPortIsAnInteger() {
|
||||
addTestPropertySource("0", null);
|
||||
this.propertySources
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", 8081)));
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", 8081)));
|
||||
this.postProcessor.postProcessEnvironment(this.environment, null);
|
||||
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
|
||||
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0");
|
||||
@@ -155,10 +155,10 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
||||
void postProcessWhenManagementServerPortPlaceholderPresentShouldResolvePlaceholder() {
|
||||
addTestPropertySource("0", null);
|
||||
MapPropertySource testPropertySource = (MapPropertySource) this.propertySources
|
||||
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
testPropertySource.getSource().put("port", "9090");
|
||||
this.propertySources
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "${port}")));
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "${port}")));
|
||||
this.postProcessor.postProcessEnvironment(this.environment, null);
|
||||
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
|
||||
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0");
|
||||
@@ -168,17 +168,17 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
||||
void postProcessWhenManagementServerPortPlaceholderAbsentShouldFail() {
|
||||
addTestPropertySource("0", null);
|
||||
this.propertySources
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "${port}")));
|
||||
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "${port}")));
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
|
||||
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");
|
||||
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
|
||||
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
void postProcessWhenServerPortPlaceholderPresentShouldResolvePlaceholder() {
|
||||
addTestPropertySource("0", null);
|
||||
MapPropertySource testPropertySource = (MapPropertySource) this.propertySources
|
||||
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
testPropertySource.getSource().put("port", "8080");
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put("server.port", "${port}");
|
||||
@@ -197,8 +197,8 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
|
||||
source.put("management.server.port", "9090");
|
||||
this.propertySources.addLast(new MapPropertySource("other", source));
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
|
||||
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");
|
||||
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
|
||||
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");
|
||||
}
|
||||
|
||||
private void addTestPropertySource(String serverPort, String managementPort) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,21 +43,21 @@ class LocalHostUriTemplateHandlerTests {
|
||||
@Test
|
||||
void createWhenEnvironmentIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new LocalHostUriTemplateHandler(null))
|
||||
.withMessageContaining("Environment must not be null");
|
||||
.withMessageContaining("Environment must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenSchemeIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new LocalHostUriTemplateHandler(new MockEnvironment(), null))
|
||||
.withMessageContaining("Scheme must not be null");
|
||||
.isThrownBy(() -> new LocalHostUriTemplateHandler(new MockEnvironment(), null))
|
||||
.withMessageContaining("Scheme must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenHandlerIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new LocalHostUriTemplateHandler(new MockEnvironment(), "http", null))
|
||||
.withMessageContaining("Handler must not be null");
|
||||
.isThrownBy(() -> new LocalHostUriTemplateHandler(new MockEnvironment(), "http", null))
|
||||
.withMessageContaining("Handler must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,13 +50,13 @@ class MockServerRestTemplateCustomizerTests {
|
||||
MockServerRestTemplateCustomizer customizer = new MockServerRestTemplateCustomizer();
|
||||
customizer.customize(new RestTemplate());
|
||||
assertThat(customizer.getServer()).extracting("expectationManager")
|
||||
.isInstanceOf(SimpleRequestExpectationManager.class);
|
||||
.isInstanceOf(SimpleRequestExpectationManager.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenExpectationManagerClassIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new MockServerRestTemplateCustomizer(null))
|
||||
.withMessageContaining("ExpectationManager must not be null");
|
||||
.withMessageContaining("ExpectationManager must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,7 +65,7 @@ class MockServerRestTemplateCustomizerTests {
|
||||
UnorderedRequestExpectationManager.class);
|
||||
customizer.customize(new RestTemplate());
|
||||
assertThat(customizer.getServer()).extracting("expectationManager")
|
||||
.isInstanceOf(UnorderedRequestExpectationManager.class);
|
||||
.isInstanceOf(UnorderedRequestExpectationManager.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,7 +74,7 @@ class MockServerRestTemplateCustomizerTests {
|
||||
UnorderedRequestExpectationManager.class);
|
||||
customizer.customize(new RestTemplateBuilder().rootUri("https://example.com").build());
|
||||
assertThat(customizer.getServer()).extracting("expectationManager")
|
||||
.isInstanceOf(RootUriRequestExpectationManager.class);
|
||||
.isInstanceOf(RootUriRequestExpectationManager.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,7 +82,7 @@ class MockServerRestTemplateCustomizerTests {
|
||||
this.customizer.setDetectRootUri(false);
|
||||
this.customizer.customize(new RestTemplateBuilder().rootUri("https://example.com").build());
|
||||
assertThat(this.customizer.getServer()).extracting("expectationManager")
|
||||
.isInstanceOf(SimpleRequestExpectationManager.class);
|
||||
.isInstanceOf(SimpleRequestExpectationManager.class);
|
||||
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ class MockServerRestTemplateCustomizerTests {
|
||||
@Test
|
||||
void getServerWhenNoServersAreBoundShouldThrowException() {
|
||||
assertThatIllegalStateException().isThrownBy(this.customizer::getServer)
|
||||
.withMessageContaining("Unable to return a single MockRestServiceServer since "
|
||||
+ "MockServerRestTemplateCustomizer has not been bound to a RestTemplate");
|
||||
.withMessageContaining("Unable to return a single MockRestServiceServer since "
|
||||
+ "MockServerRestTemplateCustomizer has not been bound to a RestTemplate");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -106,8 +106,8 @@ class MockServerRestTemplateCustomizerTests {
|
||||
this.customizer.customize(new RestTemplate());
|
||||
this.customizer.customize(new RestTemplate());
|
||||
assertThatIllegalStateException().isThrownBy(this.customizer::getServer)
|
||||
.withMessageContaining("Unable to return a single MockRestServiceServer since "
|
||||
+ "MockServerRestTemplateCustomizer has been bound to more than one RestTemplate");
|
||||
.withMessageContaining("Unable to return a single MockRestServiceServer since "
|
||||
+ "MockServerRestTemplateCustomizer has been bound to more than one RestTemplate");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,8 @@ class NoTestRestTemplateBeanChecker implements ImportSelector, BeanFactoryAware
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory,
|
||||
TestRestTemplate.class)).isEmpty();
|
||||
TestRestTemplate.class))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -71,13 +71,13 @@ class RootUriRequestExpectationManagerTests {
|
||||
@Test
|
||||
void createWhenRootUriIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new RootUriRequestExpectationManager(null, this.delegate))
|
||||
.withMessageContaining("RootUri must not be null");
|
||||
.withMessageContaining("RootUri must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenExpectationManagerIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new RootUriRequestExpectationManager(this.uri, null))
|
||||
.withMessageContaining("ExpectationManager must not be null");
|
||||
.withMessageContaining("ExpectationManager must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,9 +112,9 @@ class RootUriRequestExpectationManagerTests {
|
||||
ClientHttpRequest request = mock(ClientHttpRequest.class);
|
||||
given(request.getURI()).willReturn(new URI(this.uri + "/hello"));
|
||||
given(this.delegate.validateRequest(any(ClientHttpRequest.class)))
|
||||
.willThrow(new AssertionError("Request URI expected:</hello> was:<https://example.com/bad>"));
|
||||
.willThrow(new AssertionError("Request URI expected:</hello> was:<https://example.com/bad>"));
|
||||
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.manager.validateRequest(request))
|
||||
.withMessageContaining("Request URI expected:<https://example.com/hello>");
|
||||
.withMessageContaining("Request URI expected:<https://example.com/hello>");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -168,8 +168,8 @@ class RootUriRequestExpectationManagerTests {
|
||||
MockRestServiceServer server = RootUriRequestExpectationManager.bindTo(restTemplate);
|
||||
server.expect(requestTo("/hello")).andRespond(withSuccess());
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> restTemplate.getForEntity("https://spring.io/hello", String.class))
|
||||
.withMessageContaining("expected:<https://example.com/hello> but was:<https://spring.io/hello>");
|
||||
.isThrownBy(() -> restTemplate.getForEntity("https://spring.io/hello", String.class))
|
||||
.withMessageContaining("expected:<https://example.com/hello> but was:<https://spring.io/hello>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -82,7 +82,7 @@ class TestRestTemplateTests {
|
||||
void simple() {
|
||||
// The Apache client is on the classpath so we get the fully-fledged factory
|
||||
assertThat(new TestRestTemplate().getRestTemplate().getRequestFactory())
|
||||
.isInstanceOf(HttpComponentsClientHttpRequestFactory.class);
|
||||
.isInstanceOf(HttpComponentsClientHttpRequestFactory.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,7 +90,7 @@ class TestRestTemplateTests {
|
||||
RestTemplateBuilder builder = new RestTemplateBuilder().requestFactory(OkHttp3ClientHttpRequestFactory.class);
|
||||
TestRestTemplate testRestTemplate = new TestRestTemplate(builder);
|
||||
assertThat(testRestTemplate.getRestTemplate().getRequestFactory())
|
||||
.isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
|
||||
.isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,7 +134,8 @@ class TestRestTemplateTests {
|
||||
void options() {
|
||||
TestRestTemplate template = new TestRestTemplate(HttpClientOption.ENABLE_REDIRECTS);
|
||||
CustomHttpComponentsClientHttpRequestFactory factory = (CustomHttpComponentsClientHttpRequestFactory) template
|
||||
.getRestTemplate().getRequestFactory();
|
||||
.getRestTemplate()
|
||||
.getRequestFactory();
|
||||
RequestConfig config = factory.getRequestConfig();
|
||||
assertThat(config.isRedirectsEnabled()).isTrue();
|
||||
}
|
||||
@@ -155,7 +156,8 @@ class TestRestTemplateTests {
|
||||
method.getParameterTypes());
|
||||
assertThat(equivalent).as("Method %s not found", method).isNotNull();
|
||||
assertThat(Modifier.isPublic(equivalent.getModifiers()))
|
||||
.as("Method %s should have been public", equivalent).isTrue();
|
||||
.as("Method %s should have been public", equivalent)
|
||||
.isTrue();
|
||||
try {
|
||||
equivalent.invoke(restTemplate, mockArguments(method.getParameterTypes()));
|
||||
}
|
||||
@@ -219,8 +221,11 @@ class TestRestTemplateTests {
|
||||
}
|
||||
|
||||
private List<Class<?>> getConverterClasses(TestRestTemplate testRestTemplate) {
|
||||
return testRestTemplate.getRestTemplate().getMessageConverters().stream().map(Object::getClass)
|
||||
.collect(Collectors.toList());
|
||||
return testRestTemplate.getRestTemplate()
|
||||
.getMessageConverters()
|
||||
.stream()
|
||||
.map(Object::getClass)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -271,14 +276,14 @@ class TestRestTemplateTests {
|
||||
@Test
|
||||
void exchangeWithRequestEntityAndClassHandlesRelativeUris() throws IOException {
|
||||
verifyRelativeUriHandling((testRestTemplate, relativeUri) -> testRestTemplate
|
||||
.exchange(new RequestEntity<String>(HttpMethod.GET, relativeUri), String.class));
|
||||
.exchange(new RequestEntity<String>(HttpMethod.GET, relativeUri), String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void exchangeWithRequestEntityAndParameterizedTypeReferenceHandlesRelativeUris() throws IOException {
|
||||
verifyRelativeUriHandling((testRestTemplate, relativeUri) -> testRestTemplate.exchange(
|
||||
new RequestEntity<String>(HttpMethod.GET, relativeUri), new ParameterizedTypeReference<String>() {
|
||||
}));
|
||||
verifyRelativeUriHandling((testRestTemplate, relativeUri) -> testRestTemplate
|
||||
.exchange(new RequestEntity<String>(HttpMethod.GET, relativeUri), new ParameterizedTypeReference<String>() {
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,7 @@ class LocalHostWebClientTests {
|
||||
@Test
|
||||
void createWhenEnvironmentIsNullWillThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new LocalHostWebClient(null))
|
||||
.withMessageContaining("Environment must not be null");
|
||||
.withMessageContaining("Environment must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,20 +63,20 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
|
||||
@Test
|
||||
void createWhenEnvironmentIsNullWillThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null))
|
||||
.withMessageContaining("Environment must not be null");
|
||||
.withMessageContaining("Environment must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWithJavascriptFlagWhenEnvironmentIsNullWillThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, true))
|
||||
.withMessageContaining("Environment must not be null");
|
||||
.withMessageContaining("Environment must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWithBrowserVersionWhenEnvironmentIsNullWillThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, BrowserVersion.CHROME))
|
||||
.withMessageContaining("Environment must not be null");
|
||||
.isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, BrowserVersion.CHROME))
|
||||
.withMessageContaining("Environment must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,8 +85,8 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
|
||||
given(capabilities.getBrowserName()).willReturn("htmlunit");
|
||||
given(capabilities.getBrowserVersion()).willReturn("chrome");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, capabilities))
|
||||
.withMessageContaining("Environment must not be null");
|
||||
.isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, capabilities))
|
||||
.withMessageContaining("Environment must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,8 @@ class NoWebTestClientBeanChecker implements ImportSelector, BeanFactoryAware {
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory,
|
||||
WebTestClient.class)).isEmpty();
|
||||
WebTestClient.class))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user