in.close();
out.close();
}
public void testPartitioner() throws IOException {
UrlOnlyPartitioner part = new UrlOnlyPartitioner();
UrlWithScore k1 = new UrlWithScore("http://example.org/1", 1f);
UrlWithScore k2 = new UrlWithScore("http://example.org/1", 2f);
UrlWithScore k3 = new UrlWithScore("http://example.org/2", 1f);
UrlWithScore k4 = new UrlWithScore("http://example.org/2", 2f);
UrlWithScore k5 = new UrlWithScore("http://example.org/2", 3f);
int numReduces = 7;
// keys 1 and 2 should be partitioned together
int partForKey1 = part.getPartition(k1, null, numReduces);
assertEquals(partForKey1, part.getPartition(k2, null, numReduces));
assertEquals(partForKey1, part.getPartition(k2, null, numReduces));
// keys 3, 4 and 5 should be partitioned together
int partForKey3 = part.getPartition(k3, null, numReduces);
assertEquals(partForKey3, part.getPartition(k4, null, numReduces));
assertEquals(partForKey3, part.getPartition(k5, null, numReduces));
}