* @throws Exception
*/
@Test
public void testNotAuthorized() throws Exception
{
WicketTester tester = new WicketTester();
tester.getApplication()
.getSecuritySettings()
.setAuthorizationStrategy(
new RoleAuthorizationStrategy(new UserRolesAuthorizer("USER")));
final class Listener implements IUnauthorizedComponentInstantiationListener
{
private boolean eventReceived = false;
@Override
public void onUnauthorizedInstantiation(Component component)
{
eventReceived = true;
}
}
Listener listener = new Listener();
tester.getApplication()
.getSecuritySettings()
.setUnauthorizedComponentInstantiationListener(listener);
try
{
tester.startPage(AdminPage.class);
assertTrue("an authorization exception event should have been received",
listener.eventReceived);
}
catch (Exception e)
{