1 2/* 3This Java source file was generated by test-to-java.xsl 4and is a derived work from the source document. 5The source document contained the following notice: 6 7 8Copyright (c) 2001 World Wide Web Consortium, 9(Massachusetts Institute of Technology, Institut National de 10Recherche en Informatique et en Automatique, Keio University). All 11Rights Reserved. This program is distributed under the W3C's Software 12Intellectual Property License. This program is distributed in the 13hope that it will be useful, but WITHOUT ANY WARRANTY; without even 14the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15PURPOSE. 16See W3C License http://www.w3.org/Consortium/Legal/ for more details. 17 18*/ 19 20package org.w3c.domts.level1.core; 21 22import org.w3c.dom.*; 23 24 25import org.w3c.domts.DOMTestCase; 26import org.w3c.domts.DOMTestDocumentBuilderFactory; 27 28 29 30/** 31 * If there is not an explicit value assigned to an attribute 32 * and there is a declaration for this attribute and that 33 * declaration includes a default value, then that default 34 * value is the attributes default value. 35 * Retrieve the attribute named "street" from the last 36 * child of of the first employee and examine its 37 * value. That value should be the value given the 38 * attribute in the DTD file. The test uses the 39 * "getNamedItem(name)" method from the NamedNodeMap 40 * interface. 41* @author NIST 42* @author Mary Brady 43* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096</a> 44* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549</a> 45* @see <a href="http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html">http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html</a> 46*/ 47public final class attrdefaultvalue extends DOMTestCase { 48 49 /** 50 * Constructor. 51 * @param factory document factory, may not be null 52 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 53 */ 54 public attrdefaultvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 55 56 org.w3c.domts.DocumentBuilderSetting[] settings = 57 new org.w3c.domts.DocumentBuilderSetting[] { 58org.w3c.domts.DocumentBuilderSetting.validating 59 }; 60 DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); 61 setFactory(testFactory); 62 63 // 64 // check if loaded documents are supported for content type 65 // 66 String contentType = getContentType(); 67 preload(contentType, "staff", false); 68 } 69 70 /** 71 * Runs the test case. 72 * @throws Throwable Any uncaught exception causes test to fail 73 */ 74 public void runTest() throws Throwable { 75 Document doc; 76 NodeList addressList; 77 Node testNode; 78 NamedNodeMap attributes; 79 Attr streetAttr; 80 String value; 81 doc = (Document) load("staff", false); 82 addressList = doc.getElementsByTagName("address"); 83 testNode = addressList.item(0); 84 attributes = testNode.getAttributes(); 85 streetAttr = (Attr) attributes.getNamedItem("street"); 86 value = streetAttr.getNodeValue(); 87 assertEquals("attrDefaultValueAssert", "Yes", value); 88 } 89 /** 90 * Gets URI that identifies the test. 91 * @return uri identifier of test 92 */ 93 public String getTargetURI() { 94 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrdefaultvalue"; 95 } 96 /** 97 * Runs this test from the command line. 98 * @param args command line arguments 99 */ 100 public static void main(final String[] args) { 101 DOMTestCase.doMain(attrdefaultvalue.class, args); 102 } 103} 104 105