User: d_jencks
  Date: 01/09/11 21:55:39

  Added:       src/main/org/jboss/test/jrmp/test
                        CustomSocketsUnitTestCase.java
                        DynLoadingUnitTestCase.java
  Removed:     src/main/org/jboss/test/jrmp/test TestCustomSockets.java
                        TestDynLoading.java
  Log:
  Changed naming scheme of tests to *UnitTestCase.java for short running tests and 
*StressTestCase.java for lengthy tests.  Made tests-unit and tests-stress targets in 
build.xml
  
  Revision  Changes    Path
  1.1                  
jbosstest/src/main/org/jboss/test/jrmp/test/CustomSocketsUnitTestCase.java
  
  Index: CustomSocketsUnitTestCase.java
  ===================================================================
  package org.jboss.test.jrmp.test;
  
  import java.io.IOException;
  import java.rmi.RemoteException;
  import javax.ejb.CreateException;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  import org.jboss.test.jrmp.interfaces.StatelessSession;
  import org.jboss.test.jrmp.interfaces.StatelessSessionHome;
  import org.jboss.test.util.Deploy;
  
  /** Test of using custom RMI socket factories with the JRMP ejb
  container invoker.
  
  @author [EMAIL PROTECTED]
  @version $Revision: 1.1 $
  */
  public class CustomSocketsUnitTestCase extends junit.framework.TestCase
  {
      public CustomSocketsUnitTestCase(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          // Deploy.deploy("jrmp-comp.jar");
      }
  
      public void testCustomAccess() throws Exception
      {
          InitialContext jndiContext = new InitialContext();
          System.out.println("Lookup StatelessSession");
          Object obj = jndiContext.lookup("StatelessSession");
          StatelessSessionHome home = (StatelessSessionHome) obj;
          System.out.println("Found StatelessSession Home");
          StatelessSession bean = home.create();
          System.out.println("Created StatelessSession");
          // Test that the Entity bean sees username as its principal
          String echo = bean.echo("jrmp-comp");
          System.out.println("bean.echo(jrmp-comp) = "+echo);
          bean.remove();
      }
      public void testAccess() throws Exception
      {
          InitialContext jndiContext = new InitialContext();
          System.out.println("Lookup StatefulSession");
          Object obj = jndiContext.lookup("StatefulSession");
          StatelessSessionHome home = (StatelessSessionHome) obj;
          System.out.println("Found StatefulSession Home");
          StatelessSession bean = home.create();
          System.out.println("Created StatefulSession");
          // Test that the Entity bean sees username as its principal
          String echo = bean.echo("jrmp");
          System.out.println("bean.echo(jrmp) = "+echo);
          bean.remove();
      }
  
     /**
      * Setup the test suite.
      */
     public static Test suite() {
        TestSuite suite = new TestSuite();
          
        // add a test case to deploy our support applications
        String filename = "jrmp-comp.jar";
        suite.addTest(new Deploy.Deployer(filename));
  
        suite.addTest(new TestSuite(CustomSocketsUnitTestCase.class));
        
        // add a test case to undeploy our support applications
        suite.addTest(new Deploy.Undeployer(filename));
  
        return suite;
     }
  }
  
  
  
  1.1                  
jbosstest/src/main/org/jboss/test/jrmp/test/DynLoadingUnitTestCase.java
  
  Index: DynLoadingUnitTestCase.java
  ===================================================================
  package org.jboss.test.jrmp.test;
  
  import java.io.File;
  import java.net.URL;
  import java.rmi.RemoteException;
  import java.security.CodeSource;
  import javax.ejb.CreateException;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  import org.jboss.test.jrmp.interfaces.IString;
  import org.jboss.test.jrmp.interfaces.StatelessSession;
  import org.jboss.test.jrmp.interfaces.StatelessSessionHome;
  
  import org.jboss.test.util.Deploy;
  
  /** Test of RMI dynamic class loading.
  
  @author [EMAIL PROTECTED]
  @version $Revision: 1.1 $
  */
  public class DynLoadingUnitTestCase
     extends TestCase
  {
     public DynLoadingUnitTestCase(String name)
     {
        super(name);
        System.out.println("DynLoadingUnitTestCase");
     }
  
     /** Remove any local IString implementation so that we test RMI class loading.
      */
     protected void setUp() throws Exception
     {
        URL istringImpl = 
getClass().getResource("/org/jboss/test/jrmp/ejb/AString.class");
        if( istringImpl != null )
        {
           System.out.println("Found IString impl at: "+istringImpl);
           File implFile = new File(istringImpl.getFile());
           System.out.println("Removed: "+implFile.delete());
        }
     }
  
     public void testAccess() throws Exception
     {
        InitialContext jndiContext = new InitialContext();
        System.out.println("Lookup StatefulSession");
        Object obj = jndiContext.lookup("StatefulSession");
        StatelessSessionHome home = (StatelessSessionHome) obj;
        System.out.println("Found StatefulSession Home");
        StatelessSession bean = home.create();
        System.out.println("Created StatefulSession");
        IString echo = bean.copy("jrmp-dl");
        System.out.println("bean.copy(jrmp-dl) = "+echo);
        Class clazz = echo.getClass();
        CodeSource cs = clazz.getProtectionDomain().getCodeSource();
        URL location = cs.getLocation();
        System.out.println("IString.class = "+clazz);
        System.out.println("IString.class location = "+location);
        assertTrue("CodeSource URL.protocol != file", 
location.getProtocol().equals("file") == false);
        bean.remove();
     }
  
     /**
      * Setup the test suite.
      */
     public static Test suite()
     {
        TestSuite suite = new TestSuite();
        // add a test case to deploy our support applications
        String filename = "jrmp-dl.jar";
        suite.addTest(new Deploy.Deployer(filename));
  
        suite.addTest(new TestSuite(DynLoadingUnitTestCase.class));
  
        // add a test case to undeploy our support applications
        suite.addTest(new Deploy.Undeployer(filename));
  
        return suite;
     }
  }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to