Added -keepElementPositions for "pure" java beans. It works fine for reading and printing out, but has some difficulty with some schemas while adding new elements to the graph. QBE200302120100-BLD200302181631
authorcliffwd@netbeans.org
Fri, 07 Feb 2003 18:55:17 +0000
changeset 1192d25894c97f95
parent 1191 21b70a2ebfcb
child 1193 b7f6c25abc7d
Added -keepElementPositions for "pure" java beans. It works fine for reading and printing out, but has some difficulty with some schemas while adding new elements to the graph.
Fixed a few bugs.
A javac failure is passed up to our parent process.
schema2beans/test/unit/src/TestMain.java
schema2beans/test/unit/src/data/TestPositions.dtd
schema2beans/test/unit/src/data/TestPositions.java
schema2beans/test/unit/src/data/TestPositions.xml
schema2beans/test/unit/src/data/goldenfiles/TestMain/testPositions.pass
     1.1 --- a/schema2beans/test/unit/src/TestMain.java	Wed Feb 05 16:49:21 2003 +0000
     1.2 +++ b/schema2beans/test/unit/src/TestMain.java	Fri Feb 07 18:55:17 2003 +0000
     1.3 @@ -114,6 +114,13 @@
     1.4          generalTest("TestWebAppDelegatorBaseBean", true, config);
     1.5      }
     1.6  
     1.7 +    public void testPositions() throws IOException, Schema2BeansException, InterruptedException {
     1.8 +        GenBeans.Config config = new GenBeans.Config();
     1.9 +        config.buyPremium();
    1.10 +        config.setKeepElementPositions(true);
    1.11 +        generalTest("TestPositions", false, config);
    1.12 +    }
    1.13 +
    1.14      public void testApplication1_4() throws IOException, Schema2BeansException, InterruptedException {
    1.15          generalTest("TestApplication1_4", true, true, true);
    1.16      }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/schema2beans/test/unit/src/data/TestPositions.dtd	Fri Feb 07 18:55:17 2003 +0000
     2.3 @@ -0,0 +1,9 @@
     2.4 +<!ELEMENT menus (menu*, foo)>
     2.5 +
     2.6 +<!ELEMENT menu (name, (menu-item | separator | menu)*)>
     2.7 +
     2.8 +<!ELEMENT name #PCDATA>
     2.9 +<!ELEMENT menu-item #PCDATA>
    2.10 +<!ELEMENT separator ()>
    2.11 +
    2.12 +<!ELEMENT foo (name*, separator, name?)>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/schema2beans/test/unit/src/data/TestPositions.java	Fri Feb 07 18:55:17 2003 +0000
     3.3 @@ -0,0 +1,56 @@
     3.4 +/*
     3.5 + *	TestPositions - test the basic features.
     3.6 + *
     3.7 + *	The following test assumes that we know the content of the
     3.8 + *	graph as we get elements, add and change them. Therefore, the TestPositions.xml
     3.9 + *	file and this java test should be kept in sync.
    3.10 + *
    3.11 + * 	Test the following:
    3.12 + *
    3.13 + *	single String: get/set/remove/set/get
    3.14 + *	boolean (from true): get/set true/get/set false/get/set true/get
    3.15 + *	boolean (from false): get/set false/get/set true/get/set false/get
    3.16 + *	String[]: get/set (null & !null)/add/remove
    3.17 + *	Bean: remove/set(null)/create bean and graph of beans/set/add
    3.18 + *
    3.19 + */
    3.20 +
    3.21 +import java.io.*;
    3.22 +import java.util.*;
    3.23 +import org.w3c.dom.*;
    3.24 +
    3.25 +import menus.*;
    3.26 +
    3.27 +
    3.28 +public class TestPositions extends BaseTest {
    3.29 +    public static void main(String[] argv) {
    3.30 +        TestPositions o = new TestPositions();
    3.31 +        if (argv.length > 0)
    3.32 +            o.setDocumentDir(argv[0]);
    3.33 +        try {
    3.34 +            o.run();
    3.35 +        } catch (Exception e) {
    3.36 +            e.printStackTrace();
    3.37 +            System.exit(1);
    3.38 +        }
    3.39 +        System.exit(0);
    3.40 +    }
    3.41 +    
    3.42 +    public void run() throws Exception {
    3.43 +        Menus menus;
    3.44 +
    3.45 +        this.readDocument();
    3.46 +
    3.47 +        out("creating the bean graph");
    3.48 +        menus = Menus.read(doc);
    3.49 +	
    3.50 +        //	Check that we can read the graph an it is complete
    3.51 +        out("bean graph created");
    3.52 +        menus.write(out);
    3.53 +
    3.54 +        out("Check to make sure that elements with the same name get put into the right spot");
    3.55 +        Foo foo = menus.getFoo();
    3.56 +        check(foo.sizeName() == 2, "There are 2 names");
    3.57 +        check("name2".equals(foo.getName2()), "name2 is in the right spot");
    3.58 +    }
    3.59 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/schema2beans/test/unit/src/data/TestPositions.xml	Fri Feb 07 18:55:17 2003 +0000
     4.3 @@ -0,0 +1,24 @@
     4.4 +<?xml version='1.0' encoding='UTF-8' ?>
     4.5 +<menus>
     4.6 +  <menu>
     4.7 +	<name>Tools</name>
     4.8 +	<menu-item>Setup</menu-item>
     4.9 +	<menu-item>Update Center</menu-item>
    4.10 +	<separator/>
    4.11 +	<menu>
    4.12 +	  <name>VCS</name>
    4.13 +	  <menu-item>Update</menu-item>
    4.14 +	  <menu-item>Commit</menu-item>
    4.15 +	  <separator/>
    4.16 +	  <menu-item>Revert</menu-item>
    4.17 +	</menu>
    4.18 +	<separator/>
    4.19 +	<menu-item>Help</menu-item>
    4.20 +  </menu>
    4.21 +	<foo>
    4.22 +		<name>name1-1</name>
    4.23 +		<name>name1-2</name>
    4.24 +		<separator/>
    4.25 +		<name>name2</name>
    4.26 +	</foo>
    4.27 +</menus>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testPositions.pass	Fri Feb 07 18:55:17 2003 +0000
     5.3 @@ -0,0 +1,34 @@
     5.4 +Calling GenBeans.doIt
     5.5 +Compiling
     5.6 +Finished compiling: 0
     5.7 +out: TestPositions - creating the DOM document
     5.8 +out: TestPositions - creating the bean graph
     5.9 +out: TestPositions - bean graph created
    5.10 +out: <?xml version='1.0' encoding='UTF-8' ?>
    5.11 +out: <menus>
    5.12 +out: 	<menu>
    5.13 +out: 		<name>Tools</name>
    5.14 +out: 		<menu-item>Setup</menu-item>
    5.15 +out: 		<menu-item>Update Center</menu-item>
    5.16 +out: 		<separator/>
    5.17 +out: 		<menu>
    5.18 +out: 			<name>VCS</name>
    5.19 +out: 			<menu-item>Update</menu-item>
    5.20 +out: 			<menu-item>Commit</menu-item>
    5.21 +out: 			<separator/>
    5.22 +out: 			<menu-item>Revert</menu-item>
    5.23 +out: 		</menu>
    5.24 +out: 		<separator/>
    5.25 +out: 		<menu-item>Help</menu-item>
    5.26 +out: 	</menu>
    5.27 +out: 	<foo>
    5.28 +out: 		<name>name1-1</name>
    5.29 +out: 		<name>name1-2</name>
    5.30 +out: 		<separator/>
    5.31 +out: 		<name>name2</name>
    5.32 +out: 	</foo>
    5.33 +out: </menus>
    5.34 +out: TestPositions - Check to make sure that elements with the same name get put into the right spot
    5.35 +out: TestPositions null There are 2 names -> OK
    5.36 +out: TestPositions null name2 is in the right spot -> OK
    5.37 +Finished running TestPositions: 0