Issue #3444 - Adding testcase for HttpFields.add(PreEncoded|HttpField)

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2019-03-08 14:42:32 -06:00
parent beb4881af4
commit 133a4a10c0
1 changed files with 31 additions and 9 deletions

View File

@ -18,15 +18,6 @@
package org.eclipse.jetty.http;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.Enumeration;
@ -40,6 +31,15 @@ import org.eclipse.jetty.util.BufferUtil;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class HttpFieldsTest
{
@Test
@ -299,6 +299,28 @@ public class HttpFieldsTest
assertEquals(false, e.hasMoreElements());
}
@Test
public void testAddPreEncodedField()
{
final PreEncodedHttpField X_XSS_PROTECTION_FIELD = new PreEncodedHttpField("X-XSS-Protection", "1; mode=block");
HttpFields fields = new HttpFields();
fields.add(X_XSS_PROTECTION_FIELD);
assertThat("Fields output", fields.toString(), containsString("X-XSS-Protection: 1; mode=block"));
}
@Test
public void testAddFinalHttpField()
{
final HttpField X_XSS_PROTECTION_FIELD = new HttpField("X-XSS-Protection", "1; mode=block");
HttpFields fields = new HttpFields();
fields.add(X_XSS_PROTECTION_FIELD);
assertThat("Fields output", fields.toString(), containsString("X-XSS-Protection: 1; mode=block"));
}
@Test
public void testGetValues() throws Exception
{