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 2015/06/24 15:55:44 UTC
svn commit: r1687278 - in /tomcat/trunk/test/org/apache/coyote/http2:
Http2TestBase.java TestHttp2Section_5_2.java TestHttp2Section_5_3.java
TestHttp2Section_5_5.java
Author: markt
Date: Wed Jun 24 13:55:44 2015
New Revision: 1687278
URL: http://svn.apache.org/r1687278
Log:
Make writing the settings frame unit tests easier.
Modified:
tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_2.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_3.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_5.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=1687278&r1=1687277&r2=1687278&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java Wed Jun 24 13:55:44 2015
@@ -543,18 +543,35 @@ public abstract class Http2TestBase exte
}
- void sendSetting(int settingId, long value) throws IOException {
+ void sendSettings(int streamId, boolean ack, Setting... settings) throws IOException {
byte[] settingFrame = new byte[15];
// length
- ByteUtil.setThreeBytes(settingFrame, 0, 6);
+
+ int settingsCount;
+ if (settings == null) {
+ settingsCount = 0;
+ } else {
+ settingsCount = settings.length;
+ }
+
+ ByteUtil.setThreeBytes(settingFrame, 0, 6 * settingsCount);
// type
settingFrame[3] = FrameType.SETTINGS.getIdByte();
- // No flags
- // Stream 0
+
+ if (ack) {
+ settingFrame[4] = 0x01;
+ }
+
+ // Stream
+ ByteUtil.set31Bits(settingFrame, 5, streamId);
// Payload
- ByteUtil.setTwoBytes(settingFrame, 9, settingId);
- ByteUtil.setFourBytes(settingFrame, 11, value);
+ for (int i = 0; i < settingsCount; i++) {
+ // Stops IDE complaining about possible NPE
+ Assert.assertNotNull(settings);
+ ByteUtil.setTwoBytes(settingFrame, (i * 6) + 9, settings[i].getSetting());
+ ByteUtil.setFourBytes(settingFrame, (i * 6) + 11, settings[i].getValue());
+ }
os.write(settingFrame);
os.flush();
@@ -798,4 +815,23 @@ public abstract class Http2TestBase exte
}
}
}
+
+
+ static class Setting {
+ private final int setting;
+ private final long value;
+
+ public Setting(int setting, long value) {
+ this.setting = setting;
+ this.value = value;
+ }
+
+ public int getSetting() {
+ return setting;
+ }
+
+ public long getValue() {
+ return value;
+ }
+ }
}
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_2.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_2.java?rev=1687278&r1=1687277&r2=1687278&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_2.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_2.java Wed Jun 24 13:55:44 2015
@@ -41,7 +41,7 @@ public class TestHttp2Section_5_2 extend
http2Connect();
// Set the default window size to 1024 bytes
- sendSetting(4, 1024);
+ sendSettings(0, false, new Setting(4, 1024));
// Wait for the ack
parser.readFrame(true);
output.clearTrace();
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_3.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_3.java?rev=1687278&r1=1687277&r2=1687278&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_3.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_3.java Wed Jun 24 13:55:44 2015
@@ -62,7 +62,7 @@ public class TestHttp2Section_5_3 extend
}
// Set the default window size to 1024 bytes
- sendSetting(4, 1024);
+ sendSettings(0, false, new Setting(4, 1024));
// Wait for the ack
parser.readFrame(true);
output.clearTrace();
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_5.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_5.java?rev=1687278&r1=1687277&r2=1687278&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_5.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_5_5.java Wed Jun 24 13:55:44 2015
@@ -53,7 +53,7 @@ public class TestHttp2Section_5_5 extend
http2Connect();
// Unknown setting (should be ack'd)
- sendSetting(1 << 15, 0);
+ sendSettings(0, false, new Setting(1 << 15, 0));
parser.readFrame(true);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org