dion        2004/10/27 10:39:41

  Modified:    jelly/src/java/org/apache/commons/jelly/impl TagScript.java
  Added:       jelly/src/test/org/apache/commons/jelly outputBad.jelly
                        TestXMLOutput.java outputGood.jelly
  Log:
  Jelly-138. character data flushed XMLOuput while XML data doesn't
  
  Revision  Changes    Path
  1.1                  
jakarta-commons/jelly/src/test/org/apache/commons/jelly/outputBad.jelly
  
  Index: outputBad.jelly
  ===================================================================
  <j:jelly xmlns:j="jelly:core">

        <html/>

  </j:jelly>
  
  
  1.1                  
jakarta-commons/jelly/src/test/org/apache/commons/jelly/TestXMLOutput.java
  
  Index: TestXMLOutput.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;
  
  import java.io.ByteArrayOutputStream;
  
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.test.BaseJellyTest;
  
  /**
   * @author Hans Gilde
   *
   */
  public class TestXMLOutput extends BaseJellyTest {
  
      /** JUnit constructor
       * @param name
       */
      public TestXMLOutput(String name) {
          super(name);
      }
      
      public void testOutputGood() throws Exception {
          setUpScript("outputGood.jelly");
          Script script = getJelly().compileScript();
          
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          
          script.run(getJellyContext(),XMLOutput.createXMLOutput(bos));
          assertEquals("<html></html>x",bos.toString());
      }
      
      public void testOutputBad() throws Exception {
          setUpScript("outputBad.jelly");
          Script script = getJelly().compileScript();
          
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          
          script.run(getJellyContext(),XMLOutput.createXMLOutput(bos));
          assertEquals("<html></html>",bos.toString());
      }
      
      public void testOutputBadGood() throws Exception {
          setUpScript("outputBad.jelly");
          Script script = getJelly().compileScript();
          
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          
          XMLOutput ouput = XMLOutput.createXMLOutput(bos);
          
          script.run(getJellyContext(),ouput);
          ouput.flush();
          assertEquals("<html></html>",bos.toString());
      }
      
  }
  
  
  
  1.1                  
jakarta-commons/jelly/src/test/org/apache/commons/jelly/outputGood.jelly
  
  Index: outputGood.jelly
  ===================================================================
  <j:jelly xmlns:j="jelly:core">

        <html/>x

  </j:jelly>
  
  
  1.45      +7 -5      
jakarta-commons/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java
  
  Index: TagScript.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- TagScript.java    16 Sep 2004 01:12:11 -0000      1.44
  +++ TagScript.java    27 Oct 2004 17:39:41 -0000      1.45
  @@ -15,6 +15,7 @@
    */
   package org.apache.commons.jelly.impl;
   
  +import java.io.IOException;
   import java.lang.reflect.InvocationTargetException;
   import java.net.MalformedURLException;
   import java.net.URL;
  @@ -250,14 +251,15 @@
               }
   
               tag.doTag(output);
  +            output.flush();
           }
           catch (JellyTagException e) {
               handleException(e);
  -        }
  -        catch (JellyException e) {
  +        } catch (JellyException e) {
               handleException(e);
  -        }
  -        catch (RuntimeException e) {
  +        } catch (IOException e) {
  +            handleException(e);
  +        } catch (RuntimeException e) {
               handleException(e);
           }
           catch (Error e) {
  
  
  

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

Reply via email to