Search in sources :

Example 1 with AbstractServletWebServerFactory

use of cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory in project today-infrastructure by TAKETODAY.

the class UndertowServletWebServerFactoryTests method whenServerIsShuttingDownGracefullyThenRequestsAreRejectedWithServiceUnavailable.

@Test
void whenServerIsShuttingDownGracefullyThenRequestsAreRejectedWithServiceUnavailable() throws Exception {
    AbstractServletWebServerFactory factory = getFactory();
    factory.setShutdown(Shutdown.GRACEFUL);
    BlockingServlet blockingServlet = new BlockingServlet();
    this.webServer = factory.getWebServer((context) -> {
        Dynamic registration = context.addServlet("blockingServlet", blockingServlet);
        registration.addMapping("/blocking");
        registration.setAsyncSupported(true);
    });
    this.webServer.start();
    int port = this.webServer.getPort();
    Future<Object> request = initiateGetRequest(port, "/blocking");
    blockingServlet.awaitQueue();
    AtomicReference<GracefulShutdownResult> result = new AtomicReference<>();
    this.webServer.shutDownGracefully(result::set);
    assertThat(result.get()).isNull();
    blockingServlet.admitOne();
    assertThat(request.get()).isInstanceOf(HttpResponse.class);
    Object rejectedResult = initiateGetRequest(port, "/").get();
    assertThat(rejectedResult).isInstanceOf(HttpResponse.class);
    assertThat(((HttpResponse) rejectedResult).getStatusLine().getStatusCode()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE.value());
    this.webServer.stop();
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) AbstractServletWebServerFactoryTests(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactoryTests) URISyntaxException(java.net.URISyntaxException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Builder(io.undertow.Undertow.Builder) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) Assertions.assertThatIOException(org.assertj.core.api.Assertions.assertThatIOException) AtomicReference(java.util.concurrent.atomic.AtomicReference) Undertow(io.undertow.Undertow) PortInUseException(cn.taketoday.framework.web.server.PortInUseException) SocketException(java.net.SocketException) Future(java.util.concurrent.Future) Charset(java.nio.charset.Charset) Locale(java.util.Locale) Duration(java.time.Duration) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) ReflectionTestUtils(cn.taketoday.test.util.ReflectionTestUtils) ExampleServlet(cn.taketoday.test.web.servlet.ExampleServlet) JspServlet(org.apache.jasper.servlet.JspServlet) InOrder(org.mockito.InOrder) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) IOException(java.io.IOException) ServletContainer(io.undertow.servlet.api.ServletContainer) File(java.io.File) Shutdown(cn.taketoday.framework.web.server.Shutdown) ServletRegistrationBean(cn.taketoday.framework.web.servlet.ServletRegistrationBean) Test(org.junit.jupiter.api.Test) ErrorPage(cn.taketoday.framework.web.server.ErrorPage) GracefulShutdownResult(cn.taketoday.framework.web.server.GracefulShutdownResult) AfterEach(org.junit.jupiter.api.AfterEach) SSLException(javax.net.ssl.SSLException) Mockito.inOrder(org.mockito.Mockito.inOrder) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) HttpResponse(org.apache.http.HttpResponse) HttpStatus(cn.taketoday.http.HttpStatus) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) Matchers.is(org.hamcrest.Matchers.is) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) Awaitility(org.awaitility.Awaitility) Mockito.mock(org.mockito.Mockito.mock) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) GracefulShutdownResult(cn.taketoday.framework.web.server.GracefulShutdownResult) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Example 2 with AbstractServletWebServerFactory

use of cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory in project today-infrastructure by TAKETODAY.

the class TomcatServletWebServerFactoryTests method whenServerIsShuttingDownARequestOnAnIdleConnectionResultsInConnectionReset.

