SB_CLASS.getSimpleName(),
SimpleAuthorizationRemote.class.getName(),
isBeanClassStatefull(SB_CLASS));
log.info("JNDI name=" + myContext);
final SimpleAuthorizationRemote singleMethodsAnnOnlyBean = (SimpleAuthorizationRemote)
ctx.lookup(myContext);
try {
String echoValue = singleMethodsAnnOnlyBean.defaultAccess("alohomora");
Assert.assertEquals(echoValue, "alohomora");
} catch (EJBAccessException e) {
Assert.fail("EJBAccessException not expected");
}
try {
String echoValue = singleMethodsAnnOnlyBean.roleBasedAccessOne("alohomora");
Assert.assertEquals(echoValue, "alohomora");
} catch (EJBAccessException e) {
Assert.fail("EJBAccessException not expected");
}
try {
String echoValue = singleMethodsAnnOnlyBean.roleBasedAccessMore("alohomora");
Assert.fail("Method cannot be successfully called with logged in principal.");
} catch (Exception e) {
// expected
Assert.assertTrue("Thrown exception must be EJBAccessException, but was different", e instanceof EJBAccessException);
}
try {
String echoValue = singleMethodsAnnOnlyBean.permitAll("alohomora");
Assert.assertEquals(echoValue, "alohomora");
} catch (Exception e) {
Assert.fail("@PermitAll annotation must allow all users and no users to call the method - principal.");
}
try {
String echoValue = singleMethodsAnnOnlyBean.denyAll("alohomora");
Assert.fail("@DenyAll annotation must allow all users and no users to call the method");
} catch (Exception e) {
// expected
Assert.assertTrue("Thrown exception must be EJBAccessException, but was different", e instanceof EJBAccessException);
}