// check that via is highest precedence
CrawlURI a = new CrawlURI(
UURIFactory.getInstance("http://example.com/2"), // a > b
"2", // a > b
UURIFactory.getInstance("http://example.com/via/1"), // a < b
new SimpleLinkContext("2")); // a > b
CrawlURI b = new CrawlURI(
UURIFactory.getInstance("http://example.com/1"), // a > b
"1", // a > b
UURIFactory.getInstance("http://example.com/via/2"), // a < b
new SimpleLinkContext("1")); // a > b
assertEquals(-1, a.compareTo(b));
assertEquals(1, b.compareTo(a));
// check that uri is next highest
a = new CrawlURI(
UURIFactory.getInstance("http://example.com/1"), // a < b
"2", // a > b
UURIFactory.getInstance("http://example.com/via/1"), // a == b
new SimpleLinkContext("2")); // a > b
b = new CrawlURI(
UURIFactory.getInstance("http://example.com/2"), // a < b
"1", // a > b
UURIFactory.getInstance("http://example.com/via/1"), // a == b
new SimpleLinkContext("1")); // a > b
assertEquals(-1, a.compareTo(b));
assertEquals(1, b.compareTo(a));
// check that via context is next
a = new CrawlURI(
UURIFactory.getInstance("http://example.com/1"), // a == b
"2", // a > b
UURIFactory.getInstance("http://example.com/via/1"), // a == b
new SimpleLinkContext("1")); // a < b
b = new CrawlURI(
UURIFactory.getInstance("http://example.com/1"), // a == b
"1", // a > b
UURIFactory.getInstance("http://example.com/via/1"), // a == b
new SimpleLinkContext("2")); // a < b
assertEquals(-1, a.compareTo(b));
assertEquals(1, b.compareTo(a));
// check that pathFromSeed is next
a = new CrawlURI(
UURIFactory.getInstance("http://example.com/1"), // a == b
"1", // a < b
UURIFactory.getInstance("http://example.com/via/1"), // a == b
new SimpleLinkContext("1")); // a == b
b = new CrawlURI(
UURIFactory.getInstance("http://example.com/1"), // a == b
"2", // a < b
UURIFactory.getInstance("http://example.com/via/1"), // a == b
new SimpleLinkContext("1")); // a == b
assertEquals(-1, a.compareTo(b));
assertEquals(1, b.compareTo(a));
// check equality
a = new CrawlURI(
UURIFactory.getInstance("http://example.com/1"), // a == b
"1", // a == b
UURIFactory.getInstance("http://example.com/via/1"), // a == b
new SimpleLinkContext("1")); // a == b
b = new CrawlURI(
UURIFactory.getInstance("http://example.com/1"), // a == b
"1", // a == b
UURIFactory.getInstance("http://example.com/via/1"), // a == b
new SimpleLinkContext("1")); // a == b
assertEquals(0, a.compareTo(b));
assertEquals(0, b.compareTo(a));
}