resolver.setNegativeCacheTTL(5); // 5 secs
try {
// get the XRDS document for =foo with default trust type (none), following Refs if needed
XRDS xrds = resolver.resolveAuthToXRDS(new XRI("@freexri"), flags, new ResolverState());
// should have a positive cache for @freexri, and a negative for @freexri*nowhere2bFound
try {
xrds = resolver.resolveAuthToXRDS(new XRI("@freexri*nowhere2bFound"), flags, new ResolverState());
}
catch (PartialResolutionException e) {}
// should get cache HITs
try {
xrds = resolver.resolveAuthToXRDS(new XRI("@freexri*nowhere2bFound"), flags, new ResolverState());
}
catch (PartialResolutionException e) {}
// let the negative cache expire
try {
Thread.sleep(5000);
} catch (InterruptedException e1) {}
try {
// should get cache HIT for @freexri and MISS for @freexri*nowhere2bFound
xrds = resolver.resolveAuthToXRDS(new XRI("@freexri*nowhere2bFound"), flags, new ResolverState());
}
catch (PartialResolutionException e) {}
flags.setHttps(true);
try {
xrds = resolver.resolveAuthToXRDS(new XRI("@freexri*markus"), flags, new ResolverState());
}
catch (PartialResolutionException e) {}
xrds = resolver.resolveAuthToXRDS(new XRI("@freexri*markus"), flags, new ResolverState());
XRD xrd = xrds.getFinalXRD();
CanonicalID cid = xrd.getCanonicalidAt(0);