1 22 package org.jboss.test.jrmp.test; 23 24 import java.io.File ; 25 import java.net.URL ; 26 import java.rmi.RemoteException ; 27 import java.security.CodeSource ; 28 import javax.ejb.CreateException ; 29 import javax.naming.InitialContext ; 30 import javax.naming.NamingException ; 31 32 import junit.framework.Test; 33 import junit.framework.TestCase; 34 import junit.framework.TestSuite; 35 36 import org.jboss.test.JBossTestCase; 37 38 import org.jboss.test.jrmp.interfaces.IString; 39 import org.jboss.test.jrmp.interfaces.StatelessSession; 40 import org.jboss.test.jrmp.interfaces.StatelessSessionHome; 41 42 49 public class DynLoadingUnitTestCase 50 extends JBossTestCase 51 { 52 57 public DynLoadingUnitTestCase(String name) 58 { 59 super(name); 60 } 61 62 67 public void testAccess() throws Exception 68 { 69 InitialContext jndiContext = new InitialContext (); 70 getLog().debug("Lookup StatefulSession"); 71 Object obj = jndiContext.lookup("StatefulSession"); 72 StatelessSessionHome home = (StatelessSessionHome)obj; 73 getLog().debug("Found StatefulSession Home"); 74 StatelessSession bean = home.create(); 75 getLog().debug("Created StatefulSession"); 76 IString echo = bean.copy("jrmp-dl"); 77 getLog().debug("bean.copy(jrmp-dl) = " + echo); 78 Class clazz = echo.getClass(); 79 CodeSource cs = clazz.getProtectionDomain().getCodeSource(); 80 URL location = cs.getLocation(); 81 getLog().debug("IString.class = " + clazz); 82 getLog().debug("IString.class location = " + location); 83 assertTrue("CodeSource URL.protocol != file", location.getProtocol().equals("file") == false); 84 bean.remove(); 85 } 86 87 89 94 protected void setUp() throws Exception 95 { 96 super.setUp(); 97 URL istringImpl = getClass().getResource("/org/jboss/test/jrmp/ejb/AString.class"); 98 if (istringImpl != null) 99 { 100 getLog().debug("Found IString impl at: " + istringImpl); 101 File implFile = new File (istringImpl.getFile()); 102 getLog().debug("Removed: " + implFile.delete()); 103 } 104 deploy("jrmp-dl.jar"); 105 } 106 107 112 protected void tearDown() throws Exception 113 { 114 undeploy("jrmp-dl.jar"); 115 super.tearDown(); 116 } 117 118 } 119 | Popular Tags |