Tests pass
For Tomcat, failures occur if HttpHandlerServlet buffer size is significantly less than the Tomcat input buffer size. Also on command line Jetty tests fail with port unavailable unless the server from the Tomcat tests is also destroyed.
This commit is contained in:
@@ -34,7 +34,7 @@ import org.springframework.reactive.web.HttpHandler;
|
||||
@WebServlet(asyncSupported = true )
|
||||
public class HttpHandlerServlet extends HttpServlet {
|
||||
|
||||
private static final int BUFFER_SIZE = 4096;
|
||||
private static final int BUFFER_SIZE = 8192;
|
||||
|
||||
private HttpHandler handler;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.Random;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.SocketUtils;
|
||||
@@ -44,8 +43,7 @@ public abstract class AbstractHttpHandlerServletIntegrationTestCase {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
byte[] body = randomBytes();
|
||||
RequestEntity<byte[]>
|
||||
request = new RequestEntity<byte[]>(body, HttpMethod.POST, new URI(url()));
|
||||
RequestEntity<byte[]> request = RequestEntity.post(new URI(url())).body(body);
|
||||
ResponseEntity<byte[]> response = restTemplate.exchange(request, byte[].class);
|
||||
|
||||
assertArrayEquals(body, response.getBody());
|
||||
@@ -56,7 +54,7 @@ public abstract class AbstractHttpHandlerServletIntegrationTestCase {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
String body = randomString();
|
||||
RequestEntity<String> request = new RequestEntity<String>(body, HttpMethod.POST, new URI(url()));
|
||||
RequestEntity<String> request = RequestEntity.post(new URI(url())).body(body);
|
||||
ResponseEntity<String> response = restTemplate.exchange(request, String.class);
|
||||
|
||||
assertEquals(body, response.getBody());
|
||||
|
||||
@@ -50,6 +50,7 @@ public class HttpHandlerServletJettyIntegrationTests
|
||||
@AfterClass
|
||||
public static void stopServer() throws Exception {
|
||||
jettyServer.stop();
|
||||
jettyServer.destroy();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
@@ -33,6 +33,7 @@ public class HttpHandlerServletTomcatIntegrationTests extends AbstractHttpHandle
|
||||
|
||||
private static Tomcat tomcatServer;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void startServer() throws LifecycleException, InterruptedException {
|
||||
tomcatServer = new Tomcat();
|
||||
@@ -43,15 +44,16 @@ public class HttpHandlerServletTomcatIntegrationTests extends AbstractHttpHandle
|
||||
HttpHandlerServlet servlet = new HttpHandlerServlet();
|
||||
servlet.setHandler(new EchoHandler());
|
||||
|
||||
tomcatServer.addServlet(rootCtx, "handlerServlet", servlet);
|
||||
Tomcat.addServlet(rootCtx, "handlerServlet", servlet);
|
||||
rootCtx.addServletMapping("/rx", "handlerServlet");
|
||||
|
||||
tomcatServer.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopServer() throws LifecycleException {
|
||||
public static void stopServer() throws Exception {
|
||||
tomcatServer.stop();
|
||||
tomcatServer.destroy();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user