You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2003/07/09 00:02:56 UTC

cvs commit: jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/nowrap Componenttest.java TestNoWrap.java

rdonkin     2003/07/08 15:02:56

  Modified:    betwixt/src/test/org/apache/commons/betwixt/nowrap
                        Componenttest.java TestNoWrap.java
  Log:
  Improved unit tests
  
  Revision  Changes    Path
  1.3       +7 -7      jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/nowrap/Componenttest.java
  
  Index: Componenttest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/nowrap/Componenttest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Componenttest.java	30 Dec 2002 18:16:47 -0000	1.2
  +++ Componenttest.java	8 Jul 2003 22:02:55 -0000	1.3
  @@ -62,23 +62,23 @@
   
   public class Componenttest
   {
  -
  +    private boolean debug = false;
       private String compDescription = "";
   
       public Componenttest()
       {
  -        System.out.println("-- INSTANTIATING NEW COMPONENTTEST");
  +        if (debug) System.out.println("-- INSTANTIATING NEW COMPONENTTEST");
       }
   
       public void setCompDescription(String s)
       {
  -        System.out.println("SET component description");
  +        if (debug) System.out.println("SET component description");
           compDescription = s;
       }
   
       public String getCompDescription()
       {
  -        System.out.println("GET component description");
  +        if (debug) System.out.println("GET component description");
           return compDescription;
       }
   }
  
  
  
  1.6       +30 -6     jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/nowrap/TestNoWrap.java
  
  Index: TestNoWrap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/nowrap/TestNoWrap.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestNoWrap.java	30 Dec 2002 18:16:47 -0000	1.5
  +++ TestNoWrap.java	8 Jul 2003 22:02:55 -0000	1.6
  @@ -62,6 +62,9 @@
   
   import java.io.File;
   import java.io.FileInputStream;
  +import java.io.StringWriter;
  +
  +import java.util.List;
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
  @@ -125,6 +128,15 @@
           // create a new BeanReader
           BeanReader reader = createBeanReader(POTest.class);
           po = (POTest) reader.parse(in);
  +        assertEquals("PO Printing No", "555008805581", po.getPrintingNumber());
  +        List componentTests = po.getComponenttests();
  +        assertEquals("#Component tests", 3, componentTests.size());
  +        Componenttest testOne = (Componenttest) componentTests.get(0);
  +        assertEquals("Component Test One", "Text", testOne.getCompDescription());
  +        Componenttest testTwo = (Componenttest) componentTests.get(1);
  +        assertEquals("Component Test Two", "Binding", testTwo.getCompDescription());
  +        Componenttest testThree = (Componenttest) componentTests.get(2);
  +        assertEquals("Component Test Three", "Paper Cover", testThree.getCompDescription());
       }
   
       /**
  @@ -134,12 +146,24 @@
           throws Exception
       {
           // Let's try to write the bean
  -        BeanWriter beanWriter = new BeanWriter();
  +        StringWriter out = new StringWriter();
  +        out.write("<?xml version='1.0'?>");
  +        BeanWriter beanWriter = new BeanWriter(out);
           beanWriter.setXMLIntrospector(createXMLIntrospector());
           beanWriter.setWriteIDs(false);
           beanWriter.enablePrettyPrint();
  -        System.out.println(po);
  +        
           beanWriter.write(po);
  +        String xml = "<?xml version='1.0'?><content><printingno>555008805581</printingno>"
  +                + "<componenttest><compdescription>Text</compdescription></componenttest>"
  +                + "<componenttest><compdescription>Binding</compdescription></componenttest>"
  +                + "<componenttest><compdescription>Paper Cover</compdescription>"
  +                + "</componenttest></content>";
  +                
  +        xmlAssertIsomorphicContent(
  +                    parseString(xml),
  +                    parseString(out.getBuffer().toString()),
  +                    true);
       }
   
       // Implementation methods
  
  
  

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