1/* 2 This Java source file was generated by test-to-java.xsl 3 and is a derived work from the source document. 4 The source document contained the following notice: 5 6 7 8 Copyright (c) 2001 World Wide Web Consortium, 9 (Massachusetts Institute of Technology, Institut National de 10 Recherche en Informatique et en Automatique, Keio University). All 11 Rights Reserved. This program is distributed under the W3C's Software 12 Intellectual Property License. This program is distributed in the 13 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15 PURPOSE. 16 17 See W3C License http://www.w3.org/Consortium/Legal/ for more details. 18 19 20 */ 21 22package tests.org.w3c.dom; 23 24import dalvik.annotation.TestTargets; 25import dalvik.annotation.TestLevel; 26import dalvik.annotation.TestTargetNew; 27import dalvik.annotation.TestTargetClass; 28 29import org.w3c.dom.Node; 30import org.w3c.dom.Document; 31import org.w3c.dom.NodeList; 32 33import javax.xml.parsers.DocumentBuilder; 34 35/** 36 * The "hasAttributes()" method for a node should return false if the node does 37 * not have an attribute. Retrieve the first "name" node and invoke the 38 * "hasAttributes()" method. The method should return false since the node does 39 * not have an attribute. 40 * 41 * @author NIST 42 * @author Mary Brady 43 * @see <a 44 * href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeHasAttrs</a> 45 */ 46@TestTargetClass(Node.class) 47public final class HasAttributes extends DOMTestCase { 48 49 DOMDocumentBuilderFactory factory; 50 51 DocumentBuilder builder; 52 53 protected void setUp() throws Exception { 54 super.setUp(); 55 try { 56 factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory 57 .getConfiguration1()); 58 builder = factory.getBuilder(); 59 } catch (Exception e) { 60 fail("Unexpected exception" + e.getMessage()); 61 } 62 } 63 64 protected void tearDown() throws Exception { 65 factory = null; 66 builder = null; 67 super.tearDown(); 68 } 69 70 /** 71 * Runs the test case. 72 * 73 * @throws Throwable 74 * Any uncaught exception causes test to fail 75 */ 76 @TestTargetNew( 77 level = TestLevel.PARTIAL_COMPLETE, 78 notes = "Verifies that hasAttributes method returns false value.", 79 method = "hasAttributes", 80 args = {} 81 ) 82 public void testHasAttributes1() throws Throwable { 83 Document doc; 84 NodeList addrList; 85 Node addrNode; 86 boolean state; 87 doc = (Document) load("staff", builder); 88 addrList = doc.getElementsByTagName("name"); 89 addrNode = addrList.item(0); 90 state = addrNode.hasAttributes(); 91 assertFalse("throw_False", state); 92 } 93 @TestTargetNew( 94 level = TestLevel.PARTIAL_COMPLETE, 95 notes = "Verifies that hasAttributes method returns true value.", 96 method = "hasAttributes", 97 args = {} 98 ) 99 public void testHasAttributes2() throws Throwable { 100 Document doc; 101 NodeList addrList; 102 Node addrNode; 103 boolean state; 104 doc = (Document) load("staff", builder); 105 addrList = doc.getElementsByTagName("address"); 106 addrNode = addrList.item(0); 107 state = addrNode.hasAttributes(); 108 assertTrue("throw_True", state); 109 } 110 111} 112