final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_TEMPORARY_REDIRECT, "Temporary Redirect");
response.addHeader("Location", "http://localhost/stuff");
final HttpContext context1 = new BasicHttpContext();
final HttpUriRequest redirect1 = redirectStrategy.getRedirect(
new HttpTrace("http://localhost/"), response, context1);
Assert.assertEquals("TRACE", redirect1.getMethod());
final HttpContext context2 = new BasicHttpContext();
final HttpPost httppost = new HttpPost("http://localhost/");
final HttpEntity entity = new BasicHttpEntity();
httppost.setEntity(entity);
final HttpUriRequest redirect2 = redirectStrategy.getRedirect(
httppost, response, context2);
Assert.assertEquals("POST", redirect2.getMethod());
Assert.assertTrue(redirect2 instanceof HttpEntityEnclosingRequest);
Assert.assertSame(entity, ((HttpEntityEnclosingRequest) redirect2).getEntity());
}