[jboss-cvs] JBossAS SVN: r108532 - in branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice: servlets and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 12 17:28:26 EDT 2010


Author: smarlow at redhat.com
Date: 2010-10-12 17:28:26 -0400 (Tue, 12 Oct 2010)
New Revision: 108532

Added:
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/HttpUtils.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/ServiceTestCase.java
Modified:
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceBean.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceLocal.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceManagement.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceRemote.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceWeb.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/servlets/EJBServlet.java
Log:
package change, change server references

Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceBean.java	2010-10-12 19:57:45 UTC (rev 108531)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceBean.java	2010-10-12 21:28:26 UTC (rev 108532)
@@ -19,7 +19,8 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.ejb3.test.clusteredservice;
+package org.jboss.test.cluster.ejb3.clusteredservice;
+
 import javax.ejb.Local;
 import javax.ejb.Remote;
 

Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceLocal.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceLocal.java	2010-10-12 19:57:45 UTC (rev 108531)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceLocal.java	2010-10-12 21:28:26 UTC (rev 108532)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.ejb3.test.clusteredservice;
+package org.jboss.test.cluster.ejb3.clusteredservice;
 
 /**
  * @version <tt>$Revision$</tt>

Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceManagement.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceManagement.java	2010-10-12 19:57:45 UTC (rev 108531)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceManagement.java	2010-10-12 21:28:26 UTC (rev 108532)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.ejb3.test.clusteredservice;
+package org.jboss.test.cluster.ejb3.clusteredservice;
 
 /**
  * @version <tt>$Revision$</tt>

Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceRemote.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceRemote.java	2010-10-12 19:57:45 UTC (rev 108531)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceRemote.java	2010-10-12 21:28:26 UTC (rev 108532)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.ejb3.test.clusteredservice;
+package org.jboss.test.cluster.ejb3.clusteredservice;
 
 /**
  * @version <tt>$Revision$</tt>

Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceWeb.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceWeb.java	2010-10-12 19:57:45 UTC (rev 108531)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceWeb.java	2010-10-12 21:28:26 UTC (rev 108532)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.ejb3.test.clusteredservice;
+package org.jboss.test.cluster.ejb3.clusteredservice;
 
 import javax.jws.WebMethod; 
 import javax.jws.WebService; 

Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/servlets/EJBServlet.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/servlets/EJBServlet.java	2010-10-12 19:57:45 UTC (rev 108531)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/servlets/EJBServlet.java	2010-10-12 21:28:26 UTC (rev 108532)
@@ -19,15 +19,13 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.ejb3.test.clusteredservice.servlets;
+package org.jboss.test.cluster.ejb3.clusteredservice.servlets;
 
 import java.io.IOException;
 import java.io.PrintWriter;
 
 import java.util.Properties;
 
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.servlet.ServletException;
@@ -35,7 +33,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.jboss.ejb3.test.clusteredservice.ServiceRemote;
+import org.jboss.test.cluster.ejb3.clusteredservice.ServiceRemote;
 import org.jboss.logging.Logger;
 
 /**

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/HttpUtils.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/HttpUtils.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/HttpUtils.java	2010-10-12 21:28:26 UTC (rev 108532)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.ejb3.clusteredservice.unit;
+
+import java.net.URL;
+import java.net.HttpURLConnection;
+import java.io.IOException;
+import java.lang.System;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.HeadMethod;
+import org.apache.commons.httpclient.methods.OptionsMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.TraceMethod;
+import org.jboss.logging.Logger;
+
+/** Utilities for client http requests
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class HttpUtils
+{
+   private static Logger log = Logger.getLogger(HttpUtils.class);
+   private static String baseURL = "http://jduke:theduke@localhost:" + Integer.getInteger("web.port", 8080) + "/";
+   private static String baseURLNoAuth = "http://localhost:" + Integer.getInteger("web.port", 8080) + "/";
+
+   public static final int GET = 1;
+   public static final int POST = 2;
+   public static final int HEAD = 3;
+   public static final int OPTIONS = 4;
+   public static final int PUT = 5;
+   public static final int DELETE = 6;
+   public static final int TRACE = 7;
+   
+   public static String getBaseURL()
+   {
+      return baseURL;
+   }
+   public static String getBaseURL(String username, String password)
+   {
+      String url = "http://"+username+":"+password+"@"+ System.getProperty("jboss.bind.address") + ":"
+         + Integer.getInteger("web.port", 8080) + "/";
+      return url;
+   }
+   public static String getBaseURLNoAuth()
+   {
+      return baseURLNoAuth;
+   }
+
+   /** Perform a get on the indicated URL and assert an HTTP_OK response code
+    *
+    * @param url
+    * @return The commons HttpClient used to perform the get
+    * @throws Exception on any failure
+    */
+   public static HttpMethodBase accessURL(URL url) throws Exception
+   {
+      return accessURL(url, "JBossTest Servlets", HttpURLConnection.HTTP_OK);
+   }
+   /** Perform a get on the indicated URL and assert that the response code
+    * matches the expectedHttpCode argument.
+    *
+    * @param url
+    * @param expectedHttpCode the http response code expected
+    * @return The commons HttpClient used to perform the get
+    * @throws Exception on any failure
+    */
+   public static HttpMethodBase accessURL(URL url, String realm,
+      int expectedHttpCode)
+      throws Exception
+   {
+      return accessURL(url, realm, expectedHttpCode, null);
+   }
+   public static HttpMethodBase accessURL(URL url, String realm,
+      int expectedHttpCode, int type)
+      throws Exception
+   {
+      return accessURL(url, realm, expectedHttpCode, null, type);
+   }
+   public static HttpMethodBase accessURL(URL url, String realm,
+      int expectedHttpCode, Header[] hdrs)
+      throws Exception
+   {
+      return accessURL(url, realm, expectedHttpCode, hdrs, GET);
+   }
+   public static HttpMethodBase accessURL(URL url, String realm,
+      int expectedHttpCode, Header[] hdrs, int type)
+      throws Exception
+   {
+      HttpClient httpConn = new HttpClient();
+      HttpMethodBase request = createMethod(url, type);
+
+      int hdrCount = hdrs != null ? hdrs.length : 0;
+      for(int n = 0; n < hdrCount; n ++)
+         request.addRequestHeader(hdrs[n]);
+      try
+      {
+         log.debug("Connecting to: "+url);
+         String userInfo = url.getUserInfo();
+
+         if( userInfo != null )
+         {
+            UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
+            httpConn.getState().setCredentials(realm, url.getHost(), auth);
+         }
+         log.debug("RequestURI: "+request.getURI());
+         int responseCode = httpConn.executeMethod(request);
+         String response = request.getStatusText();
+         log.debug("responseCode="+responseCode+", response="+response);
+         String content = request.getResponseBodyAsString();
+         log.debug(content);
+         // Validate that we are seeing the requested response code
+         if( responseCode != expectedHttpCode )
+         {
+            throw new IOException("Expected reply code:"+expectedHttpCode
+               +", actual="+responseCode);
+         }
+      }
+      catch(IOException e)
+      {
+         throw e;
+      }
+      return request;
+   }
+
+   public static HttpMethodBase createMethod(URL url, int type)
+   {
+      HttpMethodBase request = null;
+      switch( type )
+      {
+         case GET:
+            request = new GetMethod(url.toString());
+            break;
+         case POST:
+            request = new PostMethod(url.toString());
+            break;
+         case HEAD:
+            request = new HeadMethod(url.toString());
+            break;
+         case OPTIONS:
+            request = new OptionsMethod(url.toString());
+            break;
+         case PUT:
+            request = new PutMethod(url.toString());
+            break;
+         case DELETE:
+            request = new DeleteMethod(url.toString());
+            break;
+         case TRACE:
+            request = new TraceMethod(url.toString());
+            break;
+      }
+      return request;
+   }
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/HttpUtils.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/ServiceTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/ServiceTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/ServiceTestCase.java	2010-10-12 21:28:26 UTC (rev 108532)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.ejb3.clusteredservice.unit;
+
+import java.net.URL;
+
+import javax.management.Attribute;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import junit.framework.TestSuite;
+import org.jboss.test.JBossClusteredTestCase;
+
+/** 
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version <tt>$Revision$</tt>
+ */
+public class ServiceTestCase extends JBossClusteredTestCase
+{
+   private static String REALM = "JBossTest Servlets";
+   private String node1 = System.getProperty("node1","localhost");
+   private String node2 = System.getProperty("node2","localhost");
+   private String node1URL = "http://jduke:theduke@" + node1 + ":8080/";
+   private String node2URL = "http://jduke:theduke@" + node2 + ":8080/";
+
+   private static final String USE_JBOSS = "UseJBossWebLoader";
+   
+   public ServiceTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testEJBServlet() throws Exception
+   {
+      String serverUrls[] = getHttpURLs();
+      log.info("serverUrls[0] = " + serverUrls + ", node1=" + node1);
+      MBeanServerConnection server = adaptors[0];
+      ObjectName tomcat = new ObjectName("jboss.web:service=WebServer");
+      
+      try {
+         server.setAttribute(tomcat, new Attribute(USE_JBOSS, true));
+         
+         assertTrue((Boolean)server.getAttribute(tomcat, USE_JBOSS));
+
+         node1URL = serverUrls[0];
+         node2URL = serverUrls[1];            
+         try 
+         {
+
+            URL url = new URL(node1URL+"clusteredservice/EJBServlet");
+            HttpUtils.accessURL(url);
+            HttpUtils.accessURL(url);
+         } catch (Exception e)
+         {
+         }
+         
+         try 
+         {
+            URL url = new URL(node2URL+"clusteredservice/EJBServlet");
+            HttpUtils.accessURL(url);
+            HttpUtils.accessURL(url);
+         } catch (Exception e)
+         {
+         }
+      }
+      finally
+      {
+         server.setAttribute(tomcat, new Attribute(USE_JBOSS, false));
+      }
+   }
+   
+   /**
+    * Setup the test suite.
+    */
+   public static Test suite() throws Exception
+   {
+      //return getDeploySetup(ServiceTestCase.class, "");
+      TestSuite suite = new TestSuite();
+      suite.addTest(new ServiceTestCase("testEJBServlet"));
+       return JBossClusteredTestCase.getDeploySetup(suite, "clusteredservice.war");
+   }
+
+    // NOTE: these variables must be static as apparently a separate instance
+   // of this class is created for each test
+   private static boolean deployed0 = true;
+   private static boolean deployed1 = true;
+
+   private MBeanServerConnection[] adaptors = null;
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      log.debug("deployed0 = " + deployed0);
+      log.debug("deployed1 = " + deployed1);
+
+      adaptors = getAdaptors();
+      if (!deployed0)
+      {
+         deploy(adaptors[0], "clusteredservice.war");
+         deployed0 = true;
+      }
+      if (!deployed1)
+      {
+         deploy(adaptors[1], "clusteredservice.war");
+         deployed1 = true;
+      }
+   }
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+
+      log.debug("deployed0 = " + deployed0);
+      log.debug("deployed1 = " + deployed1);
+   }
+   
+}


Property changes on: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/ServiceTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF



More information about the jboss-cvs-commits mailing list