< prev index next >

test/javax/xml/jaxp/functional/org/w3c/dom/ptests/AbstractCharacterDataTest.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 org.w3c.dom.ptests;
  24 
  25 import static org.testng.Assert.assertEquals;
  26 import static org.testng.Assert.fail;
  27 import static org.w3c.dom.DOMException.INDEX_SIZE_ERR;
  28 import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED;
  29 
  30 import java.io.IOException;
  31 
  32 import javax.xml.parsers.ParserConfigurationException;
  33 
  34 import jaxp.library.JAXPFileBaseTest;
  35 
  36 import org.testng.annotations.DataProvider;
  37 import org.testng.annotations.Test;
  38 import org.w3c.dom.CharacterData;
  39 import org.w3c.dom.DOMException;
  40 import org.xml.sax.SAXException;
  41 
  42 /*
  43  * @summary common test for the CharacterData Interface
  44  */
  45 public abstract class AbstractCharacterDataTest extends JAXPFileBaseTest {
  46     @DataProvider(name = "data-for-length")
  47     public Object[][] getDataForTestLength() {
  48         return new Object[][] {
  49                 { "", 0 },
  50                 { "test", 4 } };
  51     }
  52 
  53     /*
  54      * Verify getLength method works as the spec, for an empty string, should
  55      * return zero
  56      */
  57     @Test(dataProvider = "data-for-length")
  58     public void testGetLength(String text, int length) throws Exception {
  59         CharacterData cd = createCharacterData(text);
  60         assertEquals(cd.getLength(), length);
  61 
  62     }
  63 
  64     /*
  65      * Test appendData method and verify by getData method.


   1 /*
   2  * Copyright (c) 2015, 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 org.w3c.dom.ptests;
  24 
  25 import static org.testng.Assert.assertEquals;
  26 import static org.testng.Assert.fail;
  27 import static org.w3c.dom.DOMException.INDEX_SIZE_ERR;
  28 import static org.w3c.dom.ptests.DOMTestUtil.DOMEXCEPTION_EXPECTED;
  29 
  30 import java.io.IOException;
  31 
  32 import javax.xml.parsers.ParserConfigurationException;
  33 


  34 import org.testng.annotations.DataProvider;
  35 import org.testng.annotations.Test;
  36 import org.w3c.dom.CharacterData;
  37 import org.w3c.dom.DOMException;
  38 import org.xml.sax.SAXException;
  39 
  40 /*
  41  * @summary common test for the CharacterData Interface
  42  */
  43 public abstract class AbstractCharacterDataTest {
  44     @DataProvider(name = "data-for-length")
  45     public Object[][] getDataForTestLength() {
  46         return new Object[][] {
  47                 { "", 0 },
  48                 { "test", 4 } };
  49     }
  50 
  51     /*
  52      * Verify getLength method works as the spec, for an empty string, should
  53      * return zero
  54      */
  55     @Test(dataProvider = "data-for-length")
  56     public void testGetLength(String text, int length) throws Exception {
  57         CharacterData cd = createCharacterData(text);
  58         assertEquals(cd.getLength(), length);
  59 
  60     }
  61 
  62     /*
  63      * Test appendData method and verify by getData method.


< prev index next >