commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morg...@apache.org
Subject cvs commit: jakarta-commons/latka/src/webapps/latka-webapp build.xml
Date Thu, 17 Oct 2002 19:31:01 GMT
morgand     2002/10/17 12:31:01

  Modified:    latka/src/distribution/bin latka.bat
               latka/src/java/org/apache/commons/latka Latka.java
                        Suite.java
               latka/src/java/org/apache/commons/latka/servlet
                        ViewSuiteServlet.java
               latka/src/resources latka.properties.internal
               latka/src/test/org/apache/commons/latka/junit
                        TestJUnitTestAdapter.java
               latka/src/webapps/latka-webapp build.xml
  Added:       latka/src/test/org/apache/commons/latka/jelly TestLatka.java
                        TestSuiteTag.java suiteTag.jelly testLatka.jelly
  Removed:     latka/src/java/org/apache/commons/latka/util URLParser.java
               latka/src/java/org/apache/commons/latka/util/xml
                        BasicDelegateHandler.java DelegateHandler.java
                        DelegateHandlerImpl.java
               latka/src/java/org/apache/commons/latka/validators
                        ByteLengthHandler.java CookieHandler.java
                        GoldenFileHandler.java MaxRequestTimeHandler.java
                        RegexpHandler.java ResponseHeaderHandler.java
                        StatusCodeHandler.java StatusTextHandler.java
                        XPathHandler.java
               latka/src/java/org/apache/commons/latka/xml
                        FindVariablesHandler.java LatkaHandler.java
                        LatkaVariableEntityResolver.java
                        ParameterHandler.java RequestBodyHandler.java
                        RequestHandler.java RequestHeaderHandler.java
                        SessionHandler.java SuiteHandler.java
                        ValidationHandler.java
                        ValidationReflectionHandler.java
                        XMLPreprocessor.java
               latka/src/test/org/apache/commons/latka TestAll.java
  Log:
  moved out old XML parsing classes, converted Latka class to a
  Jelly backend
  
  Revision  Changes    Path
  1.2       +2 -1      jakarta-commons/latka/src/distribution/bin/latka.bat
  
  Index: latka.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/distribution/bin/latka.bat,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- latka.bat	22 Apr 2002 15:48:27 -0000	1.1
  +++ latka.bat	17 Oct 2002 19:30:58 -0000	1.2
  @@ -2,6 +2,7 @@
   
   rem pass in the path to the XML file for the Latka suite
   rem optionally override the default host and default port
  -java -classpath .;..\lib\jaxp.jar;..\lib\sax2.jar;..\lib\crimson.jar;..\lib\log4j.jar;..\lib\commons-httpclient.jar;..\lib\jakarta-latka.jar;..\lib\jakarta-regexp.jar;..\lib\jdom.jar;..\lib\xalan2.jar;..\lib\jsse.jar;..\lib\jnet.jar;..\lib\jcert.jar;..\lib
-Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol org.apache.commons.latka.Latka
%1 %2 %3 %4 %5 %6 %7 %8 %9
  +set LIB="..\lib"
  +java -classpath .;%LIB%\jaxp.jar;%LIB%\sax2.jar;%LIB%\crimson.jar;%LIB%\log4j.jar;%LIB%\commons-httpclient.jar;%LIB%\jakarta-latka.jar;%LIB%\jakarta-regexp.jar;%LIB%\jdom.jar;%LIB%\xalan2.jar;%LIB%\jsse.jar;%LIB%\jnet.jar;%LIB%\jcert.jar;%LIB%
-Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol org.apache.commons.latka.Latka
%1 %2 %3 %4 %5 %6 %7 %8 %9
   
   @echo on
  
  
  
  1.39      +46 -53    jakarta-commons/latka/src/java/org/apache/commons/latka/Latka.java
  
  Index: Latka.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/Latka.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Latka.java	11 Oct 2002 18:38:10 -0000	1.38
  +++ Latka.java	17 Oct 2002 19:30:58 -0000	1.39
  @@ -67,17 +67,12 @@
   import java.io.IOException;
   import java.io.StringReader;
   import java.io.StringWriter;
  -
   import java.net.URL;
  -
   import java.text.SimpleDateFormat;
  -
   import java.util.Date;
  +import java.util.Iterator;
   import java.util.Properties;
   
  -import javax.xml.parsers.ParserConfigurationException;
  -import javax.xml.parsers.SAXParserFactory;
  -import javax.xml.parsers.SAXParser;
   import javax.xml.transform.Source;
   import javax.xml.transform.Transformer;
   import javax.xml.transform.TransformerException;
  @@ -85,17 +80,16 @@
   import javax.xml.transform.stream.StreamResult;
   import javax.xml.transform.stream.StreamSource;
   
  +import org.apache.commons.jelly.Jelly;
  +import org.apache.commons.jelly.JellyContext;
  +import org.apache.commons.jelly.XMLOutput;
  +
   import org.apache.commons.latka.event.LatkaEventInfo;
  -import org.apache.commons.latka.xml.LatkaVariableEntityResolver;
  -import org.apache.commons.latka.xml.SuiteHandler;
  -import org.apache.commons.latka.xml.XMLPreprocessor;
  +import org.apache.commons.latka.event.LatkaEventListener;
  +import org.apache.commons.latka.jelly.JellyUtils;
   
   import org.apache.log4j.Category;
   
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.XMLReader;
  -
   /**
    * This is the primary class for executing Latka functional
    * tests.  The main(String aargs[]) class provides a convenient
  @@ -140,56 +134,53 @@
        * The Latka packages contain an implmentation of LatkaEventInfo
        * which can generate an XML report according to a standard
        * DTD (see documentation).
  -     *
  -     * @param suite test suite to execute
  +     * 
  +     * @param suite    test suite to execute
        * @param listener target for test events
  -     * @throws LatkaException when any internal error occurs
  -     *
  -     * @see XMLReporter XML-based implementation of LatkaEventInfo
  +     * @exception LatkaException
  +     *                   when any internal error occurs
  +     * @see XMLReporter XML-based implementation of LatkaEventListener
        */
  -    public void runTests(Suite suite, LatkaEventInfo listener)
  +    public void runTests(Suite suite, LatkaEventListener listener)
                   throws LatkaException {
       
  -        InputSource source = null;
  -
           try {
   
  -            XMLPreprocessor preprocessor = XMLPreprocessor.instance();
  -
  -            preprocessor.preprocessXml(suite);
  -
  -            source = new InputSource(suite.getReader());
  -            if (suite.getURL() != null) {
  -                source.setSystemId(suite.getURL().toString());
  -            }
  -
  -            SAXParserFactory factory = SAXParserFactory.newInstance();
  -            factory.setNamespaceAware(true);
  +            Jelly jelly = new Jelly();
  +            URL url = suite.getURL();
  +            jelly.setUrl(url);
  +            jelly.setValidateXML(_isValidating);
  +            jelly.setDefaultNamespaceURI("jelly:org.apache.commons.latka.jelly.LatkaTagLibrary");
  +
  +            JellyContext context = buildJellyContext();
  +            JellyUtils.getInstance().setLatkaEventListener(context,listener);
  +
  +            String exturl = url.toExternalForm();
  +            int lastSlash = exturl.lastIndexOf("/");
  +            String extBase = exturl.substring(0,lastSlash+1);
  +            URL baseurl = new URL(extBase);
  +            context.setCurrentURL(baseurl);
   
  -            // always force validation of the tests
  -            factory.setValidating(_isValidating);   
  +            // add listener
  +            jelly.compileScript().run(context,XMLOutput.createDummyXMLOutput());
   
  -            SAXParser parser = factory.newSAXParser();
  -
  -            XMLReader reader = parser.getXMLReader();
  -
  -            SuiteHandler handler = new SuiteHandler(reader, listener);
  -
  -            reader.setContentHandler(handler);
  -            reader.setErrorHandler(handler);
  -            reader.setEntityResolver(new LatkaVariableEntityResolver());
  -
  -            reader.parse(source);
  -
  -        } catch (ParserConfigurationException e) {
  -            throw new LatkaException(e);
  -        } catch (SAXException e) {
  -            throw new LatkaException(e);
  -        } catch (IOException e) {
  +        } catch (Exception e) {
               throw new LatkaException(e);
           }
       }
   
  +    protected JellyContext buildJellyContext() {
  +        JellyContext context = new JellyContext();
  +        Iterator keys = _props.keySet().iterator();
  +        while (keys.hasNext()) {
  +            String key = (String) keys.next();
  +            String value = _props.getProperty(key);
  +            context.setVariable(key,value);
  +        }
  +
  +        return context;
  +    }
  +
       /**
        * Set whether or not Latka will validate the XML in
        * each test.
  @@ -319,7 +310,9 @@
   
           String xml = null;
           XMLReporter listener = new XMLReporter();
  -        LatkaEventInfo info = new DefaultLatkaEventInfo(listener);
  +
  +        // overkill, all we need is success/failure
  +        LatkaEventInfo info = new DefaultLatkaEventInfo(listener); 
   
           try {
   
  
  
  
  1.10      +0 -32     jakarta-commons/latka/src/java/org/apache/commons/latka/Suite.java
  
  Index: Suite.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/Suite.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Suite.java	11 Apr 2002 13:54:02 -0000	1.9
  +++ Suite.java	17 Oct 2002 19:30:58 -0000	1.10
  @@ -61,7 +61,6 @@
   
   package org.apache.commons.latka;
   
  -import java.io.Reader;
   import java.net.URL;
   
   /**
  @@ -74,22 +73,10 @@
    */
   public class Suite {
   
  -    /** reader stream containing a Latka XML suite */
  -    protected Reader _reader = null;
       /** test suite URL */
       protected URL _url = null;
   
       /**
  -     * Create a test suite from an XML document located in the
  -     * designated Stream.
  -     *
  -     * @param reader stream containing a Latka XML suite
  -     */
  -    public Suite(Reader reader) {
  -        _reader = reader;
  -    }
  -
  -    /**
        * Create a test suite from an XML document located at the
        * designated URL.
        *
  @@ -118,25 +105,6 @@
        */
       public void setURL(URL url) {
           _url = url;
  -    }
  -
  -    /**
  -     * The reader containing the Latka XML suite
  -     * 
  -     * @return source of the Latka suite
  -     */
  -    public Reader getReader() {
  -        return _reader;
  -    }
  -
  -    /**
  -     * Sets a Reader for the XML.  See {@link #setURL(URL)}
  -     * method for a description of using URLs and Readers in 
  -     * conjunction.
  -     * @param reader the reader to be set
  -     */
  -    public void setReader(Reader reader) {
  -        _reader = reader;
       }
   
   }
  
  
  
  1.4       +5 -9      jakarta-commons/latka/src/java/org/apache/commons/latka/servlet/ViewSuiteServlet.java
  
  Index: ViewSuiteServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/servlet/ViewSuiteServlet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ViewSuiteServlet.java	4 Jul 2002 14:06:33 -0000	1.3
  +++ ViewSuiteServlet.java	17 Oct 2002 19:30:59 -0000	1.4
  @@ -71,7 +71,6 @@
   import javax.servlet.http.HttpServletResponse;
   
   import org.apache.commons.latka.Suite;
  -import org.apache.commons.latka.xml.XMLPreprocessor;
   
   /**
    * A servlet to view the Latka Suite
  @@ -109,10 +108,7 @@
           Suite suite = new Suite(new URL(suiteUrl));
   
           PrintWriter writer = res.getWriter();
  -        // do an identity transform to resolve any external entities
  -        XMLPreprocessor processor = XMLPreprocessor.instance();
  -        String xml = processor.identityTransform(suite);
  -        writer.print(xml);
  +        writer.print("not yet implemented");
     }
   
   }
  
  
  
  1.2       +1 -0      jakarta-commons/latka/src/resources/latka.properties.internal
  
  Index: latka.properties.internal
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/resources/latka.properties.internal,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- latka.properties.internal	22 Apr 2002 15:49:41 -0000	1.1
  +++ latka.properties.internal	17 Oct 2002 19:31:00 -0000	1.2
  @@ -1,6 +1,7 @@
   latka.validator.byteLength=org.apache.commons.latka.validators.ByteLengthHandler
   latka.validator.regexp=org.apache.commons.latka.validators.RegexpHandler
   latka.validator.statusCode=org.apache.commons.latka.validators.StatusCodeHandler
  +latka.validator.statusText=org.apache.commons.latka.validators.StatusTextHandler
   latka.validator.maxRequestTime=org.apache.commons.latka.validators.MaxRequestTimeHandler
   latka.validator.cookie=org.apache.commons.latka.validators.CookieHandler
   latka.validator.responseHeader=org.apache.commons.latka.validators.ResponseHeaderHandler
  
  
  
  1.1                  jakarta-commons/latka/src/test/org/apache/commons/latka/jelly/TestLatka.java
  
  Index: TestLatka.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/test/org/apache/commons/latka/jelly/TestLatka.java,v
1.1 2002/10/17 19:31:00 morgand Exp $
   * $Revision: 1.1 $
   * $Date: 2002/10/17 19:31:00 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: TestLatka.java,v 1.1 2002/10/17 19:31:00 morgand Exp $
   */
  package org.apache.commons.latka.jelly;
  
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.jelly.tags.junit.JellyTestSuite;
  
  /** 
   * A helper class to run jelly test cases as part of Ant's JUnit tests
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class TestLatka extends JellyTestSuite {
  
      public static void main( String[] args ) throws Exception {
          TestRunner.run( suite() );
      }
      
      public static TestSuite suite() throws Exception {
          return createTestSuite(TestLatka.class, "testLatka.jelly");
      }
  }
  
  
  
  1.6       +20 -48    jakarta-commons/latka/src/test/org/apache/commons/latka/jelly/TestSuiteTag.java
  
  
  
  
  1.1                  jakarta-commons/latka/src/test/org/apache/commons/latka/jelly/suiteTag.jelly
  
  Index: suiteTag.jelly
  ===================================================================
  <?xml version="1.0"?>
  <test:suite xmlns:j="jelly:core" xmlns:test="jelly:junit" 
    xmlns="jelly:org.apache.commons.latka.jelly.LatkaTagLibrary">
  
    <test:case name="testSuiteListener">
       
      <j:new className="org.apache.commons.latka.XMLReporter" 
        var="latkaEventListener"/>
      
      <suite>
        <test:assert test="${latkaEventListener != null}">
          Suite should contain the event listener.
        </test:assert>
      </suite>
          
    </test:case>
    
  
    <test:case name="testSuiteSettingsAllNull">
       
      <j:new className="org.apache.commons.latka.XMLReporter" 
        var="latkaEventListener"/>
      <suite>
        <test:assert test="${latkaSuiteSettings != null}">
          Suite should contain the suite settings.
        </test:assert>
        <test:assert test="${latkaSuiteSettings.defaultHost != null}">
          expected null host, got ${latkaSuiteSetttings}"
        </test:assert>       
        <test:assert test="${latkaSuiteSettings.defaultPort == 1}">
          expected port -1, got ${latkaSuiteSetttings.getDefaultPort()}
        </test:assert>       
      
      </suite>
      <test:assert test="${latkaSuiteSettings == null}">
        Suite should remove the suite settings after the end tag.
      </test:assert>
      
    </test:case>
  
  </test:suite>
  
  
  
  1.1                  jakarta-commons/latka/src/test/org/apache/commons/latka/jelly/testLatka.jelly
  
  Index: testLatka.jelly
  ===================================================================
  <?xml version="1.0"?>
  <test:suite xmlns:j="jelly:core" xmlns:test="jelly:junit" 
    xmlns="jelly:org.apache.commons.latka.jelly.LatkaTagLibrary">
  
    <test:case name="testExampleDotOrg">
       
      <suite defaultHost="example.org" defaultPort="80">
  
  <session>      
  
  <reportMessage message="boo1"/>
  
        <request path="/" host="example.net">
          <validate>
            <!-- <regexp pattern="These domain names are reserveded"/> -->
            <regexp pattern="These domain names are reserved"/>
          </validate>
        </request>
  
  
  <reportMessage message="boo2"/>
  
        <request path="/">
          <validate>
            <!-- <regexp pattern="These domain names are reserved"/> -->
            <regexp pattern="These domain names are reserved"/>
            <statusCode/>
          </validate>
        </request>
        
  
  </session>
  
  
  <reportMessage message="boo3"/>
        
        <request path="/" host="example.net">
          <validate>
            <!-- <regexp pattern="These domain names are reserved"/> -->
            <regexp pattern="These domain names are reserved"/>
          </validate>
        </request>
  
  
      </suite>        
      
    </test:case>
  
  </test:suite>
  
  
  
  1.8       +2 -2      jakarta-commons/latka/src/test/org/apache/commons/latka/junit/TestJUnitTestAdapter.java
  
  Index: TestJUnitTestAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/test/org/apache/commons/latka/junit/TestJUnitTestAdapter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestJUnitTestAdapter.java	5 Jul 2002 02:12:23 -0000	1.7
  +++ TestJUnitTestAdapter.java	17 Oct 2002 19:31:00 -0000	1.8
  @@ -109,7 +109,7 @@
          assertNotNull("The system property file.separator was not defined.", fs);
          _xmlFileName = baseDir + fs + _xmlFileName;
         _xmlFile = new File(_xmlFileName);
  -      _suite = new Suite(new FileReader(_xmlFile));
  +      _suite = new Suite(_xmlFile.toURL());
         _adapter = new JUnitTestAdapter(_suite, 9);
      }
   
  
  
  
  1.2       +2 -2      jakarta-commons/latka/src/webapps/latka-webapp/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/webapps/latka-webapp/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	22 Apr 2002 15:51:43 -0000	1.1
  +++ build.xml	17 Oct 2002 19:31:01 -0000	1.2
  @@ -20,7 +20,7 @@
         <property file="${latka-propfile}"/>
   
         <!-- read properties from the commons build.properties, if any -->
  -      <property name="commons-propfile" value="${basedir}/../../build.properties"/>
  +      <property name="commons-propfile" value="${basedir}/../../../build.properties"/>
         <property file="${commons-propfile}"/>
   
         <!-- read properties from the ${user.home}/propfile, if any -->
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message