public void testAssemblyMethodPermissionsOverride()
{
// original
JBoss50MetaData original = new JBoss50MetaData();
JBossAssemblyDescriptorMetaData assembly = new JBossAssemblyDescriptorMetaData();
original.setAssemblyDescriptor(assembly);
MethodPermissionsMetaData permissions = new MethodPermissionsMetaData();
assembly.setMethodPermissions(permissions);
// original only
MethodsMetaData methods = new MethodsMetaData();
MethodMetaData method = new MethodMetaData();
method.setEjbName("Original");
method.setMethodName("execute");
methods.add(method);
MethodPermissionMetaData permission = new MethodPermissionMetaData();
permission.setMethods(methods);
permission.setRoles(java.util.Collections.singleton("original"));
permissions.add(permission);
// mixed original part
methods = new MethodsMetaData();
method = new MethodMetaData();
method.setEjbName("Overriden");
method.setMethodName("execute");
method.setMethodIntf(MethodInterfaceType.Local);
methods.add(method);
permission = new MethodPermissionMetaData();
permission.setMethods(methods);
permission.setRoles(java.util.Collections.singleton("original"));
permissions.add(permission);
methods = new MethodsMetaData();
method = new MethodMetaData();
method.setEjbName("Overriden");
method.setMethodName("execute");
method.setMethodIntf(MethodInterfaceType.Remote);
methods.add(method);
permission = new MethodPermissionMetaData();
permission.setMethods(methods);
Set<String> roles = new HashSet<String>();
roles.add("original1");
roles.add("original2");
permission.setRoles(roles);
permissions.add(permission);
// override
JBoss50MetaData override = new JBoss50MetaData();
assembly = new JBossAssemblyDescriptorMetaData();
override.setAssemblyDescriptor(assembly);
permissions = new MethodPermissionsMetaData();
assembly.setMethodPermissions(permissions);
// override only
methods = new MethodsMetaData();
method = new MethodMetaData();
method.setEjbName("Override");
method.setMethodName("execute");
methods.add(method);
permission = new MethodPermissionMetaData();
permission.setMethods(methods);
permission.setRoles(java.util.Collections.singleton("override"));
permissions.add(permission);
// mixed override part
methods = new MethodsMetaData();
method = new MethodMetaData();
method.setEjbName("Overriden");
method.setMethodName("execute");
method.setMethodIntf(MethodInterfaceType.LocalHome);
methods.add(method);
permission = new MethodPermissionMetaData();
permission.setMethods(methods);
permission.setRoles(java.util.Collections.singleton("override"));
permissions.add(permission);
methods = new MethodsMetaData();
method = new MethodMetaData();
method.setEjbName("Overriden");
method.setMethodName("execute");
method.setMethodIntf(MethodInterfaceType.Remote);
methods.add(method);
permission = new MethodPermissionMetaData();
permission.setMethods(methods);
roles = new HashSet<String>();
roles.add("override1");
roles.add("override2");
permission.setRoles(roles);
permissions.add(permission);
// merge
JBoss50MetaData merged = new JBoss50MetaData();
merged.merge(override, original);
assembly = merged.getAssemblyDescriptor();
assertNotNull(assembly);
permissions = assembly.getMethodPermissions();
assertNotNull(permissions);
assertEquals(6, permissions.size());
for(MethodPermissionMetaData perm : permissions)
{