You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2004/09/13 05:09:29 UTC

cvs commit: jakarta-commons/jelly/jelly-tags/xml/src/test/resources import.jelly import.xsl

dion        2004/09/12 20:09:29

  Added:       jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml
                        TestImport.java
               jelly/jelly-tags/xml/src/test/resources import.jelly
                        import.xsl
  Log:
  Test case for Jelly-45
  
  Revision  Changes    Path
  1.1                  jakarta-commons/jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/TestImport.java
  
  Index: TestImport.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.commons.jelly.tags.xml;
  
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  import java.net.URL;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.XMLOutput;
  
  import junit.framework.TestCase;
  
  /**
   * Test that compiled scripts can access resources
   */
  public class TestImport extends TestCase {
      
      public TestImport(String name) {
          super(name);
      }
      
      public void testImportResources() throws JellyException, UnsupportedEncodingException, IOException {
          JellyContext context = new JellyContext();
          URL url = TestImport.class.getResource("/resources/import.jelly");
          XMLOutput out = XMLOutput.createXMLOutput(System.out);
  //         this works because of the created child context that has knowledge
  //         of the URL
          context.runScript(url, out);
          out.close();
      }
  
      public void testImportResourcesCompiled() throws JellyException, UnsupportedEncodingException, IOException {
          JellyContext context = new JellyContext();
          URL url = TestImport.class.getResource("/resources/import.jelly");
          XMLOutput out = XMLOutput.createXMLOutput(System.out);
  //      This does not work because context has no currentURL set
  //      This results in a NullPointerException when resolving the
  //      stylesheet
  //        Script script = context.compileScript(url);
  //        script.run(context, out);
  //        out.close();
      }
  
  }
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/xml/src/test/resources/import.jelly
  
  Index: import.jelly
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" >
  <x:transform xslt="import.xsl">
  <x:param name="language" value="DE"/>
  <root/>
  </x:transform>
  </j:jelly>
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/xml/src/test/resources/import.xsl
  
  Index: import.xsl
  ===================================================================
  <xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns="http://www.w3.org/TR/xhtml1/strict">
  <xsl:template match="/">
  <html>
    <head>
      <title>Expense Report Summary</title>
    </head>
    <body>
      <p>Total Amount: 12</p>
    </body>
  </html>
  </xsl:template>
  </xsl:stylesheet>
  
  

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