@Test public void testCountUniquePages() { MemoryDocumentStorage docStorage = new MemoryDocumentStorage(); docStorage.storeDocument("http://www.example.com", ""); docStorage.storeDocument("http://www.example.com/", ""); docStorage.storeDocument("http://www.otherexample.com", ""); urlStats.runStats(docStorage); long expectedCount = 3; long actualCount = urlStats.getTotalUniquePages(); assertEquals(expectedCount, actualCount); }
@Test public void testCountSubdomains_Tricky() { MemoryDocumentStorage docStorage = new MemoryDocumentStorage(); docStorage.storeDocument("http://vision.ics.uci.edu", ""); docStorage.storeDocument("http://vision.ics.uci.edu/", ""); docStorage.storeDocument("http://vision.ics.uci.edu/page.php", ""); docStorage.storeDocument("http://vision.ics.uci.edu/page.php?query", ""); ArrayList<Frequency> expected = new ArrayList<Frequency>(); expected.add(new Frequency("http://vision.ics.uci.edu", 3)); urlStats.runStats(docStorage); List<Frequency> actual = urlStats.getSubdomainFrequencies(); TestUtils.compareFrequencyLists(expected, actual); }
@Test public void testCountUniquePages_QueriesAndTags() { MemoryDocumentStorage docStorage = new MemoryDocumentStorage(); docStorage.storeDocument("http://www.example.com/page.php", ""); docStorage.storeDocument("http://www.example.com/page.php?query=1", ""); docStorage.storeDocument("http://www.example.com/page.php?query=1&query=2&query=3", ""); docStorage.storeDocument("http://www.example.com/page.php#tag", ""); docStorage.storeDocument("http://www.example.com/page.php?query#tag", ""); urlStats.runStats(docStorage); long expectedCount = 1; long actualCount = urlStats.getTotalUniquePages(); assertEquals(expectedCount, actualCount); }