You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by je...@apache.org on 2015/04/12 23:52:38 UTC
[5/8] mina git commit: Complete low level HTTP2
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Htp2SettingsFrameDecoderTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Htp2SettingsFrameDecoderTest.java b/http2/src/test/java/org/apache/mina/http2/api/Htp2SettingsFrameDecoderTest.java
deleted file mode 100644
index 073464e..0000000
--- a/http2/src/test/java/org/apache/mina/http2/api/Htp2SettingsFrameDecoderTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.mina.http2.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import java.nio.ByteBuffer;
-
-import org.apache.mina.http2.impl.Http2Connection;
-import org.junit.Test;
-
-public class Htp2SettingsFrameDecoderTest {
-
- @Test
- public void checkRstStream() {
- Http2Connection connection = new Http2Connection();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x06, /*length*/
- 0x04, /*type*/
- 0x00, /*flags*/
- 0x00, 0x00, 0x00, 0x20, /*streamID*/
- 0x00, 0x01, /*ID*/
- 0x01, 0x02, 0x03, 0x04, /*value*/});
- Http2SettingsFrame frame = (Http2SettingsFrame) connection.decode(buffer);
- assertNotNull(frame);
- assertEquals(6, frame.getLength());
- assertEquals(4, frame.getType());
- assertEquals(0x00, frame.getFlags());
- assertEquals(32, frame.getStreamID());
- assertEquals(1, frame.getSettings().size());
- Http2Setting setting = frame.getSettings().iterator().next();
- assertEquals(1, setting.getID());
- assertEquals(0x01020304L, setting.getValue());
- }
-
- @Test
- public void checkRstStreamHighestID() {
- Http2Connection connection = new Http2Connection();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x06, /*length*/
- 0x04, /*type*/
- 0x00, /*flags*/
- 0x00, 0x00, 0x00, 0x20, /*streamID*/
- (byte) 0xFF, (byte) 0xFF, /*ID*/
- 0x01, 0x02, 0x03, 0x04, /*value*/});
- Http2SettingsFrame frame = (Http2SettingsFrame) connection.decode(buffer);
- assertNotNull(frame);
- assertEquals(6, frame.getLength());
- assertEquals(4, frame.getType());
- assertEquals(0x00, frame.getFlags());
- assertEquals(32, frame.getStreamID());
- assertEquals(1, frame.getSettings().size());
- Http2Setting setting = frame.getSettings().iterator().next();
- assertEquals(0x00FFFF, setting.getID());
- assertEquals(0x01020304L, setting.getValue());
- }
-
- @Test
- public void checkRstStreamHighestValue() {
- Http2Connection connection = new Http2Connection();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x06, /*length*/
- 0x04, /*type*/
- 0x00, /*flags*/
- 0x00, 0x00, 0x00, 0x20, /*streamID*/
- 0x00, 0x01, /*ID*/
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, /*value*/});
- Http2SettingsFrame frame = (Http2SettingsFrame) connection.decode(buffer);
- assertNotNull(frame);
- assertEquals(6, frame.getLength());
- assertEquals(4, frame.getType());
- assertEquals(0x00, frame.getFlags());
- assertEquals(32, frame.getStreamID());
- assertEquals(1, frame.getSettings().size());
- Http2Setting setting = frame.getSettings().iterator().next();
- assertEquals(1, setting.getID());
- assertEquals(0xFFFFFFFFL, setting.getValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Htp2UnknownFrameDecoderTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Htp2UnknownFrameDecoderTest.java b/http2/src/test/java/org/apache/mina/http2/api/Htp2UnknownFrameDecoderTest.java
deleted file mode 100644
index ffc6149..0000000
--- a/http2/src/test/java/org/apache/mina/http2/api/Htp2UnknownFrameDecoderTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.apache.mina.http2.api;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import java.nio.ByteBuffer;
-
-import org.apache.mina.http2.impl.Http2Connection;
-import org.junit.Test;
-
-public class Htp2UnknownFrameDecoderTest {
-
- @Test
- public void checkUnknownFrame() {
- Http2Connection connection = new Http2Connection();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x02, /*length*/
- (byte) 0x00FF, /*type*/
- 0x00, /*flags*/
- 0x00, 0x00, 0x00, 0x20, /*streamID*/
- 0x0E, 0x18});
- Http2UnknownFrame frame = (Http2UnknownFrame) connection.decode(buffer);
- assertNotNull(frame);
- assertEquals(2, frame.getLength());
- assertEquals(255, frame.getType() & 0x00FF);
- assertEquals(0x00, frame.getFlags());
- assertEquals(32, frame.getStreamID());
- assertEquals(2, frame.getPayload().length);
- assertArrayEquals(new byte[] {0x0E, 0x18}, frame.getPayload());
- }
-
- @Test
- public void checkUnknownFrameWithoutPayload() {
- Http2Connection connection = new Http2Connection();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x00, /*length*/
- (byte) 0x00FF, /*type*/
- 0x00, /*flags*/
- 0x00, 0x00, 0x00, 0x20 /*streamID*/});
- Http2UnknownFrame frame = (Http2UnknownFrame) connection.decode(buffer);
- assertNotNull(frame);
- assertEquals(0, frame.getLength());
- assertEquals(255, frame.getType() & 0x00FF);
- assertEquals(0x00, frame.getFlags());
- assertEquals(32, frame.getStreamID());
- assertEquals(0, frame.getPayload().length);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2ContinuationFrameTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2ContinuationFrameTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2ContinuationFrameTest.java
new file mode 100644
index 0000000..0c0329f
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2ContinuationFrameTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2ContinuationFrameTest extends Http2Test {
+
+ @Test
+ public void decodeNoHeaderFragment() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.CONTINUATION_NO_HEADER_FRAGMENT_BUFFER);
+ Http2ContinuationFrame frame = (Http2ContinuationFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(0, frame.getLength());
+ assertEquals(9, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(0, frame.getHeaderBlockFragment().length);
+ }
+
+ @Test
+ public void encodeNoHeaderFragment() {
+ Http2ContinuationFrame frame = TestMessages.CONTINUATION_NO_HEADER_FRAGMENT_FRAME;
+ assertArrayEquals(TestMessages.CONTINUATION_NO_HEADER_FRAGMENT_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeHeaderFragment() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.CONTINUATION_HEADER_FRAGMENT_BUFFER);
+ Http2ContinuationFrame frame = (Http2ContinuationFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(10, frame.getLength());
+ assertEquals(9, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(10, frame.getHeaderBlockFragment().length);
+ assertArrayEquals(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}, frame.getHeaderBlockFragment());
+ }
+
+ @Test
+ public void encodeHeaderFragment() {
+ Http2ContinuationFrame frame = TestMessages.CONTINUATION_HEADER_FRAGMENT_FRAME;
+ assertArrayEquals(TestMessages.CONTINUATION_HEADER_FRAGMENT_BUFFER, toByteArray(frame.toBuffer()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2DataFrameTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2DataFrameTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2DataFrameTest.java
new file mode 100644
index 0000000..5c7ff95
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2DataFrameTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2DataFrameTest extends Http2Test {
+
+ @Test
+ public void decodeNoPayloadNoPadding() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.DATA_NO_PAYLOAD_NO_PADDING_BUFFER);
+ Http2DataFrame frame = (Http2DataFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(0, frame.getLength());
+ assertEquals(0, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(0, frame.getData().length);
+ assertEquals(0, frame.getPadding().length);
+ }
+
+ @Test
+ public void encodeNoPayloadNoPadding() {
+ Http2DataFrame frame = TestMessages.DATA_NO_PAYLOAD_NO_PADDING_FRAME;
+ assertArrayEquals(TestMessages.DATA_NO_PAYLOAD_NO_PADDING_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodePayloadNoPadding() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.DATA_PAYLOAD_NO_PADDING_BUFFER);
+ Http2DataFrame frame = (Http2DataFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(10, frame.getLength());
+ assertEquals(0, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(10, frame.getData().length);
+ assertArrayEquals(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}, frame.getData());
+ assertEquals(0, frame.getPadding().length);
+ }
+
+ @Test
+ public void encodePayloadNoPadding() {
+ Http2DataFrame frame = TestMessages.DATA_PAYLOAD_NO_PADDING_FRAME;
+ assertArrayEquals(TestMessages.DATA_PAYLOAD_NO_PADDING_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeNoPayloadPadding() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.DATA_NO_PAYLOAD_PADDING_BUFFER);
+ Http2DataFrame frame = (Http2DataFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(3, frame.getLength());
+ assertEquals(0, frame.getType());
+ assertEquals(0x08, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(0,frame.getData().length);
+ assertEquals(2, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x0E, 0x28}, frame.getPadding());
+ }
+
+ @Test
+ public void encodeNoPayloadPadding() {
+ Http2DataFrame frame = TestMessages.DATA_NO_PAYLOAD_PADDING_FRAME;
+ assertArrayEquals(TestMessages.DATA_NO_PAYLOAD_PADDING_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodePayloadPadding() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.DATA_PAYLOAD_PADDING_BUFFER);
+ Http2DataFrame frame = (Http2DataFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(13, frame.getLength());
+ assertEquals(0, frame.getType());
+ assertEquals(0x08, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(10, frame.getData().length);
+ assertArrayEquals(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}, frame.getData());
+ assertEquals(2, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x0E, 0x28}, frame.getPadding());
+ }
+
+ @Test
+ public void encodePayloadPadding() {
+ Http2DataFrame frame = TestMessages.DATA_PAYLOAD_PADDING_FRAME;
+ assertArrayEquals(TestMessages.DATA_PAYLOAD_PADDING_BUFFER, toByteArray(frame.toBuffer()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2FrameHeaderPartialDecoderTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2FrameHeaderPartialDecoderTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2FrameHeaderPartialDecoderTest.java
deleted file mode 100644
index af684b4..0000000
--- a/http2/src/test/java/org/apache/mina/http2/api/Http2FrameHeaderPartialDecoderTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.apache.mina.http2.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.ByteBuffer;
-
-import org.apache.mina.http2.api.Http2FrameHeadePartialDecoder.Http2FrameHeader;
-import org.junit.Test;
-
-public class Http2FrameHeaderPartialDecoderTest {
-
- @Test
- public void checkStandardValue() {
- Http2FrameHeadePartialDecoder decoder = new Http2FrameHeadePartialDecoder();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x00, /*length*/
- 0x00, /*type*/
- 0x00, /*flags*/
- 0x00, 0x00, 0x00, 0x01 /*streamID*/});
- assertTrue(decoder.consume(buffer));
- Http2FrameHeader header = decoder.getValue();
- assertNotNull(header);
- assertEquals(0, header.getLength());
- assertEquals(0, header.getType());
- assertEquals(0, header.getFlags());
- assertEquals(1, header.getStreamID());
- }
-
- @Test
- public void checkReservedBitIsNotTransmitted() {
- Http2FrameHeadePartialDecoder decoder = new Http2FrameHeadePartialDecoder();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x00, /*length*/
- 0x00, /*type*/
- 0x00, /*flags*/
- (byte)0x80, 0x00, 0x00, 0x01 /*streamID*/});
- assertTrue(decoder.consume(buffer));
- Http2FrameHeader header = decoder.getValue();
- assertNotNull(header);
- assertEquals(0, header.getLength());
- assertEquals(0, header.getType());
- assertEquals(0, header.getFlags());
- assertEquals(1, header.getStreamID());
- }
-
- @Test
- public void checkPayLoadIsTransmitted() {
- Http2FrameHeadePartialDecoder decoder = new Http2FrameHeadePartialDecoder();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x01, /*length*/
- 0x00, /*type*/
- 0x00, /*flags*/
- (byte)0x80, 0x00, 0x00, 0x01, /*streamID*/
- 0x40});
- assertTrue(decoder.consume(buffer));
- Http2FrameHeader header = decoder.getValue();
- assertNotNull(header);
- assertEquals(1, header.getLength());
- assertEquals(0, header.getType());
- assertEquals(0, header.getFlags());
- assertEquals(1, header.getStreamID());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2GoAwayFrameTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2GoAwayFrameTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2GoAwayFrameTest.java
new file mode 100644
index 0000000..1921423
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2GoAwayFrameTest.java
@@ -0,0 +1,134 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2GoAwayFrameTest extends Http2Test {
+
+
+ @Test
+ public void decodeNoAdditionalData() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_NO_DATA_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(256, frame.getLastStreamID());
+ assertEquals(0x010203, frame.getErrorCode());
+ }
+
+ @Test
+ public void encodeWNoAdditionalData() {
+ Http2GoAwayFrame frame = TestMessages.GOAWAY_NO_DATA_FRAME;
+ assertArrayEquals(TestMessages.GOAWAY_NO_DATA_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeHighestLastStreamIDNoAdditionalData() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_NO_DATA_HIGHEST_STREAMID_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(0x7FFFFFFF, frame.getLastStreamID());
+ assertEquals(0x010203, frame.getErrorCode());
+ }
+
+ @Test
+ public void encodeHighestLastStreamIDWNoAdditionalData() {
+ Http2GoAwayFrame frame = TestMessages.GOAWAY_NO_DATA_HIGHEST_STREAMID_FRAME;
+ assertArrayEquals(TestMessages.GOAWAY_NO_DATA_HIGHEST_STREAMID_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeHighestLastStreamIDReservedBitSetNoAdditionalData() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_NO_DATA_HIGHEST_STREAMID_RESERVED_BIT_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(0x7FFFFFFF, frame.getLastStreamID());
+ assertEquals(0x010203, frame.getErrorCode());
+ }
+
+ @Test
+ public void decodeHighestErrorCodeNoAdditionalData() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_NO_DATA_HIGHEST_ERROR_CODE_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(0x7FFFFFFF, frame.getLastStreamID());
+ assertEquals(0x00FFFFFFFFL, frame.getErrorCode());
+ }
+
+ @Test
+ public void encodeHighestErrorCodeNoAdditionalData() {
+ Http2GoAwayFrame frame = TestMessages.GOAWAY_NO_DATA_HIGHEST_ERROR_CODE_FRAME;
+ assertArrayEquals(TestMessages.GOAWAY_NO_DATA_HIGHEST_ERROR_CODE_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeAdditionalData() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_DATA_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(9, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(256, frame.getLastStreamID());
+ assertEquals(0x00010203, frame.getErrorCode());
+ assertArrayEquals(new byte[] {0x01}, frame.getData());
+ }
+
+ @Test
+ public void encodeAdditionalData() {
+ Http2GoAwayFrame frame = TestMessages.GOAWAY_DATA_FRAME;
+ assertArrayEquals(TestMessages.GOAWAY_DATA_BUFFER, toByteArray(frame.toBuffer()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2HeadersFrameTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2HeadersFrameTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2HeadersFrameTest.java
new file mode 100644
index 0000000..a108474
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2HeadersFrameTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2HeadersFrameTest extends Http2Test {
+
+ @Test
+ public void decodeNoPaddingNoPriority() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.HEADERS_NO_PADDING_NO_PRIORITY_BUFFER);
+ Http2HeadersFrame frame = (Http2HeadersFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(1, frame.getLength());
+ assertEquals(1, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ }
+
+ @Test
+ public void encodeNoPaddingNoPriority() {
+ Http2HeadersFrame frame = TestMessages.HEADERS_NO_PADDING_NO_PRIORITY_FRAME;
+ assertArrayEquals(TestMessages.HEADERS_NO_PADDING_NO_PRIORITY_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+
+ @Test
+ public void decodePaddingPriority() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.HEADERS_PADDING_PRIORITY_BUFFER);
+ Http2HeadersFrame frame = (Http2HeadersFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(23, frame.getLength());
+ assertEquals(1, frame.getType());
+ assertEquals(0x28, frame.getFlags());
+ assertEquals(3, frame.getStreamID());
+ assertEquals(10, frame.getWeight());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ assertEquals(16, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6E, 0x67, 0x2E}, frame.getPadding());
+ }
+
+ @Test
+ public void encodePaddingPriority() {
+ Http2HeadersFrame frame = TestMessages.HEADERS_PADDING_PRIORITY_FRAME;
+ assertArrayEquals(TestMessages.HEADERS_PADDING_PRIORITY_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodePaddingNoPriority() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.HEADERS_PADDING_NO_PRIORITY_BUFFER);
+ Http2HeadersFrame frame = (Http2HeadersFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(18, frame.getLength());
+ assertEquals(1, frame.getType());
+ assertEquals(0x08, frame.getFlags());
+ assertEquals(3, frame.getStreamID());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ assertEquals(16, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6E, 0x67, 0x2E}, frame.getPadding());
+ }
+
+ @Test
+ public void encodePaddingNoPriority() {
+ Http2HeadersFrame frame = TestMessages.HEADERS_PADDING_NO_PRIORITY_FRAME;
+ assertArrayEquals(TestMessages.HEADERS_PADDING_NO_PRIORITY_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2PingFrameTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2PingFrameTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2PingFrameTest.java
new file mode 100644
index 0000000..12d3283
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2PingFrameTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2PingFrameTest extends Http2Test {
+
+ @Test
+ public void decode() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PING_STANDARD_BUFFER);
+ Http2PingFrame frame = (Http2PingFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(6, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertArrayEquals(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, frame.getData());
+ }
+
+ @Test
+ public void encode() {
+ Http2PingFrame frame = TestMessages.PING_STANDARD_FRAME;
+ assertArrayEquals(TestMessages.PING_STANDARD_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeExtraData() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PING_EXTRA_DATA_BUFFER);
+ Http2PingFrame frame = (Http2PingFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(9, frame.getLength());
+ assertEquals(6, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertArrayEquals(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, frame.getData());
+ }
+
+ @Test
+ public void encodeExtraData() {
+ Http2PingFrame frame = TestMessages.PING_EXTRA_DATA_FRAME;
+ assertArrayEquals(TestMessages.PING_EXTRA_DATA_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeNotEnoughData() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PING_NO_ENOUGH_DATA_BUFFER);
+ Http2PingFrame frame = (Http2PingFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(1, frame.getLength());
+ assertEquals(6, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertArrayEquals(new byte[] {0x00}, frame.getData());
+ }
+
+ @Test
+ public void encodeNotEnoughData() {
+ Http2PingFrame frame = TestMessages.PING_NO_ENOUGH_DATA_FRAME;
+ assertArrayEquals(TestMessages.PING_NO_ENOUGH_DATA_BUFFER, toByteArray(frame.toBuffer()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2PriorityFrameTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2PriorityFrameTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2PriorityFrameTest.java
new file mode 100644
index 0000000..397ba36
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2PriorityFrameTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2PriorityFrameTest extends Http2Test {
+
+ @Test
+ public void decodeNoExclusive() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PRIORITY_NO_EXCLUSIVE_MODE_BUFFER);
+ Http2PriorityFrame frame = (Http2PriorityFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(5, frame.getLength());
+ assertEquals(2, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(256, frame.getStreamDependencyID());
+ assertFalse(frame.getExclusiveMode());
+ assertEquals(2, frame.getWeight());
+ }
+
+ @Test
+ public void encodeNoExclusive() {
+ Http2PriorityFrame frame = TestMessages.PRIORITY_NO_EXCLUSIVE_MODE_FRAME;
+ assertArrayEquals(TestMessages.PRIORITY_NO_EXCLUSIVE_MODE_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeExclusive() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PRIORITY_EXCLUSIVE_MODE_BUFFER);
+ Http2PriorityFrame frame = (Http2PriorityFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(5, frame.getLength());
+ assertEquals(2, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(256, frame.getStreamDependencyID());
+ assertTrue(frame.getExclusiveMode());
+ assertEquals(2, frame.getWeight());
+ }
+
+ @Test
+ public void encodeExclusive() {
+ Http2PriorityFrame frame = TestMessages.PRIORITY_EXCLUSIVE_MODE_FRAME;
+ assertArrayEquals(TestMessages.PRIORITY_EXCLUSIVE_MODE_BUFFER, toByteArray(frame.toBuffer()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2PushPromiseFrameTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2PushPromiseFrameTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2PushPromiseFrameTest.java
new file mode 100644
index 0000000..612c788
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2PushPromiseFrameTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2PushPromiseFrameTest extends Http2Test {
+
+ @Test
+ public void decodeNoPadding() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PUSH_PROMISE_NO_PADDING_BUFFER);
+ Http2PushPromiseFrame frame = (Http2PushPromiseFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(5, frame.getLength());
+ assertEquals(5, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(256, frame.getPromisedStreamID());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ }
+
+ @Test
+ public void encodeNoPadding() {
+ Http2PushPromiseFrame frame = TestMessages.PUSH_PROMISE_NO_PADDING_FRAME;
+ assertArrayEquals(TestMessages.PUSH_PROMISE_NO_PADDING_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+
+ @Test
+ public void decodePadding() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PUSH_PROMISE_PADDING_BUFFER);
+ Http2PushPromiseFrame frame = (Http2PushPromiseFrame) connection.decode(buffer);
+ assertEquals(22, frame.getLength());
+ assertEquals(5, frame.getType());
+ assertEquals(0x08, frame.getFlags());
+ assertEquals(3, frame.getStreamID());
+ assertEquals(20, frame.getPromisedStreamID());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ assertEquals(16, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6E, 0x67, 0x2E}, frame.getPadding());
+ }
+
+ @Test
+ public void encodePadding() {
+ Http2PushPromiseFrame frame = TestMessages.PUSH_PROMISE_PADDING_FRAME;
+ assertArrayEquals(TestMessages.PUSH_PROMISE_PADDING_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2RstStreamFrameTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2RstStreamFrameTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2RstStreamFrameTest.java
new file mode 100644
index 0000000..c8b42d5
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2RstStreamFrameTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.api.Http2RstStreamFrame.Http2RstStreamFrameBuilder;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2RstStreamFrameTest extends Http2Test {
+
+ @Test
+ public void decodeNoExtraPayload() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.RST_STREAM_NO_EXTRA_PAYLOAD_BUFFER);
+ Http2RstStreamFrame frame = (Http2RstStreamFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(4, frame.getLength());
+ assertEquals(3, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(256, frame.getErrorCode());
+ }
+
+ @Test
+ public void encodeNoExtraPayload() {
+ Http2RstStreamFrame frame = TestMessages.RST_STREAM_NO_EXTRA_PAYLOAD_FRAME;
+ assertArrayEquals(TestMessages.RST_STREAM_NO_EXTRA_PAYLOAD_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeHighestValueNoExtraPayload() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.RST_STREAM_HIGHEST_VALUE_NO_EXTRA_PAYLOAD_BUFFER);
+ Http2RstStreamFrame frame = (Http2RstStreamFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(4, frame.getLength());
+ assertEquals(3, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(0x00FFFFFFFFL, frame.getErrorCode());
+ }
+
+ @Test
+ public void encodeHighestValueNoExtraPayload() {
+ Http2RstStreamFrame frame = TestMessages.RST_STREAM_HIGHEST_VALUE_NO_EXTRA_PAYLOAD_FRAME;
+ assertArrayEquals(TestMessages.RST_STREAM_HIGHEST_VALUE_NO_EXTRA_PAYLOAD_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeExtraPayload() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.RST_STREAM_EXTRA_PAYLOAD_BUFFER);
+ Http2RstStreamFrame frame = (Http2RstStreamFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(3, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(256, frame.getErrorCode());
+ }
+
+ @Test
+ public void decodeHighestValueExtraPayload() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.RST_STREAM_EXTRA_PAYLOAD_HIGHEST_BUFFER);
+ Http2RstStreamFrame frame = (Http2RstStreamFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(3, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(0x00FFFFFFFFL, frame.getErrorCode());
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2SettingsFrameDecoderTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2SettingsFrameDecoderTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2SettingsFrameDecoderTest.java
new file mode 100644
index 0000000..3681978
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2SettingsFrameDecoderTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2SettingsFrameDecoderTest extends Http2Test {
+
+ @Test
+ public void decode() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.SETTINGS_DEFAULT_BUFFER);
+ Http2SettingsFrame frame = (Http2SettingsFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(4, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(1, frame.getSettings().size());
+ Http2Setting setting = frame.getSettings().iterator().next();
+ assertEquals(1, setting.getID());
+ assertEquals(0x01020304L, setting.getValue());
+ }
+
+ @Test
+ public void encode() {
+ Http2SettingsFrame frame = TestMessages.SETTINGS_DEFAULT_FRAME;
+ assertArrayEquals(TestMessages.SETTINGS_DEFAULT_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeHighestID() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.SETTINGS_HIGHEST_ID_BUFFER);
+ Http2SettingsFrame frame = (Http2SettingsFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(4, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(1, frame.getSettings().size());
+ Http2Setting setting = frame.getSettings().iterator().next();
+ assertEquals(0x00FFFF, setting.getID());
+ assertEquals(0x01020304L, setting.getValue());
+ }
+
+ @Test
+ public void encodeHighestID() {
+ Http2SettingsFrame frame = TestMessages.SETTINGS_HIGHEST_ID_FRAME;
+ assertArrayEquals(TestMessages.SETTINGS_HIGHEST_ID_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeHighestValue() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.SETTINGS_HIGHEST_VALUE_BUFFER);
+ Http2SettingsFrame frame = (Http2SettingsFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(4, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(1, frame.getSettings().size());
+ Http2Setting setting = frame.getSettings().iterator().next();
+ assertEquals(1, setting.getID());
+ assertEquals(0xFFFFFFFFL, setting.getValue());
+ }
+
+ @Test
+ public void encodeHighestValue() {
+ Http2SettingsFrame frame = TestMessages.SETTINGS_HIGHEST_VALUE_FRAME;
+ assertArrayEquals(TestMessages.SETTINGS_HIGHEST_VALUE_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/Http2UnknownFrameTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/Http2UnknownFrameTest.java b/http2/src/test/java/org/apache/mina/http2/api/Http2UnknownFrameTest.java
new file mode 100644
index 0000000..764e924
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/api/Http2UnknownFrameTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.mina.http2.api;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class Http2UnknownFrameTest extends Http2Test {
+
+ @Test
+ public void decode() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.UNKNOWN_PAYLOAD_BUFFER);
+ Http2UnknownFrame frame = (Http2UnknownFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(2, frame.getLength());
+ assertEquals(255, frame.getType() & 0x00FF);
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(2, frame.getPayload().length);
+ assertArrayEquals(new byte[] {0x0E, 0x18}, frame.getPayload());
+ }
+
+ @Test
+ public void encode() {
+ Http2UnknownFrame frame = TestMessages.UNKNOWN_PAYLOAD_FRAME;
+ assertArrayEquals(TestMessages.UNKNOWN_PAYLOAD_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+ @Test
+ public void decodeWithoutPayload() {
+ Http2Connection connection = new Http2Connection();
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.UNKNOWN_NO_PAYLOAD_BUFFER);
+ Http2UnknownFrame frame = (Http2UnknownFrame) connection.decode(buffer);
+ assertNotNull(frame);
+ assertEquals(0, frame.getLength());
+ assertEquals(255, frame.getType() & 0x00FF);
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(0, frame.getPayload().length);
+ }
+
+ @Test
+ public void encodeWithoutPayload() {
+ Http2UnknownFrame frame = TestMessages.UNKNOWN_NO_PAYLOAD_FRAME;
+ assertArrayEquals(TestMessages.UNKNOWN_NO_PAYLOAD_BUFFER, toByteArray(frame.toBuffer()));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/api/IntPartialDecoderTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/api/IntPartialDecoderTest.java b/http2/src/test/java/org/apache/mina/http2/api/IntPartialDecoderTest.java
deleted file mode 100644
index 78c9125..0000000
--- a/http2/src/test/java/org/apache/mina/http2/api/IntPartialDecoderTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.apache.mina.http2.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.nio.ByteBuffer;
-
-import org.junit.Test;
-
-public class IntPartialDecoderTest {
-
- @Test
- public void checkSimpleValue() {
- IntPartialDecoder decoder = new IntPartialDecoder();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x00, 0x00});
- assertTrue(decoder.consume(buffer));
- assertEquals(0, decoder.getValue().intValue());
- }
-
- @Test
- public void checkNotenoughData() {
- IntPartialDecoder decoder = new IntPartialDecoder();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00});
- assertFalse(decoder.consume(buffer));
- }
-
- @Test
- public void checkTooMuchData() {
- IntPartialDecoder decoder = new IntPartialDecoder();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00});
- assertTrue(decoder.consume(buffer));
- assertEquals(0, decoder.getValue().intValue());
- assertEquals(1, buffer.remaining());
- }
-
- @Test
- public void checkDecodingIn2Steps() {
- IntPartialDecoder decoder = new IntPartialDecoder();
- ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00});
- assertFalse(decoder.consume(buffer));
- buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00, 0x00});
- assertTrue(decoder.consume(buffer));
- assertEquals(0, decoder.getValue().intValue());
- assertEquals(1, buffer.remaining());
- }
-}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/codec/Http2ProtocolDecoderTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/codec/Http2ProtocolDecoderTest.java b/http2/src/test/java/org/apache/mina/http2/codec/Http2ProtocolDecoderTest.java
new file mode 100644
index 0000000..6a478dd
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/codec/Http2ProtocolDecoderTest.java
@@ -0,0 +1,458 @@
+/*
+ * 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.mina.http2.codec;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.ByteBuffer;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.api.Http2ContinuationFrame;
+import org.apache.mina.http2.api.Http2DataFrame;
+import org.apache.mina.http2.api.Http2Frame;
+import org.apache.mina.http2.api.Http2GoAwayFrame;
+import org.apache.mina.http2.api.Http2HeadersFrame;
+import org.apache.mina.http2.api.Http2PingFrame;
+import org.apache.mina.http2.api.Http2PriorityFrame;
+import org.apache.mina.http2.api.Http2PushPromiseFrame;
+import org.apache.mina.http2.api.Http2RstStreamFrame;
+import org.apache.mina.http2.api.Http2Setting;
+import org.apache.mina.http2.api.Http2SettingsFrame;
+import org.apache.mina.http2.api.Http2UnknownFrame;
+import org.apache.mina.http2.impl.Http2Connection;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+
+public class Http2ProtocolDecoderTest extends Http2Test {
+
+ private Http2ProtocolDecoder decoder = new Http2ProtocolDecoder();
+ private Http2Connection context = new Http2Connection();
+
+ @Test
+ public void continuationNoHeaderBlock() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.CONTINUATION_NO_HEADER_FRAGMENT_BUFFER);
+ Http2ContinuationFrame frame = (Http2ContinuationFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(0, frame.getLength());
+ assertEquals(9, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(0, frame.getHeaderBlockFragment().length);
+ }
+
+ @Test
+ public void continuationHeaderBlock() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.CONTINUATION_HEADER_FRAGMENT_BUFFER);
+ Http2ContinuationFrame frame = (Http2ContinuationFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(10, frame.getLength());
+ assertEquals(9, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(10, frame.getHeaderBlockFragment().length);
+ assertArrayEquals(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}, frame.getHeaderBlockFragment());
+ }
+
+ @Test
+ public void dataNoPayloadNoPadding() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.DATA_NO_PAYLOAD_NO_PADDING_BUFFER);
+ Http2DataFrame frame = (Http2DataFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(0, frame.getLength());
+ assertEquals(0, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(0, frame.getData().length);
+ assertEquals(0, frame.getPadding().length);
+ }
+
+ @Test
+ public void dataPayloadNoPadding() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.DATA_PAYLOAD_NO_PADDING_BUFFER);
+ Http2DataFrame frame = (Http2DataFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(10, frame.getLength());
+ assertEquals(0, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(10, frame.getData().length);
+ assertArrayEquals(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}, frame.getData());
+ assertEquals(0, frame.getPadding().length);
+ }
+
+ @Test
+ public void dataNoPayloadPadding() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.DATA_NO_PAYLOAD_PADDING_BUFFER);
+ Http2DataFrame frame = (Http2DataFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(3, frame.getLength());
+ assertEquals(0, frame.getType());
+ assertEquals(0x08, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(0,frame.getData().length);
+ assertEquals(2, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x0E, 0x28}, frame.getPadding());
+ }
+
+ @Test
+ public void dataPayloadPadding() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.DATA_PAYLOAD_PADDING_BUFFER);
+ Http2DataFrame frame = (Http2DataFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(13, frame.getLength());
+ assertEquals(0, frame.getType());
+ assertEquals(0x08, frame.getFlags());
+ assertEquals(50, frame.getStreamID());
+ assertEquals(10, frame.getData().length);
+ assertArrayEquals(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}, frame.getData());
+ assertEquals(2, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x0E, 0x28}, frame.getPadding());
+ }
+
+ @Test
+ public void goAwayNoAdditionalData() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_NO_DATA_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(256, frame.getLastStreamID());
+ assertEquals(0x010203, frame.getErrorCode());
+ }
+
+ @Test
+ public void goAwayHighestLastStreamIDNoAdditionalData() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_NO_DATA_HIGHEST_STREAMID_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(0x7FFFFFFF, frame.getLastStreamID());
+ assertEquals(0x010203, frame.getErrorCode());
+ }
+
+ @Test
+ public void goAwayHighestLastStreamIDReservedBitSetNoAdditionalData() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_NO_DATA_HIGHEST_STREAMID_RESERVED_BIT_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(0x7FFFFFFF, frame.getLastStreamID());
+ assertEquals(0x010203, frame.getErrorCode());
+ }
+
+ @Test
+ public void goAwayHighestErrorCodeNoAdditionalData() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_NO_DATA_HIGHEST_ERROR_CODE_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(0x7FFFFFFF, frame.getLastStreamID());
+ assertEquals(0x00FFFFFFFFL, frame.getErrorCode());
+ }
+
+ @Test
+ public void goAwayAdditionalData() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.GOAWAY_DATA_BUFFER);
+ Http2GoAwayFrame frame = (Http2GoAwayFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(9, frame.getLength());
+ assertEquals(7, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(256, frame.getLastStreamID());
+ assertEquals(0x00010203, frame.getErrorCode());
+ assertArrayEquals(new byte[] {0x01}, frame.getData());
+ }
+
+ @Test
+ public void headersNoPaddingNoPriority() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.HEADERS_NO_PADDING_NO_PRIORITY_BUFFER);
+ Http2HeadersFrame frame = (Http2HeadersFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(1, frame.getLength());
+ assertEquals(1, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ }
+
+ @Test
+ public void headersPaddingPriority() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.HEADERS_PADDING_PRIORITY_BUFFER);
+ Http2HeadersFrame frame = (Http2HeadersFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(23, frame.getLength());
+ assertEquals(1, frame.getType());
+ assertEquals(0x28, frame.getFlags());
+ assertEquals(3, frame.getStreamID());
+ assertEquals(10, frame.getWeight());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ assertEquals(16, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6E, 0x67, 0x2E}, frame.getPadding());
+ }
+
+ @Test
+ public void headersPaddingNoPriority() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.HEADERS_PADDING_NO_PRIORITY_BUFFER);
+ Http2HeadersFrame frame = (Http2HeadersFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(18, frame.getLength());
+ assertEquals(1, frame.getType());
+ assertEquals(0x08, frame.getFlags());
+ assertEquals(3, frame.getStreamID());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ assertEquals(16, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6E, 0x67, 0x2E}, frame.getPadding());
+ }
+
+ @Test
+ public void ping() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PING_STANDARD_BUFFER);
+ Http2PingFrame frame = (Http2PingFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(8, frame.getLength());
+ assertEquals(6, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertArrayEquals(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, frame.getData());
+ }
+
+ @Test
+ public void pingExtraData() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PING_EXTRA_DATA_BUFFER);
+ Http2PingFrame frame = (Http2PingFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(9, frame.getLength());
+ assertEquals(6, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertArrayEquals(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, frame.getData());
+ }
+
+ @Test
+ public void pingNotEnoughData() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PING_NO_ENOUGH_DATA_BUFFER);
+ Http2PingFrame frame = (Http2PingFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(1, frame.getLength());
+ assertEquals(6, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertArrayEquals(new byte[] {0x00}, frame.getData());
+ }
+
+ @Test
+ public void priorityNoExclusive() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PRIORITY_NO_EXCLUSIVE_MODE_BUFFER);
+ Http2PriorityFrame frame = (Http2PriorityFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(5, frame.getLength());
+ assertEquals(2, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(256, frame.getStreamDependencyID());
+ assertFalse(frame.getExclusiveMode());
+ assertEquals(2, frame.getWeight());
+ }
+
+ @Test
+ public void priorityExclusive() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PRIORITY_EXCLUSIVE_MODE_BUFFER);
+ Http2PriorityFrame frame = (Http2PriorityFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(5, frame.getLength());
+ assertEquals(2, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(256, frame.getStreamDependencyID());
+ assertTrue(frame.getExclusiveMode());
+ assertEquals(2, frame.getWeight());
+ }
+
+ @Test
+ public void pushPromiseNoPadding() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PUSH_PROMISE_NO_PADDING_BUFFER);
+ Http2PushPromiseFrame frame = (Http2PushPromiseFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(5, frame.getLength());
+ assertEquals(5, frame.getType());
+ assertEquals(0, frame.getFlags());
+ assertEquals(1, frame.getStreamID());
+ assertEquals(256, frame.getPromisedStreamID());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ }
+
+ @Test
+ public void pushPromisePadding() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PUSH_PROMISE_PADDING_BUFFER);
+ Http2PushPromiseFrame frame = (Http2PushPromiseFrame) decoder.decode(buffer, context);
+ assertEquals(22, frame.getLength());
+ assertEquals(5, frame.getType());
+ assertEquals(0x08, frame.getFlags());
+ assertEquals(3, frame.getStreamID());
+ assertEquals(20, frame.getPromisedStreamID());
+ assertEquals(1, frame.getHeaderBlockFragment().length);
+ assertEquals(0x0082, frame.getHeaderBlockFragment()[0] & 0x00FF);
+ assertEquals(16, frame.getPadding().length);
+ assertArrayEquals(new byte[] {0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6E, 0x67, 0x2E}, frame.getPadding());
+ }
+
+ @Test
+ public void rstStreamNoExtraPayload() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.RST_STREAM_NO_EXTRA_PAYLOAD_BUFFER);
+ Http2RstStreamFrame frame = (Http2RstStreamFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(4, frame.getLength());
+ assertEquals(3, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(256, frame.getErrorCode());
+ }
+
+ @Test
+ public void rstStreamHighestValueNoExtraPayload() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.RST_STREAM_HIGHEST_VALUE_NO_EXTRA_PAYLOAD_BUFFER);
+ Http2RstStreamFrame frame = (Http2RstStreamFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(4, frame.getLength());
+ assertEquals(3, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(0x00FFFFFFFFL, frame.getErrorCode());
+ }
+
+ @Test
+ public void rstStreamExtraPayload() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.RST_STREAM_EXTRA_PAYLOAD_BUFFER);
+ Http2RstStreamFrame frame = (Http2RstStreamFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(3, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(256, frame.getErrorCode());
+ }
+
+ @Test
+ public void rstStreamHighestValueExtraPayload() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.RST_STREAM_EXTRA_PAYLOAD_HIGHEST_BUFFER);
+ Http2RstStreamFrame frame = (Http2RstStreamFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(3, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(0x00FFFFFFFFL, frame.getErrorCode());
+ }
+
+ @Test
+ public void settings() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.SETTINGS_DEFAULT_BUFFER);
+ Http2SettingsFrame frame = (Http2SettingsFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(4, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(1, frame.getSettings().size());
+ Http2Setting setting = frame.getSettings().iterator().next();
+ assertEquals(1, setting.getID());
+ assertEquals(0x01020304L, setting.getValue());
+ }
+
+ @Test
+ public void settingsHighestID() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.SETTINGS_HIGHEST_ID_BUFFER);
+ Http2SettingsFrame frame = (Http2SettingsFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(4, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(1, frame.getSettings().size());
+ Http2Setting setting = frame.getSettings().iterator().next();
+ assertEquals(0x00FFFF, setting.getID());
+ assertEquals(0x01020304L, setting.getValue());
+ }
+
+ @Test
+ public void settingsHighestValue() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.SETTINGS_HIGHEST_VALUE_BUFFER);
+ Http2SettingsFrame frame = (Http2SettingsFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(6, frame.getLength());
+ assertEquals(4, frame.getType());
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(1, frame.getSettings().size());
+ Http2Setting setting = frame.getSettings().iterator().next();
+ assertEquals(1, setting.getID());
+ assertEquals(0xFFFFFFFFL, setting.getValue());
+ }
+
+ @Test
+ public void unknownFrame() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.UNKNOWN_PAYLOAD_BUFFER);
+ Http2UnknownFrame frame = (Http2UnknownFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(2, frame.getLength());
+ assertEquals(255, frame.getType() & 0x00FF);
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(2, frame.getPayload().length);
+ assertArrayEquals(new byte[] {0x0E, 0x18}, frame.getPayload());
+ }
+
+ @Test
+ public void unknownFrameNoPayload() {
+ ByteBuffer buffer = ByteBuffer.wrap(TestMessages.UNKNOWN_NO_PAYLOAD_BUFFER);
+ Http2UnknownFrame frame = (Http2UnknownFrame) decoder.decode(buffer, context);
+ assertNotNull(frame);
+ assertEquals(0, frame.getLength());
+ assertEquals(255, frame.getType() & 0x00FF);
+ assertEquals(0x00, frame.getFlags());
+ assertEquals(32, frame.getStreamID());
+ assertEquals(0, frame.getPayload().length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina/blob/8ca3d89d/http2/src/test/java/org/apache/mina/http2/codec/Http2ProtocolEncoderTest.java
----------------------------------------------------------------------
diff --git a/http2/src/test/java/org/apache/mina/http2/codec/Http2ProtocolEncoderTest.java b/http2/src/test/java/org/apache/mina/http2/codec/Http2ProtocolEncoderTest.java
new file mode 100644
index 0000000..ecea462
--- /dev/null
+++ b/http2/src/test/java/org/apache/mina/http2/codec/Http2ProtocolEncoderTest.java
@@ -0,0 +1,200 @@
+/*
+ * 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.mina.http2.codec;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import org.apache.mina.http2.Http2Test;
+import org.apache.mina.http2.TestMessages;
+import org.apache.mina.http2.api.Http2Frame;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+
+public class Http2ProtocolEncoderTest extends Http2Test {
+
+ private Http2ProtocolEncoder encoder = new Http2ProtocolEncoder();
+
+ @Test
+ public void continuationNoHeaderBlock() {
+ Http2Frame frame = TestMessages.CONTINUATION_NO_HEADER_FRAGMENT_FRAME;
+ assertArrayEquals(TestMessages.CONTINUATION_NO_HEADER_FRAGMENT_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void continuationHeaderBlock() {
+ Http2Frame frame = TestMessages.CONTINUATION_HEADER_FRAGMENT_FRAME;
+ assertArrayEquals(TestMessages.CONTINUATION_HEADER_FRAGMENT_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+
+ @Test
+ public void dataNoPayloadNoPadding() {
+ Http2Frame frame = TestMessages.DATA_NO_PAYLOAD_NO_PADDING_FRAME;
+ assertArrayEquals(TestMessages.DATA_NO_PAYLOAD_NO_PADDING_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void dataPayloadNoPadding() {
+ Http2Frame frame = TestMessages.DATA_PAYLOAD_NO_PADDING_FRAME;
+ assertArrayEquals(TestMessages.DATA_PAYLOAD_NO_PADDING_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void dataNoPayloadPadding() {
+ Http2Frame frame = TestMessages.DATA_NO_PAYLOAD_PADDING_FRAME;
+ assertArrayEquals(TestMessages.DATA_NO_PAYLOAD_PADDING_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void dataPayloadPadding() {
+ Http2Frame frame = TestMessages.DATA_PAYLOAD_PADDING_FRAME;
+ assertArrayEquals(TestMessages.DATA_PAYLOAD_PADDING_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void goAwayNoAdditionalData() {
+ Http2Frame frame = TestMessages.GOAWAY_NO_DATA_FRAME;
+ assertArrayEquals(TestMessages.GOAWAY_NO_DATA_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void goAwayHighestLastStreamIDNoAdditionalData() {
+ Http2Frame frame = TestMessages.GOAWAY_NO_DATA_HIGHEST_STREAMID_FRAME;
+ assertArrayEquals(TestMessages.GOAWAY_NO_DATA_HIGHEST_STREAMID_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void goAwayHighestErrorCodeNoAdditionalData() {
+ Http2Frame frame = TestMessages.GOAWAY_NO_DATA_HIGHEST_ERROR_CODE_FRAME;
+ assertArrayEquals(TestMessages.GOAWAY_NO_DATA_HIGHEST_ERROR_CODE_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void goAwayAdditionalData() {
+ Http2Frame frame = TestMessages.GOAWAY_DATA_FRAME;
+ assertArrayEquals(TestMessages.GOAWAY_DATA_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void headersNoPaddingNoPriority() {
+ Http2Frame frame = TestMessages.HEADERS_NO_PADDING_NO_PRIORITY_FRAME;
+ assertArrayEquals(TestMessages.HEADERS_NO_PADDING_NO_PRIORITY_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void headersPaddingPriority() {
+ Http2Frame frame = TestMessages.HEADERS_PADDING_PRIORITY_FRAME;
+ assertArrayEquals(TestMessages.HEADERS_PADDING_PRIORITY_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void headersPaddingNoPriority() {
+ Http2Frame frame = TestMessages.HEADERS_PADDING_NO_PRIORITY_FRAME;
+ assertArrayEquals(TestMessages.HEADERS_PADDING_NO_PRIORITY_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void ping() {
+ Http2Frame frame = TestMessages.PING_STANDARD_FRAME;
+ assertArrayEquals(TestMessages.PING_STANDARD_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void pingExtraData() {
+ Http2Frame frame = TestMessages.PING_EXTRA_DATA_FRAME;
+ assertArrayEquals(TestMessages.PING_EXTRA_DATA_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void pingNotEnoughData() {
+ Http2Frame frame = TestMessages.PING_NO_ENOUGH_DATA_FRAME;
+ assertArrayEquals(TestMessages.PING_NO_ENOUGH_DATA_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void priorityNoExclusive() {
+ Http2Frame frame = TestMessages.PRIORITY_NO_EXCLUSIVE_MODE_FRAME;
+ assertArrayEquals(TestMessages.PRIORITY_NO_EXCLUSIVE_MODE_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void priorityExclusive() {
+ Http2Frame frame = TestMessages.PRIORITY_EXCLUSIVE_MODE_FRAME;
+ assertArrayEquals(TestMessages.PRIORITY_EXCLUSIVE_MODE_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void pushPromiseNoPadding() {
+ Http2Frame frame = TestMessages.PUSH_PROMISE_NO_PADDING_FRAME;
+ assertArrayEquals(TestMessages.PUSH_PROMISE_NO_PADDING_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void pushPromisePadding() {
+ Http2Frame frame = TestMessages.PUSH_PROMISE_PADDING_FRAME;
+ assertArrayEquals(TestMessages.PUSH_PROMISE_PADDING_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void rstStreamNoExtraPayload() {
+ Http2Frame frame = TestMessages.RST_STREAM_NO_EXTRA_PAYLOAD_FRAME;
+ assertArrayEquals(TestMessages.RST_STREAM_NO_EXTRA_PAYLOAD_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void rstStreamHighestValueNoExtraPayload() {
+ Http2Frame frame = TestMessages.RST_STREAM_HIGHEST_VALUE_NO_EXTRA_PAYLOAD_FRAME;
+ assertArrayEquals(TestMessages.RST_STREAM_HIGHEST_VALUE_NO_EXTRA_PAYLOAD_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void settings() {
+ Http2Frame frame = TestMessages.SETTINGS_DEFAULT_FRAME;
+ assertArrayEquals(TestMessages.SETTINGS_DEFAULT_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void settingsHighestID() {
+ Http2Frame frame = TestMessages.SETTINGS_HIGHEST_ID_FRAME;
+ assertArrayEquals(TestMessages.SETTINGS_HIGHEST_ID_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void settingsHighestValue() {
+ Http2Frame frame = TestMessages.SETTINGS_HIGHEST_VALUE_FRAME;
+ assertArrayEquals(TestMessages.SETTINGS_HIGHEST_VALUE_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void unknownFrame() {
+ Http2Frame frame = TestMessages.UNKNOWN_PAYLOAD_FRAME;
+ assertArrayEquals(TestMessages.UNKNOWN_PAYLOAD_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+
+ @Test
+ public void unknownFrameNoPayload() {
+ Http2Frame frame = TestMessages.UNKNOWN_NO_PAYLOAD_FRAME;
+ assertArrayEquals(TestMessages.UNKNOWN_NO_PAYLOAD_BUFFER, toByteArray(encoder.encode(frame, null)));
+ }
+}