< prev index next >

test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java

Print this page




  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.RESOLVE_CONTINUE;
  29 import static catalog.CatalogTestUtils.RESOLVE_IGNORE;
  30 import static catalog.CatalogTestUtils.RESOLVE_STRICT;
  31 import static catalog.CatalogTestUtils.catalogResolver;
  32 import static catalog.CatalogTestUtils.catalogUriResolver;
  33 import static catalog.ResolutionChecker.checkSysIdResolution;
  34 import static catalog.ResolutionChecker.checkUriResolution;
  35 import static javax.xml.catalog.CatalogFeatures.builder;
  36 
  37 import javax.xml.catalog.CatalogException;
  38 import javax.xml.catalog.CatalogFeatures;
  39 import javax.xml.catalog.CatalogFeatures.Feature;
  40 import javax.xml.catalog.CatalogResolver;
  41 import javax.xml.catalog.CatalogUriResolver;
  42 
  43 import org.testng.annotations.Listeners;
  44 import org.testng.annotations.Test;
  45 
  46 /*
  47  * @test
  48  * @bug 8077931
  49  * @library /javax/xml/jaxp/libs
  50  * @run testng/othervm -DrunSecMngr=true catalog.ResolveFeatureTest
  51  * @run testng/othervm catalog.ResolveFeatureTest
  52  * @summary This case tests how does resolve feature affect the catalog
  53  *          resolution.
  54  */
  55 @Listeners({jaxp.library.FilePolicy.class})
  56 public class ResolveFeatureTest {
  57 
  58     /*
  59      * For strict external identifier resolution, if no match is found,
  60      * it should throw CatalogException.
  61      */


  76     }
  77 
  78     /*
  79      * For continue external identifier resolution, if no match is found,
  80      * it should continue the process.
  81      */
  82     @Test
  83     public void testContinueResolutionOnEntityResolver() {
  84         CatalogResolver resolver = createEntityResolver(RESOLVE_CONTINUE);
  85         resolver.resolveEntity(null, "http://remote/dtd/bob/docBobDummy.dtd");
  86         checkSysIdResolution(resolver, "http://remote/dtd/bob/docBob.dtd",
  87                 "http://local/base/dtd/docBobSys.dtd");
  88     }
  89 
  90     /*
  91      * For continue URI reference resolution, if no match is found,
  92      * it should continue the process.
  93      */
  94     @Test
  95     public void testContinueResolutionOnUriResolver() {
  96         CatalogUriResolver resolver = createUriResolver(RESOLVE_CONTINUE);
  97         resolver.resolve("http://remote/dtd/bob/docBobDummy.dtd", null);
  98         checkUriResolution(resolver, "http://remote/dtd/bob/docBob.dtd",
  99                 "http://local/base/dtd/docBobURI.dtd");
 100     }
 101 
 102     /*
 103      * For ignore external identifier resolution, if no match is found,
 104      * it should break the process and return null.
 105      */
 106     @Test
 107     public void testIgnoreResolutionOnEntityResolver() {
 108         checkSysIdResolution(createEntityResolver(RESOLVE_IGNORE),
 109                 "http://remote/dtd/carl/docCarlDummy.dtd", null);
 110     }
 111 
 112     /*
 113      * For ignore URI reference resolution, if no match is found,
 114      * it should break the process and return null.
 115      */
 116     @Test
 117     public void testIgnoreResolutionOnUriResolver() {
 118         checkUriResolution(createUriResolver(RESOLVE_IGNORE),
 119                 "http://remote/dtd/carl/docCarlDummy.dtd", null);
 120     }
 121 
 122     private CatalogResolver createEntityResolver(String resolve) {
 123         return catalogResolver(createFeature(resolve), CATALOG_SYSTEM);
 124     }
 125 
 126     private CatalogUriResolver createUriResolver(String resolve) {
 127         return catalogUriResolver(createFeature(resolve), CATALOG_URI);
 128     }
 129 
 130     private CatalogFeatures createFeature(String resolve) {
 131         return builder().with(Feature.RESOLVE, resolve).build();
 132     }
 133 }
 134 


  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.RESOLVE_CONTINUE;
  29 import static catalog.CatalogTestUtils.RESOLVE_IGNORE;
  30 import static catalog.CatalogTestUtils.RESOLVE_STRICT;
  31 import static catalog.CatalogTestUtils.catalogResolver;
  32 import static catalog.CatalogTestUtils.catalogUriResolver;
  33 import static catalog.ResolutionChecker.checkSysIdResolution;
  34 import static catalog.ResolutionChecker.checkUriResolution;
  35 import static javax.xml.catalog.CatalogFeatures.builder;
  36 
  37 import javax.xml.catalog.CatalogException;
  38 import javax.xml.catalog.CatalogFeatures;
  39 import javax.xml.catalog.CatalogFeatures.Feature;
  40 import javax.xml.catalog.CatalogResolver;

  41 
  42 import org.testng.annotations.Listeners;
  43 import org.testng.annotations.Test;
  44 
  45 /*
  46  * @test
  47  * @bug 8077931
  48  * @library /javax/xml/jaxp/libs
  49  * @run testng/othervm -DrunSecMngr=true catalog.ResolveFeatureTest
  50  * @run testng/othervm catalog.ResolveFeatureTest
  51  * @summary This case tests how does resolve feature affect the catalog
  52  *          resolution.
  53  */
  54 @Listeners({jaxp.library.FilePolicy.class})
  55 public class ResolveFeatureTest {
  56 
  57     /*
  58      * For strict external identifier resolution, if no match is found,
  59      * it should throw CatalogException.
  60      */


  75     }
  76 
  77     /*
  78      * For continue external identifier resolution, if no match is found,
  79      * it should continue the process.
  80      */
  81     @Test
  82     public void testContinueResolutionOnEntityResolver() {
  83         CatalogResolver resolver = createEntityResolver(RESOLVE_CONTINUE);
  84         resolver.resolveEntity(null, "http://remote/dtd/bob/docBobDummy.dtd");
  85         checkSysIdResolution(resolver, "http://remote/dtd/bob/docBob.dtd",
  86                 "http://local/base/dtd/docBobSys.dtd");
  87     }
  88 
  89     /*
  90      * For continue URI reference resolution, if no match is found,
  91      * it should continue the process.
  92      */
  93     @Test
  94     public void testContinueResolutionOnUriResolver() {
  95         CatalogResolver resolver = createUriResolver(RESOLVE_CONTINUE);
  96         resolver.resolve("http://remote/dtd/bob/docBobDummy.dtd", null);
  97         checkUriResolution(resolver, "http://remote/dtd/bob/docBob.dtd",
  98                 "http://local/base/dtd/docBobURI.dtd");
  99     }
 100 
 101     /*
 102      * For ignore external identifier resolution, if no match is found,
 103      * it should break the process and return null.
 104      */
 105     @Test
 106     public void testIgnoreResolutionOnEntityResolver() {
 107         checkSysIdResolution(createEntityResolver(RESOLVE_IGNORE),
 108                 "http://remote/dtd/carl/docCarlDummy.dtd", null);
 109     }
 110 
 111     /*
 112      * For ignore URI reference resolution, if no match is found,
 113      * it should break the process and return null.
 114      */
 115     @Test
 116     public void testIgnoreResolutionOnUriResolver() {
 117         checkUriResolution(createUriResolver(RESOLVE_IGNORE),
 118                 "http://remote/dtd/carl/docCarlDummy.dtd", null);
 119     }
 120 
 121     private CatalogResolver createEntityResolver(String resolve) {
 122         return catalogResolver(createFeature(resolve), CATALOG_SYSTEM);
 123     }
 124 
 125     private CatalogResolver createUriResolver(String resolve) {
 126         return catalogUriResolver(createFeature(resolve), CATALOG_URI);
 127     }
 128 
 129     private CatalogFeatures createFeature(String resolve) {
 130         return builder().with(Feature.RESOLVE, resolve).build();
 131     }
 132 }

< prev index next >