[#3869] Add unit test to ensure adding null header values is not allowed.

Motivation:

We need to ensure we never allow to have null values set on headers, otherwise we will see a NPE during encoding them.

Modifications:

Add unit test that shows we correctly handle null values.

Result:

Verify correct implementation.
This commit is contained in:
Norman Maurer 2015-06-08 09:59:44 +02:00
parent cf54c04241
commit e9a2cac16d

View File

@ -57,4 +57,16 @@ public class HttpHeadersTest {
assertThat(AsciiString.equalsIgnoreCase("bar", null), is(false));
assertThat(AsciiString.equalsIgnoreCase("FoO", "fOo"), is(true));
}
@Test(expected = NullPointerException.class)
public void testSetNullHeaderValueValidate() {
HttpHeaders headers = new DefaultHttpHeaders(true);
headers.set("test", (CharSequence) null);
}
@Test(expected = NullPointerException.class)
public void testSetNullHeaderValueNotValidate() {
HttpHeaders headers = new DefaultHttpHeaders(false);
headers.set("test", (CharSequence) null);
}
}