commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml TestImport.java
Date Thu, 16 Sep 2004 02:22:02 GMT
dion        2004/09/15 19:22:02

  Modified:    jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml
                        TestImport.java
  Log:
  Add asserts for expected output
  
  Revision  Changes    Path
  1.3       +15 -3     jakarta-commons/jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/TestImport.java
  
  Index: TestImport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/TestImport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestImport.java	16 Sep 2004 01:13:13 -0000	1.2
  +++ TestImport.java	16 Sep 2004 02:22:02 -0000	1.3
  @@ -16,6 +16,7 @@
   package org.apache.commons.jelly.tags.xml;
   
   import java.io.IOException;
  +import java.io.StringWriter;
   import java.io.UnsupportedEncodingException;
   import java.net.URL;
   
  @@ -33,6 +34,11 @@
    */
   public class TestImport extends TestCase {
       
  +    private String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  +        + "<html xmlns=\"http://www.w3.org/TR/xhtml1/strict\" "
  +        + "xmlns=\"http://www.w3.org/TR/xhtml1/strict\">"
  +        + "<head><title>Expense Report Summary</title></head>"
  +        + "<body><p>Total Amount: 12</p></body></html>";
       public TestImport(String name) {
           super(name);
       }
  @@ -40,29 +46,35 @@
       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);
  +        StringWriter writer = new StringWriter();
  +        XMLOutput out = XMLOutput.createXMLOutput(writer);
   //         this works because of the created child context that has knowledge
   //         of the URL
           context.runScript(url, out);
           out.close();
  +        assertEquals(expected, writer.toString());
       }
   
       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);
  +        StringWriter writer = new StringWriter();
  +        XMLOutput out = XMLOutput.createXMLOutput(writer);
           Script script = context.compileScript(url);
           script.run(context, out);
           out.close();
  +        assertEquals(expected, writer.toString());
       }
   
       public void testImportResourcesFromUncompiledScript() throws JellyException, UnsupportedEncodingException,
IOException, SAXException {
           JellyContext context = new JellyContext();
           URL url = TestImport.class.getResource("/resources/import.jelly");
  -        XMLOutput out = XMLOutput.createXMLOutput(System.out);
  +        StringWriter writer = new StringWriter();
  +        XMLOutput out = XMLOutput.createXMLOutput(writer);
           Script script = new XMLParser().parse(url);
           script.run(context, out);
           out.close();
  +        assertEquals(expected, writer.toString());
       }
   
   }
  
  
  

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


Mime
View raw message