HttpVersion extends ProtocolVersion { public static HttpVersion get(final int major, final int minor) { for (int i = 0; i < ALL.length; i++) { if (ALL[i].equals(major, minor)) { return ALL[i]; } } return new HttpVersion(major, minor); } HttpVersion(final int major, final int minor); static HttpVersion get(final int major, final int minor); static final String HTTP; static final HttpVersion HTTP_0_9; static final HttpVersion HTTP_1_0; static final HttpVersion HTTP_1_1; static final HttpVersion HTTP_2_0; static final HttpVersion HTTP_2; static final HttpVersion DEFAULT; static final HttpVersion[] ALL; }
@Test public void testGet() { Assert.assertEquals(HttpVersion.HTTP_0_9, HttpVersion.get(0, 9)); Assert.assertEquals(HttpVersion.HTTP_1_0, HttpVersion.get(1, 0)); Assert.assertEquals(HttpVersion.HTTP_1_1, HttpVersion.get(1, 1)); Assert.assertEquals(HttpVersion.HTTP_2_0, HttpVersion.get(2, 0)); Assert.assertEquals(HttpVersion.HTTP_2, HttpVersion.get(2, 0)); Assert.assertNotEquals(HttpVersion.HTTP_2_0, HttpVersion.get(2, 1)); Assert.assertSame(HttpVersion.HTTP_0_9, HttpVersion.get(0, 9)); Assert.assertSame(HttpVersion.HTTP_1_0, HttpVersion.get(1, 0)); Assert.assertSame(HttpVersion.HTTP_1_1, HttpVersion.get(1, 1)); Assert.assertSame(HttpVersion.HTTP_2_0, HttpVersion.get(2, 0)); Assert.assertSame(HttpVersion.HTTP_2, HttpVersion.get(2, 0)); Assert.assertNotSame(HttpVersion.HTTP_2_0, HttpVersion.get(2, 1)); }