Merge pull request #285 from bstick12/master

* pull285:
  Fix TomcatContextCustomizers Assert.notNull checks
pull/285/merge
Phillip Webb 11 years ago
commit 5817a01601

@ -371,7 +371,7 @@ public class TomcatEmbeddedServletContainerFactory extends
*/
public void setTomcatContextCustomizers(
Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers) {
Assert.notNull(this.contextLifecycleListeners,
Assert.notNull(tomcatContextCustomizers,
"TomcatContextCustomizers must not be null");
this.tomcatContextCustomizers = new ArrayList<TomcatContextCustomizer>(
tomcatContextCustomizers);
@ -392,8 +392,8 @@ public class TomcatEmbeddedServletContainerFactory extends
* @param tomcatContextCustomizers the customizers to add
*/
public void addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers) {
Assert.notNull(this.tomcatContextCustomizers,
"TomcatContextCustomizer must not be null");
Assert.notNull(tomcatContextCustomizers,
"TomcatContextCustomizers must not be null");
this.tomcatContextCustomizers.addAll(Arrays.asList(tomcatContextCustomizers));
}
@ -404,8 +404,8 @@ public class TomcatEmbeddedServletContainerFactory extends
*/
public void setTomcatConnectorCustomizers(
Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers) {
Assert.notNull(this.contextLifecycleListeners,
"TomcatConnectorCustomizer must not be null");
Assert.notNull(tomcatConnectorCustomizers,
"TomcatConnectorCustomizers must not be null");
this.tomcatConnectorCustomizers = new ArrayList<TomcatConnectorCustomizer>(
tomcatConnectorCustomizers);
}
@ -417,8 +417,8 @@ public class TomcatEmbeddedServletContainerFactory extends
*/
public void addConnectorCustomizers(
TomcatConnectorCustomizer... tomcatConnectorCustomizers) {
Assert.notNull(this.tomcatContextCustomizers,
"TomcatConnectorCustomizer must not be null");
Assert.notNull(tomcatConnectorCustomizers,
"TomcatConnectorCustomizers must not be null");
this.tomcatConnectorCustomizers.addAll(Arrays.asList(tomcatConnectorCustomizers));
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -138,6 +138,38 @@ public class TomcatEmbeddedServletContainerFactoryTests extends
verify(valve).setNext(any(Valve.class));
}
@Test
public void setNullTomcatContextCustomizersThrows() {
TomcatEmbeddedServletContainerFactory factory = getFactory();
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("TomcatContextCustomizers must not be null");
factory.setTomcatContextCustomizers(null);
}
@Test
public void addNullContextCustomizersThrows() {
TomcatEmbeddedServletContainerFactory factory = getFactory();
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("TomcatContextCustomizers must not be null");
factory.addContextCustomizers((TomcatContextCustomizer[]) null);
}
@Test
public void setNullTomcatConnectorCustomizersThrows() {
TomcatEmbeddedServletContainerFactory factory = getFactory();
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("TomcatConnectorCustomizers must not be null");
factory.setTomcatConnectorCustomizers(null);
}
@Test
public void addNullConnectorCustomizersThrows() {
TomcatEmbeddedServletContainerFactory factory = getFactory();
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("TomcatConnectorCustomizers must not be null");
factory.addConnectorCustomizers((TomcatConnectorCustomizer[]) null);
}
private void assertTimeout(TomcatEmbeddedServletContainerFactory factory, int expected) {
this.container = factory.getEmbeddedServletContainer();
Tomcat tomcat = ((TomcatEmbeddedServletContainer) this.container).getTomcat();

Loading…
Cancel
Save