[jboss-cvs] JBossAS SVN: r108590 - in branches/infinispan-int/testsuite: imports/sections and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 14 16:39:14 EDT 2010
Author: smarlow at redhat.com
Date: 2010-10-14 16:39:13 -0400 (Thu, 14 Oct 2010)
New Revision: 108590
Modified:
branches/infinispan-int/testsuite/imports/config/tests-clustering.xml
branches/infinispan-int/testsuite/imports/sections/cluster.xml
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/servlets/EJBServlet.java
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
branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredservice/WEB-INF/web.xml
Log:
ejb3 clusteredservice test
Modified: branches/infinispan-int/testsuite/imports/config/tests-clustering.xml
===================================================================
--- branches/infinispan-int/testsuite/imports/config/tests-clustering.xml 2010-10-14 20:37:50 UTC (rev 108589)
+++ branches/infinispan-int/testsuite/imports/config/tests-clustering.xml 2010-10-14 20:39:13 UTC (rev 108590)
@@ -10,17 +10,26 @@
<!--
| Define the Pattern Sets Here
-->
+
+ <patternset id="cluster.ejb3.includes">
+ <include name="org/jboss/test/cluster/ejb3/clusteredservice/unit/*TestCase.class"/>
+ </patternset>
+
<patternset id="cluster.defaultcfg.non.http.includes">
+
<include name="org/jboss/test/cluster/defaultcfg/test/*TestCase.class"/>
<include name="org/jboss/test/cluster/defaultcfg/ejb2/test/*TestCase.class"/>
+
<!-- These are web tier tests that shouldn't be repeated with REPL_SYNC, etc -->
+
<include name="org/jboss/test/cluster/defaultcfg/simpleweb/test/*TestCase.class"/>
<include name="org/jboss/test/cluster/defaultcfg/clusteredentity/test/*TestCase.class"/>
<include name="org/jboss/test/cluster/multicfg/test/*TestCase.class"/>
<include name="org/jboss/test/cluster/multicfg/ejb2/test/*TestCase.class"/>
+
</patternset>
<patternset id="cluster.defaultcfg.http.includes">
<include name="org/jboss/test/cluster/defaultcfg/web/test/*TestCase.class"/>
@@ -123,6 +132,7 @@
<property name="cluster.non.http.includes" value="cluster.defaultcfg.non.http.includes"/>
<property name="cluster.http.includes" value="cluster.defaultcfg.http.includes"/>
<property name="cluster.http.jk.includes" value="cluster.defaultcfg.http.jk.includes"/>
+ <property name="cluster.ejb3.includes" value="cluster.ejb3.includes"/>
<antcall target="tests-clustering-configure" inheritRefs="true"/>
@@ -148,6 +158,15 @@
<param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-1"/>
</antcall>
+ <echo message="Going to call target tests-clustering-unit for EJB3 tests"/>
+
+ <antcall target="tests-clustering-unit" inheritRefs="true">
+ <param name="cluster.includes.refid" value="${cluster.ejb3.includes}"/>
+ <param name="jboss-junit-configuration" value="Default-${jboss-junit-configuration}"/>
+ <param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-0"/>
+ <param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-1"/>
+ </antcall>
+
<server:stop name="cluster-${jboss-junit-configuration}-0"/>
<server:stop name="cluster-${jboss-junit-configuration}-1"/>
@@ -474,6 +493,28 @@
<server:stop name="cluster-${jboss-junit-configuration}-BR-1"/>
</target>
+ <!-- Runs the EJB3 tests -->
+ <target name="tests-clustering-ejb3" depends="init">
+ <property name="jboss-junit-configuration" value="udp"/>
+
+ <antcall target="tests-clustering-configure" inheritRefs="true"/>
+
+ <server:start name="cluster-${jboss-junit-configuration}-0"/>
+ <server:start name="cluster-${jboss-junit-configuration}-1"/>
+
+ <echo message="Going to call target tests-clustering-unit for ${test}"/>
+
+ <antcall target="tests-clustering-unit" inheritRefs="true">
+ <param name="cluster.includes.refid" value="cluster.ejb3.includes"/>
+ <param name="jboss-junit-configuration" value="Default-${jboss-junit-configuration}"/>
+ <param name="jbosstest.cluster.node0.config" value="cluster-${jboss-junit-configuration}-0"/>
+ <param name="jbosstest.cluster.node1.config" value="cluster-${jboss-junit-configuration}-1"/>
+ </antcall>
+
+ <server:stop name="cluster-${jboss-junit-configuration}-0"/>
+ <server:stop name="cluster-${jboss-junit-configuration}-1"/>
+ </target>
+
<!-- Runs only the non-http tests -->
<target name="tests-clustering-non-http" depends="init">
Modified: branches/infinispan-int/testsuite/imports/sections/cluster.xml
===================================================================
--- branches/infinispan-int/testsuite/imports/sections/cluster.xml 2010-10-14 20:37:50 UTC (rev 108589)
+++ branches/infinispan-int/testsuite/imports/sections/cluster.xml 2010-10-14 20:39:13 UTC (rev 108590)
@@ -10,19 +10,19 @@
</classes>
</war>
- <jar jarfile="${build.lib}/clusteredservice.jar">
+ <jar jarfile="${build.lib}/clusteredserviceejb.jar">
<fileset dir="${build.classes}">
- <include name="org/jboss/ejb3/test/clusteredservice/*.class"/>
- <exclude name="org/jboss/ejb3/test/clusteredservice/ServiceWeb.class"/>
+ <include name="org/jboss/test/cluster/ejb3/clusteredservice/*.class"/>
+ <exclude name="org/jboss/test/cluster/ejb3/clusteredservice/ServiceWeb.class"/>
</fileset>
</jar>
<war warfile="${build.lib}/clusteredservice.war"
webxml="${build.resources}/cluster/ejb3/clusteredservice/WEB-INF/web.xml">
<classes dir="${build.classes}">
- <include name="org/jboss/ejb3/test/clusteredservice/servlets/*.class"/>
- <include name="org/jboss/ejb3/test/clusteredservice/ServiceRemote.class"/>
- <include name="org/jboss/ejb3/test/clusteredservice/ServiceWeb.class"/>
+ <include name="org/jboss/test/cluster/ejb3/clusteredservice/servlets/*.class"/>
+ <include name="org/jboss/test/cluster/ejb3/clusteredservice/ServiceRemote.class"/>
+ <include name="org/jboss/test/cluster/ejb3/clusteredservice/ServiceWeb.class"/>
</classes>
</war>
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-14 20:37:50 UTC (rev 108589)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/ServiceBean.java 2010-10-14 20:39:13 UTC (rev 108590)
@@ -35,7 +35,7 @@
* @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
*/
@Service(objectName = "default:service=service")
- at Clustered(partition = "HASingletonPartition")
+ at Clustered(partition = "DefaultPartition")
@Remote(ServiceRemote.class)
@Local(ServiceLocal.class)
@Management(ServiceManagement.class)
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-14 20:37:50 UTC (rev 108589)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/servlets/EJBServlet.java 2010-10-14 20:39:13 UTC (rev 108590)
@@ -49,9 +49,11 @@
{
try
{
+ log.info("EJBServlet.processRequest invoked");
ServiceRemote test = (ServiceRemote) getInitialContext().lookup("ServiceBean/remote");
+ log.info("looked up remote bean ServiceBean/remote, about to invoke remoteMethod() on bean");
test.remoteMethod();
-
+ log.info("invoked remoteMethod() on bean");
/* MBeanServer server = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
ObjectName testerName = new ObjectName("default:service=service");
Object[] params = {};
@@ -60,8 +62,7 @@
}
catch (Exception e)
{
- e.printStackTrace();
-
+ log("error trying to invoke ServiceBean/remote remoteMethod ", e);
throw new ServletException("Failed to call ServiceBean through remote or local interfaces", e);
}
response.setContentType("text/html");
@@ -78,7 +79,8 @@
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
- p.put(Context.PROVIDER_URL, "localhost:1100");
+ String local = System.getProperty("jboss.bind.address");
+ p.put(Context.PROVIDER_URL, local + ":1100");
return new InitialContext(p);
}
Modified: 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 2010-10-14 20:37:50 UTC (rev 108589)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/HttpUtils.java 2010-10-14 20:39:13 UTC (rev 108590)
@@ -75,52 +75,56 @@
/** 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
+ * @return int http response code
* @throws Exception on any failure
*/
- public static HttpMethodBase accessURL(URL url) throws Exception
+ public static int accessURL(URL url) throws Exception
{
- return accessURL(url, "JBossTest Servlets", HttpURLConnection.HTTP_OK);
+ HttpClient httpConn = new HttpClient();
+ HttpMethodBase request = createMethod(url, GET);
+
+ int hdrCount = null != null ? ((Header[]) null).length : 0;
+ for(int n = 0; n < hdrCount; n ++)
+ request.addRequestHeader(((Header[]) null)[n]);
+ try
+ {
+ log.info("Connecting to: "+ url);
+ String userInfo = url.getUserInfo();
+
+ if( userInfo != null )
+ {
+ UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
+ httpConn.getState().setCredentials("JBossTest Servlets", url.getHost(), auth);
+ }
+ log.info("RequestURI: "+request.getURI());
+ int responseCode = httpConn.executeMethod(request);
+ String response = request.getStatusText();
+ log.info("responseCode="+responseCode+", response="+response);
+ String content = request.getResponseBodyAsString();
+ log.info(content);
+ return responseCode;
+ // Validate that we are seeing the requested response code
+ }
+ catch(IOException e)
+ {
+ throw e;
+ }
+
}
- /** 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;
+ int hdrCount = null != null ? ((Header[]) null).length : 0;
for(int n = 0; n < hdrCount; n ++)
- request.addRequestHeader(hdrs[n]);
+ request.addRequestHeader(((Header[]) null)[n]);
try
{
- log.debug("Connecting to: "+url);
+ log.info("Connecting to: "+ url);
String userInfo = url.getUserInfo();
if( userInfo != null )
@@ -128,16 +132,16 @@
UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
httpConn.getState().setCredentials(realm, url.getHost(), auth);
}
- log.debug("RequestURI: "+request.getURI());
+ log.info("RequestURI: "+request.getURI());
int responseCode = httpConn.executeMethod(request);
String response = request.getStatusText();
- log.debug("responseCode="+responseCode+", response="+response);
+ log.info("responseCode="+responseCode+", response="+response);
String content = request.getResponseBodyAsString();
- log.debug(content);
+ log.info(content);
// Validate that we are seeing the requested response code
- if( responseCode != expectedHttpCode )
+ if( responseCode != expectedHttpCode)
{
- throw new IOException("Expected reply code:"+expectedHttpCode
+ throw new IOException("Expected reply code:"+ expectedHttpCode
+", actual="+responseCode);
}
}
Modified: 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 2010-10-14 20:37:50 UTC (rev 108589)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredservice/unit/ServiceTestCase.java 2010-10-14 20:39:13 UTC (rev 108590)
@@ -21,11 +21,10 @@
*/
package org.jboss.test.cluster.ejb3.clusteredservice.unit;
+import java.net.HttpURLConnection;
import java.net.URL;
-import javax.management.Attribute;
import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
import junit.framework.Test;
@@ -38,12 +37,6 @@
*/
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)
@@ -54,57 +47,64 @@
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));
+ log.info("serverUrls[0] = " + serverUrls[0]); // http://127.0.0.2:8080
- node1URL = serverUrls[0];
- node2URL = serverUrls[1];
- try
- {
+ String node1URL = serverUrls[0];
+ String node2URL = serverUrls[1];
+ node1URL = addUserInfo(node1URL, "jduke:theduke@");
+ node2URL = addUserInfo(node2URL, "jduke:theduke@");
+ URL url=null;
+ try
+ {
+ url = new URL(node1URL+"/clusteredservice/EJBServlet");
+ log.info("about to access " + url);
+ assertEquals(HttpURLConnection.HTTP_OK,HttpUtils.accessURL(url));
+ assertEquals(HttpURLConnection.HTTP_OK,HttpUtils.accessURL(url));
+ } catch (Exception e)
+ {
+ log.error("error accessing url = " + url, e);
+ }
- 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)
- {
- }
+ try
+ {
+ url = new URL(node2URL+"/clusteredservice/EJBServlet");
+ log.info("about to access " + url);
+ assertEquals(HttpURLConnection.HTTP_OK,HttpUtils.accessURL(url));
+ assertEquals(HttpURLConnection.HTTP_OK,HttpUtils.accessURL(url));
+ } catch (Exception e)
+ {
+ log.error("error accessing url = " + url, e);
}
- finally
+ }
+
+ private String addUserInfo(String url, String userinfo)
+ {
+ String result = url;
+ // url will look like http://127.0.0.2:8080
+ // change to http://jduke:theduke@127.0.0.2:8080
+ if(url.startsWith("http://"))
{
- server.setAttribute(tomcat, new Attribute(USE_JBOSS, false));
+ result = "http://" + userinfo + url.substring("http://".length());
+ log.info("addUserInfo url=" + result);
}
+ return result;
+
}
-
+
/**
* 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");
+ return JBossClusteredTestCase.getDeploySetup(suite, "clusteredservice.war clusteredserviceejb.jar");
}
// 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 static boolean deployed0 = false;
+ private static boolean deployed1 = false;
private MBeanServerConnection[] adaptors = null;
protected void setUp() throws Exception
@@ -117,11 +117,14 @@
adaptors = getAdaptors();
if (!deployed0)
{
+ deploy(adaptors[0], "clusteredserviceejb.jar");
deploy(adaptors[0], "clusteredservice.war");
deployed0 = true;
}
+
if (!deployed1)
{
+ deploy(adaptors[1], "clusteredserviceejb.jar");
deploy(adaptors[1], "clusteredservice.war");
deployed1 = true;
}
Modified: branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredservice/WEB-INF/web.xml
===================================================================
--- branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredservice/WEB-INF/web.xml 2010-10-14 20:37:50 UTC (rev 108589)
+++ branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredservice/WEB-INF/web.xml 2010-10-14 20:39:13 UTC (rev 108590)
@@ -10,7 +10,7 @@
<servlet>
<servlet-name>EJBServlet</servlet-name>
- <servlet-class>org.jboss.ejb3.test.clusteredservice.servlets.EJBServlet</servlet-class>
+ <servlet-class>org.jboss.test.cluster.ejb3.clusteredservice.servlets.EJBServlet</servlet-class>
</servlet>
<!-- The servlet and jsp page mappings -->
More information about the jboss-cvs-commits
mailing list