Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS01.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS01.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS01.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS01.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,92 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Test; +import org.w3c.dom.*; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertTrue; + + +/** + * The "setAttributeNode(newAttr)" method raises an + * "INUSE_ATTRIBUTE_ERR DOMException if the "newAttr" + * is already an attribute of another element. + * <p> + * Retrieve the first emp:address and append + * a newly created element. The "createAttributeNS(namespaceURI,qualifiedName)" + * and "setAttributeNodeNS(newAttr)" methods are invoked + * to create and add a new attribute to the newly created + * Element. The "setAttributeNodeNS(newAttr)" method is + * once again called to add the new attribute causing an + * exception to be raised since the attribute is already + * an attribute of another element. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAtNodeNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAtNodeNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])</a> + */ +public class setAttributeNodeNS01 extends DOMTestCase { + @Test + public void testRun() throws Throwable { + String namespaceURI = "http://www.newattr.com"; + String qualifiedName = "emp:newAttr"; + Document doc; + Element newElement; + Attr newAttr; + NodeList elementList; + Node testAddr; + Node appendedChild; + Attr setAttr1; + Attr setAttr2; + doc = load("staffNS", true); + elementList = doc.getElementsByTagName("emp:address"); + testAddr = elementList.item(0); + newElement = doc.createElement("newElement"); + appendedChild = testAddr.appendChild(newElement); + newAttr = doc.createAttributeNS(namespaceURI, qualifiedName); + setAttr1 = newElement.setAttributeNodeNS(newAttr); + + { + boolean success = false; + try { + setAttr2 = ((Element) /*Node */testAddr).setAttributeNodeNS(newAttr); + } catch (DOMException ex) { + success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); + } + assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); + } + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS01"; + } + +}
Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS02.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS02.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS02.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS02.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,99 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Ignore; +import org.junit.Test; +import org.w3c.dom.*; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + + +/** + * The "setAttributeNodeNS(namespaceURI,qualifiedName,value)" method for an attribute causes the + * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised + * if the node is readonly. + * <p> + * Obtain the children of the THIRD "gender" element. The elements + * content is an entity reference. Try to set an attribute + * in the entity reference by executing the + * "setAttributeNodeNS(newAttr)" method. + * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAtNodeNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAtNodeNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])</a> + */ +public class setAttributeNodeNS02 extends DOMTestCase { + @Test + @Ignore + public void testRun() throws Throwable { + Document doc; + NodeList genderList; + Node gender; + NodeList genList; + Node gen; + NodeList gList; + Element genElement; + Attr newAttr; + Attr setAttr1; + doc = load("staffNS", true); + + if (!isExpandEntityReferences()) { + genderList = doc.getElementsByTagName("gender"); + gender = genderList.item(2); + genList = gender.getChildNodes(); + gen = genList.item(0); + } else { + gen = doc.createEntityReference("ent4"); + } + + gList = gen.getChildNodes(); + genElement = (Element) gList.item(0); + assertNotNull("notnull", genElement); + newAttr = doc.createAttributeNS("www.xyz.com", "emp:local1"); + + { + boolean success = false; + try { + setAttr1 = genElement.setAttributeNodeNS(newAttr); + } catch (DOMException ex) { + success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); + } + assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); + } + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS02"; + } + +} Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS03.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS03.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS03.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS03.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,74 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Test; +import org.w3c.dom.*; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertNull; + + +/** + * The "setAttributeNodeNS(newAttr)" adds a new attribute. + * If an attribute with that local name and that namespaceURI is already + * present in the element, it is replaced by the new one. + * <p> + * Retrieve the first emp:address element and add a new attribute + * to the element. Since an attribute with the same local name + * and namespaceURI as the newly created attribute does not exist + * the value "null" is returned. + * This test uses the "createAttributeNS(namespaceURI,localName) + * method from the Document interface to create the new attribute to add. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS</a> + */ +public class setAttributeNodeNS03 extends DOMTestCase { + @Test + public void testRun() throws Throwable { + String namespaceURI = "http://www.newattr.com"; + String qualifiedName = "emp:newAttr"; + Document doc; + NodeList elementList; + Node testAddr; + Attr newAttr; + Attr newAddrAttr; + doc = load("staffNS", true); + elementList = doc.getElementsByTagName("emp:address"); + testAddr = elementList.item(0); + newAttr = doc.createAttributeNS(namespaceURI, qualifiedName); + newAddrAttr = ((Element) /*Node */testAddr).setAttributeNodeNS(newAttr); + assertNull("throw_Null", newAddrAttr); + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS03"; + } + +} Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS04.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS04.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS04.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS04.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,74 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Test; +import org.w3c.dom.*; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertEquals; + + +/** + * The "setAttributeNodeNS(newAttr)" adds a new attribute. + * If an attribute with that local name and that namespaceURI is already + * present in the element, it is replaced by the new one. + * <p> + * Retrieve the first emp:address element and add a new attribute + * to the element. Since an attribute with the same local name + * and namespaceURI already exists, it is replaced by the new one and + * returns the replaced "Attr" node. + * This test uses the "createAttributeNS(namespaceURI,localName) + * method from the Document interface to create the new attribute to add. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D095">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D095</a> + */ +public class setAttributeNodeNS04 extends DOMTestCase { + @Test + public void testRun() throws Throwable { + Document doc; + NodeList elementList; + Node testAddr; + Attr newAttr; + Attr newAddrAttr; + String newName; + doc = load("staffNS", true); + elementList = doc.getElementsByTagName("emp:address"); + testAddr = elementList.item(0); + newAttr = doc.createAttributeNS("http://www.nist.gov", "xxx:domestic"); + newAddrAttr = ((Element) /*Node */testAddr).setAttributeNodeNS(newAttr); + newName = newAddrAttr.getNodeName(); + assertEquals("nodeName", "emp:domestic", newName); + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS04"; + } + +} Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS05.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS05.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS05.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setAttributeNodeNS05.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,88 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Test; +import org.w3c.dom.*; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertTrue; + + +/** + * The "setAttributeNodeNS(newAttr)" method raises an + * "WRONG_DOCUMENT_ERR DOMException if the "newAttr" + * was created from a different document than the one that + * created this document. + * <p> + * Retrieve the first emp:address and attempt to set a new + * attribute node. The new + * attribute was created from a document other than the + * one that created this element, therefore a + * WRONG_DOCUMENT_ERR DOMException should be raised. + * This test uses the "createAttributeNS(newAttr)" method + * from the Document interface. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAtNodeNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-ElSetAtNodeNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])</a> + */ +public class setAttributeNodeNS05 extends DOMTestCase { + @Test + public void testRun() throws Throwable { + String namespaceURI = "http://www.newattr.com"; + String qualifiedName = "emp:newAttr"; + Document doc1; + Document doc2; + Attr newAttr; + NodeList elementList; + Node testAddr; + Attr setAttr1; + doc1 = load("staffNS", true); + doc2 = load("staffNS", true); + newAttr = doc2.createAttributeNS(namespaceURI, qualifiedName); + elementList = doc1.getElementsByTagName("emp:address"); + testAddr = elementList.item(0); + + { + boolean success = false; + try { + setAttr1 = ((Element) /*Node */testAddr).setAttributeNodeNS(newAttr); + } catch (DOMException ex) { + success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); + } + assertTrue("throw_WRONG_DOCUMENT_ERR", success); + } + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setAttributeNodeNS05"; + } + +} Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS01.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS01.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS01.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS01.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,87 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Test; +import org.w3c.dom.*; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertTrue; + + +/** + * The "setNamedItemNS(arg)" method for a + * NamedNodeMap should raise INUSE_ATTRIBUTE_ERR DOMException if + * arg is an Attr that is already an attribute of another Element object. + * <p> + * Retrieve an attr node from the third "address" element whose local name + * is "domestic" and namespaceURI is "http://www.netzero.com". + * Invoke method setNamedItemNS(arg) on the map of the first "address" element with + * arg being the attr node from above. Method should raise + * INUSE_ATTRIBUTE_ERR DOMException. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])</a> + */ +public class setNamedItemNS01 extends DOMTestCase { + @Test + public void testRun() throws Throwable { + Document doc; + NodeList elementList; + Node anotherElement; + NamedNodeMap anotherMap; + Node arg; + Node testAddress; + NamedNodeMap map; + Node setNode; + doc = load("staffNS", true); + elementList = doc.getElementsByTagName("address"); + anotherElement = elementList.item(2); + anotherMap = anotherElement.getAttributes(); + arg = anotherMap.getNamedItemNS("http://www.netzero.com", "domestic"); + testAddress = elementList.item(0); + map = testAddress.getAttributes(); + + { + boolean success = false; + try { + setNode = map.setNamedItemNS(arg); + } catch (DOMException ex) { + success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); + } + assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); + } + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS01"; + } + +} Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS02.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS02.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS02.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS02.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,88 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Test; +import org.w3c.dom.*; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertTrue; + + +/** + * The "setNamedItemNS(arg)" method for a + * NamedNodeMap should raise WRONG_DOCUMENT_ERR DOMException if arg was + * created from a different document than the one that created this map. + * <p> + * Create an attr node in a different document with qualifiedName equals + * "dmstc:domestic" and namespaceURI is "http://www.usa.com". + * Access the namednodemap of the first "address" element in this document. + * Invoke method setNamedItemNS(arg) with arg being the attr node from above. + * Method should raise WRONG_DOCUMENT_ERR DOMException. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])</a> + */ +public class setNamedItemNS02 extends DOMTestCase { + @Test + public void testRun() throws Throwable { + String namespaceURI = "http://www.usa.com"; + String qualifiedName = "dmstc:domestic"; + Document doc; + Document anotherDoc; + Node arg; + NodeList elementList; + Node testAddress; + NamedNodeMap attributes; + Node setNode; + doc = load("staffNS", true); + anotherDoc = load("staffNS", true); + arg = anotherDoc.createAttributeNS(namespaceURI, qualifiedName); + arg.setNodeValue("Maybe"); + elementList = doc.getElementsByTagName("address"); + testAddress = elementList.item(0); + attributes = testAddress.getAttributes(); + + { + boolean success = false; + try { + setNode = attributes.setNamedItemNS(arg); + } catch (DOMException ex) { + success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); + } + assertTrue("throw_WRONG_DOCUMENT_ERR", success); + } + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS02"; + } + +} Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS03.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS03.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS03.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS03.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,83 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Test; +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertEquals; + + +/** + * The "setNamedItemNS(arg)" method for a + * NamedNodeMap should add a node using its namespaceURI and localName given that + * there is no existing node with the same namespaceURI and localName in the map. + * <p> + * Create an attr node with namespaceURI "http://www.nist.gov",qualifiedName + * "prefix:newAttr" and value "newValue". + * Invoke method setNamedItemNS(arg) on the map of the first "address" + * element where arg is identified by the namespaceURI and qualifiedName + * from above. Method should return the newly added attr node. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D080">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-F68D080</a> + */ +public class setNamedItemNS03 extends DOMTestCase { + @Test + public void testRun() throws Throwable { + String namespaceURI = "http://www.nist.gov"; + String qualifiedName = "prefix:newAttr"; + Document doc; + Node arg; + NodeList elementList; + Node testAddress; + NamedNodeMap attributes; + Node retnode; + String value; + Node setNode; + doc = load("staffNS", true); + arg = doc.createAttributeNS(namespaceURI, qualifiedName); + arg.setNodeValue("newValue"); + elementList = doc.getElementsByTagName("address"); + testAddress = elementList.item(0); + attributes = testAddress.getAttributes(); + setNode = attributes.setNamedItemNS(arg); + retnode = attributes.getNamedItemNS(namespaceURI, "newAttr"); + value = retnode.getNodeValue(); + assertEquals("throw_Equals", "newValue", value); + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS03"; + } + +} Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS04.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS04.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS04.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS04.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,103 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Ignore; +import org.junit.Test; +import org.w3c.dom.*; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + + +/** + * The "setNamedItemNS(arg)" method for a + * NamedNodeMap should raise NO_MODIFICATION_ALLOWED_ERR DOMException if + * this map is readonly. + * <p> + * Retrieve a list of "gender" elements. Get access to the THIRD element + * which contains an ENTITY_REFERENCE child node. Get access to the node's + * map. Try to add an attribute node specified by arg with + * method setNamedItemNS(arg). This should result in NO_MODIFICATION_ALLOWED_ERR + * DOMException. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS</a> + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])</a> + */ +public class setNamedItemNS04 extends DOMTestCase { + @Test + @Ignore + public void testRun() throws Throwable { + String namespaceURI = "http://www.w3.org/2000/xmlns/"; + String localName = "local1"; + Document doc; + NodeList elementList; + Node testAddress; + NodeList nList; + Node child; + NodeList n2List; + Node child2; + NamedNodeMap attributes; + Node arg; + Node setNode; + doc = load("staffNS", true); + + if (!isExpandEntityReferences()) { + elementList = doc.getElementsByTagName("gender"); + testAddress = elementList.item(2); + nList = testAddress.getChildNodes(); + child = nList.item(0); + } else { + child = doc.createEntityReference("ent4"); + } + + n2List = child.getChildNodes(); + child2 = n2List.item(0); + assertNotNull("notnull", child2); + attributes = child2.getAttributes(); + arg = attributes.getNamedItemNS(namespaceURI, localName); + + { + boolean success = false; + try { + setNode = attributes.setNamedItemNS(arg); + } catch (DOMException ex) { + success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); + } + assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); + } + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS04"; + } + +} Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS05.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS05.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS05.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/setNamedItemNS05.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,81 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Test; +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.domts.DOMTestCase; + +import static org.junit.Assert.assertEquals; + + +/** + * The "setNamedItemNS(arg)" method for a + * NamedNodeMap should replace an existing node n1 found in the map with arg if n1 + * has the same namespaceURI and localName as arg and return n1. + * <p> + * Create an attribute node in with namespaceURI "http://www.usa.com" + * and qualifiedName "dmstc:domestic" whose value is "newVal". + * Invoke method setNamedItemNS(arg) on the map of the first "address" + * element. Method should return the old attribute node identified + * by namespaceURI and qualifiedName from above,whose value is "Yes". + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS</a> + */ +public class setNamedItemNS05 extends DOMTestCase { + @Test + public void testRun() throws Throwable { + String namespaceURI = "http://www.usa.com"; + String qualifiedName = "dmstc:domestic"; + Document doc; + Node arg; + NodeList elementList; + Node testAddress; + NamedNodeMap attributes; + Node retnode; + String value; + doc = load("staffNS", true); + arg = doc.createAttributeNS(namespaceURI, qualifiedName); + arg.setNodeValue("newValue"); + elementList = doc.getElementsByTagName("address"); + testAddress = elementList.item(0); + attributes = testAddress.getAttributes(); + retnode = attributes.setNamedItemNS(arg); + value = retnode.getNodeValue(); + assertEquals("throw_Equals", "Yes", value); + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS05"; + } + +} Added: xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/systemId01.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/systemId01.java?rev=1896456&view=auto ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/systemId01.java (added) +++ xmlbeans/branches/gradle-build/src/test/java/org/w3c/domts/level2/core/systemId01.java Mon Dec 27 20:28:38 2021 @@ -0,0 +1,66 @@ +/* +This Java source file was generated by test-to-java.xsl +and is a derived work from the source document. +The source document contained the following notice: + + + +Copyright (c) 2001 World Wide Web Consortium, +(Massachusetts Institute of Technology, Institut National de +Recherche en Informatique et en Automatique, Keio University). All +Rights Reserved. This program is distributed under the W3C's Software +Intellectual Property License. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. + +See W3C License http://www.w3.org/Consortium/Legal/ for more details. + + +*/ + +package org.w3c.domts.level2.core; + + +import org.junit.Ignore; +import org.junit.Test; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.domts.DOMTestCase; + + +/** + * The "getSystemId()" method of a documenttype node contains + * the system identifier associated with the external subset. + * <p> + * Retrieve the documenttype. + * Apply the "getSystemId()" method. The string "staffNS.dtd" should be + * returned. + * + * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-systemId">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-systemId</a> + */ +public class systemId01 extends DOMTestCase { + @Test + @Ignore + public void testRun() throws Throwable { + Document doc; + DocumentType docType; + String systemId; + int index; + doc = load("staffNS", false); + docType = doc.getDoctype(); + systemId = docType.getSystemId(); + assertURIEquals("systemId", null, null, null, "staffNS.dtd", null, null, null, null, systemId); + + } + + /** + * Gets URI that identifies the test + * + * @return uri identifier of test + */ + public String getTargetURI() { + return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/systemId01"; + } + +} Modified: xmlbeans/branches/gradle-build/src/test/java/scomp/common/BaseCase.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/scomp/common/BaseCase.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/scomp/common/BaseCase.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/scomp/common/BaseCase.java Mon Dec 27 20:28:38 2021 @@ -21,33 +21,32 @@ import org.junit.Before; import java.util.ArrayList; public class BaseCase { - protected boolean bVerbose = true; + protected boolean bVerbose = false; protected XmlOptions validateOptions; - protected ArrayList errorList; + protected final ArrayList<XmlError> errorList = new ArrayList<>(); @Before public void setUp() { validateOptions = new XmlOptions(); - errorList = new ArrayList(); + errorList.clear(); validateOptions.setErrorListener(errorList); } protected void clearErrors() { //reset error list for next time - errorList = new ArrayList(); + errorList.clear(); validateOptions.setErrorListener(errorList); } public void showErrors() { if (bVerbose) - for (int i = 0; i < errorList.size(); i++) { - XmlError error = (XmlError) errorList.get(i); + for (XmlError error : errorList) { System.out.println("\n"); System.out.println("Message: " + error.getMessage() + "\n"); - if (error.getCursorLocation() != null) - System.out.println("Location of invalid XML: " + - error.getCursorLocation().xmlText() + "\n"); + if (error.getCursorLocation() != null) { + System.out.println("Location of invalid XML: " + error.getCursorLocation().xmlText() + "\n"); + } } } @@ -56,7 +55,7 @@ public class BaseCase { public boolean compareErrorCodes(String[] expected) { if ( errorList.size() != expected.length){ System.err.println(stringOfCodes(expected,errorList)); - + return false; } StringBuilder errMessage = new StringBuilder(); Modified: xmlbeans/branches/gradle-build/src/test/java/scomp/contentType/simple/detailed/ListType.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/scomp/contentType/simple/detailed/ListType.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/scomp/contentType/simple/detailed/ListType.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/scomp/contentType/simple/detailed/ListType.java Mon Dec 27 20:28:38 2021 @@ -18,6 +18,8 @@ package scomp.contentType.simple.detaile import org.apache.xmlbeans.XmlErrorCodes; import org.apache.xmlbeans.XmlSimpleList; import org.apache.xmlbeans.impl.values.XmlValueNotSupportedException; +import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException; +import org.junit.Ignore; import org.junit.Test; import scomp.common.BaseCase; import xbean.scomp.contentType.list.*; @@ -33,8 +35,8 @@ public class ListType extends BaseCase { public void testListTypeAnonymous() throws Throwable { ListEltTokenDocument doc = ListEltTokenDocument.Factory.newInstance(); - assertEquals(null, doc.getListEltToken()); - List values = new LinkedList(); + assertNull(doc.getListEltToken()); + List<Object> values = new LinkedList<>(); values.add("lstsmall"); values.add("lstmedium"); doc.setListEltToken(values); @@ -45,7 +47,7 @@ public class ListType extends BaseCase { showErrors(); throw t; } - values.set(0, new Integer(4)); + values.set(0, 4); // since the list has enumerations, it contains a fixed number of Java constants in the xobj // which are checked for types and an exception is expected irrespective of validateOnSet XmlOption @@ -84,10 +86,10 @@ public class ListType extends BaseCase { //immutable list assertTrue(result instanceof XmlSimpleList); } - List arrayList = new ArrayList(); + List<String> arrayList = new ArrayList<>(); arrayList.add("foobar"); - List newList = new XmlSimpleList(arrayList); - gst.setListValue(newList); + List<String> newList = new XmlSimpleList<>(arrayList); + assertThrows(XmlValueOutOfRangeException.class, () -> gst.setListValue(newList)); doc.xsetListEltInt(gst); try { assertTrue(doc.validate(validateOptions)); @@ -98,7 +100,7 @@ public class ListType extends BaseCase { } } - @Test + @Ignore public void testListofLists() { //also,a list of union that contains a list is not OK fail("Compile Time eror"); @@ -111,11 +113,11 @@ public class ListType extends BaseCase { public void testListofUnions() throws Throwable { ListUnionDocument doc = ListUnionDocument.Factory.newInstance(); - List arrayList = new ArrayList(); + List<Object> arrayList = new ArrayList<>(); arrayList.add("small"); arrayList.add("large"); - arrayList.add(new Integer(-1)); - arrayList.add(new Integer(2)); + arrayList.add(-1); + arrayList.add(2); doc.setListUnion(arrayList); try { @@ -136,7 +138,7 @@ public class ListType extends BaseCase { "</ListUnion>"; ListUnionDocument doc = ListUnionDocument.Factory.parse(input); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_VALID$UNION @@ -150,11 +152,11 @@ public class ListType extends BaseCase { public void testListofUnions2() throws Throwable { ListUnion2Document doc = ListUnion2Document.Factory.newInstance(); - List arrayList = new ArrayList(); + List<Object> arrayList = new ArrayList<>(); arrayList.add("small"); arrayList.add("large"); - arrayList.add(new Integer(-1)); - arrayList.add(new Integer(2)); + arrayList.add(-1); + arrayList.add(2); arrayList.add("addVal1"); arrayList.add("addVal2"); arrayList.add("addVal3"); Modified: xmlbeans/branches/gradle-build/src/test/java/scomp/contentType/simple/detailed/UnionType.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/scomp/contentType/simple/detailed/UnionType.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/scomp/contentType/simple/detailed/UnionType.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/scomp/contentType/simple/detailed/UnionType.java Mon Dec 27 20:28:38 2021 @@ -64,7 +64,7 @@ public class UnionType extends BaseCase throw t; } doc.setUnionElt(5); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_VALID$UNION}; @@ -105,12 +105,10 @@ public class UnionType extends BaseCase "-2" + "</UnionElt>"; UnionEltDocument doc = UnionEltDocument.Factory.parse(input); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); - String[] errExpected = new String[]{ - XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID}; - assertTrue(compareErrorCodes(errExpected)); - + String[] errExpected = {XmlErrorCodes.DATATYPE_MIN_INCLUSIVE_VALID}; + assertTrue(compareErrorCodes(errExpected)); } /** @@ -170,7 +168,7 @@ public class UnionType extends BaseCase { doc.setUnionOfUnions("foobar"); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{"cvc-attribute"}; @@ -231,7 +229,7 @@ public class UnionType extends BaseCase @Test public void testUnionOfLists() throws Throwable { UnionOfListsDocument doc = UnionOfListsDocument.Factory.newInstance(); - List vals = new ArrayList(); + List<Object> vals = new ArrayList<>(); vals.add("small"); vals.add(-1); vals.add(-2); @@ -265,7 +263,7 @@ public class UnionType extends BaseCase //mixing and matching should not be allowed //the list shoudl have exactly one of the 2 union types vals.add("lstsmall"); - vals.add(new Integer(-1)); + vals.add(-1); // if the type in a union and cannot be converted into any of the union types, and in this case // since the list have enumerations, an exception is expected irrespective of validateOnSet XmlOption Modified: xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/detailed/ElementRestriction.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/detailed/ElementRestriction.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/detailed/ElementRestriction.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/detailed/ElementRestriction.java Mon Dec 27 20:28:38 2021 @@ -14,17 +14,16 @@ */ package scomp.derivation.restriction.detailed; -import org.junit.Test; -import xbean.scomp.derivation.elementRestriction.ElementDocument; -import xbean.scomp.derivation.elementRestriction.RestrictedEltT; +import org.apache.xmlbeans.XmlDecimal; +import org.apache.xmlbeans.XmlErrorCodes; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlString; -import org.apache.xmlbeans.XmlErrorCodes; -import org.apache.xmlbeans.XmlDecimal; +import org.junit.Test; import scomp.common.BaseCase; +import xbean.scomp.derivation.elementRestriction.ElementDocument; +import xbean.scomp.derivation.elementRestriction.RestrictedEltT; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ElementRestriction extends BaseCase { @@ -65,7 +64,7 @@ public class ElementRestriction extends XmlDecimal dValue = XmlDecimal.Factory.newInstance(); dValue.setBigDecimalValue(new java.math.BigDecimal("3.5")); elt.setD(dValue); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.ELEM_COMPLEX_TYPE_LOCALLY_VALID$EXPECTED_DIFFERENT_ELEMENT, @@ -78,7 +77,7 @@ public class ElementRestriction extends elt.removeA(2); bValue.setStringValue("myval"); elt.setB(bValue); - elt.setD(new Integer(3)); + elt.setD(3); assertEquals("myval", ((XmlString)elt.getB()).getStringValue()); try { Modified: xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/facets/detailed/ListRestriction.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/facets/detailed/ListRestriction.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/facets/detailed/ListRestriction.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/facets/detailed/ListRestriction.java Mon Dec 27 20:28:38 2021 @@ -22,8 +22,7 @@ import xbean.scomp.derivation.facets.lis import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; /** */ @@ -31,12 +30,12 @@ public class ListRestriction extends Bas @Test public void testLengthFacet() throws Throwable { LengthEltDocument doc = LengthEltDocument.Factory.newInstance(); - List vals = new ArrayList(); + List<String> vals = new ArrayList<>(); vals.add("lstsmall"); doc.setLengthElt(vals); //this should be too short - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_LENGTH_VALID$LIST_LENGTH}; @@ -54,7 +53,7 @@ public class ListRestriction extends Bas vals.add("lstsmall"); doc.setLengthElt(vals); clearErrors(); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); errExpected = new String[]{ XmlErrorCodes.DATATYPE_LENGTH_VALID$LIST_LENGTH @@ -91,7 +90,7 @@ public class ListRestriction extends Bas assertEquals("lstlarge", (String) doc.xgetMinLengthElt().getListValue().get(0)); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_LENGTH_VALID$LIST_LENGTH @@ -108,14 +107,14 @@ public class ListRestriction extends Bas "lstsmall lstlarge lstsmall" + "</MaxLengthElt>"; MaxLengthEltDocument doc = MaxLengthEltDocument.Factory.parse(input); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_LENGTH_VALID$LIST_LENGTH}; assertTrue(compareErrorCodes(errExpected)); MaxLengthFacet elt = MaxLengthFacet.Factory.newInstance(); - List vals = new ArrayList(); + List<String> vals = new ArrayList<>(); vals.add("lstsmall"); vals.add("lstsmall"); //why is there no xsetListValue method here? @@ -135,7 +134,7 @@ public class ListRestriction extends Bas @Test public void testEnum() throws Throwable { EnumEltDocument doc = EnumEltDocument.Factory.newInstance(); - List vals = new ArrayList(); + List<Object> vals = new ArrayList<>(); vals.add("small"); vals.add("medium"); vals.add("large"); @@ -147,9 +146,9 @@ public class ListRestriction extends Bas throw t; } vals.clear(); - vals.add(new Integer(2)); - vals.add(new Integer(3)); - vals.add(new Integer(1)); + vals.add(2); + vals.add(3); + vals.add(1); doc.setEnumElt(vals); try { assertTrue(doc.validate(validateOptions)); @@ -160,9 +159,9 @@ public class ListRestriction extends Bas vals.clear(); vals.add("small"); - vals.add(new Integer(10)); + vals.add(10); doc.setEnumElt(vals); - assertTrue(!doc.validate(validateOptions)); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_VALID$UNION @@ -174,13 +173,13 @@ public class ListRestriction extends Bas @Test public void testPattern() throws Throwable { PatternEltDocument doc = PatternEltDocument.Factory.newInstance(); - List vals = new ArrayList(); - vals.add(new Integer(152)); - vals.add(new Integer(154)); - vals.add(new Integer(156)); - vals.add(new Integer(918)); + List<Integer> vals = new ArrayList<>(); + vals.add(152); + vals.add(154); + vals.add(156); + vals.add(918); - vals.add(new Integer(342)); + vals.add(342); doc.setPatternElt(vals); try { assertTrue(doc.validate(validateOptions)); Modified: xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/facets/detailed/UnionRestriction.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/facets/detailed/UnionRestriction.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/facets/detailed/UnionRestriction.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/scomp/derivation/restriction/facets/detailed/UnionRestriction.java Mon Dec 27 20:28:38 2021 @@ -15,14 +15,15 @@ package scomp.derivation.restriction.facets.detailed; +import org.apache.xmlbeans.XmlErrorCodes; import org.junit.Test; import scomp.common.BaseCase; -import xbean.scomp.derivation.facets.union.UnionPatternEltDocument; +import xbean.scomp.derivation.facets.union.SmallEnumUnion; import xbean.scomp.derivation.facets.union.SmallPatternUnion; import xbean.scomp.derivation.facets.union.UnionEnumEltDocument; -import xbean.scomp.derivation.facets.union.SmallEnumUnion; -import org.apache.xmlbeans.XmlErrorCodes; +import xbean.scomp.derivation.facets.union.UnionPatternEltDocument; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -42,7 +43,7 @@ public class UnionRestriction extends Ba showErrors(); throw t; } - doc.setUnionPatternElt(new Integer(1)); + doc.setUnionPatternElt(1); try { assertTrue(doc.validate(validateOptions)); } catch (Throwable t) { @@ -50,7 +51,7 @@ public class UnionRestriction extends Ba throw t; } SmallPatternUnion elt = SmallPatternUnion.Factory.newInstance(); - elt.setObjectValue(new Integer(2)); + elt.setObjectValue(2); doc.xsetUnionPatternElt(elt); try { assertTrue(doc.validate(validateOptions)); @@ -58,8 +59,8 @@ public class UnionRestriction extends Ba showErrors(); throw t; } - doc.setUnionPatternElt(new Integer(-1)); - assertTrue(!doc.validate(validateOptions)); + doc.setUnionPatternElt(-1); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID @@ -77,7 +78,7 @@ public class UnionRestriction extends Ba showErrors(); throw t; } - doc.setUnionEnumElt(new Integer(1)); + doc.setUnionEnumElt(1); try { assertTrue(doc.validate(validateOptions)); } catch (Throwable t) { @@ -85,7 +86,7 @@ public class UnionRestriction extends Ba throw t; } SmallEnumUnion elt = SmallEnumUnion.Factory.newInstance(); - elt.setObjectValue(new Integer(-1)); + elt.setObjectValue(-1); doc.xsetUnionEnumElt(elt); try { assertTrue(doc.validate(validateOptions)); @@ -93,8 +94,8 @@ public class UnionRestriction extends Ba showErrors(); throw t; } - doc.setUnionEnumElt(new Integer(2)); - assertTrue(!doc.validate(validateOptions)); + doc.setUnionEnumElt(2); + assertFalse(doc.validate(validateOptions)); showErrors(); String[] errExpected = new String[]{ XmlErrorCodes.DATATYPE_ENUM_VALID Modified: xmlbeans/branches/gradle-build/src/test/java/scomp/elements/detailed/GlobalEltNillable.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/scomp/elements/detailed/GlobalEltNillable.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/scomp/elements/detailed/GlobalEltNillable.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/scomp/elements/detailed/GlobalEltNillable.java Mon Dec 27 20:28:38 2021 @@ -56,8 +56,7 @@ public class GlobalEltNillable extends B XmlOptions options = new XmlOptions(); options.setValidateOnSet(); - GlobalEltNotNillableDocument testElt = GlobalEltNotNillableDocument - .Factory.newInstance(options); + GlobalEltNotNillableDocument testElt = GlobalEltNotNillableDocument.Factory.newInstance(options); try { testElt.setNil(); fail("Expected XmlValueNotNillableException"); @@ -72,14 +71,17 @@ public class GlobalEltNillable extends B catch (XmlValueNotNillableException e) { } + options.setValidateOnSet(false); + testElt = GlobalEltNotNillableDocument.Factory.newInstance(options); testElt.setGlobalEltNotNillable(null); + //assert that value is cleared assertEquals("<glob:GlobalEltNotNillable " + "xsi:nil=\"true\" " + "xmlns:glob=\"http://xbean/scomp/element/GlobalEltNillable\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>" ,testElt.xmlText()); - assertTrue(!testElt.validate(validateOptions)); + assertFalse(testElt.validate(validateOptions)); assertEquals(1, errorList.size()); showErrors(); String[] errExpected = @@ -206,7 +208,7 @@ public class GlobalEltNillable extends B throw t; } testElt.getGlobalEltComplex().setNil(); - assertEquals("<pre:GlobalEltComplex " + + assertEquals("<pre:GlobalEltComplex " + "testattribute=\"foobar\" " + "xsi:nil=\"true\" " + "xmlns:pre=\"http://xbean/scomp/element/GlobalEltNillable\" " + Modified: xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/averageCase/checkin/AverageTest.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/averageCase/checkin/AverageTest.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/averageCase/checkin/AverageTest.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/averageCase/checkin/AverageTest.java Mon Dec 27 20:28:38 2021 @@ -15,22 +15,19 @@ package xmlobject.extensions.interfaceFeature.averageCase.checkin; -import interfaceFeature.xbean.averageCase.purchaseOrder.PurchaseOrderDocument ; -import interfaceFeature.xbean.averageCase.purchaseOrder.PurchaseOrderType; import interfaceFeature.xbean.averageCase.purchaseOrder.Items; - -import junit.framework.*; +import interfaceFeature.xbean.averageCase.purchaseOrder.PurchaseOrderDocument; +import interfaceFeature.xbean.averageCase.purchaseOrder.PurchaseOrderType; +import org.junit.Test; import java.math.BigDecimal; +import static org.junit.Assert.assertEquals; -public class AverageTest extends TestCase{ - - public AverageTest(String s){ - super(s); - } +public class AverageTest { + @Test public void test(){ PurchaseOrderDocument poDoc ; Modified: xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/methodNameCollision/checkin/NameCollisionTest.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/methodNameCollision/checkin/NameCollisionTest.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/methodNameCollision/checkin/NameCollisionTest.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/methodNameCollision/checkin/NameCollisionTest.java Mon Dec 27 20:28:38 2021 @@ -14,21 +14,20 @@ */ package xmlobject.extensions.interfaceFeature.methodNameCollision.checkin; -import junit.framework.TestCase; import interfaceFeature.xbean.methodNameCollision.company.CompanyDocument; import interfaceFeature.xbean.methodNameCollision.company.CompanyType; -import interfaceFeature.xbean.methodNameCollision.company.DepartmentType; import interfaceFeature.xbean.methodNameCollision.company.ConsultantType; -import xmlobject.extensions.interfaceFeature.methodNameCollision.existing.IFoo; - +import interfaceFeature.xbean.methodNameCollision.company.DepartmentType; import org.apache.xmlbeans.XmlString; +import org.junit.Test; +import xmlobject.extensions.interfaceFeature.methodNameCollision.existing.IFoo; -public class NameCollisionTest extends TestCase { +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; - public NameCollisionTest(String s) { - super(s); - } +public class NameCollisionTest { + @Test public void test() { CompanyDocument poDoc; Modified: xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/multInterfaces/checkin/MultInterfacesTest.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/multInterfaces/checkin/MultInterfacesTest.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/multInterfaces/checkin/MultInterfacesTest.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/multInterfaces/checkin/MultInterfacesTest.java Mon Dec 27 20:28:38 2021 @@ -14,27 +14,21 @@ */ package xmlobject.extensions.interfaceFeature.multInterfaces.checkin; -import interfaceFeature.xbean.multInterfaces.purchaseOrder.PurchaseOrderDocument; -import interfaceFeature.xbean.multInterfaces.purchaseOrder.PurchaseOrderType; import interfaceFeature.xbean.multInterfaces.purchaseOrder.Items; import interfaceFeature.xbean.multInterfaces.purchaseOrder.Items.Item; - -import java.math.BigDecimal; - +import interfaceFeature.xbean.multInterfaces.purchaseOrder.PurchaseOrderDocument; +import interfaceFeature.xbean.multInterfaces.purchaseOrder.PurchaseOrderType; import org.apache.xmlbeans.XmlObject; +import org.junit.Test; +import java.math.BigDecimal; -import junit.framework.*; - -public class MultInterfacesTest extends TestCase { +import static org.junit.Assert.assertEquals; - public MultInterfacesTest(String s) { - super(s); - } +public class MultInterfacesTest { + @Test public void test() { - - PurchaseOrderDocument poDoc = null; poDoc = PurchaseOrderDocument.Factory.newInstance(); Modified: xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/readOnlyBean/checkin/ReadOnlyTest.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/readOnlyBean/checkin/ReadOnlyTest.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/readOnlyBean/checkin/ReadOnlyTest.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/interfaceFeature/readOnlyBean/checkin/ReadOnlyTest.java Mon Dec 27 20:28:38 2021 @@ -15,22 +15,18 @@ package xmlobject.extensions.interfaceFeature.readOnlyBean.checkin; +import interfaceFeature.xbean.readOnlyBean.purchaseOrder.Items; import interfaceFeature.xbean.readOnlyBean.purchaseOrder.PurchaseOrderDocument; import interfaceFeature.xbean.readOnlyBean.purchaseOrder.PurchaseOrderType; -import interfaceFeature.xbean.readOnlyBean.purchaseOrder.Items; - +import org.junit.Test; import java.math.BigDecimal; -import junit.framework.*; - -public class ReadOnlyTest extends TestCase { - - - public ReadOnlyTest(String s) { - super(s); - } +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +public class ReadOnlyTest { + @Test public void test() { PurchaseOrderDocument poDoc; @@ -75,8 +71,6 @@ public class ReadOnlyTest extends TestCa System.exit(-1); } - assertTrue(!poDoc.validate()); } - } Modified: xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/prePostFeature/ValueRestriction/checkin/ValueRestrictionTest.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/prePostFeature/ValueRestriction/checkin/ValueRestrictionTest.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/prePostFeature/ValueRestriction/checkin/ValueRestrictionTest.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/prePostFeature/ValueRestriction/checkin/ValueRestrictionTest.java Mon Dec 27 20:28:38 2021 @@ -14,17 +14,20 @@ */ package xmlobject.extensions.prePostFeature.ValueRestriction.checkin; -import junit.framework.TestCase; -import prePostFeature.xbean.valueRestriction.company.*; import org.apache.xmlbeans.XmlString; +import org.junit.Test; +import prePostFeature.xbean.valueRestriction.company.CompanyDocument; +import prePostFeature.xbean.valueRestriction.company.CompanyType; +import prePostFeature.xbean.valueRestriction.company.ConsultantType; +import prePostFeature.xbean.valueRestriction.company.DepartmentType; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -public class ValueRestrictionTest extends TestCase { - public ValueRestrictionTest(String s) { - super(s); - } +public class ValueRestrictionTest { + @Test public void test() throws Exception { CompanyDocument poDoc; Modified: xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/prePostFeature/readOnlyBean/checkin/ReadOnlyTest.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/prePostFeature/readOnlyBean/checkin/ReadOnlyTest.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/prePostFeature/readOnlyBean/checkin/ReadOnlyTest.java (original) +++ xmlbeans/branches/gradle-build/src/test/java/xmlobject/extensions/prePostFeature/readOnlyBean/checkin/ReadOnlyTest.java Mon Dec 27 20:28:38 2021 @@ -15,20 +15,18 @@ package xmlobject.extensions.prePostFeature.readOnlyBean.checkin; -import prePostFeature.xbean.readOnlyBean.purchaseOrder.PurchaseOrderDocument ; -import prePostFeature.xbean.readOnlyBean.purchaseOrder.PurchaseOrderType; +import org.junit.Test; import prePostFeature.xbean.readOnlyBean.purchaseOrder.Items; - +import prePostFeature.xbean.readOnlyBean.purchaseOrder.PurchaseOrderDocument; +import prePostFeature.xbean.readOnlyBean.purchaseOrder.PurchaseOrderType; import java.math.BigDecimal; -import junit.framework.*; - -public class ReadOnlyTest extends TestCase{ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; - public ReadOnlyTest(String s){ - super(s); - } +public class ReadOnlyTest { + @Test public void test(){ PurchaseOrderDocument poDoc ; Modified: xmlbeans/branches/gradle-build/src/test/resources/xbean/compile/scomp/partials/impl/RootDocumentImpl.java URL: http://svn.apache.org/viewvc/xmlbeans/branches/gradle-build/src/test/resources/xbean/compile/scomp/partials/impl/RootDocumentImpl.java?rev=1896456&r1=1896455&r2=1896456&view=diff ============================================================================== --- xmlbeans/branches/gradle-build/src/test/resources/xbean/compile/scomp/partials/impl/RootDocumentImpl.java (original) +++ xmlbeans/branches/gradle-build/src/test/resources/xbean/compile/scomp/partials/impl/RootDocumentImpl.java Mon Dec 27 20:28:38 2021 @@ -10,6 +10,7 @@ package partials.impl; import javax.xml.namespace.QName; import org.apache.xmlbeans.QNameSet; +import org.apache.xmlbeans.XmlObject; /** * A document containing one root(@partials) element. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
