Upgrade to AssertJ 3.16
This commit is contained in:
parent
b1c1a232ca
commit
12e05280ad
|
@ -178,7 +178,7 @@ configure(allprojects) { project ->
|
|||
dependency "org.testng:testng:7.1.0"
|
||||
dependency "org.hamcrest:hamcrest:2.1"
|
||||
dependency "org.awaitility:awaitility:3.1.6"
|
||||
dependency "org.assertj:assertj-core:3.15.0"
|
||||
dependency "org.assertj:assertj-core:3.16.0"
|
||||
dependencySet(group: 'org.xmlunit', version: '2.6.2') {
|
||||
entry 'xmlunit-assertj'
|
||||
entry('xmlunit-matchers') {
|
||||
|
|
|
@ -61,7 +61,7 @@ class ScheduledAndTransactionalAnnotationIntegrationTests {
|
|||
ctx.register(Config.class, JdkProxyTxConfig.class, RepoConfigA.class);
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(ctx::refresh)
|
||||
.satisfies(ex -> assertThat(ex.getRootCause()).isInstanceOf(IllegalStateException.class));
|
||||
.withCauseInstanceOf(IllegalStateException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
|
@ -360,14 +360,14 @@ public class CallbacksSecurityTests {
|
|||
public void testCustomStaticFactoryMethod() throws Exception {
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
beanFactory.getBean("custom-static-factory-method"))
|
||||
.satisfies(ex -> assertThat(ex.getMostSpecificCause()).isInstanceOf(SecurityException.class));
|
||||
.satisfies(mostSpecificCauseOf(SecurityException.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomInstanceFactoryMethod() throws Exception {
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
beanFactory.getBean("custom-factory-method"))
|
||||
.satisfies(ex -> assertThat(ex.getMostSpecificCause()).isInstanceOf(SecurityException.class));
|
||||
.satisfies(mostSpecificCauseOf(SecurityException.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -43,9 +43,10 @@ public class BeanValidationPostProcessorTests {
|
|||
ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class));
|
||||
ac.registerBeanDefinition("capp", new RootBeanDefinition(CommonAnnotationBeanPostProcessor.class));
|
||||
ac.registerBeanDefinition("bean", new RootBeanDefinition(NotNullConstrainedBean.class));
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(
|
||||
ac::refresh)
|
||||
.satisfies(ex -> assertThat(ex.getRootCause().getMessage()).contains("testBean", "invalid"));
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(ac::refresh)
|
||||
.havingRootCause()
|
||||
.withMessageContainingAll("testBean", "invalid");
|
||||
ac.close();
|
||||
}
|
||||
|
||||
|
@ -81,9 +82,10 @@ public class BeanValidationPostProcessorTests {
|
|||
bd.getPropertyValues().add("testBean", new TestBean());
|
||||
bd.getPropertyValues().add("stringValue", "s");
|
||||
ac.registerBeanDefinition("bean", bd);
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(
|
||||
ac::refresh)
|
||||
.satisfies(ex -> assertThat(ex.getRootCause().getMessage()).contains("stringValue", "invalid"));
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(ac::refresh)
|
||||
.havingRootCause()
|
||||
.withMessageContainingAll("stringValue", "invalid");
|
||||
ac.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -138,20 +138,22 @@ public class ProxyFactoryBeanTests {
|
|||
private void testDoubleTargetSourceIsRejected(String name) {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(DBL_TARGETSOURCE_CONTEXT, CLASS));
|
||||
assertThatExceptionOfType(BeanCreationException.class).as("Should not allow TargetSource to be specified in interceptorNames as well as targetSource property").isThrownBy(() ->
|
||||
bf.getBean(name))
|
||||
.withCauseInstanceOf(AopConfigException.class)
|
||||
.satisfies(ex -> assertThat(ex.getCause().getMessage()).contains("TargetSource"));
|
||||
assertThatExceptionOfType(BeanCreationException.class).as("Should not allow TargetSource to be specified in interceptorNames as well as targetSource property")
|
||||
.isThrownBy(() -> bf.getBean(name))
|
||||
.havingCause()
|
||||
.isInstanceOf(AopConfigException.class)
|
||||
.withMessageContaining("TargetSource");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTargetSourceNotAtEndOfInterceptorNamesIsRejected() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(NOTLAST_TARGETSOURCE_CONTEXT, CLASS));
|
||||
assertThatExceptionOfType(BeanCreationException.class).as("TargetSource or non-advised object must be last in interceptorNames").isThrownBy(() ->
|
||||
bf.getBean("targetSourceNotLast"))
|
||||
.withCauseInstanceOf(AopConfigException.class)
|
||||
.satisfies(ex -> assertThat(ex.getCause().getMessage()).contains("interceptorNames"));
|
||||
assertThatExceptionOfType(BeanCreationException.class).as("TargetSource or non-advised object must be last in interceptorNames")
|
||||
.isThrownBy(() -> bf.getBean("targetSourceNotLast"))
|
||||
.havingCause()
|
||||
.isInstanceOf(AopConfigException.class)
|
||||
.withMessageContaining("interceptorNames");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -311,9 +313,9 @@ public class ProxyFactoryBeanTests {
|
|||
assertThat(config.getAdvisors().length).as("Have correct advisor count").isEqualTo(2);
|
||||
|
||||
ITestBean tb1 = (ITestBean) factory.getBean("test1");
|
||||
assertThatExceptionOfType(Exception.class).isThrownBy(
|
||||
tb1::toString)
|
||||
.satisfies(thrown -> assertThat(thrown).isSameAs(ex));
|
||||
assertThatExceptionOfType(Exception.class)
|
||||
.isThrownBy(tb1::toString)
|
||||
.isSameAs(ex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -126,7 +126,8 @@ public class CustomNamespaceHandlerTests {
|
|||
assertThat(this.beanFactory.getType("debuggingTestBeanNoInstance")).isEqualTo(ApplicationListener.class);
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
this.beanFactory.getBean("debuggingTestBeanNoInstance"))
|
||||
.satisfies(ex -> assertThat(ex.getRootCause()).isInstanceOf(BeanInstantiationException.class));
|
||||
.havingRootCause()
|
||||
.isInstanceOf(BeanInstantiationException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -129,9 +129,9 @@ public class ContextNamespaceHandlerTests {
|
|||
public void propertyPlaceholderLocationWithSystemPropertyMissing() {
|
||||
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext("contextNamespaceHandlerTests-location-placeholder.xml", getClass()))
|
||||
.satisfies(ex -> assertThat(ex.getRootCause())
|
||||
.havingRootCause()
|
||||
.isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("Could not resolve placeholder 'foo' in value \"${foo}\""));
|
||||
.withMessage("Could not resolve placeholder 'foo' in value \"${foo}\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -72,9 +72,9 @@ public class LocalSlsbInvokerInterceptorTests {
|
|||
// default resourceRef=false should cause this to fail, as java:/comp/env will not
|
||||
// automatically be added
|
||||
si.setJndiTemplate(jt);
|
||||
assertThatExceptionOfType(NamingException.class).isThrownBy(
|
||||
si::afterPropertiesSet)
|
||||
.satisfies(ex -> assertThat(ex).isSameAs(nex));
|
||||
assertThatExceptionOfType(NamingException.class)
|
||||
.isThrownBy(si::afterPropertiesSet)
|
||||
.isSameAs(nex);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -132,9 +132,9 @@ public class LocalSlsbInvokerInterceptorTests {
|
|||
pf.addAdvice(si);
|
||||
LocalInterfaceWithBusinessMethods target = (LocalInterfaceWithBusinessMethods) pf.getProxy();
|
||||
|
||||
assertThatExceptionOfType(Exception.class).isThrownBy(
|
||||
target::targetMethod)
|
||||
.satisfies(ex -> assertThat(ex).isSameAs(expected));
|
||||
assertThatExceptionOfType(Exception.class)
|
||||
.isThrownBy(target::targetMethod)
|
||||
.isSameAs(expected);
|
||||
|
||||
verify(mockContext).close();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
|
@ -130,9 +130,9 @@ public class SimpleRemoteSlsbInvokerInterceptorTests {
|
|||
// default resourceRef=false should cause this to fail, as java:/comp/env will not
|
||||
// automatically be added
|
||||
si.setJndiTemplate(jt);
|
||||
assertThatExceptionOfType(NamingException.class).isThrownBy(
|
||||
si::afterPropertiesSet)
|
||||
.satisfies(ex -> assertThat(ex).isSameAs(nex));
|
||||
assertThatExceptionOfType(NamingException.class)
|
||||
.isThrownBy(si::afterPropertiesSet)
|
||||
.isSameAs(nex);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -308,9 +308,9 @@ public class SimpleRemoteSlsbInvokerInterceptorTests {
|
|||
SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);
|
||||
|
||||
RemoteInterface target = (RemoteInterface) configuredProxy(si, RemoteInterface.class);
|
||||
assertThatExceptionOfType(Exception.class).isThrownBy(
|
||||
target::targetMethod)
|
||||
.satisfies(ex -> assertThat(ex).isSameAs(expected));
|
||||
assertThatExceptionOfType(Exception.class)
|
||||
.isThrownBy(target::targetMethod)
|
||||
.isSameAs(expected);
|
||||
verify(mockContext).close();
|
||||
verify(ejb).remove();
|
||||
}
|
||||
|
|
|
@ -157,9 +157,9 @@ public class SimpleRemoteStatelessSessionProxyFactoryBeanTests extends SimpleRem
|
|||
|
||||
MyBusinessMethods mbm = (MyBusinessMethods) fb.getObject();
|
||||
assertThat(Proxy.isProxyClass(mbm.getClass())).isTrue();
|
||||
assertThatExceptionOfType(RemoteException.class).isThrownBy(
|
||||
mbm::getValue)
|
||||
.satisfies(ex -> assertThat(ex).isSameAs(rex));
|
||||
assertThatExceptionOfType(RemoteException.class)
|
||||
.isThrownBy(mbm::getValue)
|
||||
.isSameAs(rex);
|
||||
verify(myEjb).remove();
|
||||
}
|
||||
|
||||
|
|
|
@ -1887,9 +1887,10 @@ public class DataBinderTests {
|
|||
|
||||
MutablePropertyValues mpvs = new MutablePropertyValues();
|
||||
mpvs.add("friends[256]", "");
|
||||
assertThatExceptionOfType(InvalidPropertyException.class).isThrownBy(() ->
|
||||
binder.bind(mpvs))
|
||||
.satisfies(ex -> assertThat(ex.getRootCause()).isInstanceOf(IndexOutOfBoundsException.class));
|
||||
assertThatExceptionOfType(InvalidPropertyException.class)
|
||||
.isThrownBy(() -> binder.bind(mpvs))
|
||||
.havingRootCause()
|
||||
.isInstanceOf(IndexOutOfBoundsException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1913,9 +1914,10 @@ public class DataBinderTests {
|
|||
|
||||
MutablePropertyValues mpvs = new MutablePropertyValues();
|
||||
mpvs.add("friends[16]", "");
|
||||
assertThatExceptionOfType(InvalidPropertyException.class).isThrownBy(() ->
|
||||
binder.bind(mpvs))
|
||||
.satisfies(ex -> assertThat(ex.getRootCause()).isInstanceOf(IndexOutOfBoundsException.class));
|
||||
assertThatExceptionOfType(InvalidPropertyException.class)
|
||||
.isThrownBy(() -> binder.bind(mpvs))
|
||||
.havingRootCause()
|
||||
.isInstanceOf(IndexOutOfBoundsException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,9 +45,10 @@ public class BeanValidationPostProcessorTests {
|
|||
ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class));
|
||||
ac.registerBeanDefinition("capp", new RootBeanDefinition(CommonAnnotationBeanPostProcessor.class));
|
||||
ac.registerBeanDefinition("bean", new RootBeanDefinition(NotNullConstrainedBean.class));
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(
|
||||
ac::refresh)
|
||||
.satisfies(ex -> assertThat(ex.getRootCause().getMessage()).contains("testBean").contains("invalid"));
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(ac::refresh)
|
||||
.havingRootCause()
|
||||
.withMessageContainingAll("testBean", "invalid");
|
||||
ac.close();
|
||||
}
|
||||
|
||||
|
@ -97,9 +98,10 @@ public class BeanValidationPostProcessorTests {
|
|||
bd.getPropertyValues().add("testBean", new TestBean());
|
||||
bd.getPropertyValues().add("stringValue", "s");
|
||||
ac.registerBeanDefinition("bean", bd);
|
||||
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
|
||||
ac.refresh())
|
||||
.satisfies(ex -> assertThat(ex.getRootCause().getMessage()).contains("stringValue").contains("invalid"));
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> ac.refresh())
|
||||
.havingRootCause()
|
||||
.withMessageContainingAll("stringValue", "invalid");
|
||||
ac.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
|
@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test;
|
|||
import org.opentest4j.TestAbortedException;
|
||||
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
|
@ -104,11 +103,11 @@ class TestGroupTests {
|
|||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> assumeGroup(LONG_RUNNING))
|
||||
.withMessageStartingWith("Failed to parse '" + TEST_GROUPS_SYSTEM_PROPERTY + "' system property: ")
|
||||
.withCauseInstanceOf(IllegalArgumentException.class)
|
||||
.satisfies(ex ->
|
||||
assertThat(ex.getCause().getMessage()).isEqualTo(
|
||||
.havingCause()
|
||||
.isInstanceOf(IllegalArgumentException.class)
|
||||
.withMessage(
|
||||
"Unable to find test group 'bogus' when parsing testGroups value: '" + testGroups +
|
||||
"'. Available groups include: [LONG_RUNNING,PERFORMANCE]"));
|
||||
"'. Available groups include: [LONG_RUNNING,PERFORMANCE]");
|
||||
}
|
||||
|
||||
private void setTestGroups(TestGroup... testGroups) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,12 +79,14 @@ class ListenableFutureTaskTests {
|
|||
});
|
||||
task.run();
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(
|
||||
task::get)
|
||||
.satisfies(ex -> assertThat(ex.getCause().getMessage()).isEqualTo(s));
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(
|
||||
task.completable()::get)
|
||||
.satisfies(ex -> assertThat(ex.getCause().getMessage()).isEqualTo(s));
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(task::get)
|
||||
.havingCause()
|
||||
.withMessage(s);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(task.completable()::get)
|
||||
.havingCause()
|
||||
.withMessage(s);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -139,9 +139,9 @@ public class ConstructorInvocationTests extends AbstractExpressionTests {
|
|||
|
||||
// 1 will make it throw a RuntimeException - SpEL will let this through
|
||||
eContext.setVariable("bar", 1);
|
||||
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
|
||||
expr.getValue(eContext))
|
||||
.satisfies(ex -> assertThat(ex).isNotInstanceOf(SpelEvaluationException.class));
|
||||
assertThatExceptionOfType(Exception.class)
|
||||
.isThrownBy(() -> expr.getValue(eContext))
|
||||
.isNotInstanceOf(SpelEvaluationException.class);
|
||||
// A problem occurred whilst attempting to construct an object of type
|
||||
// 'org.springframework.expression.spel.ConstructorInvocationTests$Tester'
|
||||
// using arguments '(java.lang.Integer)'
|
||||
|
|
|
@ -148,8 +148,9 @@ public class MethodInvocationTests extends AbstractExpressionTests {
|
|||
Expression expr = parser.parseExpression("throwException(#bar)");
|
||||
|
||||
context.setVariable("bar", 2);
|
||||
assertThatExceptionOfType(Exception.class).isThrownBy(() -> expr.getValue(context))
|
||||
.satisfies(ex -> assertThat(ex).isNotInstanceOf(SpelEvaluationException.class));
|
||||
assertThatExceptionOfType(Exception.class)
|
||||
.isThrownBy(() -> expr.getValue(context))
|
||||
.isNotInstanceOf(SpelEvaluationException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
|
@ -100,10 +100,11 @@ public class MessagingMessageListenerAdapterTests {
|
|||
javax.jms.Message message = new StubTextMessage("foo");
|
||||
Session session = mock(Session.class);
|
||||
MessagingMessageListenerAdapter listener = getSimpleInstance("fail", String.class);
|
||||
assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() ->
|
||||
listener.onMessage(message, session))
|
||||
.withCauseExactlyInstanceOf(IllegalArgumentException.class)
|
||||
.satisfies(ex -> assertThat(ex.getCause().getMessage()).isEqualTo("Expected test exception"));
|
||||
assertThatExceptionOfType(ListenerExecutionFailedException.class)
|
||||
.isThrownBy(() -> listener.onMessage(message, session))
|
||||
.havingCause()
|
||||
.isExactlyInstanceOf(IllegalArgumentException.class)
|
||||
.withMessage("Expected test exception");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
|
@ -154,10 +154,10 @@ public class HeaderAssertionTests {
|
|||
assertions.contentTypeCompatibleWith(MediaType.parseMediaType("application/*"));
|
||||
|
||||
// MediaTypes not compatible
|
||||
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
|
||||
assertions.contentTypeCompatibleWith(MediaType.TEXT_XML))
|
||||
.satisfies(ex -> assertThat(ex.getCause()).hasMessage("Response header " +
|
||||
"'Content-Type'=[application/xml] is not compatible with [text/xml]"));
|
||||
assertThatExceptionOfType(AssertionError.class)
|
||||
.isThrownBy(() -> assertions.contentTypeCompatibleWith(MediaType.TEXT_XML))
|
||||
.havingCause()
|
||||
.withMessage("Response header 'Content-Type'=[application/xml] is not compatible with [text/xml]");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -74,8 +74,8 @@ public class DefaultResponseErrorHandlerTests {
|
|||
|
||||
assertThatExceptionOfType(HttpClientErrorException.class)
|
||||
.isThrownBy(() -> handler.handleError(response))
|
||||
.satisfies(ex -> assertThat(ex.getResponseHeaders()).isSameAs(headers))
|
||||
.satisfies(ex -> assertThat(ex.getMessage()).isEqualTo("404 Not Found: [Hello World]"));
|
||||
.withMessage("404 Not Found: [Hello World]")
|
||||
.satisfies(ex -> assertThat(ex.getResponseHeaders()).isSameAs(headers));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -92,8 +92,7 @@ public class DefaultResponseErrorHandlerTests {
|
|||
|
||||
assertThatExceptionOfType(HttpClientErrorException.class)
|
||||
.isThrownBy(() -> handler.handleError(response))
|
||||
.satisfies(ex -> assertThat(ex.getMessage()).isEqualTo(
|
||||
"404 Not Found: [" + bodyGenerator.apply(200) + "... (500 bytes)]"));
|
||||
.withMessage("404 Not Found: [" + bodyGenerator.apply(200) + "... (500 bytes)]");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
|
@ -273,20 +273,22 @@ public class ContextLoaderTests {
|
|||
MockServletContext sc = new MockServletContext("");
|
||||
ServletContextListener listener = new ContextLoaderListener();
|
||||
ServletContextEvent event = new ServletContextEvent(sc);
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
|
||||
listener.contextInitialized(event))
|
||||
.withCauseInstanceOf(IOException.class)
|
||||
.satisfies(ex -> assertThat(ex.getCause()).hasMessageContaining("/WEB-INF/applicationContext.xml"));
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
||||
.isThrownBy(() -> listener.contextInitialized(event))
|
||||
.havingCause()
|
||||
.isInstanceOf(IOException.class)
|
||||
.withMessageContaining("/WEB-INF/applicationContext.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFrameworkServletWithDefaultLocation() throws Exception {
|
||||
DispatcherServlet servlet = new DispatcherServlet();
|
||||
servlet.setContextClass(XmlWebApplicationContext.class);
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
|
||||
servlet.init(new MockServletConfig(new MockServletContext(""), "test")))
|
||||
.withCauseInstanceOf(IOException.class)
|
||||
.satisfies(ex -> assertThat(ex.getCause()).hasMessageContaining("/WEB-INF/test-servlet.xml"));
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
||||
.isThrownBy(() -> servlet.init(new MockServletConfig(new MockServletContext(""), "test")))
|
||||
.havingCause()
|
||||
.isInstanceOf(IOException.class)
|
||||
.withMessageContaining("/WEB-INF/test-servlet.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue