The Android Open Source Project | a0881d0 | 2009-01-09 17:50:54 -0800 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | This Java source file was generated by test-to-java.xsl |
| 4 | and is a derived work from the source document. |
| 5 | The source document contained the following notice: |
| 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 | See W3C License http://www.w3.org/Consortium/Legal/ for more details. |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | package org.w3c.domts.level1.core; |
| 21 | |
| 22 | import org.w3c.dom.*; |
| 23 | |
| 24 | |
| 25 | import org.w3c.domts.DOMTestCase; |
| 26 | import org.w3c.domts.DOMTestDocumentBuilderFactory; |
| 27 | |
| 28 | |
| 29 | |
| 30 | /** |
| 31 | * A comment is all the characters between the starting |
| 32 | * '<!--' and ending '-->' |
| 33 | * Retrieve the nodes of the DOM document. Search for a |
| 34 | * comment node and the content is its value. |
| 35 | * @author NIST |
| 36 | * @author Mary Brady |
| 37 | * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328</a> |
| 38 | * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095</a> |
| 39 | * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080</a> |
| 40 | * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558</a> |
| 41 | */ |
| 42 | public final class commentgetcomment extends DOMTestCase { |
| 43 | |
| 44 | /** |
| 45 | * Constructor. |
| 46 | * @param factory document factory, may not be null |
| 47 | * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration |
| 48 | */ |
| 49 | public commentgetcomment(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { |
| 50 | super(factory); |
| 51 | |
| 52 | // |
| 53 | // check if loaded documents are supported for content type |
| 54 | // |
| 55 | String contentType = getContentType(); |
| 56 | preload(contentType, "staff", false); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Runs the test case. |
| 61 | * @throws Throwable Any uncaught exception causes test to fail |
| 62 | */ |
| 63 | public void runTest() throws Throwable { |
| 64 | Document doc; |
| 65 | NodeList elementList; |
| 66 | Node child; |
| 67 | String childName; |
| 68 | String childValue; |
| 69 | int commentCount = 0; |
| 70 | int childType; |
| 71 | doc = (Document) load("staff", false); |
| 72 | elementList = doc.getChildNodes(); |
| 73 | for (int indexN10057 = 0; indexN10057 < elementList.getLength(); indexN10057++) { |
| 74 | child = (Node) elementList.item(indexN10057); |
| 75 | childType = (int) child.getNodeType(); |
| 76 | |
| 77 | if (equals(8, childType)) { |
| 78 | childName = child.getNodeName(); |
| 79 | assertEquals("nodeName", "#comment", childName); |
| 80 | childValue = child.getNodeValue(); |
| 81 | assertEquals("nodeValue", " This is comment number 1.", childValue); |
| 82 | commentCount = commentCount + 1; |
| 83 | } |
| 84 | } |
| 85 | assertEquals("commentCount", 1, commentCount); |
| 86 | } |
| 87 | /** |
| 88 | * Gets URI that identifies the test. |
| 89 | * @return uri identifier of test |
| 90 | */ |
| 91 | public String getTargetURI() { |
| 92 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/commentgetcomment"; |
| 93 | } |
| 94 | /** |
| 95 | * Runs this test from the command line. |
| 96 | * @param args command line arguments |
| 97 | */ |
| 98 | public static void main(final String[] args) { |
| 99 | DOMTestCase.doMain(commentgetcomment.class, args); |
| 100 | } |
| 101 | } |
| 102 | |