You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2016/04/16 15:33:10 UTC

svn commit: r1739460 - in /httpcomponents/httpcore/trunk/httpcore5-h2/src: main/java/org/apache/hc/core5/http2/ main/java/org/apache/hc/core5/http2/frame/ main/java/org/apache/hc/core5/http2/setting/ test/java/org/apache/hc/core5/http2/frame/

Author: olegk
Date: Sat Apr 16 13:33:10 2016
New Revision: 1739460

URL: http://svn.apache.org/viewvc?rev=1739460&view=rev
Log:
RFC 7540: Default frame factory

Added:
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/DefaultFrameFactory.java
      - copied, changed from r1739459, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Setting.java
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFactory.java   (with props)
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Param.java
      - copied, changed from r1739459, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Settings.java
    httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/
    httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java   (with props)
    httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java   (contents, props changed)
      - copied, changed from r1739459, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Settings.java
Removed:
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Settings.java
Modified:
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Setting.java

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java?rev=1739460&r1=1739459&r2=1739460&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java Sat Apr 16 13:33:10 2016
@@ -26,6 +26,9 @@
  */
 package org.apache.hc.core5.http2;
 
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
 public enum H2Error {
 
     /**
@@ -138,4 +141,16 @@ public enum H2Error {
         return code;
     }
 
+    private static final ConcurrentMap<Integer, H2Error> MAP_BY_CODE;
+    static {
+        MAP_BY_CODE = new ConcurrentHashMap<>();
+        for (H2Error error: values()) {
+            MAP_BY_CODE.putIfAbsent(error.code, error);
+        }
+    }
+
+    public static H2Error getByCode(final int code) {
+        return MAP_BY_CODE.get(code);
+    }
+
 };

Copied: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/DefaultFrameFactory.java (from r1739459, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Setting.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/DefaultFrameFactory.java?p2=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/DefaultFrameFactory.java&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Setting.java&r1=1739459&r2=1739460&rev=1739460&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Setting.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/DefaultFrameFactory.java Sat Apr 16 13:33:10 2016
@@ -24,55 +24,31 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.hc.core5.http2.setting;
 
-import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
-
-public final class H2Setting {
+package org.apache.hc.core5.http2.frame;
 
-    private final int code;
-    private final long value;
+import java.nio.ByteBuffer;
 
-    public H2Setting(final int code, final long value) {
-        Args.positive(code, "Setting code must be a positive value");
-        Args.notNegative(value, "Setting value must be a non-negative value");
-        this.code = code;
-        this.value = value;
-    }
+import org.apache.hc.core5.util.Args;
 
-    public int getCode() {
-        return code;
-    }
+public class DefaultFrameFactory extends FrameFactory {
 
-    public long getValue() {
-        return value;
+    public Frame<ByteBuffer> createHeaders(final int streamId, final ByteBuffer content, final boolean endHeaders, final boolean endStream) {
+        Args.positive(streamId, "Stream id");
+        final int flags = (endHeaders ? FrameFlag.END_HEADERS.value : 0) | (endStream ? FrameFlag.END_STREAM.value : 0);
+        return new ByteBufferFrame(FrameType.HEADERS.getValue(), flags, streamId, content);
     }
 
-    @Override
-    public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof H2Setting) {
-            final H2Setting that = (H2Setting) obj;
-            return this.code == that.code;
-        } else {
-            return false;
-        }
+    public Frame<ByteBuffer> createContinuation(final int streamId, final ByteBuffer content, final boolean endHeaders) {
+        Args.positive(streamId, "Stream id");
+        final int flags = (endHeaders ? FrameFlag.END_HEADERS.value : 0);
+        return new ByteBufferFrame(FrameType.CONTINUATION.getValue(), flags, streamId, content);
     }
 
-    @Override
-    public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, this.code);
-        return hash;
+    public Frame<ByteBuffer> createData(final int streamId, final ByteBuffer content, final boolean endStream) {
+        Args.positive(streamId, "Stream id");
+        final int flags = (endStream ? FrameFlag.END_STREAM.value : 0);
+        return new ByteBufferFrame(FrameType.DATA.getValue(), flags, streamId, content);
     }
 
-    @Override
-    public String toString() {
-        final StringBuilder sb = new StringBuilder()
-                .append("[").append(code).append(":").append(value).append(']');
-        return sb.toString();
-    }
-};
+}

Added: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFactory.java?rev=1739460&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFactory.java (added)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFactory.java Sat Apr 16 13:33:10 2016
@@ -0,0 +1,93 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http2.frame;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.hc.core5.http2.H2Error;
+import org.apache.hc.core5.http2.setting.H2Setting;
+import org.apache.hc.core5.util.Args;
+
+public abstract class FrameFactory {
+
+    public Frame<ByteBuffer> createSettings(final H2Setting... settings) {
+        final ByteBuffer payload = ByteBuffer.allocate(settings.length * 12);
+        for (H2Setting setting: settings) {
+            payload.putInt(setting.getCode());
+            payload.putLong(setting.getValue());
+        }
+        payload.flip();
+        return new ByteBufferFrame(FrameType.SETTINGS.getValue(), 0, 0, payload);
+    }
+
+    public Frame<ByteBuffer> createSettingsAck() {
+        return new ByteBufferFrame(FrameType.SETTINGS.getValue(), FrameFlag.ACK.getValue(), 0, null);
+    }
+
+    public Frame<ByteBuffer> createResetStream(final int streamId, final H2Error error) {
+        Args.positive(streamId, "Stream id");
+        Args.notNull(error, "Error");
+        final ByteBuffer payload = ByteBuffer.allocate(4);
+        payload.putInt(error.getCode());
+        payload.flip();
+        return new ByteBufferFrame(FrameType.RST_STREAM.getValue(), 0, streamId, payload);
+    }
+
+    public Frame<ByteBuffer> createPing(final byte[] opaqueData) {
+        Args.notNull(opaqueData, "Opaque data");
+        Args.check(opaqueData.length == 8, "Opaque data length must be equal 8");
+        final ByteBuffer payload = ByteBuffer.wrap(opaqueData);
+        return new ByteBufferFrame(FrameType.PING.getValue(), 0, 0, payload);
+    }
+
+    public Frame<ByteBuffer> createPingAck(final byte[] opaqueData) {
+        Args.notNull(opaqueData, "Opaque data");
+        Args.check(opaqueData.length == 8, "Opaque data length must be equal 8");
+        final ByteBuffer payload = ByteBuffer.wrap(opaqueData);
+        return new ByteBufferFrame(FrameType.PING.getValue(), FrameFlag.ACK.value, 0, payload);
+    }
+
+    public Frame<ByteBuffer> createGoAway(final int lastStream, final H2Error error, final String message) {
+        Args.positive(lastStream, "Last stream id");
+        final byte[] debugData = message != null ? message.getBytes(StandardCharsets.US_ASCII) : null;
+        final ByteBuffer payload = ByteBuffer.allocate(8 + (debugData != null ? debugData.length : 0));
+        payload.putInt(lastStream);
+        payload.putInt(error.getCode());
+        payload.put(debugData);
+        payload.flip();
+        return new ByteBufferFrame(FrameType.GOAWAY.getValue(), 0, 0, payload);
+    }
+
+    public abstract Frame<ByteBuffer> createHeaders(int streamId, ByteBuffer content, boolean endHeaders, boolean endStream);
+
+    public abstract Frame<ByteBuffer> createContinuation(int streamId, ByteBuffer content, boolean endHeaders);
+
+    public abstract Frame<ByteBuffer> createData(int streamId, ByteBuffer content, boolean endStream);
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Param.java (from r1739459, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Settings.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Param.java?p2=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Param.java&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Settings.java&r1=1739459&r2=1739460&rev=1739460&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Settings.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Param.java Sat Apr 16 13:33:10 2016
@@ -26,7 +26,10 @@
  */
 package org.apache.hc.core5.http2.setting;
 
-public enum H2Settings {
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+public enum H2Param {
 
     HEADER_TABLE_SIZE      (0x1,   4096),
     ENABLE_PUSH            (0x2,   1),
@@ -39,7 +42,7 @@ public enum H2Settings {
 
     long initialValue;
 
-    H2Settings(final int code, final long initialValue) {
+    H2Param(final int code, final long initialValue) {
         this.code = code;
         this.initialValue = initialValue;
     }
@@ -52,4 +55,16 @@ public enum H2Settings {
         return initialValue;
     }
 
+    private static final ConcurrentMap<Integer, H2Param> MAP_BY_CODE;
+    static {
+        MAP_BY_CODE = new ConcurrentHashMap<>();
+        for (H2Param param: values()) {
+            MAP_BY_CODE.putIfAbsent(param.code, param);
+        }
+    }
+
+    public static H2Param getByCode(final int code) {
+        return MAP_BY_CODE.get(code);
+    }
+
 };

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Setting.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Setting.java?rev=1739460&r1=1739459&r2=1739460&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Setting.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Setting.java Sat Apr 16 13:33:10 2016
@@ -31,18 +31,24 @@ import org.apache.hc.core5.util.LangUtil
 
 public final class H2Setting {
 
-    private final int code;
+    private final H2Param param;
     private final long value;
 
-    public H2Setting(final int code, final long value) {
-        Args.positive(code, "Setting code must be a positive value");
+    public H2Setting(final H2Param param, final long value) {
+        Args.notNull(param, "Setting parameter");
         Args.notNegative(value, "Setting value must be a non-negative value");
-        this.code = code;
+        this.param = param;
         this.value = value;
     }
 
+    public H2Setting(final H2Param param) {
+        Args.notNull(param, "Setting parameter");
+        this.param = param;
+        this.value = param.initialValue;
+    }
+
     public int getCode() {
-        return code;
+        return param.code;
     }
 
     public long getValue() {
@@ -56,7 +62,7 @@ public final class H2Setting {
         }
         if (obj instanceof H2Setting) {
             final H2Setting that = (H2Setting) obj;
-            return this.code == that.code;
+            return this.param.equals(that.param);
         } else {
             return false;
         }
@@ -65,14 +71,14 @@ public final class H2Setting {
     @Override
     public int hashCode() {
         int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, this.code);
+        hash = LangUtils.hashCode(hash, this.param);
         return hash;
     }
 
     @Override
     public String toString() {
         final StringBuilder sb = new StringBuilder()
-                .append("[").append(code).append(":").append(value).append(']');
+                .append("[").append(param).append(":").append(value).append(']');
         return sb.toString();
     }
 };

Added: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java?rev=1739460&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java (added)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java Sat Apr 16 13:33:10 2016
@@ -0,0 +1,102 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.hc.core5.http2.frame;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.hc.core5.http2.H2Error;
+import org.apache.hc.core5.http2.setting.H2Param;
+import org.apache.hc.core5.http2.setting.H2Setting;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestDefaultFrameFactory {
+
+    @Test
+    public void testDataFrame() throws Exception {
+
+        final FrameFactory frameFactory = new DefaultFrameFactory();
+
+        final byte[] data = new byte[]{'a', 'b', 'c', 'd', 'e', 'f'};
+        final Frame<ByteBuffer> dataFrame = frameFactory.createData(23, ByteBuffer.wrap(data), true);
+
+        Assert.assertEquals(FrameType.DATA.value, dataFrame.getType());
+        Assert.assertEquals(23, dataFrame.getStreamId());
+        Assert.assertEquals(1L, dataFrame.getFlags());
+    }
+
+    @Test
+    public void testSettingFrame() throws Exception {
+
+        final FrameFactory frameFactory = new DefaultFrameFactory();
+        final Frame<ByteBuffer> settingsFrame = frameFactory.createSettings(
+                new H2Setting(H2Param.HEADER_TABLE_SIZE),
+                new H2Setting(H2Param.MAX_CONCURRENT_STREAMS, 1));
+
+        Assert.assertEquals(FrameType.SETTINGS.value, settingsFrame.getType());
+        Assert.assertEquals(0, settingsFrame.getStreamId());
+        Assert.assertEquals(0, settingsFrame.getFlags());
+        final ByteBuffer payload = settingsFrame.getPayload();
+        Assert.assertNotNull(payload);
+        Assert.assertEquals(24, payload.remaining());
+    }
+
+    @Test
+    public void testResetStreamFrame() throws Exception {
+
+        final FrameFactory frameFactory = new DefaultFrameFactory();
+        final Frame<ByteBuffer> rstStreamFrame = frameFactory.createResetStream(12, H2Error.INTERNAL_ERROR);
+
+        Assert.assertEquals(FrameType.RST_STREAM.value, rstStreamFrame.getType());
+        Assert.assertEquals(12, rstStreamFrame.getStreamId());
+        Assert.assertEquals(0, rstStreamFrame.getFlags());
+        final ByteBuffer payload = rstStreamFrame.getPayload();
+        Assert.assertNotNull(payload);
+        Assert.assertEquals(4, payload.remaining());
+        Assert.assertEquals(H2Error.INTERNAL_ERROR.getCode(), payload.getInt());
+    }
+
+    @Test
+    public void testGoAwayFrame() throws Exception {
+
+        final FrameFactory frameFactory = new DefaultFrameFactory();
+        final Frame<ByteBuffer> goAwayFrame = frameFactory.createGoAway(13, H2Error.INTERNAL_ERROR, "Oopsie");
+
+        Assert.assertEquals(FrameType.GOAWAY.value, goAwayFrame.getType());
+        Assert.assertEquals(0, goAwayFrame.getStreamId());
+        Assert.assertEquals(0, goAwayFrame.getFlags());
+        final ByteBuffer payload = goAwayFrame.getPayload();
+        Assert.assertNotNull(payload);
+        Assert.assertEquals(13, payload.getInt());
+        Assert.assertEquals(H2Error.INTERNAL_ERROR.getCode(), payload.getInt());
+        final byte[] tmp = new byte[payload.remaining()];
+        payload.get(tmp);
+        Assert.assertEquals("Oopsie", new String(tmp, StandardCharsets.US_ASCII));
+    }
+
+};

Propchange: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java (from r1739459, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Settings.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java?p2=httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Settings.java&r1=1739459&r2=1739460&rev=1739460&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/setting/H2Settings.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java Sat Apr 16 13:33:10 2016
@@ -24,32 +24,18 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.hc.core5.http2.setting;
+package org.apache.hc.core5.http2.frame;
 
-public enum H2Settings {
+import org.junit.Assert;
+import org.junit.Test;
 
-    HEADER_TABLE_SIZE      (0x1,   4096),
-    ENABLE_PUSH            (0x2,   1),
-    MAX_CONCURRENT_STREAMS (0x3,   Long.MAX_VALUE),
-    INITIAL_WINDOW_SIZE    (0x4,   65535),
-    MAX_FRAME_SIZE         (0x5,   16384),
-    MAX_HEADER_LIST_SIZE   (0x6,   Long.MAX_VALUE);
+public class TestFrameFlag {
 
-    int code;
+    @Test
+    public void testFrameFlagBasics() throws Exception {
 
-    long initialValue;
-
-    H2Settings(final int code, final long initialValue) {
-        this.code = code;
-        this.initialValue = initialValue;
-    }
-
-    public int getCode() {
-        return code;
-    }
-
-    public long getInitialValue() {
-        return initialValue;
+        final int flags = FrameFlag.of(FrameFlag.END_STREAM, FrameFlag.PADDED, FrameFlag.PRIORITY);
+        Assert.assertEquals(0x01 | 0x08 | 0x20, flags);
     }
 
 };

Propchange: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain