[jboss-cvs] JBossAS SVN: r72803 - in projects/security/security-jboss-sx/trunk/identity/src: tests/org/jboss/test/identity/impl and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 28 19:37:04 EDT 2008
Author: mmoyses
Date: 2008-04-28 19:37:04 -0400 (Mon, 28 Apr 2008)
New Revision: 72803
Added:
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/FilePersistenceStrategy.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/PersistenceStrategy.java
projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/FilePersistenceStrategyUnitTestCase.java
Modified:
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/IdentityFactory.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SecurityActions.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleIdentity.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java
projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRoleGroup.java
projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleGroupUnitTestCase.java
projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleUnitTestCase.java
Log:
Adding PersistenceStrategy interface.
Added: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/FilePersistenceStrategy.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/FilePersistenceStrategy.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/FilePersistenceStrategy.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.identity.plugins;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.security.identity.Identity;
+
+/**
+ * An implementation of <code>PersistenceStrategy</code> that serializes the
+ * <code>Identity</code> to a file.
+ *
+ * @author <a href="mmoyses at redhat.com">Marcus Moyses</a>
+ * @version $Revision: 1.1 $
+ */
+public class FilePersistenceStrategy implements PersistenceStrategy
+{
+ private String fileName;
+
+ public FilePersistenceStrategy(String fileName)
+ {
+ this.fileName = fileName;
+ }
+
+ /**
+ * @see PersistenceStrategy#persistIdentity(Identity).
+ */
+ public void persistIdentity(Identity identity)
+ {
+ ObjectOutputStream oos = null;
+ try
+ {
+ FileOutputStream fos = new FileOutputStream(fileName);
+ oos = new ObjectOutputStream(fos);
+ oos.writeObject(identity);
+ }
+ catch (Exception e)
+ {
+ //TODO
+ e.printStackTrace();
+ }
+ finally
+ {
+ if (oos != null)
+ {
+ try
+ {
+ oos.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+ }
+
+ /**
+ * @see PersistenceStrategy#retrieveIdentity(String).
+ */
+ public Identity retrieveIdentity(String name)
+ {
+ ObjectInputStream ois = null;
+ try
+ {
+ FileInputStream fis = new FileInputStream(fileName);
+ ois = new ObjectInputStream(fis);
+ Identity identity = (Identity) ois.readObject();
+ return identity;
+ }
+ catch (Exception e)
+ {
+ //TODO
+ e.printStackTrace();
+ }
+ finally
+ {
+ if (ois != null)
+ {
+ try
+ {
+ ois.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ }
+
+ return null;
+ }
+}
Modified: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/IdentityFactory.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/IdentityFactory.java 2008-04-28 22:42:45 UTC (rev 72802)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/IdentityFactory.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -59,16 +59,18 @@
return (Identity) loadClass(IDENTITY_CLASS, name);
}
- public static Identity createIdentity(String identityClass, String name) throws Exception
+ public static Identity createIdentity(String identityClass, String name) throws Exception
{
return (Identity) loadClass(identityClass, name);
}
-
+
private static Object loadClass(String className, String ctorArg) throws Exception
{
Class<?> clazz = SecurityActions.getClass(className);
- Constructor<?> ctr = clazz.getConstructor(new Class[]{String.class});
- return ctr.newInstance(new Object[]{ctorArg});
+ Constructor<?> ctr = clazz.getConstructor(new Class[]
+ {String.class});
+ return ctr.newInstance(new Object[]
+ {ctorArg});
+ }
- }
-}
+}
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/PersistenceStrategy.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/PersistenceStrategy.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/PersistenceStrategy.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.identity.plugins;
+
+import org.jboss.security.identity.Identity;
+
+/**
+ * Interface for an <code>Identity</code> persistence strategy (file, db, etc.).
+ *
+ * @author <a href="mmoyses at redhat.com">Marcus Moyses</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PersistenceStrategy
+{
+
+ /**
+ * Persists the <code>Identity</code> in the backend.
+ *
+ * @param identity <code>Identity</code> to be persisted.
+ */
+ public void persistIdentity(Identity identity);
+
+ /**
+ * Retrieves an <code>Identity</code> from the backend.
+ *
+ * @param name unique name of the <code>Identity</code>.
+ * @return the <code>Identity</code> or <code>null</code> if not found
+ */
+ public Identity retrieveIdentity(String name);
+
+}
Modified: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SecurityActions.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SecurityActions.java 2008-04-28 22:42:45 UTC (rev 72802)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SecurityActions.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -31,26 +31,26 @@
* @author Anil.Saldhana at redhat.com
* @since Nov 18, 2007
* @version $Revision$
- */
+ */
public class SecurityActions
{
@SuppressWarnings("unchecked")
public static Class<?> getClass(final String FQN)
{
- return (Class<?>) AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
+ return (Class<?>) AccessController.doPrivileged(new PrivilegedAction()
{
- try
+ public Object run()
{
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- return tcl.loadClass(FQN);
+ try
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ return tcl.loadClass(FQN);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
}
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- });
+ });
}
}
\ No newline at end of file
Modified: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleIdentity.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleIdentity.java 2008-04-28 22:42:45 UTC (rev 72802)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleIdentity.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -21,7 +21,6 @@
*/
package org.jboss.security.identity.plugins;
-import java.io.Serializable;
import java.security.Principal;
import java.security.acl.Group;
@@ -36,7 +35,7 @@
* @since Nov 16, 2007
* @version $Revision$
*/
-public class SimpleIdentity implements Identity, Serializable
+public class SimpleIdentity implements Identity
{
private static final long serialVersionUID = 1L;
Modified: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java 2008-04-28 22:42:45 UTC (rev 72802)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -21,8 +21,6 @@
*/
package org.jboss.security.identity.plugins;
-import java.io.Serializable;
-
import org.jboss.security.identity.Role;
import org.jboss.security.identity.RoleType;
@@ -34,7 +32,7 @@
* @since Nov 16, 2007
* @version $Revision$
*/
-public class SimpleRole implements Role, Serializable, Cloneable
+public class SimpleRole implements Role, Cloneable
{
private static final long serialVersionUID = 1L;
@@ -42,10 +40,10 @@
private final Role parent;
- public static final Role ANYBODY_ROLE = new SimpleRole("<ANYBODY>");
-
public static final String ANYBODY = "<ANYBODY>";
+ public static final Role ANYBODY_ROLE = new SimpleRole(ANYBODY);
+
public SimpleRole(String roleName)
{
this(roleName, null);
Modified: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRoleGroup.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRoleGroup.java 2008-04-28 22:42:45 UTC (rev 72802)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRoleGroup.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -43,41 +43,43 @@
public class SimpleRoleGroup extends SimpleRole implements RoleGroup
{
private static final long serialVersionUID = 1L;
+
private ArrayList<Role> roles = new ArrayList<Role>();
+
private static final String ROLES_IDENTIFIER = "Roles";
-
+
public SimpleRoleGroup(String roleName)
{
- super(roleName);
+ super(roleName);
}
public SimpleRoleGroup(String roleName, List<Role> roles)
{
- super(roleName);
- if(this.roles == null)
+ super(roleName);
+ if (this.roles == null)
this.roles = new ArrayList<Role>();
this.roles.addAll(roles);
}
-
+
public SimpleRoleGroup(Group rolesGroup)
{
- super(rolesGroup.getName());
- Enumeration<? extends Principal> principals = rolesGroup.members();
- while(principals.hasMoreElements())
- {
- roles.add(new SimpleRole(principals.nextElement().getName()));
- }
+ super(rolesGroup.getName());
+ Enumeration<? extends Principal> principals = rolesGroup.members();
+ while (principals.hasMoreElements())
+ {
+ roles.add(new SimpleRole(principals.nextElement().getName()));
+ }
}
-
+
public SimpleRoleGroup(Set<Principal> rolesAsPrincipals)
{
super(ROLES_IDENTIFIER);
- for(Principal p: rolesAsPrincipals)
+ for (Principal p : rolesAsPrincipals)
{
- roles.add(new SimpleRole(p.getName()));
- }
+ roles.add(new SimpleRole(p.getName()));
+ }
}
-
+
@Override
public RoleType getType()
{
@@ -89,7 +91,7 @@
*/
public void addRole(Role role)
{
- this.roles.add(role);
+ this.roles.add(role);
}
/**
@@ -97,17 +99,17 @@
*/
public void removeRole(Role role)
{
- this.roles.remove(role);
+ this.roles.remove(role);
}
-
+
/**
* @see RoleGroup#clearRoles()
*/
public void clearRoles()
{
- this.roles.clear();
+ this.roles.clear();
}
-
+
/**
* @see RoleGroup#getRoles()
*/
@@ -115,39 +117,39 @@
{
return roles;
}
-
+
@SuppressWarnings("unchecked")
- public synchronized Object clone() throws CloneNotSupportedException
- {
- SimpleRoleGroup clone = (SimpleRoleGroup) super.clone();
- if(clone != null)
- clone.roles = (ArrayList<Role>)this.roles.clone();
- return clone;
+ public synchronized Object clone() throws CloneNotSupportedException
+ {
+ SimpleRoleGroup clone = (SimpleRoleGroup) super.clone();
+ if (clone != null)
+ clone.roles = (ArrayList<Role>) this.roles.clone();
+ return clone;
}
@Override
public boolean containsAll(Role anotherRole)
{
boolean isContained = false;
-
- if(anotherRole.getType() == RoleType.simple)
+
+ if (anotherRole.getType() == RoleType.simple)
{
- for(Role r: roles)
+ for (Role r : roles)
{
isContained = r.containsAll(anotherRole);
- if(isContained)
+ if (isContained)
return true;
- }
+ }
}
else
{
//Dealing with another roleGroup
RoleGroup anotherRG = (RoleGroup) anotherRole;
List<Role> anotherRoles = anotherRG.getRoles();
- for(Role r: anotherRoles)
+ for (Role r : anotherRoles)
{
//if any of the roles are not there, no point checking further
- if(!this.containsAll(r))
+ if (!this.containsAll(r))
return false;
}
return true;
@@ -159,30 +161,30 @@
* @see RoleGroup#containsAtleastOneRole(RoleGroup)
*/
public boolean containsAtleastOneRole(RoleGroup anotherRole)
- {
- if(anotherRole == null)
+ {
+ if (anotherRole == null)
throw new IllegalArgumentException("anotherRole is null");
List<Role> roleList = anotherRole.getRoles();
- for(Role r: roleList)
+ for (Role r : roleList)
{
- if(this.containsAll(r))
+ if (this.containsAll(r))
return true;
}
return false;
}
-
+
/**
* @see RoleGroup#containsRole(Role)
*/
public boolean containsRole(Role role)
{
- for(Role r: roles)
+ for (Role r : roles)
{
- if(r.containsAll(role))
+ if (r.containsAll(role))
return true;
}
return false;
- }
+ }
@Override
public String toString()
@@ -190,11 +192,11 @@
StringBuilder builder = new StringBuilder();
builder.append(this.getRoleName());
builder.append("(");
- for(Role role: roles)
- {
+ for (Role role : roles)
+ {
builder.append(role.toString()).append(",");
}
- builder.append(")");
+ builder.append(")");
return builder.toString();
- }
+ }
}
\ No newline at end of file
Added: projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/FilePersistenceStrategyUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/FilePersistenceStrategyUnitTestCase.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/FilePersistenceStrategyUnitTestCase.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.identity.impl;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.jboss.security.identity.Identity;
+import org.jboss.security.identity.plugins.FilePersistenceStrategy;
+import org.jboss.security.identity.plugins.IdentityFactory;
+
+/**
+ * A PersistenceStrategyUnitTestCase.
+ *
+ * @author <a href="mmoyses at redhat.com">Marcus Moyses</a>
+ * @version $Revision: 1.1 $
+ */
+public class FilePersistenceStrategyUnitTestCase extends TestCase
+{
+
+ private static final String fileName = System.getProperty("java.io.tmpdir") + File.separator + "identity.ser";
+
+ private static final File file = new File(fileName);
+
+ public void testWriteIdentity() throws Exception
+ {
+ Identity identity = IdentityFactory.createIdentity("test");
+ FilePersistenceStrategy fps = new FilePersistenceStrategy(fileName);
+ assertFalse("File already exists", file.exists());
+ fps.persistIdentity(identity);
+ assertTrue("File was not created", file.exists());
+ }
+
+ public void testReadIdentity() throws Exception
+ {
+ Identity identity = IdentityFactory.createIdentity("test");
+ FilePersistenceStrategy fps = new FilePersistenceStrategy(fileName);
+ assertFalse("File already exists", file.exists());
+ fps.persistIdentity(identity);
+ assertTrue("File was not created", file.exists());
+
+ Identity restored = fps.retrieveIdentity("test");
+ assertEquals("Objects are different", identity, restored);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ if (file.exists())
+ {
+ file.delete();
+ }
+ }
+
+}
Modified: projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleGroupUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleGroupUnitTestCase.java 2008-04-28 22:42:45 UTC (rev 72802)
+++ projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleGroupUnitTestCase.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -41,26 +41,25 @@
public void testAnybodyRole()
{
Role aRole = new SimpleRole("aRole");
-
+
SimpleRoleGroup srg = new SimpleRoleGroup("Roles");
srg.addRole(SimpleRole.ANYBODY_ROLE);
- assertTrue(srg.containsRole(aRole));
+ assertTrue(srg.containsRole(aRole));
}
-
-
+
public void testNestedRoles()
{
SimpleRoleGroup srg = new SimpleRoleGroup("nested");
srg.addRole(new SimpleRole("aRole"));
srg.addRole(new SimpleRole("bRole"));
-
+
SimpleRoleGroup methodRoles = new SimpleRoleGroup("Roles");
methodRoles.addRole(srg);
-
+
//Create user role now
SimpleRoleGroup userRole = new SimpleRoleGroup("Roles");
userRole.addRole(new SimpleRole("aRole"));
- methodRoles.containsAtleastOneRole(userRole);
+ methodRoles.containsAtleastOneRole(userRole);
}
}
Modified: projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleUnitTestCase.java 2008-04-28 22:42:45 UTC (rev 72802)
+++ projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleUnitTestCase.java 2008-04-28 23:37:04 UTC (rev 72803)
@@ -27,7 +27,6 @@
import org.jboss.security.identity.RoleFactory;
import org.jboss.security.identity.plugins.SimpleRole;
import org.jboss.security.identity.plugins.SimpleRoleGroup;
-
//$Id$
@@ -44,42 +43,43 @@
RoleFactory.SIMPLE_ROLE_CLASS = SimpleRole.class.getName();
RoleFactory.SIMPLE_ROLEGROUP_CLASS = SimpleRoleGroup.class.getName();
assertTrue(RoleFactory.createRole("myRole") instanceof SimpleRole);
- assertTrue(RoleFactory.createRoleGroup("myRoleGroup") instanceof SimpleRoleGroup);
+ assertTrue(RoleFactory.createRoleGroup("myRoleGroup") instanceof SimpleRoleGroup);
}
-
+
public void testSimpleRoleContains() throws Exception
{
Role firstRole = new SimpleRole("A");
Role secondRole = new SimpleRole("B");
-
+
assertTrue(firstRole.containsAll(firstRole));
assertFalse(firstRole.containsAll(secondRole));
assertFalse(secondRole.containsAll(firstRole));
- }
-
+ }
+
public void testSimpleRoleGroupContains() throws Exception
{
SimpleRoleGroup firstRoleGroup = new SimpleRoleGroup("firstrg");
firstRoleGroup.getRoles().add(new SimpleRole("A"));
firstRoleGroup.getRoles().add(new SimpleRole("B"));
firstRoleGroup.getRoles().add(new SimpleRole("C"));
-
+
SimpleRoleGroup secondRoleGroup = new SimpleRoleGroup("secondrg");
secondRoleGroup.getRoles().add(new SimpleRole("A"));
secondRoleGroup.getRoles().add(new SimpleRole("B"));
-
+
assertTrue(firstRoleGroup.containsAll(firstRoleGroup));
assertTrue(secondRoleGroup.containsAll(secondRoleGroup));
assertTrue(firstRoleGroup.containsAll(secondRoleGroup));
assertFalse(secondRoleGroup.containsAll(firstRoleGroup));
-
+
assertTrue(firstRoleGroup.containsAtleastOneRole(secondRoleGroup));
+ assertTrue(secondRoleGroup.containsAtleastOneRole(firstRoleGroup));
}
-
+
public void testSimpleRoleGroup()
{
SimpleRoleGroup srg = new SimpleRoleGroup("Roles");
srg.addRole(new SimpleRole("aRole"));
- assertTrue(srg.containsAll(new SimpleRole("aRole")));
+ assertTrue(srg.containsAll(new SimpleRole("aRole")));
}
}
More information about the jboss-cvs-commits
mailing list