You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by jr...@apache.org on 2003/04/25 17:06:11 UTC

cvs commit: jakarta-cactus/documentation/docs/xdocs/writing howto_initializer.xml

jruaux      2003/04/25 08:06:09

  Modified:    documentation/docs/xdocs navigation.xml sitemap.xml
  Added:       documentation/docs/xdocs/images jetty_eclipse.png
               documentation/docs/xdocs/integration integration_jetty.xml
               documentation/docs/xdocs/writing howto_initializer.xml
  Log:
  Added documentation for the initializer feature and JettyInitializer
  
  Revision  Changes    Path
  1.11      +2 -1      jakarta-cactus/documentation/docs/xdocs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/navigation.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- navigation.xml	28 Mar 2003 12:32:11 -0000	1.10
  +++ navigation.xml	25 Apr 2003 15:06:07 -0000	1.11
  @@ -43,7 +43,7 @@
       <item label="Runner Howto" id="howto_runner"/>
       <item label="Security Howto" id="howto_security"/>
   
  -
  +    <item label="Initializer Howto" id="howto_initializer"/>
       <item label="HttpUnit Howto" id="howto_httpunit"/>
       <item label="Sample Howto" id="howto_sample"/>
   
  @@ -61,6 +61,7 @@
     <menu label="Integration">
       <item label="Ant" id="integration_ant"/>
       <item label="Eclipse" id="integration_eclipse"/>
  +    <item label="Jetty" id="integration_jetty"/>
     </menu>
   
     <menu label="Support">
  
  
  
  1.30      +3 -0      jakarta-cactus/documentation/docs/xdocs/sitemap.xml
  
  Index: sitemap.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/sitemap.xml,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- sitemap.xml	24 Apr 2003 16:05:06 -0000	1.29
  +++ sitemap.xml	25 Apr 2003 15:06:07 -0000	1.30
  @@ -49,6 +49,7 @@
     <resource id="howto_config" target="integration/manual/howto_config.html"/>
     <resource id="howto_migration" target="howto_migration.html"/>
     <resource id="howto_testcase" target="writing/howto_testcase.html"/>
  +  <resource id="howto_initializer" target="writing/howto_initializer.html"/>
     <resource id="howto_testcase_servlet" target="writing/howto_testcase_servlet.html"/>
     <resource id="howto_testcase_jsp" target="writing/howto_testcase_jsp.html"/>
     <resource id="howto_testcase_filter" target="writing/howto_testcase_filter.html"/>
  @@ -70,6 +71,7 @@
     <resource id="howto_ide_vajava_tomcat" target="integration/manual/howto_ide_vajava_tomcat.html"/>
     <resource id="howto_ide_jbuilder4" target="integration/manual/howto_ide_jbuilder4.html"/>
     <resource id="howto_ide_jbuilder5" target="integration/manual/howto_ide_jbuilder5.html"/>
  +  <resource id="integration_jetty" target="integration/integration_jetty.html"/>  
     <resource id="howto_tomcat" target="integration/browser/howto_tomcat.html"/>
     <resource id="howto_junitee" target="integration/browser/howto_junitee.html"/>
     <resource id="mailinglist" target="mailinglist.html"/>
  @@ -140,6 +142,7 @@
     <external id="jakarta" url="http://jakarta.apache.org"/>
     <external id="jakarta_roles" url="http://jakarta.apache.org/site/roles.html"/>
     <external id="japanese" url="http://www.ingrid.org/jajakarta/cactus/"/>
  +  <external id="jetty" url="http://mortbay.org/jetty/"/>  
     <external id="jenerator" url="http://www.visioncodified.com/"/>
     <external id="junit" url="http://junit.org"/>
     <external id="junitee" url="http://www.junitee.org/"/>
  
  
  
  1.1                  jakarta-cactus/documentation/docs/xdocs/images/jetty_eclipse.png
  
  	<<Binary file>>
  
  
  1.1                  jakarta-cactus/documentation/docs/xdocs/integration/integration_jetty.xml
  
  Index: integration_jetty.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document id="integration_jetty">
  
    <properties>
      <title>Jetty Integration</title>
      <authors>
        <author name="Julien Ruaux" email="jruaux@octo.com"/>
      </authors>
    </properties>
  
    <body>
  
      <section title="Forewords and Requirements">
  
        <p>
          This page explains how to run Cactus tests with the Jetty servlet
          container. You will need the single <link href="ext:jetty">Jetty</link>
          jar, and if you are using JSPs you will also need the Jasper jars.
        </p>
  
      </section>
      
      <section title="Setting up Jetty">
  
        <p>
          The idea is to use the Jetty initializer provided by Cactus so that
          Jetty is run before the tests are run. Generally Cactus tests are
          launched by a JUnit runner, so we will describe here how to hook the
          initializer to it.
        </p>
        
        <p>
          There are only two things to do to set up Cactus for Jetty :
          <ul>
            <li>
              Add the Jetty and optionally Jasper jars to the classpath
            </li>
            <li>
              Set the appropriate system properties :
              <ul>
                <li>
                  <code>cactus.initializer</code> (required), value :
                  <code>org.apache.cactus.extension.jetty.JettyInitializer</code> 
                  : tells Cactus to use JettyInitializer as the initializer.
                </li>
                <li>
                  <code>cactus.jetty.config</code> (optional), value :
                  location of a jetty.xml file (see Jetty's documentation
                  for details)
                </li>
                <li>
                  <code>cactus.jetty.resourceDir</code> (optional), value :
                  location of a webapp directory (expanded war)
                </li>
              </ul>
            </li>
          </ul>
        </p>
  
  	    <section title="Case 1: running from Ant">
  	
  	      <p>
  	        Let's assume we have a JUnit task that launches the tests.
  	        All we have to do is add the correct VM arguments to tell Cactus
  	        to launch Jetty before the tests, and add the Jetty and optionally
  	        Jasper jars to the classpath. For example : <br/><br/>
  <source><![CDATA[
  <junit>
  
      [...]
      
      <jvmarg value="-Dcactus.contextURL=http://localhost:${test.port}/test"/>
      <jvmarg value="-Dcactus.jetty.resourceDir=${src.webapp.dir}"/>
      <jvmarg value="-Dcactus.initializer=org.apache.cactus.extension.jetty.JettyInitializer"/>
      <jvmarg value="-Dcactus.jetty.config=${src.webapp.dir}/test/jetty.xml"/>
  
      <classpath>
          [...]
          <!-- Include Jetty jar and optionally Jasper jars in the classpath -->
          <pathelement location="${jetty.jar}"/>
          <pathelement location="${jasperc.jar}"/>
          <pathelement location="${jasperr.jar}"/>    
      </classpath>
      
      <test name="org.apache.cactus.sample.TestAll"/>
  
  </junit>
  ]]></source>
  	      </p>
  	    
  	    </section>
  	    
  		  <section title="Case 2: running from an IDE">
  		
  		    <p>
  		      Again all you have to do is add the correct VM arguments, and the
  		      Jetty and Jasper jars, to the JUnit launch.
  		    </p>
  		    
  		    <p>
  		      For example in Eclipse you would add the jars, and create a JUnit
  		      launch configuration as below:
  		      <figure src="images/jetty_eclipse.png"
  		        alt="Eclipse configuration for Jetty"/>          
  		    </p>
  		
  		  </section>
  
      </section>
    </body>
  </document>
  
  
  
  1.1                  jakarta-cactus/documentation/docs/xdocs/writing/howto_initializer.xml
  
  Index: howto_initializer.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document id="howto_initializer">
  
    <properties>
      <title>Using the Cactus Initializer</title>
      <authors>
        <author name="Julien Ruaux" email="jruaux@octo.com"/>
      </authors>
    </properties>
  
    <body>
  
      <section title="What is it ?">
  
        <p>
          An initializer in Cactus consists in a class that will be run once on
          the client to initialize the system.
        </p>
  
      </section>
  
      <section title="Creating an initializer">
        
        <section title="Step 1: implement Initializable"> 
          <p>
            We first need an initializer class that implements the interface
            <code>Initializable</code>. For example:<br/><br/>
  <source><![CDATA[
  public class MyInitializer implements Initializable
  {
      public void initialize() throws Exception
      {
          // Here is where we initialize our class.
      }
  }
  ]]></source>          
          </p>
          
        </section>
  
        <section title="Step 2: add the system property"> 
          <p>
            Once we have an initializer class, we need to tell Cactus to use it.
            This is done via the <code>cactus.initializer</code> system property.
            For example using the previous class we would add the VM argument :
            <code>"-Dcactus.initializer=MyInitializer"</code>.
          </p>
        </section>
  
      </section>
      
      <section title="Use case">
  
        <p>
          For a hint on how and when to use this feature, take a look at the 
          <link href="site:integration_jetty">JettyInitializer</link>.
        </p>
  
      </section>
  
    </body>
  </document>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org