User: starksm
Date: 01/07/29 09:32:43
Modified: src/main/org/jboss/test/security/test Tag: Branch_2_4
TestEJBSpec.java
Log:
Need to flush the security manager authentication cache as different tests
use the same security domain with different user to role mappings
Revision Changes Path
No revision
No revision
1.6.2.4 +38 -12 jbosstest/src/main/org/jboss/test/security/test/TestEJBSpec.java
Index: TestEJBSpec.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/TestEJBSpec.java,v
retrieving revision 1.6.2.3
retrieving revision 1.6.2.4
diff -u -r1.6.2.3 -r1.6.2.4
--- TestEJBSpec.java 2001/07/14 17:10:53 1.6.2.3
+++ TestEJBSpec.java 2001/07/29 16:32:43 1.6.2.4
@@ -1,8 +1,10 @@
package org.jboss.test.security.test;
import java.io.IOException;
+import java.net.InetAddress;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
+import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
@@ -19,10 +21,12 @@
import org.jboss.test.security.interfaces.StatelessSession;
import org.jboss.test.security.interfaces.StatelessSessionHome;
+import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.jboss.jmx.interfaces.RMIConnector;
import org.jboss.test.util.AppCallbackHandler;
import org.jboss.test.util.Deploy;
@@ -30,7 +34,7 @@
deployment unit. These test the basic role based access model.
@author [EMAIL PROTECTED]
- @version $Revision: 1.6.2.3 $
+ @version $Revision: 1.6.2.4 $
*/
public class TestEJBSpec
extends TestCase
@@ -293,21 +297,43 @@
}
}
+ private static void flushAuthCache() throws Exception
+ {
+ String serverName = InetAddress.getLocalHost().getHostName();
+ String connectorName = "jmx:" +serverName+ ":rmi";
+ RMIConnector server = (RMIConnector) new
InitialContext().lookup(connectorName);
+ ObjectName jaasMgr = new ObjectName("Security:name=JaasSecurityManager");
+ // Ask the deployer for the getWarDeployerName
+ Object[] params = {"other"};
+ String[] signature = {"java.lang.String"};
+ String warDeployerName = (String) server.invoke(jaasMgr,
+ "flushAuthenticationCache", params, signature);
+
+ }
+
/**
* Setup the test suite.
*/
- public static Test suite() {
+ public static Test suite()
+ {
TestSuite suite = new TestSuite();
-
- // add a test case to deploy our support applications
- String filename = "security-spec.jar";
- suite.addTest(new Deploy.Deployer(filename));
-
suite.addTest(new TestSuite(TestEJBSpec.class));
-
- // add a test case to undeploy our support applications
- suite.addTest(new Deploy.Undeployer(filename));
-
- return suite;
+
+ final String filename = "security-spec.jar";
+
+ // Create an initializer for the test suite
+ TestSetup wrapper= new TestSetup(suite)
+ {
+ protected void setUp() throws Exception
+ {
+ Deploy.deploy(filename);
+ flushAuthCache();
+ }
+ protected void tearDown() throws Exception
+ {
+ Deploy.undeploy(filename);
+ }
+ };
+ return wrapper;
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development