craigmcc    2004/08/03 00:01:09

  Modified:    contrib/struts-faces README.txt build.properties.sample
                        build.xml
  Added:       contrib/struts-faces/src/sysclient/org/apache/struts/faces/sysclient
                        AbstractTestCase.java SimpleTestCase.java
               contrib/struts-faces/web/systest simple.jsp
               contrib/struts-faces/web/systest/WEB-INF faces-config.xml
                        struts-config.xml web.xml
  Log:
  Commit the foundation for a system integration test suite for the
  Struts-Faces integration library.  The suite is comprised of a standard
  web application utilizing the integration library, and an HtmlUnit based
  client application that makes requests to the test webapp and verifies
  the contents of the result.  This initial commit only has a few very
  simple tests on a static output page; additional tests will be added
  soon to verify the behavior of form submits that leverage the integration
  logic.
  
  Revision  Changes    Path
  1.15      +40 -4     jakarta-struts/contrib/struts-faces/README.txt
  
  Index: README.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/README.txt,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- README.txt        7 Jul 2004 22:08:56 -0000       1.14
  +++ README.txt        3 Aug 2004 07:01:07 -0000       1.15
  @@ -346,13 +346,15 @@
   
   * Add the following JAR files from the JavaServer Faces reference
     implementation's "lib" directory to your application's
  -  "/WEB-INF/lib" directory:  jsf-api.jar, jsf-impl.jar.
  +  "/WEB-INF/lib" directory:  jsf-api.jar, jsf-impl.jar,
  +  or install them in your servlet container's shared folder.
     (You can also use any other JSF implementation that has
     been certified to be compatible with the JSF specification.)
   
   * Add the following JAR files, containing the JSTL release (or
     from the JavaServer Faces release) to your application's
  -  "/WEB-INF/lib" directory:  jstl.jar, standard.jar.
  +  "/WEB-INF/lib" directory:  jstl.jar, standard.jar, or
  +  install them in your servlet container's shared folder.
   
   * Add the servlet definition for the JavaServer Faces servlet into
     your web application's deployment descriptor (/WEB-INF/web.xml):
  @@ -506,7 +508,8 @@
   fully implemented or tested:
   
   * Use of the Struts-Faces integration library in multiple application modules
  -  (although in theory this should "just work").
  +  (likely to not work without the addition of a Filter to set the correct
  +  module configuration instance).
   
   * Use of the "forwardPattern" or "pagePattern" attributes on the
     <controller> element.
  @@ -526,3 +529,36 @@
     combining JSF component tags and other JSP source elements (including
     custom tags from other tag libraries) on the same page.  See
     Section 9.2.8 of the JSF spec for more information.
  +
  +
  +===============
  +DEVELOPER NOTES:
  +===============
  +
  +The CVS sources for the Struts-Faces integration library include a System
  +Integration test suite that is comprised of a test web application (default
  +context path is "/struts-faces-systest") and a client application based on
  +the HtmlUnit package from SourceForge.  To execute the test suite:
  +
  +* Update your build.properties file as needed to declare appropriate values
  +  for the "htmlunit.home" and "junit.home" properties.
  +
  +* Update your build.properties file as necessary for deploying applications
  +  to a standalone Tomcat instance.  You should be able to successfully use
  +  the "example.install" and "example2.install" targets.
  +
  +* Compile and deploy the system integration application by executing the
  +  Ant target "systest.install".
  +
  +* Execute the test client by executing the Ant target "sysclient.execute".
  +
  +* When you have finished testing, you can remove the test application by
  +  executing the Ant target "systest.remove".
  +
  +* Before committing any changes to the integration library, be sure that the
  +  system integration tests can be succesfully executed.
  +
  +* If you add new functionality to the integration library, you should also
  +  add or enhance the system integration tests to catch potential future
  +  regressions as the library is updated by you, or others, in the future.
  +
  
  
  
  1.9       +17 -1     jakarta-struts/contrib/struts-faces/build.properties.sample
  
  Index: build.properties.sample
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/build.properties.sample,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- build.properties.sample   7 Jul 2004 19:40:29 -0000       1.8
  +++ build.properties.sample   3 Aug 2004 07:01:07 -0000       1.9
  @@ -132,3 +132,19 @@
   
   # The context path to which the example web application will be deployed
   example.path=/struts-faces
  +example2.path=/struts-faces2
  +
  +
  +# ------------------------- System Integration Test Properties -----------------
  +
  +# The following properties are only required if you wish to execute the
  +# system integration test client against the corresponding webapp.
  +
  +# The absolute or relative pathname to your installation of HtmlUnit 1.2.3
  +# or later.  This code can be acquired at SourceForge.
  +htmlunit.home=/usr/local/htmlunit-1.2.3
  +
  +# The type of JSF state saving that should be used when the system integration
  +# test web application is depoyed ("client" or "server")
  +systest.state.saving=server
  +
  
  
  
  1.15      +194 -1    jakarta-struts/contrib/struts-faces/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/build.xml,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- build.xml 26 Jul 2004 19:34:48 -0000      1.14
  +++ build.xml 3 Aug 2004 07:01:07 -0000       1.15
  @@ -31,9 +31,10 @@
   
   
     <!-- Dependency home directory defaults -->
  +  <property name="htmlunit.home"    value="/usr/local/htmlunit-1.2.3"/>
     <property name="jsf.home"         value="/usr/local/jsf-1_1"/>
     <property name="jstl.home"        value="/usr/local/standard-1.0.3"/>
  -  <property name="server.home"       value="/usr/local/jakarta-tomcat-4.1.29"/>
  +  <property name="server.home"      value="/usr/local/jakarta-tomcat-5.0.25"/>
     <property name="struts.home"      value="/usr/local/jakarta-struts-1.1"/>
   
   
  @@ -89,6 +90,13 @@
       <pathelement location="${build.home}/classes"/>
     </path>
   
  +  <!-- System Integration Test Client Classpath -->
  +  <path id="sysclient.classpath">
  +    <pathelement location="${junit.jar}"/>
  +    <fileset          dir="${htmlunit.home}/lib"
  +                 includes="*.jar"/>
  +    <pathelement location="${build.home}/sysclient"/>
  +  </path>
   
     <!-- Custom Tomcat Integration -->
     <taskdef  name="deploy"   classname="org.apache.catalina.ant.DeployTask"/>
  @@ -103,6 +111,13 @@
   
     <property name="example.path"     value="/struts-faces"/>
     <property name="example2.path"    value="/struts-faces2"/>
  +  <property name="systest.path"         value="/struts-faces-systest"/>
  +
  +
  +  <!-- System Integration Test Settings -->
  +  <property name="systest.state.saving" value="server"/>
  +  <property name="systest.url"          
