[jboss-cvs] JBossAS SVN: r58331 - in trunk/testsuite: imports/sections src/main/org/jboss/test/web/servlets src/main/org/jboss/test/web/test src/resources/web src/resources/web/altdd

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 13 23:10:46 EST 2006


Author: scott.stark at jboss.org
Date: 2006-11-13 23:10:42 -0500 (Mon, 13 Nov 2006)
New Revision: 58331

Added:
   trunk/testsuite/src/main/org/jboss/test/web/servlets/RequestInfoServlet.java
   trunk/testsuite/src/main/org/jboss/test/web/test/AltDDUnitTestCase.java
   trunk/testsuite/src/resources/web/altdd/
   trunk/testsuite/src/resources/web/altdd/altdd-web.xml
   trunk/testsuite/src/resources/web/altdd/application.xml
   trunk/testsuite/src/resources/web/altdd/web.xml
Modified:
   trunk/testsuite/imports/sections/web.xml
Log:
Add support for an alt-dd specification of an alternate web.xml descriptor.

Modified: trunk/testsuite/imports/sections/web.xml
===================================================================
--- trunk/testsuite/imports/sections/web.xml	2006-11-14 04:07:22 UTC (rev 58330)
+++ trunk/testsuite/imports/sections/web.xml	2006-11-14 04:10:42 UTC (rev 58331)
@@ -3,6 +3,23 @@
    <target name="_jars-web">
       <mkdir dir="${build.lib}"/>
 
+      <!-- The altdd.war/altddweb.ear -->
+      <war warfile="${build.lib}/altdd.war"
+         webxml="${build.resources}/web/altdd/web.xml">
+         <classes dir="${build.classes}">
+            <include name="org/jboss/test/web/servlets/RequestInfoServlet.class"/>
+         </classes>
+      </war>
+      <ear earfile="${build.lib}/altdd-web.ear"
+         appxml="${build.resources}/web/altdd/application.xml">
+         <fileset dir="${build.lib}">
+            <include name="altdd.war"/>
+         </fileset>
+         <zipfileset dir="${build.resources}/web/altdd" prefix="alt">
+            <include name="altdd-web.xml" />
+         </zipfileset>
+      </ear>
+      
       <!-- build jbosstest-web-ejbs.jar -->
       <jar destfile="${build.lib}/jbosstest-web-ejbs.jar">
          <fileset dir="${build.classes}">

