@Test
public void testEncodeHeaders() {

  String validOrigin = "http://localhost:12345";
  String encodedValidOrigin = CrossOriginFilter.encodeHeader(validOrigin);
  Assert.assertEquals("Valid origin encoding should match exactly",
      validOrigin, encodedValidOrigin);
  String httpResponseSplitOrigin = validOrigin + " \nSecondHeader: value";
  String encodedResponseSplitOrigin =
    CrossOriginFilter.encodeHeader(httpResponseSplitOrigin);
  Assert.assertEquals("Http response split origin should be protected against",
      validOrigin, encodedResponseSplitOrigin);
  // Test Origin List
  String validOriginList = "http://foo.example.com:12345 http://bar.example.com:12345";
  String encodedValidOriginList = CrossOriginFilter
      .encodeHeader(validOriginList);
  Assert.assertEquals("Valid origin list encoding should match exactly",
      validOriginList, encodedValidOriginList);
}