< prev index next >

test/javax/xml/jaxp/unittest/dom/ElementTraversal.java

Print this page


   1 /*
   2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package dom;
  24 
  25 import java.io.IOException;
  26 import java.io.InputStream;
  27 import javax.xml.parsers.DocumentBuilder;
  28 import javax.xml.parsers.DocumentBuilderFactory;
  29 import javax.xml.parsers.ParserConfigurationException;
  30 import org.testng.Assert;
  31 import org.testng.annotations.DataProvider;

  32 import org.testng.annotations.Test;
  33 import org.w3c.dom.Document;
  34 import org.w3c.dom.DOMImplementation;
  35 import org.w3c.dom.Element;
  36 import org.xml.sax.SAXException;
  37 
  38 /*
  39  * @bug 8135283 8138721
  40  * @summary Tests for the Element Traversal interface.
  41  */
  42 

  43 public class ElementTraversal {
  44     /*
  45        Verifies that ElementTraversal is supported.
  46      */
  47     @Test(dataProvider = "doc")
  48     public void testHasFeature(Document doc) {
  49         DOMImplementation di = doc.getImplementation();
  50 
  51         //return false if feasure == null
  52         Assert.assertFalse(di.hasFeature(null, null));
  53 
  54         //A feature is supported without specifying version
  55         Assert.assertTrue(di.hasFeature("ElementTraversal", null));
  56         Assert.assertTrue(di.hasFeature("ElementTraversal", ""));
  57 
  58         //ElementTraversal Version 1.0 is supported
  59         Assert.assertTrue(di.hasFeature("ElementTraversal", "1.0"));
  60     }
  61 
  62     /*


   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package dom;
  24 
  25 import java.io.IOException;
  26 import java.io.InputStream;
  27 import javax.xml.parsers.DocumentBuilder;
  28 import javax.xml.parsers.DocumentBuilderFactory;
  29 import javax.xml.parsers.ParserConfigurationException;
  30 import org.testng.Assert;
  31 import org.testng.annotations.DataProvider;
  32 import org.testng.annotations.Listeners;
  33 import org.testng.annotations.Test;
  34 import org.w3c.dom.Document;
  35 import org.w3c.dom.DOMImplementation;
  36 import org.w3c.dom.Element;
  37 import org.xml.sax.SAXException;
  38 
  39 /*
  40  * @bug 8135283 8138721
  41  * @summary Tests for the Element Traversal interface.
  42  */
  43 
  44 @Listeners({jaxp.library.FilePolicy.class})
  45 public class ElementTraversal {
  46     /*
  47        Verifies that ElementTraversal is supported.
  48      */
  49     @Test(dataProvider = "doc")
  50     public void testHasFeature(Document doc) {
  51         DOMImplementation di = doc.getImplementation();
  52 
  53         //return false if feasure == null
  54         Assert.assertFalse(di.hasFeature(null, null));
  55 
  56         //A feature is supported without specifying version
  57         Assert.assertTrue(di.hasFeature("ElementTraversal", null));
  58         Assert.assertTrue(di.hasFeature("ElementTraversal", ""));
  59 
  60         //ElementTraversal Version 1.0 is supported
  61         Assert.assertTrue(di.hasFeature("ElementTraversal", "1.0"));
  62     }
  63 
  64     /*


< prev index next >