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 2019/05/30 20:29:46 UTC
[tomcat] branch master updated: Refactor unit tests to make it
easier to configure the Http2Protocol
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 553922b Refactor unit tests to make it easier to configure the Http2Protocol
553922b is described below
commit 553922beb209cae550b3871b4d4aa57eb911b4be
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu May 30 21:29:31 2019 +0100
Refactor unit tests to make it easier to configure the Http2Protocol
---
test/org/apache/coyote/http2/Http2TestBase.java | 6 +++++-
test/org/apache/coyote/http2/TestAbortedUpload.java | 2 --
test/org/apache/coyote/http2/TestHttp2Limits.java | 4 ----
test/org/apache/coyote/http2/TestHttp2Section_6_8.java | 17 ++---------------
test/org/apache/coyote/http2/TestHttp2Section_8_1.java | 2 --
5 files changed, 7 insertions(+), 24 deletions(-)
diff --git a/test/org/apache/coyote/http2/Http2TestBase.java b/test/org/apache/coyote/http2/Http2TestBase.java
index 29008f1..d618112 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -79,6 +79,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
protected static final String TRAILER_HEADER_NAME = "x-trailertest";
protected static final String TRAILER_HEADER_VALUE = "test";
+ // Client
private Socket s;
protected HpackEncoder hpackEncoder;
protected Input input;
@@ -86,6 +87,9 @@ public abstract class Http2TestBase extends TomcatBaseTest {
protected Http2Parser parser;
protected OutputStream os;
+ // Server
+ protected Http2Protocol http2Protocol;
+
private long pingAckDelayMillis = 0;
@@ -534,7 +538,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
protected void enableHttp2(long maxConcurrentStreams) {
Connector connector = getTomcatInstance().getConnector();
- Http2Protocol http2Protocol = new Http2Protocol();
+ http2Protocol = new Http2Protocol();
// Short timeouts for now. May need to increase these for CI systems.
http2Protocol.setReadTimeout(6000);
http2Protocol.setWriteTimeout(6000);
diff --git a/test/org/apache/coyote/http2/TestAbortedUpload.java b/test/org/apache/coyote/http2/TestAbortedUpload.java
index 403d0db..69e093b 100644
--- a/test/org/apache/coyote/http2/TestAbortedUpload.java
+++ b/test/org/apache/coyote/http2/TestAbortedUpload.java
@@ -37,8 +37,6 @@ public class TestAbortedUpload extends Http2TestBase {
public void testAbortedRequest() throws Exception {
http2Connect();
- Http2Protocol http2Protocol =
- (Http2Protocol) getTomcatInstance().getConnector().findUpgradeProtocols()[0];
http2Protocol.setAllowedTrailerHeaders(TRAILER_HEADER_NAME);
int bodySize = 8192;
diff --git a/test/org/apache/coyote/http2/TestHttp2Limits.java b/test/org/apache/coyote/http2/TestHttp2Limits.java
index 91b59b0..97f7b4e 100644
--- a/test/org/apache/coyote/http2/TestHttp2Limits.java
+++ b/test/org/apache/coyote/http2/TestHttp2Limits.java
@@ -193,8 +193,6 @@ public class TestHttp2Limits extends Http2TestBase {
enableHttp2();
- Http2Protocol http2Protocol =
- (Http2Protocol) getTomcatInstance().getConnector().findUpgradeProtocols()[0];
http2Protocol.setMaxHeaderCount(maxHeaderCount);
http2Protocol.setMaxHeaderSize(maxHeaderSize);
@@ -432,8 +430,6 @@ public class TestHttp2Limits extends Http2TestBase {
FailureMode failMode) throws Exception {
enableHttp2();
- Http2Protocol http2Protocol =
- (Http2Protocol) getTomcatInstance().getConnector().findUpgradeProtocols()[0];
http2Protocol.setAllowedTrailerHeaders(TRAILER_HEADER_NAME);
http2Protocol.setMaxTrailerCount(maxTrailerCount);
http2Protocol.setMaxTrailerSize(maxTrailerSize);
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java
index 7105bc1..c43a0b5 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java
@@ -19,8 +19,6 @@ package org.apache.coyote.http2;
import org.junit.Assert;
import org.junit.Test;
-import org.apache.catalina.connector.Connector;
-
/**
* Unit tests for Section 6.8 of
* <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
@@ -40,20 +38,9 @@ public class TestHttp2Section_6_8 extends Http2TestBase {
public void testGoawayIgnoreNewStreams() throws Exception {
setPingAckDelayMillis(PING_ACK_DELAY_MS);
- // HTTP2 upgrade - need longer timeouts for this test
- Connector connector = getTomcatInstance().getConnector();
- Http2Protocol http2Protocol = new Http2Protocol();
- // Short timeouts for now. May need to increase these for CI systems.
- http2Protocol.setReadTimeout(5000);
- http2Protocol.setKeepAliveTimeout(10000);
- http2Protocol.setWriteTimeout(5000);
+ http2Connect();
+
http2Protocol.setMaxConcurrentStreams(200);
- connector.addUpgradeProtocol(http2Protocol);
- configureAndStartWebApplication();
- openClientConnection();
- doHttpUpgrade();
- sendClientPreface();
- validateHttp2InitialResponse();
Thread.sleep(PING_ACK_DELAY_MS + TIMING_MARGIN_MS);
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_8_1.java b/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
index 5eb0606..cd44280 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
@@ -47,8 +47,6 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
private void doTestPostWithTrailerHeaders(boolean allowTrailerHeader) throws Exception{
http2Connect();
if (allowTrailerHeader) {
- Http2Protocol http2Protocol =
- (Http2Protocol) getTomcatInstance().getConnector().findUpgradeProtocols()[0];
http2Protocol.setAllowedTrailerHeaders(TRAILER_HEADER_NAME);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org