Made test behave the same for different proxy servlets to reduce
instanceof checks.
This commit is contained in:
parent
a686e26c31
commit
d2e4eff686
|
@ -30,6 +30,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -264,15 +265,18 @@ public class ProxyServletFailureTest
|
||||||
@Override
|
@Override
|
||||||
protected ContentProvider proxyRequestContent(HttpServletRequest request, HttpServletResponse response, Request proxyRequest) throws IOException
|
protected ContentProvider proxyRequestContent(HttpServletRequest request, HttpServletResponse response, Request proxyRequest) throws IOException
|
||||||
{
|
{
|
||||||
return new DeferredContentProvider()
|
DeferredContentProvider provider = new DeferredContentProvider()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean offer(ByteBuffer buffer, Callback callback)
|
public boolean offer(ByteBuffer buffer, Callback callback)
|
||||||
{
|
{
|
||||||
// Ignore all content to trigger the test condition.
|
// Send less content to trigger the test condition.
|
||||||
return true;
|
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))
|
.content(new BytesContentProvider(content))
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
// TODO which is correct?
|
Assert.assertEquals(500, response.getStatus());
|
||||||
if (proxyServlet instanceof AsyncProxyServlet)
|
|
||||||
Assert.assertEquals(502, response.getStatus());
|
|
||||||
else
|
|
||||||
Assert.assertEquals(500, response.getStatus());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = TimeoutException.class)
|
@Test(expected = TimeoutException.class)
|
||||||
|
|
Loading…
Reference in New Issue