You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2004/05/27 21:45:33 UTC
cvs commit: jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security AbstractSecurityTestcase.java TestSecurityHelper.java TestRdbmsPolicy.java TestUserManager.java TestGroupManager.java TestPermissionManager.java TestRoleManager.java TestLoginModule.java
weaver 2004/05/27 12:45:33
Modified: components/security/src/test/org/apache/jetspeed/security
TestSecurityHelper.java TestRdbmsPolicy.java
TestUserManager.java TestGroupManager.java
TestPermissionManager.java TestRoleManager.java
TestLoginModule.java
Added: components/security/src/test/org/apache/jetspeed/security
AbstractSecurityTestcase.java
Log:
see JS2-40: <http://nagoya.apache.org/jira/browse/JS2-40>
& JS2-59
Revision Changes Path
1.3 +7 -30 jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestSecurityHelper.java
Index: TestSecurityHelper.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestSecurityHelper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestSecurityHelper.java 11 Mar 2004 05:04:15 -0000 1.2
+++ TestSecurityHelper.java 27 May 2004 19:45:32 -0000 1.3
@@ -21,9 +21,8 @@
import javax.security.auth.Subject;
import junit.framework.Test;
+import junit.framework.TestSuite;
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.ComponentAwareTestSuite;
import org.apache.jetspeed.security.impl.UserPrincipalImpl;
/**
@@ -32,7 +31,7 @@
* @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id$
*/
-public class TestSecurityHelper extends AbstractComponentAwareTestCase
+public class TestSecurityHelper extends AbstractSecurityTestcase
{
/**
* Defines the testcase name for JUnit.
@@ -41,36 +40,14 @@
*/
public TestSecurityHelper(String name)
{
- super(name, "./src/test/Log4j.properties");
+ super(name);
}
- /**
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception
- {
- super.setUp();
- }
-
- /**
- * @see junit.framework.TestCase#tearDown()
- */
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- /**
- * Creates the test suite.
- *
- * @return a test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
+
public static Test suite()
{
- ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestSecurityHelper.class);
- suite.setScript("org/apache/jetspeed/security/containers/test.security.groovy");
- return suite;
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(TestSecurityHelper.class);
}
public void testHelpers() throws Exception
1.4 +11 -31 jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestRdbmsPolicy.java
Index: TestRdbmsPolicy.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestRdbmsPolicy.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestRdbmsPolicy.java 25 Mar 2004 21:39:55 -0000 1.3
+++ TestRdbmsPolicy.java 27 May 2004 19:45:32 -0000 1.4
@@ -14,8 +14,8 @@
*/
package org.apache.jetspeed.security;
-import java.security.AccessController;
import java.security.AccessControlException;
+import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.security.auth.Subject;
@@ -23,39 +23,26 @@
import javax.security.auth.login.LoginException;
import junit.framework.Test;
+import junit.framework.TestSuite;
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.ComponentAwareTestSuite;
-import org.apache.jetspeed.security.UserPrincipal;
import org.apache.jetspeed.security.impl.PassiveCallbackHandler;
import org.apache.jetspeed.security.impl.UserPrincipalImpl;
-import org.picocontainer.MutablePicoContainer;
-
/**
* @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
*/
-public class TestRdbmsPolicy extends AbstractComponentAwareTestCase
+public class TestRdbmsPolicy extends AbstractSecurityTestcase
{
/** <p>The JAAS login context.</p> */
private LoginContext loginContext = null;
- /** The mutable pico container. */
- private MutablePicoContainer container;
-
- /** The user manager. */
- private UserManager ums;
-
- /** <p>The permission manager.</p> */
- private PermissionManager pms;
-
/**
* <p>Defines the test case name for junit.</p>
* @param testName The test case name.
*/
public TestRdbmsPolicy(String testName)
{
- super(testName, "./src/test/Log4j.properties");
+ super(testName);
}
/**
@@ -64,9 +51,7 @@
public void setUp() throws Exception
{
super.setUp();
- container = (MutablePicoContainer) getContainer();
- ums = (UserManager) container.getComponentInstance(UserManager.class);
- pms = (PermissionManager) container.getComponentInstance(PermissionManager.class);
+
initUser();
// Let's login in.
@@ -90,7 +75,7 @@
*/
public void tearDown() throws Exception
{
- super.tearDown();
+
// Logout.
try
@@ -103,20 +88,15 @@
assertTrue("\t\t[TestRdbmsPolicy] Failed to tear down test.", false);
}
destroyUser();
+ super.tearDown();
}
- /**
- * <p>Creates the test suite.</p>
- * @return A test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
- public static Test suite()
+ public static Test suite()
{
- ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestRdbmsPolicy.class);
- suite.setScript("org/apache/jetspeed/security/containers/test.security.groovy");
- return suite;
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(TestRdbmsPolicy.class);
}
-
+
/**
* <p>Executing this test requires adding an entry to java.policy.</p>
* <p>A possible entry would be to grant for all principals:</p>
1.7 +9 -40 jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestUserManager.java
Index: TestUserManager.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestUserManager.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TestUserManager.java 8 May 2004 16:17:38 -0000 1.6
+++ TestUserManager.java 27 May 2004 19:45:32 -0000 1.7
@@ -22,73 +22,42 @@
import javax.security.auth.login.LoginException;
import junit.framework.Test;
+import junit.framework.TestSuite;
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.ComponentAwareTestSuite;
import org.apache.jetspeed.security.impl.PassiveCallbackHandler;
-import org.picocontainer.MutablePicoContainer;
-
/**
* <p>Unit testing for {@link UserManager}.</p>
*
* @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
*/
-public class TestUserManager extends AbstractComponentAwareTestCase
+public class TestUserManager extends AbstractSecurityTestcase
{
- /** The mutable pico container. */
- private MutablePicoContainer container;
-
- /** The user manager. */
- private UserManager ums;
-
/**
* <p>Defines the test case name for junit.</p>
* @param testName The test case name.
*/
public TestUserManager(String testName)
{
- super(testName, "./src/test/Log4j.properties");
- }
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception
- {
- super.setUp();
- container = (MutablePicoContainer) getContainer();
- ums = (UserManager) container.getComponentInstance(UserManager.class);
+ super(testName);
}
+
/**
* @see junit.framework.TestCase#tearDown()
*/
public void tearDown() throws Exception
- {
- super.tearDown();
+ {
destroyUserObject();
+ super.tearDown();
}
- /**
- * <p>Creates the test suite.</p>
- * @return A test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
+
+
public static Test suite()
{
- ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestUserManager.class);
- suite.setScript("org/apache/jetspeed/security/containers/test.security.groovy");
- return suite;
- }
-
- /**
- * <p>Test the container.</p>
- */
- public void testContainer()
- {
- assertNotNull(container);
+ return new TestSuite(TestUserManager.class);
}
/**
1.4 +10 -45 jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestGroupManager.java
Index: TestGroupManager.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestGroupManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestGroupManager.java 8 May 2004 16:17:38 -0000 1.3
+++ TestGroupManager.java 27 May 2004 19:45:32 -0000 1.4
@@ -22,79 +22,44 @@
import javax.security.auth.Subject;
import junit.framework.Test;
+import junit.framework.TestSuite;
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.ComponentAwareTestSuite;
import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
-import org.picocontainer.MutablePicoContainer;
-
/**
* <p>Unit testing for {@link GroupManager}.</p>
*
* @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
*/
-public class TestGroupManager extends AbstractComponentAwareTestCase
+public class TestGroupManager extends AbstractSecurityTestcase
{
- /** The mutable pico container. */
- private MutablePicoContainer container;
-
- /** The user manager. */
- private UserManager ums;
-
- /** The group manager. */
- private GroupManager gms;
-
/**
* <p>Defines the test case name for junit.</p>
* @param testName The test case name.
*/
public TestGroupManager(String testName)
{
- super(testName, "./src/test/Log4j.properties");
- }
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception
- {
- super.setUp();
- container = (MutablePicoContainer) getContainer();
- gms = (GroupManager) container.getComponentInstance(GroupManager.class);
- ums = (UserManager) container.getComponentInstance(UserManager.class);
+ super(testName);
}
+
/**
* @see junit.framework.TestCase#tearDown()
*/
public void tearDown() throws Exception
{
- super.tearDown();
destroyGroups();
+ super.tearDown();
+
}
- /**
- * <p>Creates the test suite.</p>
- * @return A test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
- public static Test suite()
- {
- ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestGroupManager.class);
- suite.setScript("org/apache/jetspeed/security/containers/test.security.groovy");
- return suite;
- }
-
- /**
- * <p>Test the container.</p>
- */
- public void testContainer()
+ public static Test suite()
{
- assertNotNull(container);
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(TestGroupManager.class);
}
-
+
/**
* <p>Test add group.</p>
*/
1.2 +10 -54 jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestPermissionManager.java
Index: TestPermissionManager.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestPermissionManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestPermissionManager.java 10 Mar 2004 06:09:25 -0000 1.1
+++ TestPermissionManager.java 27 May 2004 19:45:32 -0000 1.2
@@ -14,96 +14,52 @@
*/
package org.apache.jetspeed.security;
+import java.security.Permission;
+import java.security.Permissions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
-import java.security.Permission;
-import java.security.Permissions;
import junit.framework.Test;
+import junit.framework.TestSuite;
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.ComponentAwareTestSuite;
import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
import org.apache.jetspeed.security.impl.RolePrincipalImpl;
import org.apache.jetspeed.security.impl.UserPrincipalImpl;
-import org.picocontainer.MutablePicoContainer;
-
/**
* <p>Unit testing for {@link PermissionManager}.</p>
*
* @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
*/
-public class TestPermissionManager extends AbstractComponentAwareTestCase
+public class TestPermissionManager extends AbstractSecurityTestcase
{
- /** The mutable pico container. */
- private MutablePicoContainer container;
-
- /** The user manager. */
- private UserManager ums;
-
- /** The group manager. */
- private GroupManager gms;
-
- /** The role manager. */
- private RoleManager rms;
-
- /** The role manager. */
- private PermissionManager pms;
-
/**
* <p>Defines the test case name for junit.</p>
* @param testName The test case name.
*/
public TestPermissionManager(String testName)
{
- super(testName, "./src/test/Log4j.properties");
- }
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception
- {
- super.setUp();
- container = (MutablePicoContainer) getContainer();
- ums = (UserManager) container.getComponentInstance(UserManager.class);
- gms = (GroupManager) container.getComponentInstance(GroupManager.class);
- rms = (RoleManager) container.getComponentInstance(RoleManager.class);
- pms = (PermissionManager) container.getComponentInstance(PermissionManager.class);
+ super(testName);
}
+
/**
* @see junit.framework.TestCase#tearDown()
*/
public void tearDown() throws Exception
{
- super.tearDown();
destroyPermissions();
+ super.tearDown();
}
- /**
- * <p>Creates the test suite.</p>
- * @return A test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
public static Test suite()
{
- ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestPermissionManager.class);
- suite.setScript("org/apache/jetspeed/security/containers/test.security.groovy");
- return suite;
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(TestPermissionManager.class);
}
-
- /**
- * <p>Test the container.</p>
- */
- public void testContainer()
- {
- assertNotNull(container);
- }
-
+
/**
* <p>Test remove principal and associated permissions.</p>
*/
1.4 +8 -48 jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestRoleManager.java
Index: TestRoleManager.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestRoleManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestRoleManager.java 8 May 2004 16:17:38 -0000 1.3
+++ TestRoleManager.java 27 May 2004 19:45:32 -0000 1.4
@@ -22,83 +22,43 @@
import javax.security.auth.Subject;
import junit.framework.Test;
+import junit.framework.TestSuite;
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.ComponentAwareTestSuite;
import org.apache.jetspeed.security.impl.RolePrincipalImpl;
-import org.picocontainer.MutablePicoContainer;
-
/**
* <p>Unit testing for {@link RoleManager}.</p>
*
* @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
*/
-public class TestRoleManager extends AbstractComponentAwareTestCase
+public class TestRoleManager extends AbstractSecurityTestcase
{
- /** The mutable pico container. */
- private MutablePicoContainer container;
-
- /** The user manager. */
- private UserManager ums;
-
- /** The group manager. */
- private GroupManager gms;
-
- /** The role manager. */
- private RoleManager rms;
-
/**
* <p>Defines the test case name for junit.</p>
* @param testName The test case name.
*/
public TestRoleManager(String testName)
{
- super(testName, "./src/test/Log4j.properties");
+ super(testName);
}
- /**
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception
- {
- super.setUp();
- container = (MutablePicoContainer) getContainer();
- ums = (UserManager) container.getComponentInstance(UserManager.class);
- gms = (GroupManager) container.getComponentInstance(GroupManager.class);
- rms = (RoleManager) container.getComponentInstance(RoleManager.class);
- }
/**
* @see junit.framework.TestCase#tearDown()
*/
public void tearDown() throws Exception
- {
- super.tearDown();
+ {
destroyRoles();
+ super.tearDown();
}
- /**
- * <p>Creates the test suite.</p>
- * @return A test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
public static Test suite()
{
- ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestRoleManager.class);
- suite.setScript("org/apache/jetspeed/security/containers/test.security.groovy");
- return suite;
- }
-
- /**
- * <p>Test the container.</p>
- */
- public void testContainer()
- {
- assertNotNull(container);
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(TestRoleManager.class);
}
-
+
/**
* <p>Test add role.</p>
*/
1.4 +10 -25 jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestLoginModule.java
Index: TestLoginModule.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/TestLoginModule.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestLoginModule.java 25 Mar 2004 21:39:55 -0000 1.3
+++ TestLoginModule.java 27 May 2004 19:45:32 -0000 1.4
@@ -20,36 +20,26 @@
import javax.security.auth.login.LoginException;
import junit.framework.Test;
+import junit.framework.TestSuite;
-import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
-import org.apache.jetspeed.components.ComponentAwareTestSuite;
-import org.apache.jetspeed.security.SecurityHelper;
-import org.apache.jetspeed.security.impl.UserPrincipalImpl;
import org.apache.jetspeed.security.impl.PassiveCallbackHandler;
-
-import org.picocontainer.MutablePicoContainer;
+import org.apache.jetspeed.security.impl.UserPrincipalImpl;
/**
* @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
*/
-public class TestLoginModule extends AbstractComponentAwareTestCase
+public class TestLoginModule extends AbstractSecurityTestcase
{
/** <p>The JAAS login context.</p> */
private LoginContext loginContext = null;
- /** The mutable pico container. */
- private MutablePicoContainer container;
-
- /** The user manager. */
- private UserManager ums;
-
/**
* <p>Defines the test case name for junit.</p>
* @param testName The test case name.
*/
public TestLoginModule(String testName)
{
- super(testName, "./src/test/Log4j.properties");
+ super(testName);
}
/**
@@ -58,8 +48,8 @@
public void setUp() throws Exception
{
super.setUp();
- container = (MutablePicoContainer) getContainer();
- ums = (UserManager) container.getComponentInstance(UserManager.class);
+
+
initUserObject();
// Set up login context.
@@ -79,20 +69,15 @@
*/
public void tearDown() throws Exception
{
- super.tearDown();
destroyUserObject();
+ super.tearDown();
+
}
- /**
- * <p>Creates the test suite.</p>
- * @return A test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
public static Test suite()
{
- ComponentAwareTestSuite suite = new ComponentAwareTestSuite(TestLoginModule.class);
- suite.setScript("org/apache/jetspeed/security/containers/test.security.groovy");
- return suite;
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(TestLoginModule.class);
}
public void testLogin() throws LoginException
1.1 jakarta-jetspeed-2/components/security/src/test/org/apache/jetspeed/security/AbstractSecurityTestcase.java
Index: AbstractSecurityTestcase.java
===================================================================
/*
* Created on May 27, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package org.apache.jetspeed.security;
import org.apache.jetspeed.components.persistence.store.util.PersistenceSupportedTestCase;
import org.apache.jetspeed.security.impl.GroupManagerImpl;
import org.apache.jetspeed.security.impl.PermissionManagerImpl;
import org.apache.jetspeed.security.impl.RdbmsPolicy;
import org.apache.jetspeed.security.impl.RoleManagerImpl;
import org.apache.jetspeed.security.impl.SecurityProviderImpl;
import org.apache.jetspeed.security.impl.UserManagerImpl;
/**
* @author <a href="mailto:sweaver@einnovation.com">Scott T. Weaver</a>
*
*/
public class AbstractSecurityTestcase extends PersistenceSupportedTestCase
{
protected UserManagerImpl ums;
protected GroupManagerImpl gms;
protected RoleManagerImpl rms;
protected PermissionManagerImpl pms;
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception
{
super.setUp();
ums = new UserManagerImpl(persistenceStore);
gms = new GroupManagerImpl(persistenceStore);
rms =new RoleManagerImpl(persistenceStore);
pms = new PermissionManagerImpl(persistenceStore);
new SecurityProviderImpl("login.conf", new RdbmsPolicy(pms), ums);
}
/**
*
*/
public AbstractSecurityTestcase()
{
super();
}
/**
* @param arg0
*/
public AbstractSecurityTestcase( String arg0 )
{
super(arg0);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org