epugh       2003/11/04 08:23:08

  Modified:    security/src/test/org/apache/fulcrum/security/acl
                        AccessControlListTest.java
               security/src/java/org/apache/fulcrum/security/entity/impl
                        SecurityEntityImpl.java
               security/xdocs changes.xml
               security/src/test/org/apache/fulcrum/security/entity/impl
                        SecurityEntityImplTest.java
               security/src/java/org/apache/fulcrum/security/util
                        SecuritySet.java
  Added:       
security/src/test/org/apache/fulcrum/security/spi/hibernate/simple/entity
                        UserSetTest.java
               security/src/test/org/apache/fulcrum/security/util
                        GroupSetTest.java
  Log:
  Unit tests for UserSet/GroupSet for when you pass null in as the name.
  
  Revision  Changes    Path
  1.1                  
jakarta-turbine-fulcrum/security/src/test/org/apache/fulcrum/security/spi/hibernate/simple/entity/UserSetTest.java
  
  Index: UserSetTest.java
  ===================================================================
  package org.apache.fulcrum.security.spi.hibernate.simple.entity;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.fulcrum.security.entity.User;
  import org.apache.fulcrum.security.model.simple.entity.SimpleUser;
  import org.apache.fulcrum.testcontainer.BaseUnitTest;
  /**
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
   * @version $Id: UserSetTest.java,v 1.1 2003/11/04 16:23:08 epugh Exp $
   */
  public class UserSetTest extends BaseUnitTest
  {
  
      /**
         * Defines the testcase name for JUnit.
         * 
         * @param name the testcase's name.
         */
      public UserSetTest(String name)
      {
          super(name);
      }
      public static void main(String[] args)
      {
          junit.textui.TestRunner.run(UserSetTest.class);
      }
  
      public void testAddUsers() throws Exception
      {
          User user = new SimpleUser();
          user.setId(new Integer(1));
          user.setName("Eric");
          UserSet userSet = new UserSet();
          userSet.add(user);
          assertTrue(userSet.contains(user));
  
          User user2 = new SimpleUser();
          user2.setName("Kate");
          user2.setId(new Integer(2));
          userSet.add(user2);
  
          User user3 = new SimpleUser();
          user3.setId(new Integer(1));
          user3.setName("Eric");
          assertTrue(userSet.contains(user));
          assertTrue(userSet.contains((Object) user));
          assertTrue(userSet.contains(user2));
          assertFalse(userSet.contains(user3));
                assertTrue(userSet.contains(user));
  
      }
  
  }
  
  
  
  1.6       +4 -2      
