You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2004/02/13 15:26:58 UTC

cvs commit: jakarta-turbine-fulcrum/xslt/src/test/org/apache/fulcrum/xslt XSLTServiceFacadeTest.java XSLTServiceTest.java

epugh       2004/02/13 06:26:58

  Added:       xslt/src/java/org/apache/fulcrum/xslt XSLTServiceFacade.java
                        DefaultXSLTService.java XSLTService.java
               xslt/src/test TestComponentConfig.xml TestRoleConfig.xml
               xslt/xdocs index.xml changes.xml navigation.xml
               xslt     LICENSE.txt project.properties .cvsignore
                        project.xml
               xslt/src/test/org/apache/fulcrum/xslt
                        XSLTServiceFacadeTest.java XSLTServiceTest.java
  Log:
  Conversion to Avalon Component
  
  Revision  Changes    Path
  1.1                  jakarta-turbine-fulcrum/xslt/src/java/org/apache/fulcrum/xslt/XSLTServiceFacade.java
  
  Index: XSLTServiceFacade.java
  ===================================================================
  package org.apache.fulcrum.xslt;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" 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",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  
  import java.io.Reader;
  import java.io.Writer;
  import org.w3c.dom.Node;
  
  /**
   * This is a static accesor class for {@link XSLTService}.
   *
   * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
   */
  public class XSLTServiceFacade
  {
      private static XSLTService xsltService;
      /**
       * Utility method for accessing the service
       * implementation
       *
       * @return a XSLTService implementation instance
       */
      protected static XSLTService getService()
      {
          return xsltService;
      }
      
      protected static void setService(XSLTService xsltService){
          XSLTServiceFacade.xsltService=xsltService;
      }
  
      public static void transform (String xslName, Reader in, Writer out)
          throws Exception
      {
          getService().transform (xslName,in,out);
      }
  
      public static String transform (String xslName, Reader in)
          throws Exception
      {
          return getService().transform (xslName,in);
      }
  
      public void transform (String xslName, Node in, Writer out)
          throws Exception
      {
          getService().transform (xslName,in,out);
      }
  
  
      public String transform (String xslName, Node in)
          throws Exception
      {
          return getService().transform (xslName,in);
      }
  }
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/src/java/org/apache/fulcrum/xslt/DefaultXSLTService.java
  
  Index: DefaultXSLTService.java
  ===================================================================
  package org.apache.fulcrum.xslt;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" 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",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  
  import java.io.File;
  import java.io.Reader;
  import java.io.StringWriter;
  import java.io.Writer;
  import java.util.Hashtable;
  
  
  import javax.xml.transform.Result;
  import javax.xml.transform.Source;
  import javax.xml.transform.Templates;
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.dom.DOMSource;
  import javax.xml.transform.stream.StreamResult;
  import javax.xml.transform.stream.StreamSource;
  
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.Serviceable;
  
  /**
   * Implementation of the Turbine XSLT Service. It transforms xml with a given
   * xsl file.  XSL stylesheets are compiled and cached (if the service property
   * is set) to improve speeds.
   *
   * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
   * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
   * @author <a href="mailto:epugh@opensourceconnections.com">Eric Pugh</a>
   */
  public class DefaultXSLTService
      extends AbstractLogEnabled
      implements XSLTService,Initializable,Configurable,Contextualizable,Serviceable
  
  {
      /**
       * The application root
       */
      private String applicationRoot;
      
      /**
       * Property to control the caching of Templates.
       */
      protected boolean caching = false;
  
      /**
       * Path to style sheets used for tranforming well-formed
       * XML documents. The path is relative to the webapp context.
       */
      protected  String path;
  
      /**
       * What the configured value was
       */
      private  String styleSheetPath;    
      
      /**
       * Cache of compiled Templates.
       */
      protected Hashtable cache = new Hashtable();
  
      protected final static String STYLESHEET_PATH = "path";
  
      protected final static String STYLESHEET_CACHING = "cache";
  
      /**
       * Factory for producing templates and null transformers
       */
      private static TransformerFactory tfactory;
  
  
  
      /**
       * Get a valid and existing filename from a template name.
       * The extension is removed and replaced with .xsl.  If this
       * file does not exist the method attempts to find default.xsl.
       * If it fails to find default.xsl it returns null.
       */
      protected String getFileName (String templateName)
      {
          // First we chop of the existing extension
          int colon = templateName.lastIndexOf (".");
          if (colon > 0)
          {
              templateName = templateName.substring (0,colon);
          }
  
          // Now we try to find the file ...
          File f = new File (path+templateName+".xsl");
          if (f.exists())
          {
              return path+templateName+".xsl";
          }
          else
          {
              // ... or the default file
              f = new File (path+"default.xsl");
              if (f.exists())
              {
                  return path+"default.xsl";
              }
              else
              {
                  return null;
              }
          }
      }
  
      /**
       * Compile Templates from an input file.
       */
      protected Templates compileTemplates (String source) throws Exception
      {
          StreamSource xslin = new StreamSource(new File(source));
          Templates root = tfactory.newTemplates(xslin);
          return root;
      }
  
      /**
       * Retrieves Templates.  If caching is switched on the
       * first attempt is to load Templates from the cache.
       * If caching is switched of or if the Stylesheet is not found
       * in the cache new Templates are compiled from an input
       * file.
       * <p>
       * This method is synchronized on the xsl cache so that a thread
       * does not attempt to load Templates from the cache while
       * it is still being compiled.
       */
      protected Templates getTemplates(String xslName) throws Exception
      {
          synchronized (cache)
          {
              String fn = getFileName (xslName);
              if (fn == null) return null;
  
              if (caching && cache.containsKey (fn))
              {
                  return (Templates)cache.get(fn);
              }
  
              Templates sr = compileTemplates (fn);
  
              if (caching)
              {
                  cache.put (fn,sr);
              }
  
              return sr;
          }
  
      }
  
      protected void transform (String xslName, Source xmlin, Result xmlout)
          throws Exception
      {
          Transformer transformer = getTransformer( xslName );
  
          transformer.transform(xmlin, xmlout);
      }
  
      /**
       * Execute an xslt
       */
      public void transform (String xslName, Reader in, Writer out)
          throws Exception
      {
          Source xmlin = new StreamSource(in);
          Result xmlout = new StreamResult(out);
          transform (xslName,xmlin,xmlout);
      }
  
      /**
       * Execute an xslt
       */
      public String transform (String xslName, Reader in)
          throws Exception
      {
          StringWriter sw = new StringWriter();
          transform (xslName,in,sw);
          return sw.toString();
      }
  
  
      /**
       * Execute an xslt
       */
      public void transform (String xslName, org.w3c.dom.Node in, Writer out)
          throws Exception
      {
          Source xmlin = new DOMSource(in);
          Result xmlout = new StreamResult(out);
          transform (xslName,xmlin,xmlout);
      }
  
      /**
       * Execute an xslt
       */
      public String transform (String xslName, org.w3c.dom.Node in)
          throws Exception
      {
          StringWriter sw = new StringWriter();
          transform (xslName,in,sw);
          return sw.toString();
      }
  
      /**
       * Retrieve a transformer for the given stylesheet name. If no stylesheet
       * is available for the provided name, an identity transformer will be
       * returned. This allows clients of this service to perform more complex
       * transformations (for example, where parameters must be set). When
       * possible prefer using one of the forms of {@link #transform}.
       *
       * @param xslName Identifies stylesheet to get transformer for
       * @return A transformer for that stylesheet
       */
      public Transformer getTransformer(String xslName) throws Exception
      {
          Templates sr = getTemplates(xslName);
  
          if (sr == null)
          {
              return tfactory.newTransformer();
          }
          else
          {
              return sr.newTransformer();
          }
      }
      
      /**
       * @see org.apache.fulcrum.ServiceBroker#getRealPath(String)
       */
      public String getRealPath(String path)
      {
          String absolutePath = null;
          if (applicationRoot == null) 
          {
              absolutePath = new File(path).getAbsolutePath();
          }
          else 
          {
              absolutePath = new File(applicationRoot, path).getAbsolutePath();
          }
          
          return absolutePath;
      }        
      // ---------------- Avalon Lifecycle Methods ---------------------
      /**
       * Avalon component lifecycle method
       */
      public void configure(Configuration conf)  throws ConfigurationException
      {
          styleSheetPath =conf.getAttribute(STYLESHEET_PATH);       
          caching = conf.getAttributeAsBoolean(STYLESHEET_CACHING);
  
      }
      
      /**
       * Initializes the service.
       *
       * This method processes the repository path, to make it relative to the
       * web application root, if neccessary
       */
      public void initialize() throws Exception
      {
          path = getRealPath(styleSheetPath);
          if (!path.endsWith("/") && !path.endsWith ("\\"))
          {
              path=path+File.separator;
          }
          
          tfactory = TransformerFactory.newInstance();
      }    
      
      public void contextualize(Context context) throws ContextException {
          this.applicationRoot = context.get( "urn:avalon:home" ).toString();
      }  
      
      /**
       * Avalon component lifecycle method
       */
      public void service( ServiceManager manager) {        
          
          XSLTServiceFacade.setService(this);
          
      }    
      /**
       * Avalon component lifecycle method
       */
      public void dispose()
      {
          
      }       
  
  }
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/src/java/org/apache/fulcrum/xslt/XSLTService.java
  
  Index: XSLTService.java
  ===================================================================
  package org.apache.fulcrum.xslt;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" 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",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  
  import java.io.Reader;
  import java.io.Writer;
  import org.w3c.dom.Node;
  
  /**
   * The Turbine XSLT Service is used to transform xml with a xsl stylesheet.
   * The service makes use of the Xalan xslt engine available from apache.
   *
   *
   * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
   */
  public interface XSLTService
  {
      public static final String ROLE = XSLTService.class.getName();
  
      /**
       * Uses an xsl file to transform xml input from a reader and writes the
       * output to a writer.
       *
       * @param xslName The name of the file that contains the xsl stylesheet.
       * @param in The reader that passes the xml to be transformed
       * @param out The writer for the transformed output
       */
      public void transform (String xslName, Reader in, Writer out) throws Exception;
  
      /**
       * Uses an xsl file to transform xml input from a reader and returns a
       * string containing the transformed output.
       *
       * @param xslName The name of the file that contains the xsl stylesheet.
       * @param in The reader that passes the xml to be transformed
       */
      public String transform (String xslName, Reader in) throws Exception;
  
      /**
       * Uses an xsl file to transform xml input from a DOM note and writes the
       * output to a writer.
       *
       * @param xslName The name of the file that contains the xsl stylesheet.
       * @param in The DOM Node to be transformed
       * @param out The writer for the transformed output
       */
      public void transform (String xslName, Node in, Writer out) throws Exception;
  
      /**
       * Uses an xsl file to transform xml input from a DOM note and returns a
       * string containing the transformed output.
       *
       * @param xslName The name of the file that contains the xsl stylesheet.
       * @param out The writer for the transformed output
       */
      public String transform (String xslName, Node in) throws Exception;
  }
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/src/test/TestComponentConfig.xml
  
  Index: TestComponentConfig.xml
  ===================================================================
  <componentConfig>
      <xslt path="target" cache="true"/>
  </componentConfig>
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/src/test/TestRoleConfig.xml
  
  Index: TestRoleConfig.xml
  ===================================================================
  <!-- This configuration file for Avalon components is used for testing the TestComponent -->
  <role-list>
      <role
          name="org.apache.fulcrum.xslt.XSLTService"
          shorthand="xslt"
          default-class="org.apache.fulcrum.xslt.DefaultXSLTService"/>
  </role-list>
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
  
    <properties>
      <title>XSLT Component</title>
      <author email="epugh@opensourceconnections.com">Eric Pugh</author>
    </properties>
  
    <body>
  
    <section name="Overview">
      <p>
       This Service functions as a XSLT component.
     </p>
        
      <p>
        It is written 
        for use in Turbine but it can be used in any container compatible 
        with Avalon's ECM container.
      </p>    
    </section>
    
  <section name="Configuration">
  
      <p>
        First, here is the role configuration.
      </p>
  
      <source>
      <![CDATA[
          <role
              name="org.apache.fulcrum.bsf.BSFService"
              shorthand="cache"
              default-class="org.apache.fulcrum.bsf.DefaultBSFService"/>
      ]]>
      </source>
  
        <p>
          And here is the configuration:
        </p>
      <source>
  
      <![CDATA[
          <cache cacheInitialSize="20" cacheCheckFrequency="5"/>
      ]]>
      </source>
  
    </section>
  
    <section name="Usage">
  
      <source><![CDATA[
  
      GlobalCacheService gs = null;
      try
      {
          /*
           * Look for the item in the cache.
           * If it doesn't exist or the item is stale,
           * the cache will throw an exception.
           */
          gs = (GlobalCacheService)avalonComponentService.lookup(GlobalCacheService.ROLE)
  
          CachedObject obj = gs.getObject("cached_object");
  
          data.setMessage( data.getScreen() + " Got " +
              obj.getContents().toString() + " from global cache!" );
      }
      catch(ObjectExpiredException gone)
      {
          /*
           * Add the item to the cache.
           */
          gs.addObject("cached_object",
              new CachedObject("in_the_cache",5000));
  
          data.setMessage( data.getScreen() +
              " Refreshed/or added new item to" +
              " the cache! Expires in 5 seconds" );
      }
  
      ]]></source>
  
      <p>
      You can also place an expiration time on your objects so the Service will
      automatically remove them when they expire. If you don't specify an expiration
      time, the Service uses 5 seconds. To see an example, look at the 
      test case <a href="xref-test/org/apache/fulcrum/cache/CacheTest.html">CacheTest</a>
      </p>
  
    </section> 
  
  </body>
  </document>
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  <?xml version="1.0"?>
  <document>
    <properties>
      <title>Fulcrum BSF</title>
      <author email="epugh@opensourceconnections.com">Eric Pugh</author>
    </properties>
  
    <body>
      <release version="1.0-alpha-2" date="in CVS">
       <action dev="epugh" type="add">
          Initial conversion to Avalon component.
        </action>      
      </release>
  
    </body>
  </document>
  
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/xdocs/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <project
    name="cache"
    href="http://jakarta.apache.org/turbine/fulcrum/cache/">
  
    <body>
      <links>
        <item name="Turbine"
              href="http://jakarta.apache.org/turbine/"/>
        <item name="Fulcrum"
              href="http://jakarta.apache.org/turbine/fulcrum/"/>
      </links>
  
      <menu name="Overview">
        <item name="Main"                 href="/index.html"/>
      </menu>
    </body>
  </project>
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/LICENSE.txt
  
  Index: LICENSE.txt
  ===================================================================
  /* ----------------------------------------------------------------------------
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-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", "Plexus", 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/>.
   *
   * ----------------------------------------------------------------------------
   */
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/project.properties
  
  Index: project.properties
  ===================================================================
  
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  target
  .classpath
  .project
  *.ser
  *.log
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0"?>
  <project>
    <extend>${basedir}/../project.xml</extend>
    <id>fulcrum-xslt</id>
    <name>Fulcrum XSLT Component</name>
    <currentVersion>1.0-alpha-1</currentVersion>
  
    <dependencies>
      <dependency>
        <id>xalan</id>
        <version>2.5.1</version>
        <url>http://xml.apache.org/xalan-j/</url>
      </dependency>    
      
      <!--  Needed only for testing -->
      <dependency>
        <groupId>fulcrum</groupId>
        <artifactId>fulcrum-testcontainer</artifactId>
        <version>1.0-alpha-3</version>
      </dependency>
  
      <dependency>
        <id>xerces:xercesImpl</id>
        <version>2.0.2</version>
        <url>http://xml.apache.org/xerces2-j/</url>
      </dependency>
  
      <dependency>
        <id>xerces:xmlParserAPIs</id>
        <version>2.0.2</version>
        <url>http://xml.apache.org/xerces2-j/</url>
      </dependency>
  
    </dependencies>
  
  
  </project>
  
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/src/test/org/apache/fulcrum/xslt/XSLTServiceFacadeTest.java
  
  Index: XSLTServiceFacadeTest.java
  ===================================================================
  package org.apache.fulcrum.xslt;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" 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" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  
  import org.apache.fulcrum.testcontainer.BaseUnitTest;
  
  
  /**
   * Test the XSLTServiceFacade.  
   *
   * @author <a href="epugh@upstate.com">Eric Pugh</a>
   * @version $Id: XSLTServiceFacadeTest.java,v 1.1 2004/02/13 14:26:58 epugh Exp $
   */
  public class XSLTServiceFacadeTest extends BaseUnitTest
  {
      /**
       * Defines the testcase name for JUnit.
       *
       * @param name the testcase's name.
       */
      public XSLTServiceFacadeTest(String name)
      {
          super(name);
      }
    
  
      public void testWorkflowFacadeNotConfigured() throws Exception
      {
          try
          {
              XSLTServiceFacade.getService();
          }
          catch (RuntimeException re)
          {
              //good;
          }
      }
  
      public void testWorkflowFacadeConfigured() throws Exception
      {
      	// this.lookup causes the workflow service to be configured.
  		this.lookup(XSLTService.ROLE);
  		XSLTServiceFacade.getService();    
      }
  
  }
  
  
  
  1.1                  jakarta-turbine-fulcrum/xslt/src/test/org/apache/fulcrum/xslt/XSLTServiceTest.java
  
  Index: XSLTServiceTest.java
  ===================================================================
  package org.apache.fulcrum.xslt;
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" 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" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.fulcrum.testcontainer.BaseUnitTest;
  /**
   * XSLTServiceTest
   *
   * @author <a href="paulsp@apache.org">Paul Spencer</a>
   * @author <a href="epugh@upstate.com">Eric Pugh</a> 
   * @version $Id: XSLTServiceTest.java,v 1.1 2004/02/13 14:26:58 epugh Exp $
   */
  public class XSLTServiceTest extends BaseUnitTest
  {
      private XSLTService xsltService = null;
  
      
  
      /**
       * Defines the testcase name for JUnit.
       *
       * @param name the testcase's name.
       */
      public XSLTServiceTest(String name)
      {
          super(name);
      }
   
      protected void setUp() throws Exception
      {
          super.setUp();
          try
          {
              xsltService = (XSLTService) this.lookup(XSLTService.ROLE);
          }
          catch (ComponentException e)
          {
              e.printStackTrace();
              fail(e.getMessage());
          }
      }
      /**
       * Simple test that verify an object can be created and deleted.
       * @throws Exception
       */
      public void testPath() throws Exception
      {
          assertNotNull(xsltService);
      }
     
  }
  
  
  

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