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
8
9Copyright (c) 2001 World Wide Web Consortium,
10(Massachusetts Institute of Technology, Institut National de
11Recherche en Informatique et en Automatique, Keio University).  All
12Rights Reserved.  This program is distributed under the W3C's Software
13Intellectual Property License.  This program is distributed in the
14hope that it will be useful, but WITHOUT ANY WARRANTY; without even
15the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16PURPOSE.
17
18See W3C License http://www.w3.org/Consortium/Legal/ for more details.
19
20
21*/
22
23package org.w3c.domts.level2.core;
24
25import org.w3c.dom.*;
26
27
28import org.w3c.domts.DOMTestCase;
29import org.w3c.domts.DOMTestDocumentBuilderFactory;
30
31
32
33/**
34 *  The method "hasFeature(feature,version)" tests if the DOMImplementation implements
35 *  a specific feature and if so returns true.
36 *
37 *  Call the hasFeature method on this DOMImplementation with a combination of features
38 *  versions as below.  Valid feature names are case insensitive and versions "2.0",
39 *  "1.0" and if the version is not specified, supporting any version of the feature
40 *  should return true.  Check if the value returned value was true.
41* @author IBM
42* @author Neil Delima
43* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-5CED94D7">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-5CED94D7</a>
44*/
45public final class domimplementationhasfeature01 extends DOMTestCase {
46
47   /**
48    * Constructor.
49    * @param factory document factory, may not be null
50    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
51    */
52   public domimplementationhasfeature01(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
53      super(factory);
54
55    //
56    //   check if loaded documents are supported for content type
57    //
58    String contentType = getContentType();
59    preload(contentType, "staffNS", false);
60    }
61
62   /**
63    * Runs the test case.
64    * @throws Throwable Any uncaught exception causes test to fail
65    */
66   public void runTest() throws Throwable {
67      Document doc;
68      DOMImplementation domImpl;
69      String version = "";
70      String version1 = "1.0";
71      String version2 = "2.0";
72      String featureCore;
73      String featureXML;
74      boolean success;
75      java.util.List featuresXML = new java.util.ArrayList();
76      featuresXML.add("XML");
77      featuresXML.add("xmL");
78
79      java.util.List featuresCore = new java.util.ArrayList();
80      featuresCore.add("Core");
81      featuresCore.add("CORE");
82
83      doc = (Document) load("staffNS", false);
84      domImpl = doc.getImplementation();
85      for (int indexN10063 = 0; indexN10063 < featuresXML.size(); indexN10063++) {
86          featureXML = (String) featuresXML.get(indexN10063);
87    success = domImpl.hasFeature(featureXML, version);
88assertTrue("domimplementationhasfeature01_XML_1", success);
89      success = domImpl.hasFeature(featureXML, version1);
90assertTrue("domimplementationhasfeature01_XML_2", success);
91        }
92      for (int indexN1007C = 0; indexN1007C < featuresCore.size(); indexN1007C++) {
93          featureCore = (String) featuresCore.get(indexN1007C);
94    success = domImpl.hasFeature(featureCore, version);
95assertTrue("domimplementationhasfeature01_Core_1", success);
96      success = domImpl.hasFeature(featureCore, version1);
97success = domImpl.hasFeature(featureCore, version2);
98assertTrue("domimplementationhasfeature01_Core_3", success);
99        }
100      }
101   /**
102    *  Gets URI that identifies the test.
103    *  @return uri identifier of test
104    */
105   public String getTargetURI() {
106      return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationhasfeature01";
107   }
108   /**
109    * Runs this test from the command line.
110    * @param args command line arguments
111    */
112   public static void main(final String[] args) {
113        DOMTestCase.doMain(domimplementationhasfeature01.class, args);
114   }
115}
116
117