aspects.interceptor(Pointcuts.instancesOf(SecureObject.class),
Pointcuts.ALL_METHODS, new AccessInterceptor((MethodAccessManager) callAccessManager.proxy()));
proxyFactory = ProxyFactory.getInstance(aspects);
SecureObject object = new SecureObjectImpl("TestName");
SecureObject wrapped = (SecureObject) proxyFactory.wrap(object);
try {
wrapped.setName("NewTestName");
fail("Access should be denied to method setName() for NotAllowedPrincipal");
} catch (SecurityException e) {
// System.out.println(e.getMessage());
}
assertEquals("Name not set by wrong principal.", "TestName", object.getName());