< prev index next >

test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.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.catalogResolver;
  27 
  28 import javax.xml.catalog.CatalogException;
  29 
  30 import org.testng.annotations.DataProvider;

  31 import org.testng.annotations.Test;
  32 
  33 /*
  34  * @test
  35  * @bug 8077931
  36  * @summary Via nextCatalog entry, the catalog reference chain may be
  37  *          a (partial) closed circuit. For instance, a catalog may use itself
  38  *          as an additional catalog specified in its own nextCatalog entry.
  39  *          This case tests if the implementation handles this issue.
  40  * @compile ../../libs/catalog/CatalogTestUtils.java
  41  */

  42 public class CatalogReferCircularityTest {
  43 
  44     @Test(dataProvider = "catalogName",
  45             expectedExceptions = CatalogException.class)
  46     public void testReferCircularity(String catalogFile) {
  47         catalogResolver(catalogFile).resolveEntity(null,
  48                 "http://remote/dtd/ghost/docGhost.dtd");
  49     }
  50 
  51     @DataProvider(name = "catalogName")
  52     private Object[][] catalogName() {
  53         return new Object[][] {
  54                 // This catalog defines itself as next catalog.
  55                 { "catalogReferCircle-itself.xml" },
  56 
  57                 // This catalog defines catalogReferCircle-right.xml as its next
  58                 // catalog. And catalogReferCircle-right.xml also defines
  59                 // catalogReferCircle-left.xml as its next catalog, too.
  60                 { "catalogReferCircle-left.xml" } };
  61     }
   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.catalogResolver;
  27 
  28 import javax.xml.catalog.CatalogException;
  29 
  30 import org.testng.annotations.DataProvider;
  31 import org.testng.annotations.Listeners;
  32 import org.testng.annotations.Test;
  33 
  34 /*
  35  * @test
  36  * @bug 8077931
  37  * @summary Via nextCatalog entry, the catalog reference chain may be
  38  *          a (partial) closed circuit. For instance, a catalog may use itself
  39  *          as an additional catalog specified in its own nextCatalog entry.
  40  *          This case tests if the implementation handles this issue.
  41  * @compile ../../libs/catalog/CatalogTestUtils.java
  42  */
  43 @Listeners({jaxp.library.FilePolicy.class})
  44 public class CatalogReferCircularityTest {
  45 
  46     @Test(dataProvider = "catalogName",
  47             expectedExceptions = CatalogException.class)
  48     public void testReferCircularity(String catalogFile) {
  49         catalogResolver(catalogFile).resolveEntity(null,
  50                 "http://remote/dtd/ghost/docGhost.dtd");
  51     }
  52 
  53     @DataProvider(name = "catalogName")
  54     private Object[][] catalogName() {
  55         return new Object[][] {
  56                 // This catalog defines itself as next catalog.
  57                 { "catalogReferCircle-itself.xml" },
  58 
  59                 // This catalog defines catalogReferCircle-right.xml as its next
  60                 // catalog. And catalogReferCircle-right.xml also defines
  61                 // catalogReferCircle-left.xml as its next catalog, too.
  62                 { "catalogReferCircle-left.xml" } };
  63     }
< prev index next >