Server server = startServer(new RedirectResponseHandler(true), 8089);
BaseFetcher fetcher = new SimpleHttpFetcher(1, policy, ConfigUtils.BIXO_TEST_AGENT);
String url = "http://localhost:8089/base";
try {
fetcher.get(new ScoredUrlDatum(url));
fail("Exception should have been thrown");
} catch (RedirectFetchException e) {
assertEquals("Redirected URL", "http://localhost:8089/redirect", e.getRedirectedUrl());
assertEquals(RedirectExceptionReason.PERM_REDIRECT_DISALLOWED, e.getReason());
} finally {
server.stop();
}
// Now try setting the mode to follow none
policy.setRedirectMode(RedirectMode.FOLLOW_NONE);
server = startServer(new RedirectResponseHandler(false), 8089);
fetcher = new SimpleHttpFetcher(1, policy, ConfigUtils.BIXO_TEST_AGENT);
try {
fetcher.get(new ScoredUrlDatum(url));
fail("Exception should have been thrown");
} catch (RedirectFetchException e) {
assertEquals("Redirected URL", "http://localhost:8089/redirect", e.getRedirectedUrl());
assertEquals(RedirectExceptionReason.TEMP_REDIRECT_DISALLOWED, e.getReason());
} finally {