public void testParsesCheckpoints()
throws RepositoryException, AuthenticationException {
List entries = new LinkedList();
Entry entry = new Entry();
entry.setUpdated(DateTime.now());
entry.setId("meow");
entries.add(entry);
Feed riggedFeed = new Feed();
riggedFeed.getEntries().addAll(entries);
RiggedCalendarService service = new RiggedCalendarService(riggedFeed);
CalendarEntryProvider provider =
new CalendarEntryProvider(service, "admin@example.com", "secret");
// In this test we are not interested in the results, just what exceptions
// are thrown.
List results = null;
String checkpoint = null;
try {
results = provider.getOrderedEntriesForUser("somebody", null);
fail("Should have thrown DidNotPassIfModifiedSinceException.");
} catch (DidNotPassIfModifiedSinceException dnpimse) {
// this is the desired behavior
}
String realCheckpoint = provider.getCheckpointForEntry(entry);
try {
results = provider.getOrderedEntriesForUser("somebody", realCheckpoint);
} catch (DidNotPassIfModifiedSinceException dnpimse) {
// checkpoint was generated by this provider, it should be able to parse
fail(dnpimse.toString());
}
try {
String brokenCheckpoint = "123hax" + "!" + entry.getId();
results = provider.getOrderedEntriesForUser("somebody", brokenCheckpoint);
fail("Should have thrown DidNotPassIfModifiedSinceException.");
} catch (DidNotPassIfModifiedSinceException dnpimse) {
// this is the desired behavior again
}