}
}
public void testEntityWithMultipleContentLengthSomeWrong() throws Exception {
SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
HttpMessage message = new HttpMessageMockup();
// lenient mode
message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
message.addHeader("Content-Type", "unknown");
message.addHeader("Content-Length", "1");
message.addHeader("Content-Length", "yyy");
message.addHeader("Content-Length", "xxx");
EntityDeserializer entitygen = new EntityDeserializer(
new LaxContentLengthStrategy());
HttpEntity entity = entitygen.deserialize(datareceiver, message);
assertNotNull(entity);
assertEquals(1, entity.getContentLength());
assertFalse(entity.isChunked());
InputStream instream = entity.getContent();
assertNotNull(instream);
assertTrue(instream instanceof ContentLengthInputStream);
// strict mode
message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
try {
entitygen.deserialize(datareceiver, message);
fail("ProtocolException should have been thrown");
} catch (ProtocolException ex) {
// expected