value="http://localhost:8080${systest.path}"/>
  +
   
   
     <!-- ===================== LIBRARY: Maintenance ========================= -->
  @@ -119,6 +134,7 @@
       <echo message="---------- ${project.name} ${project.version} ----------"/>
       <filter token="name"     value="${project.name}"/>
       <filter token="package"  value="${project.package}"/>
  +    <filter token="state"    value="${systest.state.saving}"/>
       <filter token="version"  value="${project.version}"/>
     </target>
   
  @@ -464,6 +480,183 @@
      description="Remove example2 webapp from Tomcat">
       <remove url="${url}" username="${username}" password="${password}"
               path="${example2.path}"/>
  +  </target>
  +
  +
  +  <!-- ===================== SYSTEST: Create Webapp ======================== -->
  +
  +
  +  <target name="systest.prepare" depends="library">
  +
  +    <echo message="------------ ${project.name} Systest Webapp -------------"/>
  +    <mkdir         dir="${build.home}/webapps"/>
  +    <mkdir         dir="${build.home}/webapps/systest"/>
  +
  +  </target>
  +
  +
  +  <target name="systest.static" depends="systest.prepare">
  +
  +    <!-- Copy static web resources -->
  +    <copy        todir="${build.home}/webapps/systest"
  +             filtering="on">
  +      <fileset     dir="web/systest"/>
  +    </copy>
  +
  +    <!-- Copy required configuration files -->
  +<!--
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF">
  +      <fileset     dir="${build.home}/conf">
  +        <include  name="*.tld"/>
  +      </fileset>
  +    </copy>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF">
  +      <fileset     dir="${struts.home}/lib">
  +        <include  name="*.tld"/>
  +        <include  name="valid*.xml"/>
  +      </fileset>
  +    </copy>
  +-->
  +
  +    <!-- Copy required library JAR files -->
  +    <mkdir         dir="${build.home}/webapps/systest/WEB-INF/lib"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${build.home}/lib/struts-faces.jar"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${commons-beanutils.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${commons-collections.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${commons-digester.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${commons-fileupload.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${commons-logging.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${commons-validator.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${jakarta-oro.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${struts.jar}"/>
  +
  +  </target>
  +
  +
  +  <target name="systest.libraries" depends="systest.static"
  +            if="build.standalone">
  +
  +    <!-- Copy libraries required for standalone use only -->
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${jsf-api.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${jsf-impl.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${jstl.jar}"/>
  +    <copy        todir="${build.home}/webapps/systest/WEB-INF/lib"
  +                  file="${standard.jar}"/>
  +
  +  </target>
  +
  +
  +  <target name="systest.compile" depends="systest.libraries">
  +
  +    <!-- Compile Java Sources -->
  +    <mkdir         dir="${build.home}/webapps/systest/WEB-INF/classes"/>
  +<!--
  +    <javac      srcdir="src/systest"
  +               destdir="${build.home}/webapps/systest/WEB-INF/classes"
  +                 debug="${compile.debug}"
  +           deprecation="${compile.deprecation}"
  +              optimize="${compile.optimize}">
  +      <classpath refid="classpath" />
  +    </javac>
  +-->
  +
  +    <!-- Copy non-Java Sources -->
  +<!--
  +    <copy    todir="${build.home}/webapps/systest/WEB-INF/classes">
  +      <fileset dir="src/systest">
  +        <exclude name="**/*.java"/>
  +      </fileset>
  +    </copy>
  +-->
  +
  +  </target>
  +
  +
  +  <!-- ====================== SYSTEST:  Tomcat Integration ================= -->
  +
  +
  +  <target name="systest.install" depends="systest.compile"
  +   description="Install systest webapp on Tomcat">
  +    <install url="${url}" username="${username}" password="${password}"
  +            path="${systest.path}"
  +             war="file://${build.home}/webapps/systest"/>
  +  </target>
  +
  +
  +  <target name="systest.reload" depends="systest.compile"
  +   description="Reload systest webapp on Tomcat">
  +    <reload url="${url}" username="${username}" password="${password}"
  +            path="${systest.path}"/>
  +  </target>
  +
  +
  +  <target name="systest.remove"
  +   description="Remove systest webapp from Tomcat">
  +    <remove url="${url}" username="${username}" password="${password}"
  +            path="${systest.path}"/>
  +  </target>
  +
  +
  +  <!-- ====================== SYSTEST: Client Execution =================== -->
  +
  +
  +  <target name="sysclient.compile"
  +   description="Prepare system integration test client">
  +
  +    <!-- Compile Java Sources -->
  +    <mkdir         dir="${build.home}/sysclient"/>
  +    <javac      srcdir="src/sysclient"
  +               destdir="${build.home}/sysclient"
  +                 debug="${compile.debug}"
  +           deprecation="${compile.deprecation}"
  +              optimize="${compile.optimize}">
  +      <classpath refid="sysclient.classpath"/>
  +    </javac>
  +
  +    <!-- Copy non-Java Sources -->
  +    <copy        todir="${build.home}/sysclient">
  +      <fileset     dir="src/sysclient">
  +        <exclude  name="**/*.java"/>
  +      </fileset>
  +    </copy>
  +
  +  </target>
  +
  +
  +  <target name="sysclient.execute" depends="sysclient.compile"
  +   description="Execute system integration test client">
  +
  +    <junit         fork="yes"
  +           printSummary="yes"
  +            haltonerror="yes"
  +          haltonfailure="yes">
  +
  +      <classpath  refid="sysclient.classpath"/>
  +      <formatter   type="plain"
  +                usefile="false"/>
  +      <sysproperty  key="systest"
  +                  value="${systest.url}"/>
  +
  +      <batchtest>
  +        <fileset    dir="${build.home}/sysclient"
  +               excludes="**/AbstractTestCase.class"
  +               includes="**/*TestCase.class"/>
  +      </batchtest>
  +
  +    </junit>
  +
     </target>
   
   
  
  
  
  1.1                  
jakarta-struts/contrib/struts-faces/src/sysclient/org/apache/struts/faces/sysclient/AbstractTestCase.java
  
  Index: AbstractTestCase.java
  ===================================================================
  /*
   * Copyright 2002,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.struts.faces.sysclient;
  
  import com.gargoylesoftware.htmlunit.ElementNotFoundException;
  import com.gargoylesoftware.htmlunit.WebClient;
  import com.gargoylesoftware.htmlunit.html.HtmlBody;
  import com.gargoylesoftware.htmlunit.html.HtmlElement;
  import com.gargoylesoftware.htmlunit.html.HtmlForm;
  import com.gargoylesoftware.htmlunit.html.HtmlHead;
  import com.gargoylesoftware.htmlunit.html.HtmlPage;
  
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  import org.apache.commons.httpclient.Cookie;
  import org.apache.commons.httpclient.HttpState;
  
  
  
  /**
   * <p>Abstract base class for system integration tests based on HtmlUnit.</p>
   *
   * @version $Revision: 1.1 $ $Date: 2004/08/03 07:01:08 $
   */
  
  public abstract class AbstractTestCase extends TestCase {
  
  
      // ------------------------------------------------------------ Constructors
  
  
      /**
       * <p>Construct a new instance of this test case.</p>
       *
       * @param name Name of the new test case
       */
      public AbstractTestCase(String name) {
  
          super(name);
  
      }
  
  
      // ------------------------------------------------------ Instance Variables
  
  
      /**
       * <p>The HTTP state information for this test case.</p>
       */
      protected HttpState httpState = null;
  
  
      /**
       * <p>The most recently retrieved page from the server.</p>
       */
      protected HtmlPage page = null;
  
  
      /**
       * <p>The calculated URL for the installed "systest" web application.
       * This value is based on a system property named <code>systest</code>,
       * which must be defined as part of the command line that executes
       * each test case.</p>
       */
      protected URL url = null;
  
  
      /**
       * <p>The web client for this test case.</p>
       */
      protected WebClient webClient = null;
  
  
      // ------------------------------------------------------ Test Setup Methods
  
  
      /**
       * <p>Set up the instance variables required for this test case.</p>
       */
      public void setUp() throws Exception {
  
          // Calculate the URL for the installed "systest" web application
          String systest = System.getProperty("systest");
          url = new URL(systest + "/");
  
          // Initialize HtmlUnit constructs for this test case
          webClient = new WebClient();
          httpState = webClient.getWebConnection().getStateForUrl(url("/"));
  
      }
  
  
      /**
       * <p>Return the set of tests included in this test suite.</p>
       */
      public static Test suite() {
  
          return (new TestSuite(AbstractTestCase.class));
  
      }
  
  
      /**
       * <p>Tear down instance variables required by this test case.</p>
       */
      public void tearDown() {
  
          httpState = null;
          page = null;
          // sessionId = null;
          url = null;
          webClient = null;
  
      }
  
  
  
      // ------------------------------------------------------- Protected Methods
  
  
      /**
       * <p>Return the body element for the most recently retrieved page.
       * If there is no such element, return <code>null</code>.</p>
       */
      protected HtmlBody body() throws Exception {
  
          Iterator elements = page.getChildElements().iterator();
          while (elements.hasNext()) {
              HtmlElement element = (HtmlElement) elements.next();
              if (element instanceof HtmlBody) {
                  return ((HtmlBody) element);
              }
          }
          return (null);
  
      }
  
  
      /**
       * <p>Return the HTML element with the specified <code>id</code> from the
       * most recently retrieved page.  If there is no such element, return
       * <code>null</code>.</p>
       *
       * @param id Identifier of the requested element.
       */
      protected HtmlElement element(String id) throws Exception {
  
          try {
              return (page.getHtmlElementById(id));
          } catch (ElementNotFoundException e) {
              return (null);
          }
  
      }
  
  
      /**
       * <p>Return the form with the specified <code>id</code> from the most
       * recently retrieved page.  If there is no such form, return
       * <code>null</code>.<p>
       *
       * @param id Identifier of the requested form.
       */
      protected HtmlForm form(String id) throws Exception {
  
          Iterator forms = page.getAllForms().iterator();
          while (forms.hasNext()) {
              HtmlForm form = (HtmlForm) forms.next();
              if (id.equals(form.getAttributeValue("id"))) {
                  return (form);
              }
          }
          return (null);
  
      }
  
  
      /**
       * <p>Return the head element for the most recently retrieved page.
       * If there is no such element, return <code>null</code>.</p>
       */
      protected HtmlHead head() throws Exception {
  
          Iterator elements = page.getChildElements().iterator();
          while (elements.hasNext()) {
              HtmlElement element = (HtmlElement) elements.next();
              if (element instanceof HtmlHead) {
                  return ((HtmlHead) element);
              }
          }
          return (null);
  
      }
  
  
      /**
       * <p>Retrieve and return the page at the specified context relative path.
       * Save a reference to this page so that other utility methods may be used
       * to retrieve information from it.</p>
       *
       * @param path Context relative path
       *
       * @exception IllegalArgumentException if the context relative path
       *  does not begin with a '/' character
       */
      protected HtmlPage page(String path) throws Exception {
  
          HtmlPage page = (HtmlPage) webClient.getPage(url(path));
          /*
          if (sessionId == null) {
              saveSessionId(page);
          }
          */
          this.page = page;
          return (page);
  
      }
  
  
      /**
       * <p>Return the page title from the most recently retrieved page.
       * Any leading and trailing whitespace will be trimmed.</p>
       */
      protected String title() throws Exception {
  
          return (page.getTitleText().trim());
  
      }
  
  
      /**
       * <p>Calculate and return an absolute URL for the specified context
       * relative path, which must begin with a '/' character.</p>
       *
       * @param path Context relative path
       *
       * @exception IllegalArgumentException if the context relative path
       *  does not begin with a '/' character
       */
      protected URL url(String path) throws Exception {
  
          if (path.charAt(0) != '/') {
              throw new IllegalArgumentException("Context path '" + path +
                                                 "' does not start with '/'");
          }
          return new URL(url, path.substring(1));
  
      }
  
  
  }
  
  
  
  1.1                  
jakarta-struts/contrib/struts-faces/src/sysclient/org/apache/struts/faces/sysclient/SimpleTestCase.java
  
  Index: SimpleTestCase.java
  ===================================================================
  /*
   * Copyright 2002,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.struts.faces.sysclient;
  
  import com.gargoylesoftware.htmlunit.ElementNotFoundException;
  import com.gargoylesoftware.htmlunit.WebClient;
  import com.gargoylesoftware.htmlunit.html.HtmlBase;
  import com.gargoylesoftware.htmlunit.html.HtmlBody;
  import com.gargoylesoftware.htmlunit.html.HtmlElement;
  import com.gargoylesoftware.htmlunit.html.HtmlForm;
  import com.gargoylesoftware.htmlunit.html.HtmlHead;
  import com.gargoylesoftware.htmlunit.html.HtmlLink;
  import com.gargoylesoftware.htmlunit.html.HtmlPage;
  
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  import org.apache.commons.httpclient.Cookie;
  import org.apache.commons.httpclient.HttpState;
  
  
  /**
   * <p>Test case for a simple Struts-Faces page that is statically examined
   * to ensure that all of the expected elements have been rendered correctly.</p>
   *
   * @version $Revision: 1.1 $ $Date: 2004/08/03 07:01:09 $
   */
  
  public class SimpleTestCase extends AbstractTestCase {
  
  
      // ------------------------------------------------------------ Constructors
  
  
      /**
       * <p>Construct a new instance of this test case.</p>
       *
       * @param name Name of the new test case
       */
      public SimpleTestCase(String name) {
  
          super(name);
  
      }
  
  
      // ------------------------------------------------------ Instance Variables
  
  
      // ------------------------------------------------------ Test Setup Methods
  
  
      /**
       * <p>Set up the instance variables required for this test case.</p>
       */
      public void setUp() throws Exception {
  
          super.setUp();
          page("/simple.faces");
  
      }
  
  
      /**
       * <p>Return the set of tests included in this test suite.</p>
       */
      public static Test suite() {
  
          return (new TestSuite(SimpleTestCase.class));
  
      }
  
  
      /**
       * <p>Tear down instance variables required by this test case.</p>
       */
      public void tearDown() {
  
          super.tearDown();
  
      }
  
  
  
      // ------------------------------------------------- Individual Test Methods
  
  
      /**
       * <p>Verify the presence and contents of a base element.</p>
       */
      public void testBase() throws Exception {
  
          HtmlBase base = null;
          Iterator kids = head().getChildElements().iterator();
          while (kids.hasNext()) {
              HtmlElement kid = (HtmlElement) kids.next();
              if (kid instanceof HtmlBase) {
                  assertNull("Only one base element present", base);
                  base = (HtmlBase) kid;
              }
          }
          assertNotNull("Exactly one base element present", base);
          assertEquals("base", base.getTagName());
          assertEquals(url("/simple.jsp").toString(), base.getHrefAttribute());
          assertEquals("", base.getTargetAttribute());
  
      }
  
  
      /**
       * <p>Verify the presence and contents of an html element.</p>
       */
      public void testHtml() throws Exception {
  
          HtmlElement html = (HtmlElement) page;
          assertEquals("html", html.getTagName());
          assertEquals("http://www.w3.org/1999/xhtml";, 
html.getAttributeValue("xmlns"));
          // TODO: verify the "lang" attribute
          // TODO: verify the "xml:lang" attribute
  
      }
  
  
      /**
       * <p>Verify the presence and contents of a stylesheet element.</p>
       */
      public void testStylesheet() throws Exception {
  
          HtmlLink link = null;
          Iterator kids = head().getChildElements().iterator();
          while (kids.hasNext()) {
              HtmlElement kid = (HtmlElement) kids.next();
              if (kid instanceof HtmlLink) {
                  assertNull("Only one stylesheet element present", link);
                  link = (HtmlLink) kid;
              }
          }
          assertNotNull("Exactly one stylesheet element present", link);
          assertEquals("link", link.getTagName());
          assertEquals("", link.getCharsetAttribute());
          String url = this.url.toString();
          url = url.substring(0, url.length() - 1);
          url = url.substring(url.lastIndexOf('/'));
          assertEquals(url + "/stylesheet.css", link.getHrefAttribute());
          assertEquals("", link.getHrefLangAttribute());
          assertEquals("", link.getMediaAttribute());
          assertEquals("stylesheet", link.getRelAttribute());
          assertEquals("", link.getRevAttribute());
          assertEquals("", link.getTargetAttribute());
          assertEquals("text/css", link.getTypeAttribute());
          
      }
  
  
      /**
       * <p>Verify the title of the returned page.</p>
       */
      public void testTitle() throws Exception {
  
          assertEquals("simple", title());
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/contrib/struts-faces/web/systest/simple.jsp
  
  Index: simple.jsp
  ===================================================================
  <!--
  
   Copyright 2002,2004 The Apache Software Foundation.
  
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
  
        http://www.apache.org/licenses/LICENSE-2.0
  
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  
  -->
  
  <%@ page contentType="text/html;charset=UTF-8" %>
  <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"; %>
  <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"; %>
  <%@ taglib prefix="s" uri="http://jakarta.apache.org/struts/tags-faces"; %>
  
  <f:view>
    <s:html locale="true" xhtml="true">
      <head>
        <title>simple</title>
        <s:base/>
        <s:stylesheet path="/stylesheet.css"/>
      </head>
      <body>
        This is the body text
      </body>
    </s:html>
  </f:view>
  
  
  
  1.1                  
jakarta-struts/contrib/struts-faces/web/systest/WEB-INF/faces-config.xml
  
  Index: faces-config.xml
  ===================================================================
  <?xml version="1.0"?>
  
  
  <!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_0.dtd";>
  
  
  <!--
  
   Copyright 2002,2004 The Apache Software Foundation.
   
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
   
        http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  
  -->
  
  
  <faces-config>
  
  </faces-config>
  
  
  
  1.1                  
jakarta-struts/contrib/struts-faces/web/systest/WEB-INF/struts-config.xml
  
  Index: struts-config.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  
  <!DOCTYPE struts-config PUBLIC
            "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
            "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";>
  
  <!--
  
   Copyright 2002,2004 The Apache Software Foundation.
   
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
   
        http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  
  -->
  
  
  <!--
       This is the Struts configuration file for the example application,
       using the proposed new syntax.
  
       NOTE:  You would only flesh out the details in the "form-bean"
       declarations if you had a generator tool that used them to create
       the corresponding Java classes for you.  Otherwise, you would
       need only the "form-bean" element itself, with the corresponding
       "name" and "type" attributes.
  -->
  
  
  <struts-config>
  
  
  
    <!-- ========== Form Bean Definitions =================================== -->
    <form-beans>
  
      <!-- Logon form bean -->
  <!--
      <form-bean      name="logonForm"
                      type="org.apache.struts.validator.DynaValidatorForm">
        <form-property name="username" type="java.lang.String"/>
        <form-property name="password" type="java.lang.String"/>
      </form-bean>
  -->
  
      <!-- Registration form bean -->
  <!--
      <form-bean      name="registrationForm"
                      type="org.apache.struts.webapp.example.RegistrationForm"/>
  -->
  
      <!-- Subscription form bean -->
  <!--
      <form-bean      name="subscriptionForm"
                      type="org.apache.struts.webapp.example.SubscriptionForm"/>
  -->
  
    </form-beans>
  
  
    <!-- ========== Global Forward Definitions ============================== -->
    <global-forwards>
  <!--
      <forward   name="logoff"               path="/logoff.do"/>
      <forward   name="logon"                path="/logon.faces"/>
      <forward   name="registration"         path="/registration.faces"/>
      <forward   name="subscription"         path="/subscription.faces"/>
      <forward   name="success"              path="/mainMenu.faces"/>
  -->
    </global-forwards>
  
  
    <!-- ========== Action Mapping Definitions ============================== -->
    <action-mappings>
  
      <!-- Edit user registration -->
  <!--
      <action    path="/editRegistration"
                 type="org.apache.struts.webapp.example.EditRegistrationAction"
            attribute="registrationForm"
                scope="request"
             validate="false">
        <forward name="success"              path="/registration.faces"/>
      </action>
  -->
  
      <!-- Edit mail subscription -->
  <!--
      <action    path="/editSubscription"
                 type="org.apache.struts.webapp.example.EditSubscriptionAction"
            attribute="subscriptionForm"
                scope="request"
             validate="false">
        <forward name="failure"              path="/mainMenu.faces"/>
        <forward name="success"              path="/subscription.faces"/>
      </action>
  -->
  
      <!-- Process a user logoff -->
  <!--
      <action    path="/logoff"
                 type="org.apache.struts.webapp.example.LogoffAction">
        <forward name="success"              path="/index.faces"/>
      </action>
  -->
  
      <!-- Process a user logon -->
  <!--
      <action    path="/logon"
                 type="org.apache.struts.webapp.example.LogonAction"
                 name="logonForm"
                scope="request"
                input="logon">
        <exception
                  key="expired.password"
                 type="org.apache.struts.webapp.example.ExpiredPasswordException"
                 path="/changePassword.faces"/>
      </action>
  -->
  
      <!-- Save user registration -->
  <!--
      <action    path="/saveRegistration"
                 type="org.apache.struts.webapp.example.SaveRegistrationAction"
                 name="registrationForm"
                scope="request"
                input="registration"/>
  -->
  
      <!-- Save mail subscription -->
  <!--
      <action    path="/saveSubscription"
                 type="org.apache.struts.webapp.example.SaveSubscriptionAction"
                 name="subscriptionForm"
                scope="request"
                input="subscription">
        <forward name="success"         path="/editRegistration.do?action=Edit"/>
      </action>
  -->
  
  
      <!-- Display the "walking tour" documentation -->
  <!--
      <action    path="/tour"
              forward="/tour.htm">
      </action>
  -->
  
    </action-mappings>
  
  
    <!-- ========== Controller Configuration ================================ -->
  
    <controller>
      <!-- The "input" parameter on "action" elements is the name of a
           local or global "forward" rather than a subapp-relative path -->
      <set-property property="inputForward" value="true"/>
      <set-property property="processorClass"
              value="org.apache.struts.faces.application.FacesRequestProcessor"/>
    </controller>
  
  
    <!-- ========== Message Resources Definitions =========================== -->
  
  <!--
    <message-resources
      parameter="org.apache.struts.webapp.example.ApplicationResources"/>
  -->
  
  
    <!-- ========== Plug Ins Configuration ================================== -->
  
  <!--
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
      <set-property property="pathnames"
                       value="/WEB-INF/validator-rules.xml,
                              /WEB-INF/validation.xml"/>
    </plug-in>
  -->
  
  </struts-config>
  
  
  
  1.1                  jakarta-struts/contrib/struts-faces/web/systest/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd";>
  
  
  <!--
  
   Copyright 2002,2004 The Apache Software Foundation.
   
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
   
        http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  
  -->
  
  
  <web-app>
  
    <display-name>Struts-Faces System Integration Test Webapp</display-name>
  
    <context-param>
      <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
      <param-value>@state@</param-value>
    </context-param>
  
    <!-- JavaServer Faces Servlet Configuration -->
    <servlet>
      <servlet-name>faces</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
  
  
    <!-- Action Servlet Configuration -->
    <servlet>
      <servlet-name>action</servlet-name>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      <init-param>
        <param-name>config</param-name>
        <param-value>/WEB-INF/struts-config.xml</param-value>
      </init-param>
      <load-on-startup>2</load-on-startup>
    </servlet>
  
  
    <!-- JavaServer Faces Servlet Mapping -->
    <servlet-mapping>
      <servlet-name>faces</servlet-name>
      <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
  
  
    <!-- Action Servlet Mapping -->
    <servlet-mapping>
      <servlet-name>action</servlet-name>
      <url-pattern>*.do</url-pattern>
    </servlet-mapping>
  
  
    <!-- The Welcome File List -->
    <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
  
  </web-app>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to