Given the -attrprop flag, make attributes into properties (IZ 22014).
1.1 --- a/schema2beans/test/unit/src/TestMain.java Sat Oct 12 23:10:17 2002 +0000
1.2 +++ b/schema2beans/test/unit/src/TestMain.java Mon Oct 14 22:42:39 2002 +0000
1.3 @@ -36,11 +36,11 @@
1.4 }
1.5
1.6 public void testPurchaseOrder() throws IOException, Schema2BeansException, InterruptedException {
1.7 - generalTest("TestPurchaseOrder", true);
1.8 + generalTest("TestPurchaseOrder", true, true, true);
1.9 }
1.10
1.11 public void testBookXMLSchema() throws IOException, Schema2BeansException, InterruptedException {
1.12 - generalTest("TestBookXMLSchema", true);
1.13 + generalTest("TestBookXMLSchema", true, false, false);
1.14 }
1.15
1.16 public void testBook() throws IOException, Schema2BeansException, InterruptedException {
1.17 @@ -56,7 +56,7 @@
1.18 }
1.19
1.20 public void testAttr() throws IOException, Schema2BeansException, InterruptedException {
1.21 - generalTest("TestAttr");
1.22 + generalTest("TestAttr", false, false, true);
1.23 }
1.24
1.25 public void testMdd() throws IOException, Schema2BeansException, InterruptedException {
1.26 @@ -92,16 +92,23 @@
1.27 }
1.28
1.29 public void generalTest(String testName) throws IOException, Schema2BeansException, InterruptedException {
1.30 - generalTest(testName, false);
1.31 + generalTest(testName, false, false, false);
1.32 }
1.33
1.34 - public void generalTest(String testName, boolean xmlSchema) throws IOException, Schema2BeansException, InterruptedException {
1.35 + public void generalTest(String testName, boolean xmlSchema,
1.36 + boolean pureJavaBeans, boolean attrProp) throws IOException, Schema2BeansException, InterruptedException {
1.37 String testOnly = System.getProperty("TestMain.testOnly");
1.38 if (testOnly != null && !testOnly.equals(testName))
1.39 return;
1.40 try {
1.41 System.out.println("Starting "+testName);
1.42 File workDir = getWorkDir();
1.43 +
1.44 + //File diffCommandFile = new File(workDir, "diffCommand");
1.45 + //Writer cmdOut = new FileWriter(diffCommandFile);
1.46 + //cmdOut.write("ediff "+workDir.toString());
1.47 + //cmdOut.close();
1.48 +
1.49 GenBeans.Config config = new GenBeans.Config();
1.50 config.setAuto(true);
1.51 config.setStandalone(false);
1.52 @@ -126,6 +133,12 @@
1.53 // It's okay if there is no mdd file present
1.54 }
1.55 config.setRootDir(workDir.toString());
1.56 + if (attrProp) {
1.57 + config.setAttributesAsProperties(true);
1.58 + }
1.59 + if (pureJavaBeans) {
1.60 + config.setOutputType(GenBeans.Config.OUTPUT_JAVABEANS);
1.61 + }
1.62 //config.setPackagePath();
1.63 //config.setMessageOut(getRef());
1.64 //if (testName.equals("TestBookXMLSchema")) {
2.1 --- a/schema2beans/test/unit/src/data/TestAttr.java Sat Oct 12 23:10:17 2002 +0000
2.2 +++ b/schema2beans/test/unit/src/data/TestAttr.java Mon Oct 14 22:42:39 2002 +0000
2.3 @@ -400,6 +400,14 @@
2.4 anotherBook.setSummary("This is my summary.");
2.5 out(anotherBook);
2.6
2.7 + setTest("attributes as properties");
2.8 + book.setGood("no");
2.9 + check("no".equals(book.getGood()));
2.10 + out("Checking chapter title");
2.11 + Chapter chap0 = book.getChapter(0);
2.12 + chap0.setTitle("My title");
2.13 + out(chap0.getTitle());
2.14 +
2.15 /*setTest("get non set attribute");
2.16 book.setAttributeValue("Summary", "lang", "");
2.17 ByteArrayOutputStream bout = new ByteArrayOutputStream();
3.1 --- a/schema2beans/test/unit/src/data/TestPurchaseOrder.java Sat Oct 12 23:10:17 2002 +0000
3.2 +++ b/schema2beans/test/unit/src/data/TestPurchaseOrder.java Mon Oct 14 22:42:39 2002 +0000
3.3 @@ -42,14 +42,49 @@
3.4 this.readDocument();
3.5
3.6 out("creating the bean graph");
3.7 - po = PurchaseOrder.createGraph(doc);
3.8 + po = PurchaseOrder.read(doc);
3.9
3.10 // Check that we can read the graph an it is complete
3.11 out("bean graph created");
3.12 -
3.13 + po.write(out);
3.14 +
3.15 + out("Adjusting shipTo");
3.16 USAddress shipTo = new USAddress();
3.17 po.setShipTo(shipTo);
3.18 - shipTo.setName("To you");
3.19 - out(po);
3.20 + shipTo.setCountry("B&B's are us");
3.21 + shipTo.setName("To you & me");
3.22 + po.write(out);
3.23 +
3.24 + out("Adding a Daffodil");
3.25 + Items items = po.getItems();
3.26 + Item item = new Item();
3.27 + item.setProductName("Daffodil");
3.28 + item.setQuantity(3);
3.29 + item.setUSPrice(new java.math.BigDecimal("1.00"));
3.30 + item.setComment("Yellow & Green");
3.31 + int position = items.addItem(item);
3.32 + po.write(out);
3.33 +
3.34 + check(items.getItem(position) == item, "addItem returned correct position");
3.35 +
3.36 + out("Removing that Daffodil");
3.37 + items.removeItem(item);
3.38 + po.write(out);
3.39 +
3.40 + Item[] itemsArray = items.getItem();
3.41 + /*
3.42 + out(""+itemsArray.length);
3.43 + check(itemsArray.length == 2, "we should have 2 items now");
3.44 + */
3.45 + check(items.sizeItem() == 2, "sizeItem should return 2");
3.46 +
3.47 + PurchaseOrder po2 = new PurchaseOrder(po);
3.48 + check(po != po2, "po should not be po2");
3.49 + check(po.equals(po2), "po should equal po2");
3.50 + check(po2.equals(po), "po2 should equal po");
3.51 + /*
3.52 + po.write(out);
3.53 + po2.write(out);
3.54 + */
3.55 }
3.56 }
4.1 --- a/schema2beans/test/unit/src/data/TestPurchaseOrder.xml Sat Oct 12 23:10:17 2002 +0000
4.2 +++ b/schema2beans/test/unit/src/data/TestPurchaseOrder.xml Mon Oct 14 22:42:39 2002 +0000
4.3 @@ -1,6 +1,6 @@
4.4 <?xml version='1.0' encoding='UTF-8' ?>
4.5 -<purchaseOrder>
4.6 - <shipTo>
4.7 +<purchaseOrder orderDate='20021010'>
4.8 + <shipTo country="US">
4.9 <name>J</name>
4.10 <city>Foster City</city>
4.11 </shipTo>
4.12 @@ -9,12 +9,12 @@
4.13 </billTo>
4.14 <comment>comment for the purchase order</comment>
4.15 <items>
4.16 - <item>
4.17 + <item partNum='123'>
4.18 <productName>Stargazer lily</productName>
4.19 <quantity>5</quantity>
4.20 <USPrice>1.21</USPrice>
4.21 </item>
4.22 - <item>
4.23 + <item partNum='124'>
4.24 <productName>Red Rose</productName>
4.25 <quantity>2</quantity>
4.26 <USPrice>2</USPrice>
5.1 --- a/schema2beans/test/unit/src/data/TestPurchaseOrder.xsd Sat Oct 12 23:10:17 2002 +0000
5.2 +++ b/schema2beans/test/unit/src/data/TestPurchaseOrder.xsd Mon Oct 14 22:42:39 2002 +0000
5.3 @@ -20,7 +20,7 @@
5.4 <xsd:element ref="comment" minOccurs="0"/>
5.5 <xsd:element name="items" type="Items"/>
5.6 </xsd:sequence>
5.7 - <xsd:attribute name="orderDate" type="xsd:string"/>
5.8 + <xsd:attribute name="orderDate" type="xsd:int"/>
5.9 </xsd:complexType>
5.10
5.11 <xsd:complexType name="USAddress">
6.1 --- a/schema2beans/test/unit/src/data/goldenfiles/TestMain/testAttr.pass Sat Oct 12 23:10:17 2002 +0000
6.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testAttr.pass Mon Oct 14 22:42:39 2002 +0000
6.3 @@ -222,4 +222,11 @@
6.4 out: <book>
6.5 out: <summary size="12">This is my summary.</summary>
6.6 out: </book>
6.7 +out: TestAttr - <Chg Lnr:Book Evt:/Book:Good Src:book.Book>
6.8 +out: TestAttr - <Attr:Book.Good - ParentName: - ParentClass:book.Book>
6.9 +out: TestAttr attributes as properties -> OK
6.10 +out: TestAttr - Checking chapter title
6.11 +out: TestAttr - <Add Lnr:Book Evt:/Book/Chapter.6:Title Src:book.Book>
6.12 +out: TestAttr - <Attr:Chapter[0].Title - ParentName: Book - ParentClass:book.Book>
6.13 +out: TestAttr - My title
6.14 Finished running TestAttr: 0
7.1 --- a/schema2beans/test/unit/src/data/goldenfiles/TestMain/testPurchaseOrder.pass Sat Oct 12 23:10:17 2002 +0000
7.2 +++ b/schema2beans/test/unit/src/data/goldenfiles/TestMain/testPurchaseOrder.pass Mon Oct 14 22:42:39 2002 +0000
7.3 @@ -4,26 +4,107 @@
7.4 out: TestPurchaseOrder - creating the DOM document
7.5 out: TestPurchaseOrder - creating the bean graph
7.6 out: TestPurchaseOrder - bean graph created
7.7 -out: <?xml version="1.0" encoding="UTF-8"?>
7.8 -out: <purchaseOrder>
7.9 -out: <shipTo country="US">
7.10 -out: <name>To you</name>
7.11 -out: </shipTo>
7.12 -out: <billTo>
7.13 -out: <name>C</name>
7.14 -out: </billTo>
7.15 -out: <comment>comment for the purchase order</comment>
7.16 -out: <items>
7.17 -out: <item>
7.18 -out: <productName>Stargazer lily</productName>
7.19 -out: <quantity>5</quantity>
7.20 -out: <USPrice>1.21</USPrice>
7.21 -out: </item>
7.22 -out: <item>
7.23 -out: <productName>Red Rose</productName>
7.24 -out: <quantity>2</quantity>
7.25 -out: <USPrice>2</USPrice>
7.26 -out: </item>
7.27 -out: </items>
7.28 +out: <?xml version='1.0' encoding='UTF-8' ?>
7.29 +out: <purchaseOrder orderDate='20021010'>
7.30 +out: <shipTo country='US'>
7.31 +out: <name>J</name>
7.32 +out: <city>Foster City</city>
7.33 +out: </shipTo>
7.34 +out: <billTo>
7.35 +out: <name>C</name>
7.36 +out: </billTo>
7.37 +out: <comment>comment for the purchase order</comment>
7.38 +out: <items>
7.39 +out: <item partNum='123'>
7.40 +out: <productName>Stargazer lily</productName>
7.41 +out: <quantity>5</quantity>
7.42 +out: <USPrice>1.21</USPrice>
7.43 +out: </item>
7.44 +out: <item partNum='124'>
7.45 +out: <productName>Red Rose</productName>
7.46 +out: <quantity>2</quantity>
7.47 +out: <USPrice>2</USPrice>
7.48 +out: </item>
7.49 +out: </items>
7.50 out: </purchaseOrder>
7.51 +out: TestPurchaseOrder - Adjusting shipTo
7.52 +out: <?xml version='1.0' encoding='UTF-8' ?>
7.53 +out: <purchaseOrder orderDate='20021010'>
7.54 +out: <shipTo country='B&B's are us'>
7.55 +out: <name>To you & me</name>
7.56 +out: </shipTo>
7.57 +out: <billTo>
7.58 +out: <name>C</name>
7.59 +out: </billTo>
7.60 +out: <comment>comment for the purchase order</comment>
7.61 +out: <items>
7.62 +out: <item partNum='123'>
7.63 +out: <productName>Stargazer lily</productName>
7.64 +out: <quantity>5</quantity>
7.65 +out: <USPrice>1.21</USPrice>
7.66 +out: </item>
7.67 +out: <item partNum='124'>
7.68 +out: <productName>Red Rose</productName>
7.69 +out: <quantity>2</quantity>
7.70 +out: <USPrice>2</USPrice>
7.71 +out: </item>
7.72 +out: </items>
7.73 +out: </purchaseOrder>
7.74 +out: TestPurchaseOrder - Adding a Daffodil
7.75 +out: <?xml version='1.0' encoding='UTF-8' ?>
7.76 +out: <purchaseOrder orderDate='20021010'>
7.77 +out: <shipTo country='B&B's are us'>
7.78 +out: <name>To you & me</name>
7.79 +out: </shipTo>
7.80 +out: <billTo>
7.81 +out: <name>C</name>
7.82 +out: </billTo>
7.83 +out: <comment>comment for the purchase order</comment>
7.84 +out: <items>
7.85 +out: <item partNum='123'>
7.86 +out: <productName>Stargazer lily</productName>
7.87 +out: <quantity>5</quantity>
7.88 +out: <USPrice>1.21</USPrice>
7.89 +out: </item>
7.90 +out: <item partNum='124'>
7.91 +out: <productName>Red Rose</productName>
7.92 +out: <quantity>2</quantity>
7.93 +out: <USPrice>2</USPrice>
7.94 +out: </item>
7.95 +out: <item>
7.96 +out: <productName>Daffodil</productName>
7.97 +out: <quantity>3</quantity>
7.98 +out: <USPrice>1.00</USPrice>
7.99 +out: <comment>Yellow & Green</comment>
7.100 +out: </item>
7.101 +out: </items>
7.102 +out: </purchaseOrder>
7.103 +out: TestPurchaseOrder null addItem returned correct position -> OK
7.104 +out: TestPurchaseOrder - Removing that Daffodil
7.105 +out: <?xml version='1.0' encoding='UTF-8' ?>
7.106 +out: <purchaseOrder orderDate='20021010'>
7.107 +out: <shipTo country='B&B's are us'>
7.108 +out: <name>To you & me</name>
7.109 +out: </shipTo>
7.110 +out: <billTo>
7.111 +out: <name>C</name>
7.112 +out: </billTo>
7.113 +out: <comment>comment for the purchase order</comment>
7.114 +out: <items>
7.115 +out: <item partNum='123'>
7.116 +out: <productName>Stargazer lily</productName>
7.117 +out: <quantity>5</quantity>
7.118 +out: <USPrice>1.21</USPrice>
7.119 +out: </item>
7.120 +out: <item partNum='124'>
7.121 +out: <productName>Red Rose</productName>
7.122 +out: <quantity>2</quantity>
7.123 +out: <USPrice>2</USPrice>
7.124 +out: </item>
7.125 +out: </items>
7.126 +out: </purchaseOrder>
7.127 +out: TestPurchaseOrder null sizeItem should return 2 -> OK
7.128 +out: TestPurchaseOrder null po should not be po2 -> OK
7.129 +out: TestPurchaseOrder null po should equal po2 -> OK
7.130 +out: TestPurchaseOrder null po2 should equal po -> OK
7.131 Finished running TestPurchaseOrder: 0