public void testNegativeCacheEntries() throws RepositoryException, NotExecutableException { String unknownName = "UnknownPrincipal"; PrincipalProvider caching = new DummyProvider(); Properties options = new Properties(); options.setProperty(DefaultPrincipalProvider.NEGATIVE_ENTRY_KEY, "true"); caching.init(options); // accessing from wrapper must not throw! as negative entry is expected // to be in the cache (default behavior of the DefaultPrincipalProvider) assertNull(caching.getPrincipal(unknownName)); assertNull(caching.getPrincipal(unknownName)); PrincipalProvider throwing = new DummyProvider(); options = new Properties(); options.setProperty(DefaultPrincipalProvider.NEGATIVE_ENTRY_KEY, "false"); throwing.init(options); // however: the noNegativeCacheProvider configured NOT to cache null-results // is expected to call 'providePrincipal' for each call to 'getPrincipal' // with a principalName that doesn't exist. assertNull(throwing.getPrincipal(unknownName)); try { throwing.getPrincipal(unknownName); fail("exception expected"); } catch (UnsupportedOperationException e) { // success } }