Polish "Allow Jetty's ThreadPool to be customized" (gh-5324)

pull/5667/head
Andy Wilkinson 9 years ago
parent 6f094243bb
commit acda000975

@ -913,8 +913,7 @@ public class JettyEmbeddedServletContainerFactory
@Override
public Server createServer(ThreadPool threadPool) {
Server server = new Server(threadPool);
return server;
return new Server(threadPool);
}
}

@ -259,26 +259,23 @@ public class JettyEmbeddedServletContainerFactoryTests
}
@Test
public void threadPool() throws Exception {
public void defaultThreadPool() throws Exception {
JettyEmbeddedServletContainerFactory factory = getFactory();
ThreadPool threadPool = mock(ThreadPool.class);
factory.setThreadPool(threadPool);
JettyEmbeddedServletContainer servletContainer = (JettyEmbeddedServletContainer) factory.getEmbeddedServletContainer();
assertThat(servletContainer.getServer().getThreadPool()).isSameAs(threadPool);
factory.setThreadPool(null);
assertThat(factory.getThreadPool()).isNull();
JettyEmbeddedServletContainer servletContainer = (JettyEmbeddedServletContainer) factory
.getEmbeddedServletContainer();
assertThat(servletContainer.getServer().getThreadPool()).isNotNull();
}
@Test
public void nullThreadPool() throws Exception {
public void customThreadPool() throws Exception {
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setThreadPool(null);
assertThat(factory.getThreadPool()).isNull();
JettyEmbeddedServletContainer servletContainer = (JettyEmbeddedServletContainer) factory.getEmbeddedServletContainer();
assertThat(servletContainer.getServer().getThreadPool()).isNotNull();
ThreadPool threadPool = mock(ThreadPool.class);
factory.setThreadPool(threadPool);
JettyEmbeddedServletContainer servletContainer = (JettyEmbeddedServletContainer) factory
.getEmbeddedServletContainer();
assertThat(servletContainer.getServer().getThreadPool()).isSameAs(threadPool);
}
@Override

Loading…
Cancel
Save