Fix a bug in the XML Schema parser where an extended type was not picking up the attributes of the type it extended. BLD200303280100
authorcliffwd@netbeans.org
Thu, 27 Mar 2003 21:16:58 +0000
changeset 1257022018daa195
parent 1256 44ed18860b71
child 1258 596396c66ee1
Fix a bug in the XML Schema parser where an extended type was not picking up the attributes of the type it extended.
schema2beans/test/unit/src/TestMain.java
schema2beans/test/unit/src/data/TestExtension.java
schema2beans/test/unit/src/data/TestExtension.xml
schema2beans/test/unit/src/data/TestExtension.xsd
schema2beans/test/unit/src/data/goldenfiles/TestMain/testExtension.pass
     1.1 --- a/schema2beans/test/unit/src/TestMain.java	Thu Mar 27 08:51:00 2003 +0000
     1.2 +++ b/schema2beans/test/unit/src/TestMain.java	Thu Mar 27 21:16:58 2003 +0000
     1.3 @@ -114,6 +114,17 @@
     1.4          generalTest("TestExtensionSample", true, true, true);
     1.5      }
     1.6  
     1.7 +    public void testExtension() throws IOException, Schema2BeansException, InterruptedException {
     1.8 +        GenBeans.Config config = new GenBeans.Config();
     1.9 +        config.setOutputType(GenBeans.Config.OUTPUT_JAVABEANS);
    1.10 +        config.setAttributesAsProperties(true);
    1.11 +        config.setGenerateValidate(true);
    1.12 +        config.setProcessComments(true);
    1.13 +        config.setProcessDocType(true);
    1.14 +        config.setGenerateCommonInterface("CommonBean");
    1.15 +        generalTest("TestExtension", true, config);
    1.16 +    }
    1.17 +
    1.18      public void testWebApp() throws IOException, Schema2BeansException, InterruptedException {
    1.19          GenBeans.Config config = new GenBeans.Config();
    1.20          config.setOutputType(GenBeans.Config.OUTPUT_JAVABEANS);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/schema2beans/test/unit/src/data/TestExtension.java	Thu Mar 27 21:16:58 2003 +0000
     2.3 @@ -0,0 +1,51 @@
     2.4 +/*
     2.5 + *	TestExtension - test the basic features.
     2.6 + *
     2.7 + *	The following test assumes that we know the content of the
     2.8 + *	graph as we get elements, add and change them. Therefore, the TestExtension.xml
     2.9 + *	file and this java test should be kept in sync.
    2.10 + *
    2.11 + * 	Test the following:
    2.12 + *
    2.13 + *	single String: get/set/remove/set/get
    2.14 + *	boolean (from true): get/set true/get/set false/get/set true/get
    2.15 + *	boolean (from false): get/set false/get/set true/get/set false/get
    2.16 + *	String[]: get/set (null & !null)/add/remove
    2.17 + *	Bean: remove/set(null)/create bean and graph of beans/set/add
    2.18 + *
    2.19 + */
    2.20 +
    2.21 +import java.io.*;
    2.22 +import java.util.*;
    2.23 +import org.w3c.dom.*;
    2.24 +
    2.25 +import complexfunspec.*;
    2.26 +
    2.27 +
    2.28 +public class TestExtension extends BaseTest {
    2.29 +    public static void main(String[] argv) {
    2.30 +        TestExtension o = new TestExtension();
    2.31 +        if (argv.length > 0)
    2.32 +            o.setDocumentDir(argv[0]);
    2.33 +        try {
    2.34 +            o.run();
    2.35 +        } catch (Exception e) {
    2.36 +            e.printStackTrace();
    2.37 +            System.exit(1);
    2.38 +        }
    2.39 +        System.exit(0);
    2.40 +    }
    2.41 +    
    2.42 +    public void run() throws Exception {
    2.43 +        ComplexFunSpec extension;
    2.44 +
    2.45 +        this.readDocument();
    2.46 +
    2.47 +        out("creating the bean graph");
    2.48 +        extension = ComplexFunSpec.read(doc);
    2.49 +	
    2.50 +        //	Check that we can read the graph an it is complete
    2.51 +        out("bean graph created");
    2.52 +        extension.write(out);
    2.53 +    }
    2.54 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/schema2beans/test/unit/src/data/TestExtension.xml	Thu Mar 27 21:16:58 2003 +0000
     3.3 @@ -0,0 +1,10 @@
     3.4 +<ComplexFunSpec name='Hank' funSpecType='cool'>
     3.5 +	<InputRecord>a</InputRecord>
     3.6 +	<OutputRecord>b</OutputRecord>
     3.7 +	<Description>c</Description>
     3.8 +	<FunSpec name='Joe'>
     3.9 +		<InputRecord>d</InputRecord>
    3.10 +		<OutputRecord>e</OutputRecord>
    3.11 +		<Description>f</Description>
    3.12 +	</FunSpec>
    3.13 +</ComplexFunSpec>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/schema2beans/test/unit/src/data/TestExtension.xsd	Thu Mar 27 21:16:58 2003 +0000
     4.3 @@ -0,0 +1,33 @@
     4.4 +<?xml version="1.0" ?>
     4.5 +
     4.6 +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
     4.7 +
     4.8 +	<xs:complexType name="ComplexFunSpec">
     4.9 +		<xs:annotation>
    4.10 +			<xs:documentation>ComplexFun Spec Type definition</xs:documentation>
    4.11 +		</xs:annotation>
    4.12 +		<xs:complexContent>
    4.13 +			<xs:extension base="FunSpec">
    4.14 +				<xs:sequence>
    4.15 +					<xs:element name="FunSpec" type="FunSpec" minOccurs="0" maxOccurs="unbounded"/>
    4.16 +				</xs:sequence>
    4.17 +			</xs:extension>
    4.18 +		</xs:complexContent>
    4.19 +	</xs:complexType>
    4.20 +	
    4.21 +	<xs:complexType name="FunSpec">
    4.22 +		<xs:annotation>
    4.23 +			<xs:documentation>Fun Specification Type definition</xs:documentation>
    4.24 +		</xs:annotation>
    4.25 +		<xs:sequence>
    4.26 +			<xs:element name="Property" type="Element" minOccurs="0" 
    4.27 +maxOccurs="unbounded"/>
    4.28 +			<xs:element name="InputRecord" type="Record"/>
    4.29 +			<xs:element name="OutputRecord" type="Record"/>
    4.30 +			<xs:element name="Description" type="Description"/>
    4.31 +		</xs:sequence>
    4.32 +		<xs:attribute name="name" type="xs:string" use="required"/>
    4.33 +		<xs:attribute name="funSpecType" type="xs:string" use="optional"/>
    4.34 +	</xs:complexType>	
    4.35 +
    4.36 +</xs:schema>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testExtension.pass	Thu Mar 27 21:16:58 2003 +0000
     5.3 @@ -0,0 +1,34 @@
     5.4 +Calling GenBeans.doIt
     5.5 +Bean Tree:
     5.6 +ComplexFunSpec : ComplexFunSpec
     5.7 +	[attr: name CDATA #REQUIRED  : java.lang.String]
     5.8 +	[attr: funSpecType CDATA #IMPLIED  : java.lang.String]
     5.9 +	Property : String[0,n]
    5.10 +	InputRecord : String
    5.11 +	OutputRecord : String
    5.12 +	Description : String
    5.13 +	FunSpec : FunSpec[0,n]
    5.14 +		[attr: name CDATA #REQUIRED  : java.lang.String]
    5.15 +		[attr: funSpecType CDATA #IMPLIED  : java.lang.String]
    5.16 +		Property : String[0,n]
    5.17 +		InputRecord : String
    5.18 +		OutputRecord : String
    5.19 +		Description : String
    5.20 +
    5.21 +Compiling
    5.22 +Finished compiling: 0
    5.23 +out: TestExtension - creating the DOM document
    5.24 +out: TestExtension - creating the bean graph
    5.25 +out: TestExtension - bean graph created
    5.26 +out: <?xml version='1.0' encoding='UTF-8' ?>
    5.27 +out: <ComplexFunSpec name='Hank' funSpecType='cool'>
    5.28 +out: 	<InputRecord>a</InputRecord>
    5.29 +out: 	<OutputRecord>b</OutputRecord>
    5.30 +out: 	<Description>c</Description>
    5.31 +out: 	<FunSpec name='Joe'>
    5.32 +out: 		<InputRecord>d</InputRecord>
    5.33 +out: 		<OutputRecord>e</OutputRecord>
    5.34 +out: 		<Description>f</Description>
    5.35 +out: 	</FunSpec>
    5.36 +out: </ComplexFunSpec>
    5.37 +Finished running TestExtension: 0