You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/12/02 14:29:32 UTC
svn commit: r1772353 - in /tomcat/trunk/test/org/apache/coyote/http2:
Http2TestBase.java TestStreamProcessor.java
Author: markt
Date: Fri Dec 2 14:29:32 2016
New Revision: 1772353
URL: http://svn.apache.org/viewvc?rev=1772353&view=rev
Log:
Add a disabled test case for async + complete on non-container thread with HTTP/2
The test currently fails.
Added:
tomcat/trunk/test/org/apache/coyote/http2/TestStreamProcessor.java (with props)
Modified:
tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java
Modified: tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java?rev=1772353&r1=1772352&r2=1772353&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java Fri Dec 2 14:29:32 2016
@@ -505,7 +505,7 @@ public abstract class Http2TestBase exte
protected void openClientConnection() throws IOException {
// Open a connection
s = SocketFactory.getDefault().createSocket("localhost", getPort());
- s.setSoTimeout(30000);
+ s.setSoTimeout(300000);
os = s.getOutputStream();
InputStream is = s.getInputStream();
@@ -1042,7 +1042,7 @@ public abstract class Http2TestBase exte
}
- private static class SimpleServlet extends HttpServlet {
+ protected static class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
Added: tomcat/trunk/test/org/apache/coyote/http2/TestStreamProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestStreamProcessor.java?rev=1772353&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestStreamProcessor.java (added)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestStreamProcessor.java Fri Dec 2 14:29:32 2016
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.coyote.http2;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.ByteBuffer;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Wrapper;
+import org.apache.catalina.startup.Tomcat;
+
+public class TestStreamProcessor extends Http2TestBase {
+
+ @Ignore // Disabled until it passes
+ @Test
+ public void testAsyncComplete() throws Exception {
+ enableHttp2();
+
+ Tomcat tomcat = getTomcatInstance();
+
+ // Map the async servlet to /simple so we can re-use the HTTP/2 handling
+ // logic from the super class.
+ Context ctxt = tomcat.addContext("", null);
+ Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
+ ctxt.addServletMappingDecoded("/simple", "simple");
+ Wrapper w = Tomcat.addServlet(ctxt, "async", new AsyncComplete());
+ w.setAsyncSupported(true);
+ ctxt.addServletMappingDecoded("/async", "async");
+
+ tomcat.start();
+
+ openClientConnection();
+ doHttpUpgrade();
+ sendClientPreface();
+ validateHttp2InitialResponse();
+
+ byte[] frameHeader = new byte[9];
+ ByteBuffer headersPayload = ByteBuffer.allocate(128);
+ buildGetRequest(frameHeader, headersPayload, null, 3, "/async");
+ writeFrame(frameHeader, headersPayload);
+
+ readSimpleGetResponse();
+
+ Assert.assertEquals(
+ "3-HeadersStart\n" +
+ "3-Header-[:status]-[200]\n" +
+ "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
+ "3-HeadersEnd\n" +
+ "3-Body-25\n" +
+ "3-EndOfStream\n", output.getTrace());
+
+ }
+
+
+ private static final class AsyncComplete extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ response.setContentType("text/plain");
+ response.setCharacterEncoding("UTF-8");
+
+ PrintWriter pw = response.getWriter();
+ pw.print("Enter-");
+
+ final AsyncContext asyncContext = request.startAsync(request, response);
+ pw.print("StartAsync-");
+ pw.flush();
+
+ asyncContext.start(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ asyncContext.getResponse().getWriter().print("Complete");
+ asyncContext.complete();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ }
+}
Propchange: tomcat/trunk/test/org/apache/coyote/http2/TestStreamProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org