@Test
  public void testParseExtension() {
    /*
       Original header:
       Sec-WebSocket-Extensions: x-webkit-deflate-message, x-custom-extension
    */
    final String EXTENSION_HEADER1 = " x-webkit-deflate-message , x-custom-extension ";

    final List<WebSocketExtension> extensions1 = WebSocketExtension.parse(EXTENSION_HEADER1);
    Assert.assertEquals(2, extensions1.size());
    Assert.assertEquals("x-webkit-deflate-message", extensions1.get(0).getName());
    Assert.assertEquals("x-custom-extension", extensions1.get(1).getName());

    /*
       Original header:
       Sec-WebSocket-Extensions: foo, bar; baz=2
    */
    final String EXTENSION_HEADER2 = " foo, bar; baz=2";

    final List<WebSocketExtension> extensions2 = WebSocketExtension.parse(EXTENSION_HEADER2);
    Assert.assertEquals(2, extensions2.size());
    Assert.assertEquals("foo", extensions2.get(0).getName());
    Assert.assertEquals(0, extensions2.get(0).getParameters().size());
    Assert.assertEquals("bar", extensions2.get(1).getName());
    Assert.assertEquals(1, extensions2.get(1).getParameters().size());
    Assert.assertEquals("baz", extensions2.get(1).getParameters().get(0).getName());
    Assert.assertEquals("2", extensions2.get(1).getParameters().get(0).getValue());
  }
  @Test
  public void testToExtensionHeader() {
    /*
       Original header:
       Sec-WebSocket-Extensions: x-webkit-deflate-message, x-custom-extension
    */
    final String EXTENSION_HEADER1 = " x-webkit-deflate-message , x-custom-extension ";

    final List<WebSocketExtension> extensions1 = WebSocketExtension.parse(EXTENSION_HEADER1);
    final String extensionHeader1 = WebSocketExtension.toExtensionHeader(extensions1);
    Assert.assertEquals("x-webkit-deflate-message, x-custom-extension", extensionHeader1);

    /*
       Original header:
       Sec-WebSocket-Extensions: foo, bar; baz=2
    */
    final String EXTENSION_HEADER2 = " foo, bar; baz=2";

    final List<WebSocketExtension> extensions2 = WebSocketExtension.parse(EXTENSION_HEADER2);
    final String extensionHeader2 = WebSocketExtension.toExtensionHeader(extensions2);
    Assert.assertEquals("foo, bar; baz=2", extensionHeader2);
  }