< prev index next >

test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.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 
  24 package catalog;
  25 
  26 import static catalog.CatalogTestUtils.CATALOG_SYSTEM;
  27 import static catalog.CatalogTestUtils.CATALOG_URI;
  28 import static catalog.CatalogTestUtils.catalogResolver;
  29 import static catalog.CatalogTestUtils.catalogUriResolver;
  30 import static catalog.ResolutionChecker.checkSysIdResolution;
  31 import static catalog.ResolutionChecker.checkUriResolution;
  32 
  33 import javax.xml.catalog.CatalogException;
  34 

  35 import org.testng.annotations.Test;
  36 
  37 /*
  38  * @test
  39  * @bug 8077931
  40  * @summary A legal catalog file must be well-formed XML, the root element
  41  *          must be catalog, and the naming space of the root element must be
  42  *          urn:oasis:names:tc:entity:xmlns:xml:catalog.
  43  * @compile ../../libs/catalog/CatalogTestUtils.java
  44  * @compile ../../libs/catalog/ResolutionChecker.java
  45  */

  46 public class ValidateCatalogTest {
  47 
  48     private static final String CATALOG_WRONGROOT = "validateCatalog-wrongRoot.xml";
  49     private static final String CATALOG_MALFORMED = "validateCatalog-malformed.xml";
  50 
  51     /*
  52      * EntityResolver tries to load catalog with wrong root,
  53      * it should throw CatalogException.
  54      */
  55     @Test(expectedExceptions = CatalogException.class)
  56     public void validateWrongRootCatalogOnEntityResolver() {
  57         catalogResolver(CATALOG_WRONGROOT);
  58     }
  59 
  60     /*
  61      * URIResolver tries to load catalog with wrong root,
  62      * it should throw CatalogException.
  63      */
  64     @Test(expectedExceptions = CatalogException.class)
  65     public void validateWrongRootCatalogOnUriResolver() {


   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 
  24 package catalog;
  25 
  26 import static catalog.CatalogTestUtils.CATALOG_SYSTEM;
  27 import static catalog.CatalogTestUtils.CATALOG_URI;
  28 import static catalog.CatalogTestUtils.catalogResolver;
  29 import static catalog.CatalogTestUtils.catalogUriResolver;
  30 import static catalog.ResolutionChecker.checkSysIdResolution;
  31 import static catalog.ResolutionChecker.checkUriResolution;
  32 
  33 import javax.xml.catalog.CatalogException;
  34 
  35 import org.testng.annotations.Listeners;
  36 import org.testng.annotations.Test;
  37 
  38 /*
  39  * @test
  40  * @bug 8077931
  41  * @summary A legal catalog file must be well-formed XML, the root element
  42  *          must be catalog, and the naming space of the root element must be
  43  *          urn:oasis:names:tc:entity:xmlns:xml:catalog.
  44  * @compile ../../libs/catalog/CatalogTestUtils.java
  45  * @compile ../../libs/catalog/ResolutionChecker.java
  46  */
  47 @Listeners({jaxp.library.FilePolicy.class})
  48 public class ValidateCatalogTest {
  49 
  50     private static final String CATALOG_WRONGROOT = "validateCatalog-wrongRoot.xml";
  51     private static final String CATALOG_MALFORMED = "validateCatalog-malformed.xml";
  52 
  53     /*
  54      * EntityResolver tries to load catalog with wrong root,
  55      * it should throw CatalogException.
  56      */
  57     @Test(expectedExceptions = CatalogException.class)
  58     public void validateWrongRootCatalogOnEntityResolver() {
  59         catalogResolver(CATALOG_WRONGROOT);
  60     }
  61 
  62     /*
  63      * URIResolver tries to load catalog with wrong root,
  64      * it should throw CatalogException.
  65      */
  66     @Test(expectedExceptions = CatalogException.class)
  67     public void validateWrongRootCatalogOnUriResolver() {


< prev index next >