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/schema SimpleBean.java TestSchemaGeneration.java TestSchemaValidity.java
Date Tue, 03 Feb 2004 20:44:08 GMT
rdonkin     2004/02/03 12:44:08

  Modified:    betwixt/src/test/org/apache/commons/betwixt/schema Tag:
                        REFACTORING-BRANCH_2004-01-13 SimpleBean.java
                        TestSchemaGeneration.java TestSchemaValidity.java
  Log:
  Added one more unit test for schema generation
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.2   +11 -4     jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/Attic/SimpleBean.java
  
  Index: SimpleBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/Attic/SimpleBean.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SimpleBean.java	18 Jan 2004 12:36:30 -0000	1.1.2.1
  +++ SimpleBean.java	3 Feb 2004 20:44:03 -0000	1.1.2.2
  @@ -75,6 +75,13 @@
   	
   	public SimpleBean() {}
   
  +    public SimpleBean(String one, String two, String three, String four) {
  +        setOne(one);
  +        setTwo(two);
  +        setThree(three);
  +        setFour(four);
  +    }
  +
       public String getOne() {
           return one;
       }
  
  
  
  1.1.2.4   +32 -4     jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/Attic/TestSchemaGeneration.java
  
  Index: TestSchemaGeneration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/Attic/TestSchemaGeneration.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- TestSchemaGeneration.java	3 Feb 2004 19:43:55 -0000	1.1.2.3
  +++ TestSchemaGeneration.java	3 Feb 2004 20:44:04 -0000	1.1.2.4
  @@ -128,4 +128,32 @@
               
           xmlAssertIsomorphicContent(parseString(expected), parseString(xsd));
       }
  +    
  +    public void testSimpleBean() throws Exception {
  +        SchemaTranscriber transcriber = new SchemaTranscriber();
  +        Schema schema = transcriber.generate(SimpleBean.class);
  +        
  +        StringWriter out = new StringWriter();
  +        out.write("<?xml version='1.0'?>");
  +        BeanWriter writer = new BeanWriter(out);
  +        writer.setBindingConfiguration(transcriber.createSchemaBindingConfiguration());
  +        writer.getXMLIntrospector().setConfiguration(transcriber.createSchemaIntrospectionConfiguration());
  +        writer.write(schema);
  +        
  +        String xsd = out.getBuffer().toString();
  +        
  +        String expected ="<?xml version='1.0'?><xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
+
  +        "<xsd:element name='simple' type='org.apache.commons.betwixt.schema.SimpleBean'/>"
+
  +        "<xsd:complexType name='org.apache.commons.betwixt.schema.SimpleBean'>" +
  +        "<xsd:sequence>" +
  +        "<xsd:element name='three' type='xsd:string'/>" +
  +        "<xsd:element name='four' type='xsd:string'/>" +
  +        "</xsd:sequence>" +
  +        "<xsd:attribute name='one' type='xsd:string'/>" +
  +        "<xsd:attribute name='two' type='xsd:string'/>" +
  +        "</xsd:complexType>" +
  +        "</xsd:schema>";
  +            
  +        xmlAssertIsomorphicContent(parseString(expected), parseString(xsd));
  +    }
   }
  
  
  
  1.1.2.4   +22 -4     jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/Attic/TestSchemaValidity.java
  
  Index: TestSchemaValidity.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/schema/Attic/TestSchemaValidity.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- TestSchemaValidity.java	3 Feb 2004 19:43:55 -0000	1.1.2.3
  +++ TestSchemaValidity.java	3 Feb 2004 20:44:04 -0000	1.1.2.4
  @@ -129,4 +129,22 @@
          
          xmlAssertIsValid(new InputSource(new StringReader(xml)), new InputSource(new StringReader(xsd)));
       }   
  +    
  +    
  +    public void testSimpleBean() throws Exception {
  +       String xsd = generateSchema(SimpleBean.class);
  +            
  +       StringWriter out = new StringWriter();
  +       out.write("<?xml version='1.0'?>");
  +       BeanWriter writer = new BeanWriter(out);
  +       writer.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true);
  +       writer.getXMLIntrospector().getConfiguration().getPrefixMapper().setPrefix(SchemaTranscriber.W3C_SCHEMA_INSTANCE_URI,
"xsi");
  +       writer.getBindingConfiguration().setMapIDs(false);
  +       SimpleBean bean = new SimpleBean("One", "Two", "A", "One, Two, Three, Four");
  +       writer.write(bean);
  +       
  +       String xml = out.getBuffer().toString();
  +       
  +       xmlAssertIsValid(new InputSource(new StringReader(xml)), new InputSource(new StringReader(xsd)));
  +    }   
   }
  
  
  

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