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( public void setTomcatContextCustomizers(
Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers) { Collection<? extends TomcatContextCustomizer> tomcatContextCustomizers) {
Assert.notNull(this.contextLifecycleListeners, Assert.notNull(tomcatContextCustomizers,
"TomcatContextCustomizers must not be null"); "TomcatContextCustomizers must not be null");
this.tomcatContextCustomizers = new ArrayList<TomcatContextCustomizer>( this.tomcatContextCustomizers = new ArrayList<TomcatContextCustomizer>(
tomcatContextCustomizers); tomcatContextCustomizers);
@ -392,8 +392,8 @@ public class TomcatEmbeddedServletContainerFactory extends
* @param tomcatContextCustomizers the customizers to add * @param tomcatContextCustomizers the customizers to add
*/ */
public void addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers) { public void addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers) {
Assert.notNull(this.tomcatContextCustomizers, Assert.notNull(tomcatContextCustomizers,
"TomcatContextCustomizer must not be null"); "TomcatContextCustomizers must not be null");
this.tomcatContextCustomizers.addAll(Arrays.asList(tomcatContextCustomizers)); this.tomcatContextCustomizers.addAll(Arrays.asList(tomcatContextCustomizers));
} }
@ -404,8 +404,8 @@ public class TomcatEmbeddedServletContainerFactory extends
*/ */
public void setTomcatConnectorCustomizers( public void setTomcatConnectorCustomizers(
Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers) { Collection<? extends TomcatConnectorCustomizer> tomcatConnectorCustomizers) {
Assert.notNull(this.contextLifecycleListeners, Assert.notNull(tomcatConnectorCustomizers,
"TomcatConnectorCustomizer must not be null"); "TomcatConnectorCustomizers must not be null");
this.tomcatConnectorCustomizers = new ArrayList<TomcatConnectorCustomizer>( this.tomcatConnectorCustomizers = new ArrayList<TomcatConnectorCustomizer>(
tomcatConnectorCustomizers); tomcatConnectorCustomizers);
} }
@ -417,8 +417,8 @@ public class TomcatEmbeddedServletContainerFactory extends
*/ */
public void addConnectorCustomizers( public void addConnectorCustomizers(
TomcatConnectorCustomizer... tomcatConnectorCustomizers) { TomcatConnectorCustomizer... tomcatConnectorCustomizers) {
Assert.notNull(this.tomcatContextCustomizers, Assert.notNull(tomcatConnectorCustomizers,
"TomcatConnectorCustomizer must not be null"); "TomcatConnectorCustomizers must not be null");
this.tomcatConnectorCustomizers.addAll(Arrays.asList(tomcatConnectorCustomizers)); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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)); 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) { private void assertTimeout(TomcatEmbeddedServletContainerFactory factory, int expected) {
this.container = factory.getEmbeddedServletContainer(); this.container = factory.getEmbeddedServletContainer();
Tomcat tomcat = ((TomcatEmbeddedServletContainer) this.container).getTomcat(); Tomcat tomcat = ((TomcatEmbeddedServletContainer) this.container).getTomcat();

Loading…
Cancel
Save