FileDocCategorySizeDatePackage
NodeIsSupported.javaAPI DocAndroid 1.5 API8078Wed May 06 22:41:06 BST 2009tests.org.w3c.dom

NodeIsSupported

public final class NodeIsSupported extends DOMTestCase
The method "isSupported(feature,version)" Tests whether the DOM implementation implements a specific feature and that feature is supported by this node. Call the isSupported method on the document element node with a combination of features versions and versions as below. Valid feature names are case insensitive and versions "2.0", "1.0" and if the version is not specified, supporting any version of the feature should return true. Check if the value returned value was true.
author
IBM
author
Neil Delima
see
http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-Node-supports

Fields Summary
DOMDocumentBuilderFactory
factory
DocumentBuilder
builder
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
        try {
            factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
                    .getConfiguration1());
            builder = factory.getBuilder();
        } catch (Exception e) {
            fail("Unexpected exception" + e.getMessage());
        }
    
protected voidtearDown()

        factory = null;
        builder = null;
        super.tearDown();
    
public voidtestIsSupported1()
Runs the test case.

throws
Throwable Any uncaught exception causes test to fail

        Document doc;
        Element element;
        String version = "";
        String version1 = "1.0";
        String version2 = "2.0";
        String featureCore;
        String featureXML;
        boolean success;
        List<String> featuresXML = new ArrayList<String>();
        featuresXML.add("XML");
        featuresXML.add("xmL");

        List<String> featuresCore = new ArrayList<String>();
        featuresCore.add("Core");
        featuresCore.add("CORE");

        doc = (Document) load("staffNS", builder);
        element = doc.getDocumentElement();
        for (int indexN10063 = 0; indexN10063 < featuresXML.size(); indexN10063++) {
            featureXML = (String) featuresXML.get(indexN10063);
            success = element.isSupported(featureXML, version);
            assertTrue("nodeissupported01_XML1", success);
            success = element.isSupported(featureXML, version1);
            assertTrue("nodeissupported01_XML2", success);
        }
        for (int indexN1007C = 0; indexN1007C < featuresCore.size(); indexN1007C++) {
            featureCore = (String) featuresCore.get(indexN1007C);
            success = element.isSupported(featureCore, version);
            assertTrue("nodeissupported01_Core1", success);
            success = element.isSupported(featureCore, version1);
            success = element.isSupported(featureCore, version2);
            assertTrue("nodeissupported01_Core3", success);
        }
    
public voidtestIsSupported2()

        Document doc;
        Attr attribute;
        String version = "";
        String version1 = "1.0";
        String version2 = "2.0";
        String featureCore;
        String featureXML;
        boolean success;
        List<String> featuresXML = new ArrayList<String>();
        featuresXML.add("XML");
        featuresXML.add("xmL");

        List<String> featuresCore = new ArrayList<String>();
        featuresCore.add("Core");
        featuresCore.add("CORE");

        doc = (Document) load("staffNS", builder);
        attribute = doc.createAttribute("TestAttr");
        for (int indexN10064 = 0; indexN10064 < featuresXML.size(); indexN10064++) {
            featureXML = (String) featuresXML.get(indexN10064);
            success = attribute.isSupported(featureXML, version);
            assertTrue("nodeissupported02_XML1", success);
            success = attribute.isSupported(featureXML, version1);
            assertTrue("nodeissupported02_XML2", success);
        }
        for (int indexN1007D = 0; indexN1007D < featuresCore.size(); indexN1007D++) {
            featureCore = (String) featuresCore.get(indexN1007D);
            success = attribute.isSupported(featureCore, version);
            assertTrue("nodeissupported02_Core1", success);
            success = attribute.isSupported(featureCore, version1);
            success = attribute.isSupported(featureCore, version2);
            assertTrue("nodeissupported02_Core3", success);
        }
    
public voidtestIsSupported3()

        Document doc;
        DocumentType docType;
        boolean success;
        doc = (Document) load("staffNS", builder);
        docType = doc.getDoctype();
        success = docType.isSupported("", "");
        assertFalse("nodeissupported03", success);
    
public voidtestIsSupported4()

        Document doc;
        EntityReference entRef;
        boolean success;
        doc = (Document) load("staffNS", builder);
        entRef = doc.createEntityReference("ent1");
        assertNotNull("createdEntRefNotNull", entRef);
        success = entRef.isSupported("XML CORE", "");
        assertFalse("nodeissupported04", success);
    
public voidtestIsSupported5()

        Document doc;
        ProcessingInstruction pi;
        boolean success;
        doc = (Document) load("staffNS", builder);
        pi = doc.createProcessingInstruction("PITarget", "PIData");
        success = pi.isSupported("-", "+");
        assertFalse("nodeissupported05", success);