BaseFetcher fetcher = new SimpleHttpFetcher(1, policy, ConfigUtils.BIXO_TEST_AGENT);
fetcher.setDefaultMaxContentSize(1000);
fetcher.setMaxContentSize("image/png", 5000);
ScoredUrlDatum datumToFetch = new ScoredUrlDatum("http://localhost:8089/karlie.html");
FetchedDatum result1 = fetcher.get(datumToFetch);
FetchedDatum result2 = fetcher.get(datumToFetch);
// Verify that we got the same data from each fetch request.
assertEquals(1000, result1.getContentLength());
assertEquals(1000, result2.getContentLength());
byte[] bytes1 = result1.getContentBytes();
byte[] bytes2 = result2.getContentBytes();
for (int i = 0; i < bytes1.length; i++) {
assertEquals(bytes1[i], bytes2[i]);
}
datumToFetch = new ScoredUrlDatum("http://localhost:8089/bixolabs_mining.png");
FetchedDatum result3 = fetcher.get(datumToFetch);
assertTrue(result3.getContentLength() > 1000);
fetcher.setMaxContentSize("image/png", 1500);
try {
fetcher.get(datumToFetch);
fail("Aborted fetch exception not thrown");