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 TestSchemaGeneration.java TestSchemaValidity.java
Date Tue, 03 Feb 2004 19:43:55 GMT
rdonkin     2004/02/03 11:43:55

  Modified:    betwixt/src/test/org/apache/commons/betwixt/schema Tag:
                        REFACTORING-BRANCH_2004-01-13
                        TestSchemaGeneration.java TestSchemaValidity.java
  Log:
  Added two more tests for basic schema generation.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +31 -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.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- TestSchemaGeneration.java	2 Feb 2004 22:21:44 -0000	1.1.2.2
  +++ TestSchemaGeneration.java	3 Feb 2004 19:43:55 -0000	1.1.2.3
  @@ -101,4 +101,31 @@
               
           xmlAssertIsomorphicContent(parseString(expected), parseString(xsd));
       }
  +    
  +    
  +    public void testSimplestBeanWithElement() throws Exception {
  +        SchemaTranscriber transcriber = new SchemaTranscriber();
  +        transcriber.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true);
  +        Schema schema = transcriber.generate(SimplestElementBean.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='SimplestBean' type='org.apache.commons.betwixt.schema.SimplestElementBean'/>"
+
  +        "<xsd:complexType name='org.apache.commons.betwixt.schema.SimplestElementBean'>"
+
  +        "<xsd:sequence>" +
  +        "<xsd:element name='name' type='xsd:string'/>" +
  +        "</xsd:sequence>" +
  +        "</xsd:complexType>" +
  +        "</xsd:schema>";
  +            
  +        xmlAssertIsomorphicContent(parseString(expected), parseString(xsd));
  +    }
   }
  
  
  
  1.1.2.3   +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.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- TestSchemaValidity.java	2 Feb 2004 22:21:44 -0000	1.1.2.2
  +++ TestSchemaValidity.java	3 Feb 2004 19:43:55 -0000	1.1.2.3
  @@ -111,4 +111,22 @@
          
          xmlAssertIsValid(new InputSource(new StringReader(xml)), new InputSource(new StringReader(xsd)));
       }   
  +    
  +    
  +    public void testSimplestBeanWithElements() throws Exception {
  +       String xsd = generateSchema(SimplestElementBean.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);
  +       SimplestElementBean bean = new SimplestElementBean("Simon");
  +       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