commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/betwixt/src/test/org/apache/commons/betwixt TestBeanReader.java
Date Sat, 28 Jun 2003 10:49:37 GMT
rdonkin     2003/06/28 03:49:37

  Modified:    betwixt/src/test/org/apache/commons/betwixt
                        TestBeanReader.java
  Log:
  Improved unit tests by replacing prints to out with checking of xml
  
  Revision  Changes    Path
  1.13      +17 -7     jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanReader.java
  
  Index: TestBeanReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestBeanReader.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TestBeanReader.java	14 Apr 2003 16:24:05 -0000	1.12
  +++ TestBeanReader.java	28 Jun 2003 10:49:37 -0000	1.13
  @@ -121,11 +121,18 @@
   
               testCustomer(bean);
               
  -            System.out.println( "Read bean: " + bean );
  -            System.out.println();
  -            System.out.println( "Lets turn it back into XML" );
  -            
  -            writeBean( bean );
  +            String out = writeBean( bean );
  +            String xml = "<?xml version='1.0'?><CustomerBean><name>James</name><time>20:30:40</time>"
  +                + "<date>2002-03-17</date><projectMap/><bigDecimal>1234567890.12345</bigDecimal>"
  +                + "<bigInteger>1234567890</bigInteger><projectNames/><emails>"
  +                + "<email>jstrachan@apache.org</email><email>james_strachan@yahoo.co.uk</email>"
  +                + "</emails><timestamp>2002-03-17 20:30:40.0</timestamp><locations>"
  +                + "<location>London</location><location>Bath</location></locations>"
  +                + "<ID/><projectURLs/><nickName/><address><code/><country/>"
  +                + "<city/><street/></address><numbers><number>3</number><number>4</number>"
  +                + "<number>5</number></numbers></CustomerBean>";
  +                
  +            xmlAssertIsomorphic(parseString(xml), parseString(out) , true);
           }
           finally {
               in.close();
  @@ -166,10 +173,13 @@
           assertEquals("[Attribute] Person name wrong", "John Smith" , bean.getName());
       }
   
  -    public void writeBean(Object bean) throws Exception {
  -        BeanWriter writer = new BeanWriter();
  +    public String writeBean(Object bean) throws Exception {
  +        StringWriter out = new StringWriter();
  +        out.write("<?xml version='1.0'?>");
  +        BeanWriter writer = new BeanWriter(out);
           writer.enablePrettyPrint();
           writer.write( bean );
  +        return out.getBuffer().toString();
       }
       
       /** @return the bean class to use as the root */
  
  
  

---------------------------------------------------------------------
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