jakarta-turbine-fulcrum/security/src/test/org/apache/fulcrum/security/acl/AccessControlListTest.java
  
  Index: AccessControlListTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-fulcrum/security/src/test/org/apache/fulcrum/security/acl/AccessControlListTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AccessControlListTest.java        4 Nov 2003 14:16:47 -0000       1.5
  +++ AccessControlListTest.java        4 Nov 2003 16:23:08 -0000       1.6
  @@ -73,10 +73,12 @@
   import org.apache.fulcrum.security.util.PermissionSet;
   import org.apache.fulcrum.security.util.RoleSet;
   import org.apache.fulcrum.testcontainer.BaseUnitTest;
  +
   /**
  - * @author Eric Pugh
  - *
    * Test that we can generate AccessControlLists from the Factory
  + * 
  + * @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
  + * @version $Id$
    */
   public class AccessControlListTest extends BaseUnitTest
   {
  
  
  
  1.6       +6 -4      
jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/entity/impl/SecurityEntityImpl.java
  
  Index: SecurityEntityImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/entity/impl/SecurityEntityImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SecurityEntityImpl.java   4 Nov 2003 14:14:59 -0000       1.5
  +++ SecurityEntityImpl.java   4 Nov 2003 16:23:08 -0000       1.6
  @@ -53,6 +53,8 @@
    * <http://www.apache.org/>.
    */
   
  +import java.security.InvalidParameterException;
  +
   import org.apache.commons.lang.builder.HashCodeBuilder;
   import org.apache.fulcrum.security.entity.SecurityEntity;
   
  @@ -95,10 +97,10 @@
        */
       public void setName(String name)
       {
  -        if (name !=null){
  -            name = name.toLowerCase();
  +        if (name ==null){
  +            throw new InvalidParameterException("Must provide a valid name for all 
SecurityEntities.");
           }
  -        this.name = name;
  +             this.name = name.toLowerCase();
       }
       public String toString()
       {
  
  
  
  1.8       +1 -1      jakarta-turbine-fulcrum/security/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/xdocs/changes.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- changes.xml       4 Nov 2003 14:14:59 -0000       1.7
  +++ changes.xml       4 Nov 2003 16:23:08 -0000       1.8
  @@ -8,7 +8,7 @@
     <body>
        <release version="1.0-alpha-3" date="in cvs">
          <action dev="epugh" type="fix">
  -             For a SecurityEntityImpl, if the name is null, don't lowercase it.
  +             For a SecurityEntityImpl, if the name is null then throw an 
InvalidParameterException.
         </action>                              
         <action dev="epugh" type="add">
                Add ModelManager interface and SimpleModelManager and 
TurbineModelManager 
  
  
  
  1.1                  
jakarta-turbine-fulcrum/security/src/test/org/apache/fulcrum/security/util/GroupSetTest.java
  
  Index: GroupSetTest.java
  ===================================================================
  package org.apache.fulcrum.security.util;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-group documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.fulcrum.security.entity.Group;
  import org.apache.fulcrum.security.model.simple.entity.SimpleGroup;
  import org.apache.fulcrum.testcontainer.BaseUnitTest;
  /**
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
   * @version $Id: GroupSetTest.java,v 1.1 2003/11/04 16:23:08 epugh Exp $
   */
  public class GroupSetTest extends BaseUnitTest
  {
     
      /**
       * Defines the testcase name for JUnit.
       *
       * @param name the testcase's name.
       */
      public GroupSetTest(String name)
      {
          super(name);
      }
      public static void main(String[] args)
      {
          junit.textui.TestRunner.run(GroupSetTest.class);
      }
      
        public void testAddGroups() throws Exception
           {
                Group group = new SimpleGroup();
                   group.setId(new Integer(1));
                   group.setName("Eric");
                   GroupSet groupSet = new GroupSet();
                   groupSet.add(group);
                   assertTrue(groupSet.contains(group));
  
                   Group group2 = new SimpleGroup();
                   group2.setName("Kate");
                   group2.setId(new Integer(2));
                   groupSet.add(group2);
  
                   Group group3 = new SimpleGroup();
                   group3.setId(new Integer(1));
                   group3.setName("Eric");
                   assertTrue(groupSet.contains(group));
                   assertTrue(groupSet.contains((Object) group));
                   assertTrue(groupSet.contains(group2));
                   assertFalse(groupSet.contains(group3));
                   assertTrue(groupSet.contains(group));
  
           }
    
     
  }
  
  
  
  1.2       +11 -3     
jakarta-turbine-fulcrum/security/src/test/org/apache/fulcrum/security/entity/impl/SecurityEntityImplTest.java
  
  Index: SecurityEntityImplTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-fulcrum/security/src/test/org/apache/fulcrum/security/entity/impl/SecurityEntityImplTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SecurityEntityImplTest.java       4 Nov 2003 14:14:59 -0000       1.1
  +++ SecurityEntityImplTest.java       4 Nov 2003 16:23:08 -0000       1.2
  @@ -53,6 +53,8 @@
    * <http://www.apache.org/>.
    */
   
  +import java.security.InvalidParameterException;
  +
   import org.apache.fulcrum.security.entity.SecurityEntity;
   import org.apache.fulcrum.testcontainer.BaseUnitTest;
   /**
  @@ -84,7 +86,13 @@
           assertEquals("hello",se.getName());
           se.setName("HelLo");
                assertEquals("hello",se.getName());
  -             se.setName(null);
  -             assertEquals(null,se.getName());
  +             try {
  +                 se.setName(null);
  +                 fail("Should throw an InvalidParameterException");
  +             }
  +             catch(InvalidParameterException ipe){
  +                 //good
  +             }
  +             
       }
   }
  
  
  
  1.4       +4 -2      
jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/util/SecuritySet.java
  
  Index: SecuritySet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/util/SecuritySet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SecuritySet.java  26 Aug 2003 01:57:29 -0000      1.3
  +++ SecuritySet.java  4 Nov 2003 16:23:08 -0000       1.4
  @@ -67,7 +67,9 @@
    * It wraps a TreeSet object to enforce that only relevant
    * methods are available.
    * TreeSet's contain only unique Objects (no duplicates).
  - 
  + * Additionally, they must have both a Name and an ID!  You can
  + * add only one object that has a null of each.
  + * 
    * @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">John D. McNally</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Brett McLaughlin</a>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to