converted.set(key, value);
@Test public void testInvalidSettings() throws Exception { io.vertx.core.http.Http2Settings settings = new io.vertx.core.http.Http2Settings(); try { settings.set(Integer.MAX_VALUE, 0); fail("max id should be 0-0xFFFF"); } catch (RuntimeException e) { // expected } try { settings.set(7, -1); fail("max value should be 0-0xFFFFFFFF"); } catch (RuntimeException e) { // expected } }
/** * Create random {@link Http2Settings} with valid values. * * @return the random settings */ public static Http2Settings randomHttp2Settings() { long headerTableSize = 10 + randomPositiveInt() % (Http2CodecUtil.MAX_HEADER_TABLE_SIZE - 10); boolean enablePush = randomBoolean(); long maxConcurrentStreams = 10 + randomPositiveLong() % (Http2CodecUtil.MAX_CONCURRENT_STREAMS - 10); int initialWindowSize = 10 + randomPositiveInt() % (Http2CodecUtil.MAX_INITIAL_WINDOW_SIZE - 10); int maxFrameSize = Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND + randomPositiveInt() % (Http2CodecUtil.MAX_FRAME_SIZE_UPPER_BOUND - Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND); long maxHeaderListSize = 10 + randomPositiveLong() % (Http2CodecUtil.MAX_HEADER_LIST_SIZE - 10); Http2Settings settings = new Http2Settings(); settings.setHeaderTableSize(headerTableSize); settings.setPushEnabled(enablePush); settings.setMaxConcurrentStreams(maxConcurrentStreams); settings.setInitialWindowSize(initialWindowSize); settings.setMaxFrameSize(maxFrameSize); settings.setMaxHeaderListSize(maxHeaderListSize); settings.set('\u0007', (randomPositiveLong() & 0xFFFFFFFFL)); return settings; }
@Test public void testSettingsMin() { for (int i = 1;i <= 6;i++) { try { new Http2Settings().set(i, min[i - 1] - 1); fail(); } catch (IllegalArgumentException ignore) { } } Http2Settings settings = new Http2Settings(); for (int i = 1;i <= 6;i++) { settings.set(i, min[i - 1]); } HttpUtils.fromVertxSettings(settings); }
converted.set(key, value);
@Test public void testSettinsMax() { for (int i = 1;i <= 6;i++) { try { new Http2Settings().set(i, max[i - 1] + 1); fail("Was expecting setting " + (i - 1) + " update to throw IllegalArgumentException"); } catch (IllegalArgumentException ignore) { } } Http2Settings settings = new Http2Settings(); for (int i = 1;i <= 6;i++) { settings.set(i, max[i - 1]); } HttpUtils.fromVertxSettings(settings); }
/** * Create random {@link Http2Settings} with valid values. * * @return the random settings */ public static Http2Settings randomHttp2Settings() { long headerTableSize = 10 + randomPositiveInt() % (Http2CodecUtil.MAX_HEADER_TABLE_SIZE - 10); boolean enablePush = randomBoolean(); long maxConcurrentStreams = 10 + randomPositiveLong() % (Http2CodecUtil.MAX_CONCURRENT_STREAMS - 10); int initialWindowSize = 10 + randomPositiveInt() % (Http2CodecUtil.MAX_INITIAL_WINDOW_SIZE - 10); int maxFrameSize = Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND + randomPositiveInt() % (Http2CodecUtil.MAX_FRAME_SIZE_UPPER_BOUND - Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND); long maxHeaderListSize = 10 + randomPositiveLong() % (Http2CodecUtil.MAX_HEADER_LIST_SIZE - 10); Http2Settings settings = new Http2Settings(); settings.setHeaderTableSize(headerTableSize); settings.setPushEnabled(enablePush); settings.setMaxConcurrentStreams(maxConcurrentStreams); settings.setInitialWindowSize(initialWindowSize); settings.setMaxFrameSize(maxFrameSize); settings.setMaxHeaderListSize(maxHeaderListSize); settings.set('\u0007', (randomPositiveLong() & 0xFFFFFFFFL)); return settings; }
@Test public void toNettySettings() { Http2Settings settings = new Http2Settings(); for (int i = 7;i <= 0xFFFF;i += 1) { // we need to clamp the random value to pass validation settings.set(0xFFFF, Math.min(0xFFFFFFFFL, TestUtils.randomPositiveLong())); } io.netty.handler.codec.http2.Http2Settings conv = HttpUtils.fromVertxSettings(settings); for (int i = 1;i <= 0xFFFF;i += 1) { assertEquals(settings.get(i), conv.get((char)i)); } settings = HttpUtils.toVertxSettings(conv); for (int i = 1;i <= 0xFFFF;i += 1) { assertEquals(settings.get(i), conv.get((char)i)); } }
@Test public void testInvalidSettings() throws Exception { io.vertx.core.http.Http2Settings settings = new io.vertx.core.http.Http2Settings(); try { settings.set(Integer.MAX_VALUE, 0); fail("max id should be 0-0xFFFF"); } catch (RuntimeException e) { // expected } try { settings.set(7, -1); fail("max value should be 0-0xFFFFFFFF"); } catch (RuntimeException e) { // expected } }
@Test public void testSettingsMin() { for (int i = 1;i <= 6;i++) { try { new Http2Settings().set(i, min[i - 1] - 1); fail(); } catch (IllegalArgumentException ignore) { } } Http2Settings settings = new Http2Settings(); for (int i = 1;i <= 6;i++) { settings.set(i, min[i - 1]); } HttpUtils.fromVertxSettings(settings); }
@Test public void testSettinsMax() { for (int i = 1;i <= 6;i++) { try { new Http2Settings().set(i, max[i - 1] + 1); fail("Was expecting setting " + (i - 1) + " update to throw IllegalArgumentException"); } catch (IllegalArgumentException ignore) { } } Http2Settings settings = new Http2Settings(); for (int i = 1;i <= 6;i++) { settings.set(i, max[i - 1]); } HttpUtils.fromVertxSettings(settings); }
@Test public void toNettySettings() { Http2Settings settings = new Http2Settings(); for (int i = 7;i <= 0xFFFF;i += 1) { // we need to clamp the random value to pass validation settings.set(0xFFFF, Math.min(0xFFFFFFFFL, TestUtils.randomPositiveLong())); } io.netty.handler.codec.http2.Http2Settings conv = HttpUtils.fromVertxSettings(settings); for (int i = 1;i <= 0xFFFF;i += 1) { assertEquals(settings.get(i), conv.get((char)i)); } settings = HttpUtils.toVertxSettings(conv); for (int i = 1;i <= 0xFFFF;i += 1) { assertEquals(settings.get(i), conv.get((char)i)); } }