@Test
void whenServerIsShuttingDownARequestOnAnIdleConnectionResultsInConnectionReset() throws Exception {
    AbstractServletWebServerFactory factory = getFactory();
    factory.setShutdown(Shutdown.GRACEFUL);
    BlockingServlet blockingServlet = new BlockingServlet();
    this.webServer = factory.getWebServer((context) -> {
        Dynamic registration = context.addServlet("blockingServlet", blockingServlet);
        registration.addMapping("/blocking");
        registration.setAsyncSupported(true);
    });
    HttpClient httpClient = HttpClients.createMinimal();
    this.webServer.start();
    int port = this.webServer.getPort();
    Future<Object> keepAliveRequest = initiateGetRequest(httpClient, port, "/blocking");
    blockingServlet.awaitQueue();
    blockingServlet.admitOne();
    assertThat(keepAliveRequest.get()).isInstanceOf(HttpResponse.class);
    Future<Object> request = initiateGetRequest(port, "/blocking");
    blockingServlet.awaitQueue();
    this.webServer.shutDownGracefully((result) -> {
    });
    Object idleConnectionRequestResult = Awaitility.await().until(() -> {
        Future<Object> idleConnectionRequest = initiateGetRequest(httpClient, port, "/");
        Object result = idleConnectionRequest.get();
        return result;
    }, (result) -> result instanceof Exception);
    assertThat(idleConnectionRequestResult).isInstanceOfAny(SocketException.class, NoHttpResponseException.class);
    if (idleConnectionRequestResult instanceof SocketException) {
        assertThat((SocketException) idleConnectionRequestResult).hasMessage("Connection reset");
    }
    blockingServlet.admitOne();
    Object response = request.get();
    assertThat(response).isInstanceOf(HttpResponse.class);
    this.webServer.stop();
}
Also used : LinkedMultiValueMap(cn.taketoday.core.LinkedMultiValueMap) Arrays(java.util.Arrays) AbstractServletWebServerFactoryTests(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactoryTests) URISyntaxException(java.net.URISyntaxException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) NoHttpResponseException(org.apache.http.NoHttpResponseException) NamingException(javax.naming.NamingException) ServletException(jakarta.servlet.ServletException) LifecycleListener(org.apache.catalina.LifecycleListener) HttpHostConnectException(org.apache.http.conn.HttpHostConnectException) Future(java.util.concurrent.Future) HttpHeaders(cn.taketoday.http.HttpHeaders) Locale(java.util.Locale) LifecycleState(org.apache.catalina.LifecycleState) Duration(java.time.Duration) Map(java.util.Map) AprLifecycleListener(org.apache.catalina.core.AprLifecycleListener) JspServlet(org.apache.jasper.servlet.JspServlet) InitialContext(javax.naming.InitialContext) SessionIdGenerator(org.apache.catalina.SessionIdGenerator) WebServerException(cn.taketoday.framework.web.server.WebServerException) ResponseEntity(cn.taketoday.http.ResponseEntity) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) ByteArrayResource(cn.taketoday.core.io.ByteArrayResource) JarScanFilter(org.apache.tomcat.JarScanFilter) Mockito.inOrder(org.mockito.Mockito.inOrder) CapturedOutput(cn.taketoday.framework.test.system.CapturedOutput) HttpStatus(cn.taketoday.http.HttpStatus) StandardContext(org.apache.catalina.core.StandardContext) ServletContext(jakarta.servlet.ServletContext) Awaitility(org.awaitility.Awaitility) HttpClients(org.apache.http.impl.client.HttpClients) FileSystemUtils(cn.taketoday.util.FileSystemUtils) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) LifecycleEvent(org.apache.catalina.LifecycleEvent) HttpServletRequest(jakarta.servlet.http.HttpServletRequest) Valve(org.apache.catalina.Valve) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol) Connector(org.apache.catalina.connector.Connector) HashMap(java.util.HashMap) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) AtomicReference(java.util.concurrent.atomic.AtomicReference) PortInUseException(cn.taketoday.framework.web.server.PortInUseException) SocketException(java.net.SocketException) CharsetMapper(org.apache.catalina.util.CharsetMapper) ThrowingCallable(org.assertj.core.api.ThrowableAssert.ThrowingCallable) ArgumentCaptor(org.mockito.ArgumentCaptor) Charset(java.nio.charset.Charset) HttpClient(org.apache.http.client.HttpClient) StandardJarScanFilter(org.apache.tomcat.util.scan.StandardJarScanFilter) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) MultiValueMap(cn.taketoday.core.MultiValueMap) Service(org.apache.catalina.Service) RemoteIpValve(org.apache.catalina.valves.RemoteIpValve) InOrder(org.mockito.InOrder) JarScanType(org.apache.tomcat.JarScanType) BDDMockito.then(org.mockito.BDDMockito.then) IOException(java.io.IOException) Context(org.apache.catalina.Context) HttpServlet(jakarta.servlet.http.HttpServlet) File(java.io.File) MultipartConfigElement(jakarta.servlet.MultipartConfigElement) Shutdown(cn.taketoday.framework.web.server.Shutdown) Tomcat(org.apache.catalina.startup.Tomcat) AfterEach(org.junit.jupiter.api.AfterEach) Container(org.apache.catalina.Container) ProtocolHandler(org.apache.coyote.ProtocolHandler) RestTemplate(cn.taketoday.web.client.RestTemplate) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) HttpResponse(org.apache.http.HttpResponse) StandardWrapper(org.apache.catalina.core.StandardWrapper) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) HttpEntity(cn.taketoday.http.HttpEntity) HttpServletResponse(jakarta.servlet.http.HttpServletResponse) MediaType(cn.taketoday.http.MediaType) SocketException(java.net.SocketException) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) HttpClient(org.apache.http.client.HttpClient) URISyntaxException(java.net.URISyntaxException) NoHttpResponseException(org.apache.http.NoHttpResponseException) NamingException(javax.naming.NamingException) ServletException(jakarta.servlet.ServletException) HttpHostConnectException(org.apache.http.conn.HttpHostConnectException) WebServerException(cn.taketoday.framework.web.server.WebServerException) PortInUseException(cn.taketoday.framework.web.server.PortInUseException) SocketException(java.net.SocketException) IOException(java.io.IOException) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) Test(org.junit.jupiter.api.Test)

Example 3 with AbstractServletWebServerFactory

use of cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory in project today-infrastructure by TAKETODAY.

the class JettyServletWebServerFactoryTests method whenServerIsShuttingDownGracefullyThenResponseToRequestOnIdleConnectionWillHaveAConnectionCloseHeader.

@Test
void whenServerIsShuttingDownGracefullyThenResponseToRequestOnIdleConnectionWillHaveAConnectionCloseHeader() throws Exception {
    AbstractServletWebServerFactory factory = getFactory();
    factory.setShutdown(Shutdown.GRACEFUL);
    BlockingServlet blockingServlet = new BlockingServlet();
    this.webServer = factory.getWebServer((context) -> {
        Dynamic registration = context.addServlet("blockingServlet", blockingServlet);
        registration.addMapping("/blocking");
        registration.setAsyncSupported(true);
    });
    this.webServer.start();
    int port = this.webServer.getPort();
    HttpClient client = HttpClients.createMinimal();
    Future<Object> request = initiateGetRequest(client, port, "/blocking");
    blockingServlet.awaitQueue();
    blockingServlet.admitOne();
    Object response = request.get();
    assertThat(response).isInstanceOf(HttpResponse.class);
    assertThat(((HttpResponse) response).getStatusLine().getStatusCode()).isEqualTo(200);
    assertThat(((HttpResponse) response).getFirstHeader("Connection")).isNull();
    this.webServer.shutDownGracefully((result) -> {
    });
    request = initiateGetRequest(client, port, "/blocking");
    blockingServlet.awaitQueue();
    blockingServlet.admitOne();
    response = request.get();
    assertThat(response).isInstanceOf(HttpResponse.class);
    assertThat(((HttpResponse) response).getStatusLine().getStatusCode()).isEqualTo(200);
    assertThat(((HttpResponse) response).getFirstHeader("Connection")).isNotNull().extracting(Header::getValue).isEqualTo("close");
    this.webServer.stop();
}
Also used : SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Arrays(java.util.Arrays) AbstractServletWebServerFactoryTests(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactoryTests) ClassMatcher(org.eclipse.jetty.webapp.ClassMatcher) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Disabled(org.junit.jupiter.api.Disabled) Header(org.apache.http.Header) HttpHostConnectException(org.apache.http.conn.HttpHostConnectException) InetAddress(java.net.InetAddress) AbstractConfiguration(org.eclipse.jetty.webapp.AbstractConfiguration) Future(java.util.concurrent.Future) Configuration(org.eclipse.jetty.webapp.Configuration) BDDMockito.given(org.mockito.BDDMockito.given) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) Locale(java.util.Locale) Duration(java.time.Duration) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) Server(org.eclipse.jetty.server.Server) Method(java.lang.reflect.Method) JspServlet(org.apache.jasper.servlet.JspServlet) Collection(java.util.Collection) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) WebServerException(cn.taketoday.framework.web.server.WebServerException) ThreadPool(org.eclipse.jetty.util.thread.ThreadPool) Test(org.junit.jupiter.api.Test) GracefulShutdownResult(cn.taketoday.framework.web.server.GracefulShutdownResult) EventListener(java.util.EventListener) Mockito.inOrder(org.mockito.Mockito.inOrder) ServletContextEvent(jakarta.servlet.ServletContextEvent) CapturedOutput(cn.taketoday.framework.test.system.CapturedOutput) Awaitility(org.awaitility.Awaitility) HttpClients(org.apache.http.impl.client.HttpClients) ServletContextListener(jakarta.servlet.ServletContextListener) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Handler(org.eclipse.jetty.server.Handler) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) AtomicReference(java.util.concurrent.atomic.AtomicReference) Compression(cn.taketoday.framework.web.server.Compression) PortInUseException(cn.taketoday.framework.web.server.PortInUseException) Charset(java.nio.charset.Charset) HttpClient(org.apache.http.client.HttpClient) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) ErrorPageErrorHandler(org.eclipse.jetty.servlet.ErrorPageErrorHandler) InOrder(org.mockito.InOrder) Ssl(cn.taketoday.framework.web.server.Ssl) ReflectionUtils(cn.taketoday.util.ReflectionUtils) HandlerWrapper(org.eclipse.jetty.server.handler.HandlerWrapper) Shutdown(cn.taketoday.framework.web.server.Shutdown) ExecutionException(java.util.concurrent.ExecutionException) ServerConnector(org.eclipse.jetty.server.ServerConnector) HttpResponse(org.apache.http.HttpResponse) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) Connector(org.eclipse.jetty.server.Connector) Collections(java.util.Collections) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) HttpClient(org.apache.http.client.HttpClient) HttpResponse(org.apache.http.HttpResponse) Test(org.junit.jupiter.api.Test)

