< prev index next >

test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.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.PREFER_PUBLIC;
  27 import static catalog.CatalogTestUtils.PREFER_SYSTEM;
  28 import static catalog.CatalogTestUtils.catalogResolver;
  29 import static javax.xml.catalog.CatalogFeatures.Feature.PREFER;
  30 
  31 import javax.xml.catalog.CatalogException;
  32 import javax.xml.catalog.CatalogFeatures;
  33 import javax.xml.catalog.CatalogResolver;
  34 
  35 import org.testng.annotations.DataProvider;

  36 import org.testng.annotations.Test;
  37 
  38 /*
  39  * @test
  40  * @bug 8077931
  41  * @summary This case tests how does the feature affect the catalog resolution,
  42  *          and tests the priority between this feature and attribute prefer
  43  *          in catalog file.
  44  * @compile ../../libs/catalog/CatalogTestUtils.java
  45  */

  46 public class PreferFeatureTest {
  47 
  48     @Test(dataProvider = "prefer-publicId-systemId",
  49             expectedExceptions = CatalogException.class)
  50     public void testPreferFeature(String prefer, String systemId,
  51             String publicId) {
  52         createResolver(prefer).resolveEntity(systemId, publicId);
  53     }
  54 
  55     @DataProvider(name = "prefer-publicId-systemId")
  56     private Object[][] data() {
  57         return new Object[][] {
  58                 // The feature prefer is system. There's a match for the
  59                 // specified public id, and no match for the specified system id.
  60                 // But the resolver cannot find the expected match, and raises a
  61                 // CatalogException.
  62                 { PREFER_SYSTEM, "-//REMOTE//DTD ALICE DOCALICE XML//EN",
  63                         "http://remote/dtd/alice/docAliceDummy.dtd" },
  64 
  65                 // The feature prefer is public, and the prefer attribute of a
   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.PREFER_PUBLIC;
  27 import static catalog.CatalogTestUtils.PREFER_SYSTEM;
  28 import static catalog.CatalogTestUtils.catalogResolver;
  29 import static javax.xml.catalog.CatalogFeatures.Feature.PREFER;
  30 
  31 import javax.xml.catalog.CatalogException;
  32 import javax.xml.catalog.CatalogFeatures;
  33 import javax.xml.catalog.CatalogResolver;
  34 
  35 import org.testng.annotations.DataProvider;
  36 import org.testng.annotations.Listeners;
  37 import org.testng.annotations.Test;
  38 
  39 /*
  40  * @test
  41  * @bug 8077931
  42  * @summary This case tests how does the feature affect the catalog resolution,
  43  *          and tests the priority between this feature and attribute prefer
  44  *          in catalog file.
  45  * @compile ../../libs/catalog/CatalogTestUtils.java
  46  */
  47 @Listeners({jaxp.library.FilePolicy.class})
  48 public class PreferFeatureTest {
  49 
  50     @Test(dataProvider = "prefer-publicId-systemId",
  51             expectedExceptions = CatalogException.class)
  52     public void testPreferFeature(String prefer, String systemId,
  53             String publicId) {
  54         createResolver(prefer).resolveEntity(systemId, publicId);
  55     }
  56 
  57     @DataProvider(name = "prefer-publicId-systemId")
  58     private Object[][] data() {
  59         return new Object[][] {
  60                 // The feature prefer is system. There's a match for the
  61                 // specified public id, and no match for the specified system id.
  62                 // But the resolver cannot find the expected match, and raises a
  63                 // CatalogException.
  64                 { PREFER_SYSTEM, "-//REMOTE//DTD ALICE DOCALICE XML//EN",
  65                         "http://remote/dtd/alice/docAliceDummy.dtd" },
  66 
  67                 // The feature prefer is public, and the prefer attribute of a
< prev index next >