Made test behave the same for different proxy servlets to reduce

instanceof checks.
This commit is contained in:
Simone Bordet 2015-11-25 17:21:51 +01:00
parent a686e26c31
commit d2e4eff686
1 changed files with 8 additions and 9 deletions

View File

@ -30,6 +30,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@ -264,15 +265,18 @@ public class ProxyServletFailureTest
@Override
protected ContentProvider proxyRequestContent(HttpServletRequest request, HttpServletResponse response, Request proxyRequest) throws IOException
{
return new DeferredContentProvider()
DeferredContentProvider provider = new DeferredContentProvider()
{
@Override
public boolean offer(ByteBuffer buffer, Callback callback)
{
// Ignore all content to trigger the test condition.
return true;
// Send less content to trigger the test condition.
buffer.limit(buffer.limit() - 1);
return super.offer(buffer.slice(), callback);
}
};
request.getInputStream().setReadListener(newReadListener(request, response, proxyRequest, provider));
return provider;
}
};
}
@ -305,12 +309,7 @@ public class ProxyServletFailureTest
.content(new BytesContentProvider(content))
.send();
// TODO which is correct?
if (proxyServlet instanceof AsyncProxyServlet)
Assert.assertEquals(502, response.getStatus());
else
Assert.assertEquals(500, response.getStatus());
Assert.assertEquals(500, response.getStatus());
}
@Test(expected = TimeoutException.class)