Example 4 with AbstractServletWebServerFactory

use of cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory in project today-infrastructure by TAKETODAY.

the class JettyServletWebServerFactoryTests method whenARequestCompletesAfterGracefulShutdownHasBegunThenItHasAConnectionCloseHeader.

@Test
void whenARequestCompletesAfterGracefulShutdownHasBegunThenItHasAConnectionCloseHeader() throws InterruptedException, ExecutionException {
    AbstractServletWebServerFactory factory = getFactory();
    factory.setShutdown(Shutdown.GRACEFUL);
    BlockingServlet blockingServlet = new BlockingServlet();
    this.webServer = factory.getWebServer((context) -> {
        Dynamic registration = context.addServlet("blockingServlet", blockingServlet);
        registration.addMapping("/blocking");
        registration.setAsyncSupported(true);
    });
    this.webServer.start();
    int port = this.webServer.getPort();
    Future<Object> request = initiateGetRequest(port, "/blocking");
    blockingServlet.awaitQueue();
    AtomicReference<GracefulShutdownResult> result = new AtomicReference<>();
    this.webServer.shutDownGracefully(result::set);
    blockingServlet.admitOne();
    Awaitility.await().atMost(Duration.ofSeconds(5)).until(() -> GracefulShutdownResult.IDLE == result.get());
    Object requestResult = request.get();
    assertThat(requestResult).isInstanceOf(HttpResponse.class);
    assertThat(((HttpResponse) requestResult).getFirstHeader("Connection").getValue()).isEqualTo("close");
}
Also used : SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Arrays(java.util.Arrays) AbstractServletWebServerFactoryTests(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactoryTests) ClassMatcher(org.eclipse.jetty.webapp.ClassMatcher) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Disabled(org.junit.jupiter.api.Disabled) Header(org.apache.http.Header) HttpHostConnectException(org.apache.http.conn.HttpHostConnectException) InetAddress(java.net.InetAddress) AbstractConfiguration(org.eclipse.jetty.webapp.AbstractConfiguration) Future(java.util.concurrent.Future) Configuration(org.eclipse.jetty.webapp.Configuration) BDDMockito.given(org.mockito.BDDMockito.given) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) Locale(java.util.Locale) Duration(java.time.Duration) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) Server(org.eclipse.jetty.server.Server) Method(java.lang.reflect.Method) JspServlet(org.apache.jasper.servlet.JspServlet) Collection(java.util.Collection) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) WebServerException(cn.taketoday.framework.web.server.WebServerException) ThreadPool(org.eclipse.jetty.util.thread.ThreadPool) Test(org.junit.jupiter.api.Test) GracefulShutdownResult(cn.taketoday.framework.web.server.GracefulShutdownResult) EventListener(java.util.EventListener) Mockito.inOrder(org.mockito.Mockito.inOrder) ServletContextEvent(jakarta.servlet.ServletContextEvent) CapturedOutput(cn.taketoday.framework.test.system.CapturedOutput) Awaitility(org.awaitility.Awaitility) HttpClients(org.apache.http.impl.client.HttpClients) ServletContextListener(jakarta.servlet.ServletContextListener) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Handler(org.eclipse.jetty.server.Handler) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) AtomicReference(java.util.concurrent.atomic.AtomicReference) Compression(cn.taketoday.framework.web.server.Compression) PortInUseException(cn.taketoday.framework.web.server.PortInUseException) Charset(java.nio.charset.Charset) HttpClient(org.apache.http.client.HttpClient) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) ErrorPageErrorHandler(org.eclipse.jetty.servlet.ErrorPageErrorHandler) InOrder(org.mockito.InOrder) Ssl(cn.taketoday.framework.web.server.Ssl) ReflectionUtils(cn.taketoday.util.ReflectionUtils) HandlerWrapper(org.eclipse.jetty.server.handler.HandlerWrapper) Shutdown(cn.taketoday.framework.web.server.Shutdown) ExecutionException(java.util.concurrent.ExecutionException) ServerConnector(org.eclipse.jetty.server.ServerConnector) HttpResponse(org.apache.http.HttpResponse) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) Connector(org.eclipse.jetty.server.Connector) Collections(java.util.Collections) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) GracefulShutdownResult(cn.taketoday.framework.web.server.GracefulShutdownResult) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Example 5 with AbstractServletWebServerFactory

