1 22 package org.jboss.test.security.test; 23 24 import java.util.Properties ; 25 import java.security.Principal ; 26 27 import javax.naming.Context ; 28 import javax.naming.InitialContext ; 29 import javax.rmi.PortableRemoteObject ; 30 31 import org.jboss.test.JBossTestCase; 32 import org.jboss.test.security.clientlogin.IClientLoginHome; 33 import org.jboss.test.security.clientlogin.IClientLogin; 34 import junit.framework.Test; 35 36 42 public class ClientLoginModuleEJBUnitTestCase 43 extends JBossTestCase 44 { 45 public ClientLoginModuleEJBUnitTestCase(String name) 46 { 47 super(name); 48 } 49 50 57 public void testClientLoginModule() throws Exception 58 { 59 log.debug("+++ testPublicMethod()"); 60 Properties env = new Properties (); 61 env.setProperty(Context.INITIAL_CONTEXT_FACTORY, 62 "org.jboss.security.jndi.JndiLoginInitialContextFactory"); 63 env.setProperty(Context.SECURITY_PRINCIPAL, "jduke"); 64 env.setProperty(Context.SECURITY_CREDENTIALS, "theduke"); 65 InitialContext ctx = new InitialContext (env); 66 Object obj = ctx.lookup("client-login-tests/BeanA"); 67 obj = PortableRemoteObject.narrow(obj, IClientLoginHome.class); 68 IClientLoginHome home = (IClientLoginHome) obj; 69 log.debug("Found IClientLoginHome"); 70 IClientLogin bean = home.create(); 71 log.debug("Created IClientLogin"); 72 73 Principal user = bean.callBeanAsClientLoginUser(); 74 assertTrue("callBeanAsClientLoginUser value == jduke", 75 user.getName().equals("jduke")); 76 bean.remove(); 77 } 78 79 public static Test suite() throws Exception 80 { 81 return JBossTestCase.getDeploySetup(ClientLoginModuleEJBUnitTestCase.class, 82 "client-login-tests.jar"); 83 } 84 85 } 86 | Popular Tags |