User: starksm 
  Date: 01/06/12 13:55:57

  Modified:    src/main/org/jboss/test/web/test TestWebIntegration.java
  Log:
  Probing the http port was not a reliable test for the existence of an
  integrated web container. Now a check is made for a registered WarDeployer
  using the rmi jmx connector.
  
  Revision  Changes    Path
  1.7       +38 -16    
jbosstest/src/main/org/jboss/test/web/test/TestWebIntegration.java
  
  Index: TestWebIntegration.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/web/test/TestWebIntegration.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestWebIntegration.java   2001/05/31 03:16:16     1.6
  +++ TestWebIntegration.java   2001/06/12 20:55:57     1.7
  @@ -2,11 +2,16 @@
   
   import java.io.IOException;
   import java.net.HttpURLConnection;
  +import java.net.InetAddress;
   import java.net.URL;
  +import javax.management.ObjectName;
  +import javax.management.RuntimeMBeanException;
  +import javax.naming.InitialContext;
   
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  +import org.jboss.jmx.interfaces.RMIConnector;
   import org.jboss.test.util.Deploy;
   
   /** Tests of servlet container integration into the JBoss server. This test
  @@ -20,7 +25,7 @@
   with a role of 'AuthorizedUser' in the servlet container.
   
   @author [EMAIL PROTECTED]
  -@version $Revision: 1.6 $
  +@version $Revision: 1.7 $
   */
   public class TestWebIntegration extends TestCase
   {
  @@ -42,32 +47,49 @@
               return;
           setUp = true;
   
  -        // Test for the existence of a web server
           Integer port = Integer.getInteger("web.port", 8080);
           baseURL = "http://jduke:theduke@localhost:"; + port + '/';
  -        URL url = new URL(baseURL);
           try
           {
  -            HttpClient httpConn = new HttpClient(url);
  -            int responseCode = httpConn.getResponseCode();
  -            String responseMessage = httpConn.getResponseMessage();
  -            if( responseCode < 100 )
  +            String serverName = InetAddress.getLocalHost().getHostName();
  +            String connectorName = "jmx:" +serverName+ ":rmi";
  +            RMIConnector server = (RMIConnector) new 
InitialContext().lookup(connectorName);
  +            ObjectName deployerName = new ObjectName("J2EE:service=J2eeDeployer");
  +            // Ask the deployer for the getWarDeployerName
  +            Object[] params = {};
  +            String[] signature = {};
  +            String warDeployerName = (String) server.invoke(deployerName,
  +                "getWarDeployerName", params, signature);
  +            // See if the warDeployerName exists
  +            deployerName = new ObjectName(warDeployerName);
  +            webServerAvailable = server.isRegistered(deployerName);
  +            if( webServerAvailable == true )
               {
  -                System.out.println(baseURL+" No valid HTTP response, 
code="+responseCode+", skipping tests");
  +                System.out.println("Found warDeployer named: "+warDeployerName);
  +                try
  +                {
  +                    Deploy.deploy("jbosstest-web.ear");
  +                }
  +                catch(Exception e)
  +                {
  +                    e.printStackTrace();
  +                    fail("Failed to deploy jbosstest-web.ear");
  +                }
               }
               else
               {
  -                webServerAvailable = true;
  -                System.out.println("Found webserver at: "+baseURL+", 
code="+responseCode+", msg="+responseMessage);
  -                Deploy.deploy("jbosstest-web.ear");
  +                System.out.println("No war deployer found, skipping tests");
               }
           }
  -        catch(Exception e)
  +        catch(Exception x)
           {
  -         if( webServerAvailable == false )
  -             System.out.println("No webserver found at: "+baseURL);
  -         else
  -             fail("Failed to deploy jbosstest-web.ear");
  +            webServerAvailable = false;
  +            x.printStackTrace();
  +            if (x instanceof RuntimeMBeanException)
  +            {
  +                ((RuntimeMBeanException)x).getTargetException().printStackTrace();
  +            }
  +            System.out.println("No war deployer found, skipping tests");
           }
       }
   
  
  
  

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

Reply via email to