1.1 --- a/schema2beans/test/unit/src/TestMain.java Sun Aug 07 00:32:00 2005 +0000
1.2 +++ b/schema2beans/test/unit/src/TestMain.java Mon Aug 08 00:53:58 2005 +0000
1.3 @@ -139,6 +139,16 @@
1.4 generalTest("TestExtension", true, config);
1.5 }
1.6
1.7 + public void testExtension2() throws IOException, Schema2BeansException, InterruptedException {
1.8 + GenBeans.Config config = new GenBeans.Config();
1.9 + config.buyPremium();
1.10 + config.setRespectExtension(true);
1.11 + config.setOutputType(GenBeans.Config.OUTPUT_JAVABEANS);
1.12 + config.setAttributesAsProperties(true);
1.13 + config.setGenerateCommonInterface("CommonBean");
1.14 + generalTest("TestExtension2", true, config);
1.15 + }
1.16 +
1.17 public void testWebApp() throws IOException, Schema2BeansException, InterruptedException {
1.18 GenBeans.Config config = new GenBeans.Config();
1.19 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/TestExtension2.java Mon Aug 08 00:53:58 2005 +0000
2.3 @@ -0,0 +1,56 @@
2.4 +/*
2.5 + * TestExtension2 - 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 TestExtension2.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 mycar.*;
2.26 +
2.27 +
2.28 +public class TestExtension2 extends BaseTest {
2.29 + public static void main(String[] argv) {
2.30 + TestExtension2 o = new TestExtension2();
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 + Mycar extension;
2.44 +
2.45 + this.readDocument();
2.46 +
2.47 + out("creating the bean graph");
2.48 + extension = Mycar.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 + Object extensionObject = extension;
2.54 + if (extensionObject instanceof Vehicle)
2.55 + out("Mycar is a vehicle"); // This should be true
2.56 + if (extensionObject instanceof Boat)
2.57 + out("Mycar is a boat"); // should be false
2.58 + }
2.59 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/schema2beans/test/unit/src/data/TestExtension2.xml Mon Aug 08 00:53:58 2005 +0000
3.3 @@ -0,0 +1,8 @@
3.4 +
3.5 +<mycar vehicle-attr='98'>
3.6 + <automatic>true</automatic>
3.7 + <wheels>4</wheels>
3.8 + <max-speed>185.0</max-speed>
3.9 + <occupancy>5</occupancy>
3.10 + <description>Audi A4</description>
3.11 +</mycar>
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/schema2beans/test/unit/src/data/TestExtension2.xsd Mon Aug 08 00:53:58 2005 +0000
4.3 @@ -0,0 +1,37 @@
4.4 +<?xml version="1.0" ?>
4.5 +
4.6 +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
4.7 + <xs:element name='mycar' type='car'/>
4.8 +
4.9 + <xs:complexType name="car">
4.10 + <xs:complexContent>
4.11 + <xs:extension base="vehicle">
4.12 + <xs:sequence>
4.13 + <xs:element name="automatic" type="xsd:boolean"/>
4.14 + </xs:sequence>
4.15 + </xs:extension>
4.16 + </xs:complexContent>
4.17 + </xs:complexType>
4.18 +
4.19 + <xs:complexType name="boat">
4.20 + <xs:complexContent>
4.21 + <xs:extension base="vehicle">
4.22 + <xs:sequence>
4.23 + <xs:element name="sailboat" type="xsd:boolean"/>
4.24 + </xs:sequence>
4.25 + </xs:extension>
4.26 + </xs:complexContent>
4.27 + <xs:attribute name='boat-attr' type='xs:int'/>
4.28 + </xs:complexType>
4.29 +
4.30 + <xs:complexType name="vehicle" abstract='true'>
4.31 + <xs:sequence>
4.32 + <xs:element name="wheels" type="xs:int"/>
4.33 + <xs:element name="max-speed" type="xs:double"/>
4.34 + <xs:element name="occupancy" type="xs:int"/>
4.35 + <xs:element name="description" type="xs:string"/>
4.36 + </xs:sequence>
4.37 + <xs:attribute name='vehicle-attr' type='xs:int'/>
4.38 + </xs:complexType>
4.39 +
4.40 +</xs:schema>
5.1 --- a/schema2beans/test/unit/src/data/goldenfiles/TestMain/testExtension.pass Sun Aug 07 00:32:00 2005 +0000
5.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testExtension.pass Mon Aug 08 00:53:58 2005 +0000
5.3 @@ -14,6 +14,10 @@
5.4 inputRecord <InputRecord> : String
5.5 outputRecord <OutputRecord> : String
5.6 description <Description> : String
5.7 + property <Property> : String[0,n]
5.8 + inputRecord <InputRecord> : String
5.9 + outputRecord <OutputRecord> : String
5.10 + description <Description> : String
5.11
5.12 Compiling
5.13 Finished compiling: 0
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testExtension2.pass Mon Aug 08 00:53:58 2005 +0000
6.3 @@ -0,0 +1,24 @@
6.4 +Calling GenBeans.doIt
6.5 +Bean Tree:
6.6 +mycar <mycar> : Mycar
6.7 + automatic <automatic> : boolean
6.8 + wheels <wheels> : int
6.9 + maxSpeed <max-speed> : double
6.10 + occupancy <occupancy> : int
6.11 + description <description> : java.lang.String
6.12 +
6.13 +Compiling
6.14 +Finished compiling: 0
6.15 +out: TestExtension2 - creating the DOM document
6.16 +out: TestExtension2 - creating the bean graph
6.17 +out: TestExtension2 - bean graph created
6.18 +out: <?xml version='1.0' encoding='UTF-8' ?>
6.19 +out: <mycar vehicle-attr='98'>
6.20 +out: <automatic>true</automatic>
6.21 +out: <wheels>4</wheels>
6.22 +out: <max-speed>185.0</max-speed>
6.23 +out: <occupancy>5</occupancy>
6.24 +out: <description>Audi A4</description>
6.25 +out: </mycar>
6.26 +out: TestExtension2 - Mycar is a vehicle
6.27 +Finished running TestExtension2: 0