assertMyStatefulBean(metaData.getEnterpriseBean("AnotherName")); // MyStatefulBean
assertMyStateless21Bean(metaData.getEnterpriseBean("MyStateless21Bean"));
assertMyStatelessBean(metaData.getEnterpriseBean("MyStatelessBean"));
assertMyMDB(metaData.getEnterpriseBean("MailMDB"));
AssemblyDescriptorMetaData assembly = metaData.getAssemblyDescriptor();
assertNotNull("no application exceptions defined", assembly.getApplicationExceptions());
assertEquals(1, assembly.getApplicationExceptions().size());
//System.out.println(assembly.getContainerTransactionsByEjbName("MyStatelessBean"));
// @DeclareRoles
SecurityRolesMetaData securityRoles = assembly.getSecurityRoles();
assertNotNull(securityRoles);
assertEquals(2, securityRoles.size());
SecurityRoleMetaData role1 = securityRoles.get("Role1");
assertNotNull(role1);
assertEquals("Role1", role1.getRoleName());
SecurityRoleMetaData role2 = securityRoles.get("Role2");
assertNotNull(role2);
assertEquals("Role2", role2.getRoleName());
// @DenyAll
// cls.getDeclaredMethods is un-ordered, so we must use bestMatch
ExcludeListMetaData excludes = assembly.getExcludeList();
assertNotNull(excludes);
MethodsMetaData excludedMethods = excludes.getMethods();
assertEquals(2, excludedMethods.size());
MethodMetaData m0 = excludedMethods.bestMatch("denyAll", (Class[]) null, null, null);
assertEquals("MyStatelessBean", m0.getEjbName());
assertEquals("denyAll", m0.getMethodName());
MethodParametersMetaData noargs = new MethodParametersMetaData();
assertEquals(noargs, m0.getMethodParams());
MethodMetaData m1 = excludedMethods.bestMatch("excluded", (Class[]) null, null, null);;
assertEquals("MyStatelessBean", m1.getEjbName());
assertEquals("excluded", m1.getMethodName());
assertEquals(noargs, m1.getMethodParams());
// @PermitAll, @RolesAllowed({"AccessRole1", "AccessRole2"})
MethodPermissionsMetaData allPerms = assembly.getMethodPermissions();
assertEquals(8, allPerms.size());
MethodPermissionsMetaData perms = assembly.getMethodPermissionsByEjbName("MyStatelessBean");
assertEquals(2, perms.size());
MethodPermissionMetaData permitAll = null;
MethodPermissionMetaData rolesAllowed = null;
for (MethodPermissionMetaData mp : perms)
{
if (mp.matches("permitAll", null, null))
permitAll = mp;
if (mp.matches("rolesAllowed", null, null))
rolesAllowed = mp;
}
assertNotNull(permitAll);
assertTrue(permitAll.isNotChecked());
assertTrue(permitAll.isNotChecked("permitAll", null, null));
assertNotNull(rolesAllowed);
HashSet<String> roles = new HashSet<String>();
roles.add("AccessRole1");
roles.add("AccessRole2");
assertEquals(roles, rolesAllowed.getRoles());
// Validate the MyStateless @Interceptors
InterceptorBindingsMetaData interceptorBindings = assembly.getInterceptorBindings();
assertEquals(2, interceptorBindings.size());
InterceptorBindingMetaData ib0 = interceptorBindings.get(0);
InterceptorBindingMetaData ib1 = interceptorBindings.get(1);
assertEquals("MyStatelessBean", ib0.getEjbName());
NamedMethodMetaData ib0Method = ib0.getMethod();