Added: trunk/testsuite/src/main/org/jboss/test/web/servlets/RequestInfoServlet.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/servlets/RequestInfoServlet.java	2006-11-14 04:07:22 UTC (rev 58330)
+++ trunk/testsuite/src/main/org/jboss/test/web/servlets/RequestInfoServlet.java	2006-11-14 04:10:42 UTC (rev 58331)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.web.servlets;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * A simple servlet that spits out the request info.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class RequestInfoServlet extends HttpServlet
+{
+   private static final long serialVersionUID = 1;
+
+   @Override
+   protected void doGet(HttpServletRequest req, HttpServletResponse res)
+      throws ServletException, IOException
+   {
+      PrintWriter out = res.getWriter();
+      out.println("<html><head><title>RequestInfoServlet</title></head><body>");
+      out.println("<h1>Request Info</h1>");
+      out.println("getCharacterEncoding"+req.getCharacterEncoding()+"<br>");
+      out.println("getContextPath"+req.getContextPath()+"<br>");
+      out.println("getContentLength"+req.getContentLength()+"<br>");
+      out.println("getContentType"+req.getContentType()+"<br>");
+      out.println("</body></html>");
+      out.flush();
+   }
+   
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/web/servlets/RequestInfoServlet.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: trunk/testsuite/src/main/org/jboss/test/web/test/AltDDUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/test/AltDDUnitTestCase.java	2006-11-14 04:07:22 UTC (rev 58330)
+++ trunk/testsuite/src/main/org/jboss/test/web/test/AltDDUnitTestCase.java	2006-11-14 04:10:42 UTC (rev 58331)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.web.test;
+
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.util.web.HttpUtils;
+
+/** Tests of using a war alt-dd web.xml
+ 
+ @author Scott.Stark at jboss.org
+ @version $Revision$
+ */
+public class AltDDUnitTestCase extends JBossTestCase
+{
+   private String baseURL = HttpUtils.getBaseURL(); 
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(AltDDUnitTestCase.class, "altdd-web.ear");
+   }
+
+   public AltDDUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   /** Access the http://{host}/altdd-test/AltRequestInfoServlet to see
+    * that the altenate uri for the RequestInfoServlet was used
+    */
+   public void testAltRequestInfoServlet()
+      throws Exception
+   {
+      URL url = new URL(baseURL+"altdd-test/AltRequestInfoServlet");
+      HttpMethodBase request = HttpUtils.accessURL(url);
+      Header errors = request.getResponseHeader("X-Exception");
+      log.info("X-Exception: "+errors);
+      assertTrue("X-Exception("+errors+") is null", errors == null);      
+   }
+
+   /** Access the http://{host}/altdd-test/AltRequestInfoServlet2 to see
+    * that the RequestInfoServlet2 was added
+    */
+   public void testAltRequestInfoServlet2()
+      throws Exception
+   {
+      URL url = new URL(baseURL+"altdd-test/AltRequestInfoServlet2");
+      HttpMethodBase request = HttpUtils.accessURL(url);
+      Header errors = request.getResponseHeader("X-Exception");
+      log.info("X-Exception: "+errors);
+      assertTrue("X-Exception("+errors+") is null", errors == null);      
+   }
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/web/test/AltDDUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: trunk/testsuite/src/resources/web/altdd/altdd-web.xml
===================================================================
--- trunk/testsuite/src/resources/web/altdd/altdd-web.xml	2006-11-14 04:07:22 UTC (rev 58330)
+++ trunk/testsuite/src/resources/web/altdd/altdd-web.xml	2006-11-14 04:10:42 UTC (rev 58331)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+   <description>The overriden webapplication</description>
+   
+   <servlet>
+      <description>A servlet in WEB-INF/classes</description>
+      <servlet-name>RequestInfoServlet</servlet-name>
+      <servlet-class>org.jboss.test.web.servlets.RequestInfoServlet</servlet-class>
+   </servlet>
+   <servlet>
+      <description>A servlet in WEB-INF/classes</description>
+      <servlet-name>RequestInfoServlet2</servlet-name>
+      <servlet-class>org.jboss.test.web.servlets.RequestInfoServlet</servlet-class>
+   </servlet>
+
+   <servlet-mapping>
+      <servlet-name>RequestInfoServlet</servlet-name>
+      <url-pattern>/AltRequestInfoServlet</url-pattern>
+   </servlet-mapping>
+   <servlet-mapping>
+      <servlet-name>RequestInfoServlet2</servlet-name>
+      <url-pattern>/AltRequestInfoServlet2</url-pattern>
+   </servlet-mapping>
+   
+</web-app>


Property changes on: trunk/testsuite/src/resources/web/altdd/altdd-web.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: trunk/testsuite/src/resources/web/altdd/application.xml
===================================================================
--- trunk/testsuite/src/resources/web/altdd/application.xml	2006-11-14 04:07:22 UTC (rev 58330)
+++ trunk/testsuite/src/resources/web/altdd/application.xml	2006-11-14 04:10:42 UTC (rev 58331)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+   http://java.sun.com/xml/ns/javaee/application_5.xsd"
+	version="5">
+	<description>Tests of the alt-dd behavior</description>
+
+    <module>
+       <web>
+           <web-uri>altdd.war</web-uri>
+           <context-root>/altdd-test</context-root>
+       </web>
+       <!-- Specify the ear relative path -->
+       <alt-dd>alt/altdd-web.xml</alt-dd>
+    </module>
+
+</application>


Property changes on: trunk/testsuite/src/resources/web/altdd/application.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: trunk/testsuite/src/resources/web/altdd/web.xml
===================================================================
--- trunk/testsuite/src/resources/web/altdd/web.xml	2006-11-14 04:07:22 UTC (rev 58330)
+++ trunk/testsuite/src/resources/web/altdd/web.xml	2006-11-14 04:10:42 UTC (rev 58331)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+   <description>The web.xml that should be overriden by altdd-web.xml</description>
+   
+   <servlet>
+      <description>A servlet in WEB-INF/classes</description>
+      <servlet-name>RequestInfoServlet</servlet-name>
+      <servlet-class>org.jboss.test.web.servlets.RequestInfoServlet</servlet-class>
+   </servlet>
+
+   <servlet-mapping>
+      <servlet-name>RequestInfoServlet</servlet-name>
+      <url-pattern>/RequestInfoServlet</url-pattern>
+   </servlet-mapping>
+
+</web-app>


Property changes on: trunk/testsuite/src/resources/web/altdd/web.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jboss-cvs-commits mailing list