use of cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory in project today-infrastructure by TAKETODAY.

the class JettyServletWebServerFactoryTests method whenServerIsShuttingDownGracefullyThenNewConnectionsCannotBeMade.

@Test
void whenServerIsShuttingDownGracefullyThenNewConnectionsCannotBeMade() throws Exception {
    AbstractServletWebServerFactory factory = getFactory();
    factory.setShutdown(Shutdown.GRACEFUL);
    BlockingServlet blockingServlet = new BlockingServlet();
    this.webServer = factory.getWebServer((context) -> {
        Dynamic registration = context.addServlet("blockingServlet", blockingServlet);
        registration.addMapping("/blocking");
        registration.setAsyncSupported(true);
    });
    this.webServer.start();
    int port = this.webServer.getPort();
    Future<Object> request = initiateGetRequest(port, "/blocking");
    blockingServlet.awaitQueue();
    this.webServer.shutDownGracefully((result) -> {
    });
    Future<Object> unconnectableRequest = initiateGetRequest(port, "/");
    blockingServlet.admitOne();
    Object response = request.get();
    assertThat(response).isInstanceOf(HttpResponse.class);
    assertThat(unconnectableRequest.get()).isInstanceOf(HttpHostConnectException.class);
    this.webServer.stop();
}
Also used : SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Arrays(java.util.Arrays) AbstractServletWebServerFactoryTests(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactoryTests) ClassMatcher(org.eclipse.jetty.webapp.ClassMatcher) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Disabled(org.junit.jupiter.api.Disabled) Header(org.apache.http.Header) HttpHostConnectException(org.apache.http.conn.HttpHostConnectException) InetAddress(java.net.InetAddress) AbstractConfiguration(org.eclipse.jetty.webapp.AbstractConfiguration) Future(java.util.concurrent.Future) Configuration(org.eclipse.jetty.webapp.Configuration) BDDMockito.given(org.mockito.BDDMockito.given) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) Locale(java.util.Locale) Duration(java.time.Duration) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) Server(org.eclipse.jetty.server.Server) Method(java.lang.reflect.Method) JspServlet(org.apache.jasper.servlet.JspServlet) Collection(java.util.Collection) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) WebServerException(cn.taketoday.framework.web.server.WebServerException) ThreadPool(org.eclipse.jetty.util.thread.ThreadPool) Test(org.junit.jupiter.api.Test) GracefulShutdownResult(cn.taketoday.framework.web.server.GracefulShutdownResult) EventListener(java.util.EventListener) Mockito.inOrder(org.mockito.Mockito.inOrder) ServletContextEvent(jakarta.servlet.ServletContextEvent) CapturedOutput(cn.taketoday.framework.test.system.CapturedOutput) Awaitility(org.awaitility.Awaitility) HttpClients(org.apache.http.impl.client.HttpClients) ServletContextListener(jakarta.servlet.ServletContextListener) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Handler(org.eclipse.jetty.server.Handler) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) AtomicReference(java.util.concurrent.atomic.AtomicReference) Compression(cn.taketoday.framework.web.server.Compression) PortInUseException(cn.taketoday.framework.web.server.PortInUseException) Charset(java.nio.charset.Charset) HttpClient(org.apache.http.client.HttpClient) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) ErrorPageErrorHandler(org.eclipse.jetty.servlet.ErrorPageErrorHandler) InOrder(org.mockito.InOrder) Ssl(cn.taketoday.framework.web.server.Ssl) ReflectionUtils(cn.taketoday.util.ReflectionUtils) HandlerWrapper(org.eclipse.jetty.server.handler.HandlerWrapper) Shutdown(cn.taketoday.framework.web.server.Shutdown) ExecutionException(java.util.concurrent.ExecutionException) ServerConnector(org.eclipse.jetty.server.ServerConnector) HttpResponse(org.apache.http.HttpResponse) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) Connector(org.eclipse.jetty.server.Connector) Collections(java.util.Collections) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) Dynamic(jakarta.servlet.ServletRegistration.Dynamic) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) Test(org.junit.jupiter.api.Test)

Aggregations

AbstractServletWebServerFactory (cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory)16 Test (org.junit.jupiter.api.Test)16 PortInUseException (cn.taketoday.framework.web.server.PortInUseException)12 Shutdown (cn.taketoday.framework.web.server.Shutdown)12 AbstractServletWebServerFactoryTests (cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactoryTests)12 Dynamic (jakarta.servlet.ServletRegistration.Dynamic)12 Charset (java.nio.charset.Charset)12 Duration (java.time.Duration)12 Arrays (java.util.Arrays)12 Locale (java.util.Locale)12 Map (java.util.Map)12 Future (java.util.concurrent.Future)12 AtomicReference (java.util.concurrent.atomic.AtomicReference)12 HttpResponse (org.apache.http.HttpResponse)12 JspServlet (org.apache.jasper.servlet.JspServlet)12 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)12 Awaitility (org.awaitility.Awaitility)12 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)12 InOrder (org.mockito.InOrder)12 Mockito.inOrder (org.mockito.Mockito.inOrder)12