User: d_jencks
Date: 01/09/17 10:33:54
Modified: src/main/org/jboss/test/security/test
EJBAccessUnitTestCase.java EJBSpecUnitTestCase.java
NamespacePermissionCollection.java
NamespacePermissionsUnitTestCase.java
PermissionName.java PermissionNameUnitTestCase.java
ProjRepositoryUnitTestCase.java
SecurityProxyUnitTestCase.java
StatelessSessionClient.java
Log:
Finished converting to JBossTestCase for deploy and logging. Security tests still
do not work due to deploy problems
Revision Changes Path
1.2 +24 -28
jbosstest/src/main/org/jboss/test/security/test/EJBAccessUnitTestCase.java
Index: EJBAccessUnitTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/EJBAccessUnitTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EJBAccessUnitTestCase.java 2001/09/12 04:55:40 1.1
+++ EJBAccessUnitTestCase.java 2001/09/17 17:33:53 1.2
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.security.test;
import java.io.IOException;
@@ -13,7 +20,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.jboss.test.util.Deploy;
+import org.jboss.test.JBossTestCase;
import org.jboss.test.security.interfaces.StatelessSession;
import org.jboss.test.security.interfaces.StatelessSessionHome;
@@ -24,7 +31,7 @@
* @author [EMAIL PROTECTED]
*/
public class EJBAccessUnitTestCase
- extends TestCase
+ extends JBossTestCase
{
private boolean deployed;
@@ -33,29 +40,19 @@
super(name);
}
- /**
- * Setup the test suite.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite();
-
- // add a test case to deploy our support applications
- String filename = "security.jar";
- suite.addTest(new Deploy.Deployer(filename));
-
- suite.addTest(new TestSuite(EJBAccessUnitTestCase.class));
-
- // add a test case to undeploy our support applications
- suite.addTest(new Deploy.Undeployer(filename));
-
- return suite;
- }
/** Deploy the security ejb jar one time
*/
protected void setUp() throws Exception
+ {
+ super.setUp();
+ deployJ2ee("security.jar");
+ }
+
+ protected void tearDown() throws Exception
{
- //Deploy.deploy("security.jar");
+ undeployJ2ee("security.jar");
+ super.tearDown();
}
public void testDeclarativeAccess() throws Exception
@@ -91,7 +88,7 @@
}
catch(Exception e)
{
- System.out.println("UnsecureStatelessSession not accessible");
+ getLog().debug("UnsecureStatelessSession not accessible");
}
}
else
@@ -104,24 +101,23 @@
private void accessUnsecureStatelessSession() throws Exception
{
- InitialContext jndiContext = new InitialContext();
StatelessSession bean = null;
- Object obj = jndiContext.lookup("UnsecureStatelessSession");
+ Object obj = getInitialContext().lookup("UnsecureStatelessSession");
obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
StatelessSessionHome home = (StatelessSessionHome) obj;
- System.out.println("Found Unsecure StatelessSessionHome");
+ getLog().debug("Found Unsecure StatelessSessionHome");
try
{
bean = home.create();
- System.out.println("Created UnsecureStatelessSession");
- System.out.println("Bean.echo('Hello') -> "+bean.echo("Hello"));
- System.out.println("Bean.npeError() -> ");
+ getLog().debug("Created UnsecureStatelessSession");
+ getLog().debug("Bean.echo('Hello') -> "+bean.echo("Hello"));
+ getLog().debug("Bean.npeError() -> ");
bean.npeError();
}
catch(Exception e)
{
- System.out.println("Produced error as expected");
+ getLog().debug("Produced error as expected");
}
}
}
1.2 +77 -68
jbosstest/src/main/org/jboss/test/security/test/EJBSpecUnitTestCase.java
Index: EJBSpecUnitTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/EJBSpecUnitTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EJBSpecUnitTestCase.java 2001/09/12 04:55:40 1.1
+++ EJBSpecUnitTestCase.java 2001/09/17 17:33:53 1.2
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.security.test;
import java.io.IOException;
@@ -29,16 +36,16 @@
import org.jboss.jmx.connector.rmi.RMIConnector;
import org.jboss.test.util.AppCallbackHandler;
-import org.jboss.test.util.Deploy;
+import org.jboss.test.JBossTestCase;
/** Test of EJB spec conformace using the security-spec.jar
deployment unit. These test the basic role based access model.
@author [EMAIL PROTECTED]
- @version $Revision: 1.1 $
+ @version $Revision: 1.2 $
*/
public class EJBSpecUnitTestCase
- extends TestCase
+ extends JBossTestCase
{
static String username = "scott";
static char[] password = "echoman".toCharArray();
@@ -53,9 +60,19 @@
}
protected void setUp() throws Exception
+ {
+ super.setUp();
+ deployJ2ee("security-spec.jar");
+ flushAuthCache();
+ }
+
+ protected void tearDown() throws Exception
{
- // Deploy.deploy("security-spec.jar");
+ undeployJ2ee("security-spec.jar");
+ super.tearDown();
}
+
+
/** Test that:
1. SecureBean returns a non-null principal when getCallerPrincipal
@@ -68,14 +85,13 @@
public void testGetCallerPrincipal() throws Exception
{
logout();
- System.out.println("+++ testGetCallerPrincipal()");
- InitialContext jndiContext = new InitialContext();
- Object obj = jndiContext.lookup("spec.UnsecureStatelessSession2");
+ getLog().debug("+++ testGetCallerPrincipal()");
+ Object obj = getInitialContext().lookup("spec.UnsecureStatelessSession2");
obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
StatelessSessionHome home = (StatelessSessionHome) obj;
- System.out.println("Found Unsecure StatelessSessionHome");
+ getLog().debug("Found Unsecure StatelessSessionHome");
StatelessSession bean = home.create();
- System.out.println("Created spec.UnsecureStatelessSession2");
+ getLog().debug("Created spec.UnsecureStatelessSession2");
try
{
@@ -85,20 +101,20 @@
}
catch(RemoteException e)
{
- System.out.println("echo failed as expected");
+ getLog().debug("echo failed as expected");
}
bean.remove();
login();
- obj = jndiContext.lookup("spec.StatelessSession2");
+ obj = getInitialContext().lookup("spec.StatelessSession2");
obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
home = (StatelessSessionHome) obj;
- System.out.println("Found spec.StatelessSession2");
+ getLog().debug("Found spec.StatelessSession2");
bean = home.create();
- System.out.println("Created spec.StatelessSession2");
+ getLog().debug("Created spec.StatelessSession2");
// Test that the Entity bean sees username as its principal
String echo = bean.echo(username);
- System.out.println("bean.echo(username) = "+echo);
+ getLog().debug("bean.echo(username) = "+echo);
assertTrue("username == echo", echo.equals(username));
bean.remove();
}
@@ -107,17 +123,16 @@
*/
public void testPrincipalPropagation() throws Exception
{
- System.out.println("+++ testPrincipalPropagation");
+ getLog().debug("+++ testPrincipalPropagation");
logout();
login();
- InitialContext jndiContext = new InitialContext();
- Object obj = jndiContext.lookup("spec.UnsecureStatelessSession2");
+ Object obj = getInitialContext().lookup("spec.UnsecureStatelessSession2");
obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
StatelessSessionHome home = (StatelessSessionHome) obj;
- System.out.println("Found Unsecure StatelessSessionHome");
+ getLog().debug("Found Unsecure StatelessSessionHome");
StatelessSession bean = home.create();
- System.out.println("Created spec.UnsecureStatelessSession2");
- System.out.println("Bean.forward('Hello') -> "+bean.forward("Hello"));
+ getLog().debug("Created spec.UnsecureStatelessSession2");
+ getLog().debug("Bean.forward('Hello') -> "+bean.forward("Hello"));
bean.remove();
}
@@ -128,16 +143,15 @@
*/
public void testMethodAccess() throws Exception
{
- System.out.println("+++ testMethodAccess");
+ getLog().debug("+++ testMethodAccess");
login();
- InitialContext jndiContext = new InitialContext();
- Object obj = jndiContext.lookup("spec.StatelessSession");
+ Object obj = getInitialContext().lookup("spec.StatelessSession");
obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
StatelessSessionHome home = (StatelessSessionHome) obj;
- System.out.println("Found StatelessSessionHome");
+ getLog().debug("Found StatelessSessionHome");
StatelessSession bean = home.create();
- System.out.println("Created spec.StatelessSession");
- System.out.println("Bean.echo('Hello') -> "+bean.echo("Hello"));
+ getLog().debug("Created spec.StatelessSession");
+ getLog().debug("Bean.echo('Hello') -> "+bean.echo("Hello"));
try
{
@@ -147,7 +161,7 @@
}
catch(RemoteException e)
{
- System.out.println("StatelessSession.noop failed as expected");
+ getLog().debug("StatelessSession.noop failed as expected");
}
bean.remove();
}
@@ -158,21 +172,20 @@
*/
public void testUnchecked() throws Exception
{
- System.out.println("+++ testUnchecked");
+ getLog().debug("+++ testUnchecked");
// Login as scott to create the bean
login();
- InitialContext jndiContext = new InitialContext();
- Object obj = jndiContext.lookup("spec.StatelessSession");
+ Object obj = getInitialContext().lookup("spec.StatelessSession");
obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
StatelessSessionHome home = (StatelessSessionHome) obj;
- System.out.println("Found spec.StatelessSession Home");
+ getLog().debug("Found spec.StatelessSession Home");
StatelessSession bean = home.create();
- System.out.println("Created spec.StatelessSession");
+ getLog().debug("Created spec.StatelessSession");
// Logout and login back in as stark to test access to the unchecked method
logout();
login("stark", "javaman".toCharArray());
bean.unchecked();
- System.out.println("Called Bean.unchecked()");
+ getLog().debug("Called Bean.unchecked()");
logout();
}
@@ -184,15 +197,14 @@
*/
public void testExcluded() throws Exception
{
- System.out.println("+++ testExcluded");
+ getLog().debug("+++ testExcluded");
login();
- InitialContext jndiContext = new InitialContext();
- Object obj = jndiContext.lookup("spec.StatelessSession2");
+ Object obj = getInitialContext().lookup("spec.StatelessSession2");
obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
StatelessSessionHome home = (StatelessSessionHome) obj;
- System.out.println("Found spec.StatelessSession2 Home");
+ getLog().debug("Found spec.StatelessSession2 Home");
StatelessSession bean = home.create();
- System.out.println("Created spec.StatelessSession2");
+ getLog().debug("Created spec.StatelessSession2");
try
{
bean.excluded();
@@ -200,7 +212,7 @@
}
catch(Exception e)
{
- System.out.println("Bean.excluded() failed as expected");
+ getLog().debug("Bean.excluded() failed as expected");
// This is what we expect
}
logout();
@@ -219,18 +231,17 @@
*/
public void testRunAs() throws Exception
{
- System.out.println("+++ testRunAs");
+ getLog().debug("+++ testRunAs");
login();
- InitialContext jndiContext = new InitialContext();
- Object obj = jndiContext.lookup("spec.RunAsStatelessSession");
+ Object obj = getInitialContext().lookup("spec.RunAsStatelessSession");
obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
StatelessSessionHome home = (StatelessSessionHome) obj;
- System.out.println("Found RunAsStatelessSession Home");
+ getLog().debug("Found RunAsStatelessSession Home");
StatelessSession bean = home.create();
- System.out.println("Created spec.RunAsStatelessSession");
- System.out.println("Bean.echo('Hello') -> "+bean.echo("Hello"));
+ getLog().debug("Created spec.RunAsStatelessSession");
+ getLog().debug("Bean.echo('Hello') -> "+bean.echo("Hello"));
bean.noop();
- System.out.println("Bean.noop(), ok");
+ getLog().debug("Bean.noop(), ok");
try
{
@@ -240,7 +251,7 @@
}
catch(RemoteException e)
{
- System.out.println("StatelessSession.forward failed as expected");
+ getLog().debug("StatelessSession.forward failed as expected");
}
bean.remove();
}
@@ -250,11 +261,10 @@
*/
public void testMDBRunAs() throws Exception
{
- System.out.println("+++ testMDBRunAs");
+ getLog().debug("+++ testMDBRunAs");
logout();
- InitialContext jndiContext = new InitialContext();
- QueueConnectionFactory queueFactory = (QueueConnectionFactory)
jndiContext.lookup(QUEUE_FACTORY);
- Queue que = (Queue) jndiContext.lookup("queue/A");
+ QueueConnectionFactory queueFactory = (QueueConnectionFactory)
getInitialContext().lookup(QUEUE_FACTORY);
+ Queue que = (Queue) getInitialContext().lookup("queue/A");
QueueConnection queueConn = queueFactory.createQueueConnection();
QueueSession session = queueConn.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
Message msg = session.createMessage();
@@ -262,10 +272,10 @@
QueueSender sender = session.createSender(que);
sender.send(msg);
sender.close();
- System.out.println("Sent msg to queue/A");
+ getLog().debug("Sent msg to queue/A");
QueueReceiver recv = session.createReceiver(que);
msg = recv.receive(5000);
- System.out.println("Recv msg: "+msg);
+ getLog().debug("Recv msg: "+msg);
recv.close();
session.close();
queueConn.close();
@@ -276,20 +286,19 @@
*/
public void testHandle() throws Exception
{
- System.out.println("+++ testHandle");
+ getLog().debug("+++ testHandle");
login();
- InitialContext jndiContext = new InitialContext();
- Object obj = jndiContext.lookup("spec.StatelessSession");
+ Object obj = getInitialContext().lookup("spec.StatelessSession");
obj = PortableRemoteObject.narrow(obj, StatelessSessionHome.class);
StatelessSessionHome home = (StatelessSessionHome) obj;
- System.out.println("Found StatelessSessionHome");
+ getLog().debug("Found StatelessSessionHome");
StatelessSession bean = home.create();
- System.out.println("Created spec.StatelessSession");
+ getLog().debug("Created spec.StatelessSession");
Handle h = bean.getHandle();
- System.out.println("Obtained handle: "+h);
+ getLog().debug("Obtained handle: "+h);
bean = (StatelessSession) h.getEJBObject();
- System.out.println("Obtained bean from handle: "+bean);
- System.out.println("Bean.echo('Hello') -> "+bean.echo("Hello"));
+ getLog().debug("Obtained bean from handle: "+bean);
+ getLog().debug("Bean.echo('Hello') -> "+bean.echo("Hello"));
logout();
/* Attempting to obtain the EJB fron the handle without security
@@ -302,7 +311,7 @@
}
catch(Exception e)
{
- System.out.println("Obtaining bean from handle failed as expected,
e="+e.getMessage());
+ getLog().debug("Obtaining bean from handle failed as expected,
e="+e.getMessage());
}
// One should be able to obtain a handle without a login
@@ -310,8 +319,8 @@
login();
// Now we should be able to obtain and use the secure bean
bean = (StatelessSession) h.getEJBObject();
- System.out.println("Obtained bean from handle: "+bean);
- System.out.println("Bean.echo('Hello') -> "+bean.echo("Hello"));
+ getLog().debug("Obtained bean from handle: "+bean);
+ getLog().debug("Bean.echo('Hello') -> "+bean.echo("Hello"));
logout();
}
@@ -330,10 +339,10 @@
lc = null;
String confName = System.getProperty("conf.name", "spec-test");
AppCallbackHandler handler = new AppCallbackHandler(username, password);
- System.out.println("Creating LoginContext("+confName+")");
+ getLog().debug("Creating LoginContext("+confName+")");
lc = new LoginContext(confName, handler);
lc.login();
- System.out.println("Created LoginContext, subject="+lc.getSubject());
+ getLog().debug("Created LoginContext, subject="+lc.getSubject());
loggedIn = true;
}
private void logout() throws Exception
@@ -359,7 +368,7 @@
/**
* Setup the test suite.
- */
+ * /
public static Test suite()
{
TestSuite suite = new TestSuite();
@@ -381,5 +390,5 @@
}
};
return wrapper;
- }
+ }*/
}
1.3 +7 -0
jbosstest/src/main/org/jboss/test/security/test/NamespacePermissionCollection.java
Index: NamespacePermissionCollection.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/NamespacePermissionCollection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NamespacePermissionCollection.java 2001/04/18 19:48:29 1.2
+++ NamespacePermissionCollection.java 2001/09/17 17:33:53 1.3
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.security.test;
import java.security.Permission;
@@ -14,7 +21,7 @@
/** The PermissionCollection object for NamespacePermissions.
@author [EMAIL PROTECTED]
-@version $Revision: 1.2 $
+@version $Revision: 1.3 $
*/
public class NamespacePermissionCollection extends PermissionCollection
{
1.2 +8 -1
jbosstest/src/main/org/jboss/test/security/test/NamespacePermissionsUnitTestCase.java
Index: NamespacePermissionsUnitTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/NamespacePermissionsUnitTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NamespacePermissionsUnitTestCase.java 2001/09/12 04:55:40 1.1
+++ NamespacePermissionsUnitTestCase.java 2001/09/17 17:33:53 1.2
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.security.test;
import java.io.FilePermission;
@@ -12,7 +19,7 @@
* classes.
*
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class NamespacePermissionsUnitTestCase
extends junit.framework.TestCase
1.2 +7 -0
jbosstest/src/main/org/jboss/test/security/test/PermissionName.java
Index: PermissionName.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/PermissionName.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PermissionName.java 2001/03/05 10:11:07 1.1
+++ PermissionName.java 2001/09/17 17:33:53 1.2
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.security.test;
import java.io.Serializable;
@@ -12,7 +19,7 @@
by NamespacePermissions.
@author [EMAIL PROTECTED]
-@version $Revision: 1.1 $
+@version $Revision: 1.2 $
*/
public class PermissionName implements Comparable, Serializable
{
1.2 +8 -1
jbosstest/src/main/org/jboss/test/security/test/PermissionNameUnitTestCase.java
Index: PermissionNameUnitTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/PermissionNameUnitTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PermissionNameUnitTestCase.java 2001/09/12 04:55:40 1.1
+++ PermissionNameUnitTestCase.java 2001/09/17 17:33:53 1.2
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.security.test;
import java.io.FilePermission;
@@ -11,7 +18,7 @@
* A JUnit TestCase for the PermissionNames class.
*
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class PermissionNameUnitTestCase
extends junit.framework.TestCase
1.2 +41 -29
jbosstest/src/main/org/jboss/test/security/test/ProjRepositoryUnitTestCase.java
Index: ProjRepositoryUnitTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/ProjRepositoryUnitTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProjRepositoryUnitTestCase.java 2001/09/12 04:55:40 1.1
+++ ProjRepositoryUnitTestCase.java 2001/09/17 17:33:53 1.2
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.security.test;
import java.rmi.RemoteException;
@@ -23,7 +30,7 @@
import org.jboss.test.security.interfaces.ProjRepositoryHome;
import org.jboss.test.security.ejb.project.support.DefaultName;
import org.jboss.test.util.AppCallbackHandler;
-import org.jboss.test.util.Deploy;
+import org.jboss.test.JBossTestCase;
/**
* The client driver for testing secure access to the ProjRepository bean.
@@ -39,10 +46,10 @@
* is deployed.
*
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class ProjRepositoryUnitTestCase
- extends TestCase
+ extends JBossTestCase
{
static String[] users = {"scott", "starksm", "guest", "nobody"};
static String[] passwds = {"stark", "scott_stark", "guest", "badpass"};
@@ -87,17 +94,16 @@
{
lc = null;
this.userIndex = userIndex;
- System.out.print("expect: ");
+ getLog().debug("expect: ");
for(int t = 0; t < accessTests[userIndex].length; t ++)
- System.out.print(accessTests[userIndex][t]+", ");
- System.out.println();
+ getLog().debug(accessTests[userIndex][t]+", ");
runAs();
}
finally
{
if( lc != null )
lc.logout();
- System.out.println("User logged out");
+ getLog().debug("User logged out");
}
}
void runAs() throws Exception
@@ -109,7 +115,7 @@
try
{
lc = new LoginContext("test-domain", handler);
- System.out.println("Created LoginContext, username="+username);
+ getLog().debug("Created LoginContext, username="+username);
lc.login();
if( accessTests[userIndex][LOGIN] == false )
fail("Was able to login");
@@ -121,16 +127,15 @@
throw e;
return;
}
- System.out.println("Login complete");
- InitialContext iniCtx = new InitialContext();
- Object ref = iniCtx.lookup("ProjRepository");
+ getLog().debug("Login complete");
+ Object ref = getInitialContext().lookup("ProjRepository");
ProjRepositoryHome home = (ProjRepositoryHome) ref;
- System.out.println("Found ProjRepositoryHome");
+ getLog().debug("Found ProjRepositoryHome");
DefaultName projectName = new DefaultName("Project1");
try
{
bean = home.create(projectName);
- System.out.println("Created ProjRepository");
+ getLog().debug("Created ProjRepository");
if( accessTests[userIndex][CREATE] == false )
fail("Was able to create project");
}
@@ -144,7 +149,7 @@
return;
}
- System.out.println("Test of getItem()");
+ getLog().debug("Test of getItem()");
int pathIndex = PATH0;
for(int p = 0; p < paths.length; p ++, pathIndex ++)
{
@@ -152,7 +157,7 @@
tryGetItem(name, pathIndex);
}
- System.out.println("Test of deleteItem()");
+ getLog().debug("Test of deleteItem()");
// Try to delete an item
try
{
@@ -160,11 +165,11 @@
bean.deleteItem(name);
if( accessTests[userIndex][DELETE0] == false )
fail("Was able to delete: "+name.toString());
- System.out.println("deleteItem("+name+") succeeded");
+ getLog().debug("deleteItem("+name+") succeeded");
}
catch(RemoteException e)
{
- System.out.println("Failed to deleteItem");
+ getLog().debug("Failed to deleteItem");
if( accessTests[userIndex][DELETE0] == true )
{
printException(e);
@@ -180,11 +185,11 @@
bean.deleteItem(name);
if( accessTests[userIndex][DELETE1] == false )
fail("Was able to delete: "+name.toString());
- System.out.println("deleteItem("+name+") succeeded");
+ getLog().debug("deleteItem("+name+") succeeded");
}
catch(RemoteException e)
{
- System.out.println("Failed to deleteItem");
+ getLog().debug("Failed to deleteItem");
if( accessTests[userIndex][DELETE1] == true )
{
printException(e);
@@ -215,6 +220,8 @@
*/
protected void setUp() throws Exception
{
+ super.setUp();
+ deployJ2ee("security.jar");
// Set up a log4j configuration that logs on the console.
Category root = Category.getRoot();
root.setPriority(Priority.DEBUG);
@@ -222,9 +229,15 @@
// Deploy.deploy("security.jar");
}
+ protected void tearDown() throws Exception
+ {
+ undeployJ2ee("security.jar");
+ super.tearDown();
+ }
+
/**
* Setup the test suite.
- */
+ * /
public static Test suite() {
TestSuite suite = new TestSuite();
@@ -238,7 +251,7 @@
suite.addTest(new Deploy.Undeployer(filename));
return suite;
- }
+ }*/
/** Try to invoke getItem for the given name on the bean.
If this fails the bean will be discarded by the server,
@@ -255,7 +268,7 @@
}
catch(RemoteException e)
{
- System.out.println("Failed to getItem, name="+name.toString());
+ getLog().debug("Failed to getItem, name="+name.toString());
if( accessTests[userIndex][pathIndex] == true )
{
throw e;
@@ -267,15 +280,14 @@
private void restoreProjectBean() throws Exception
{
- InitialContext iniCtx = new InitialContext();
- Object ref = iniCtx.lookup("ProjRepository");
+ Object ref = getInitialContext().lookup("ProjRepository");
ProjRepositoryHome home = (ProjRepositoryHome) ref;
DefaultName projectName = new DefaultName("Project1");
bean = home.create(projectName);
- System.out.println("Restored ProjRepository");
+ getLog().debug("Restored ProjRepository");
}
- static void printException(RemoteException e)
+ void printException(RemoteException e)
{
Throwable d = e.detail;
if( d instanceof TransactionRolledbackException )
@@ -290,11 +302,11 @@
}
if( d instanceof SecurityException )
- System.out.println("Security Failure: "+e.getMessage());
+ getLog().debug("Security Failure: "+e.getMessage());
else if( d != null )
- d.printStackTrace();
+ getLog().error("error", d);
else
- e.printStackTrace();
+ getLog().error("error", e);
}
}
1.2 +32 -20
jbosstest/src/main/org/jboss/test/security/test/SecurityProxyUnitTestCase.java
Index: SecurityProxyUnitTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/SecurityProxyUnitTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SecurityProxyUnitTestCase.java 2001/09/12 04:55:40 1.1
+++ SecurityProxyUnitTestCase.java 2001/09/17 17:33:53 1.2
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.security.test;
import java.io.IOException;
@@ -17,17 +24,17 @@
import org.jboss.test.security.interfaces.IOSession;
import org.jboss.test.security.interfaces.IOSessionHome;
import org.jboss.test.util.AppCallbackHandler;
-import org.jboss.test.util.Deploy;
+import org.jboss.test.JBossTestCase;
/**
* Simple tests of security stateless, stateful and entity beans via custom
* security proxies.
*
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class SecurityProxyUnitTestCase
- extends TestCase
+ extends JBossTestCase
{
static String username = "scott";
static char[] password = "echoman".toCharArray();
@@ -42,7 +49,7 @@
/**
* Setup the test suite.
- */
+ * /
public static Test suite() {
TestSuite suite = new TestSuite();
@@ -56,26 +63,32 @@
suite.addTest(new Deploy.Undeployer(filename));
return suite;
- }
+ }*/
protected void setUp() throws Exception
+ {
+ super.setUp();
+ deployJ2ee("security-proxy.jar");
+ }
+
+ protected void tearDown() throws Exception
{
- // Deploy.deploy("security-proxy.jar");
+ undeployJ2ee("security-proxy.jar");
+ super.tearDown();
}
public void testProxiedStatelessBean() throws Exception
{
login();
- InitialContext jndiContext = new InitialContext();
- Object obj = jndiContext.lookup("ProxiedStatelessBean");
+ Object obj = getInitialContext().lookup("ProxiedStatelessBean");
obj = PortableRemoteObject.narrow(obj, IOSessionHome.class);
IOSessionHome home = (IOSessionHome) obj;
- System.out.println("Found ProxiedStatelessBean");
+ getLog().debug("Found ProxiedStatelessBean");
IOSession bean = home.create();
- System.out.println("Created ProxiedStatelessBean");
- System.out.println("ProxiedStatelessBean.read() ->
"+bean.read("/user/scott/.password"));
+ getLog().debug("Created ProxiedStatelessBean");
+ getLog().debug("ProxiedStatelessBean.read() ->
"+bean.read("/user/scott/.password"));
bean.write("/user/scott/.password");
- System.out.println("ProxiedStatelessBean.write()");
+ getLog().debug("ProxiedStatelessBean.write()");
bean.remove();
logout();
}
@@ -83,16 +96,15 @@
public void testProxiedStatefulBean() throws Exception
{
login();
- InitialContext jndiContext = new InitialContext();
- Object obj = jndiContext.lookup("ProxiedStatefulBean");
+ Object obj = getInitialContext().lookup("ProxiedStatefulBean");
obj = PortableRemoteObject.narrow(obj, IOSessionHome.class);
IOSessionHome home = (IOSessionHome) obj;
- System.out.println("Found ProxiedStatefulBean");
+ getLog().debug("Found ProxiedStatefulBean");
IOSession bean = home.create();
- System.out.println("Created ProxiedStatefulBean");
- System.out.println("ProxiedStatefulBean.read() ->
"+bean.read("/user/scott/.password"));
+ getLog().debug("Created ProxiedStatefulBean");
+ getLog().debug("ProxiedStatefulBean.read() ->
"+bean.read("/user/scott/.password"));
bean.write("/user/scott/.password");
- System.out.println("ProxiedStatefulBean.write()");
+ getLog().debug("ProxiedStatefulBean.write()");
bean.remove();
logout();
}
@@ -112,10 +124,10 @@
lc = null;
String confName = System.getProperty("conf.name", "spec-test");
AppCallbackHandler handler = new AppCallbackHandler(username, password);
- System.out.println("Creating LoginContext("+confName+")");
+ getLog().debug("Creating LoginContext("+confName+")");
lc = new LoginContext(confName, handler);
lc.login();
- System.out.println("Created LoginContext, subject="+lc.getSubject());
+ getLog().debug("Created LoginContext, subject="+lc.getSubject());
loggedIn = true;
}
private void logout() throws Exception
1.3 +8 -1
jbosstest/src/main/org/jboss/test/security/test/StatelessSessionClient.java
Index: StatelessSessionClient.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/test/StatelessSessionClient.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StatelessSessionClient.java 2001/07/14 16:02:43 1.2
+++ StatelessSessionClient.java 2001/09/17 17:33:53 1.3
@@ -1,3 +1,10 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
package org.jboss.test.security.test;
import java.io.IOException;
@@ -17,7 +24,7 @@
/** Run with -Djava.security.auth.login.config=url_to_jaas_login_conf
@author [EMAIL PROTECTED]
-@version $Revision: 1.2 $
+@version $Revision: 1.3 $
*/
public class StatelessSessionClient
{
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development