< prev index next >

test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.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 java.io.File;
  27 import java.io.IOException;
  28 import java.nio.file.Files;
  29 import java.nio.file.Path;
  30 import java.nio.file.Paths;
  31 import java.util.Map;
  32 import java.util.stream.Collectors;
  33 import java.util.stream.Stream;
  34 
  35 import javax.xml.catalog.CatalogFeatures;
  36 import javax.xml.catalog.CatalogManager;
  37 import javax.xml.catalog.CatalogResolver;
  38 import javax.xml.catalog.CatalogUriResolver;
  39 
  40 import jaxp.library.JAXPTestUtilities;
  41 
  42 /*
  43  * Utilities for testing XML Catalog API.
  44  */
  45 final class CatalogTestUtils {
  46 
  47     /* catalog files */
  48     static final String CATALOG_PUBLIC = "public.xml";
  49     static final String CATALOG_SYSTEM = "system.xml";
  50     static final String CATALOG_URI = "uri.xml";
  51 
  52     /* features */
  53     static final String FEATURE_FILES = "javax.xml.catalog.files";
  54     static final String FEATURE_PREFER = "javax.xml.catalog.prefer";
  55     static final String FEATURE_DEFER = "javax.xml.catalog.defer";
  56     static final String FEATURE_RESOLVE = "javax.xml.catalog.resolve";
  57 
  58     /* values of prefer feature */


  84     /*
  85      * Creates CatalogResolver with a set of catalogs.
  86      */
  87     static CatalogResolver catalogResolver(String... catalogName) {
  88         return catalogResolver(CatalogFeatures.defaults(), catalogName);
  89     }
  90 
  91     /*
  92      * Creates CatalogResolver with a feature and a set of catalogs.
  93      */
  94     static CatalogResolver catalogResolver(CatalogFeatures features,
  95             String... catalogName) {
  96         return (catalogName == null) ?
  97                 CatalogManager.catalogResolver(features) :
  98                 CatalogManager.catalogResolver(features, getCatalogPaths(catalogName));
  99     }
 100 
 101     /*
 102      * Creates catalogUriResolver with a set of catalogs.
 103      */
 104     static CatalogUriResolver catalogUriResolver(String... catalogName) {
 105         return catalogUriResolver(CatalogFeatures.defaults(), catalogName);
 106     }
 107 
 108     /*
 109      * Creates catalogUriResolver with a feature and a set of catalogs.
 110      */
 111     static CatalogUriResolver catalogUriResolver(
 112             CatalogFeatures features, String... catalogName) {
 113         return (catalogName == null) ?
 114                 CatalogManager.catalogUriResolver(features) :
 115                 CatalogManager.catalogUriResolver(features, getCatalogPaths(catalogName));
 116     }
 117 
 118     // Gets the paths of the specified catalogs.
 119     private static String[] getCatalogPaths(String... catalogNames) {
 120         return catalogNames == null
 121                 ? null
 122                 : Stream.of(catalogNames).map(
 123                         catalogName -> getCatalogPath(catalogName)).collect(
 124                                 Collectors.toList()).toArray(new String[0]);
 125     }
 126 
 127     // Gets the paths of the specified catalogs.
 128     static String getCatalogPath(String catalogName) {
 129         return catalogName == null
 130                 ? null
 131                 : JAXPTestUtilities.getPathByClassName(CatalogTestUtils.class, "catalogFiles")
 132                         + catalogName;
 133     }
 134 
 135     /* ********** jaxp.properties ********** */


   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 java.io.File;
  27 import java.io.IOException;
  28 import java.nio.file.Files;
  29 import java.nio.file.Path;
  30 import java.nio.file.Paths;
  31 import java.util.Map;
  32 import java.util.stream.Collectors;
  33 import java.util.stream.Stream;
  34 
  35 import javax.xml.catalog.CatalogFeatures;
  36 import javax.xml.catalog.CatalogManager;
  37 import javax.xml.catalog.CatalogResolver;

  38 
  39 import jaxp.library.JAXPTestUtilities;
  40 
  41 /*
  42  * Utilities for testing XML Catalog API.
  43  */
  44 final class CatalogTestUtils {
  45 
  46     /* catalog files */
  47     static final String CATALOG_PUBLIC = "public.xml";
  48     static final String CATALOG_SYSTEM = "system.xml";
  49     static final String CATALOG_URI = "uri.xml";
  50 
  51     /* features */
  52     static final String FEATURE_FILES = "javax.xml.catalog.files";
  53     static final String FEATURE_PREFER = "javax.xml.catalog.prefer";
  54     static final String FEATURE_DEFER = "javax.xml.catalog.defer";
  55     static final String FEATURE_RESOLVE = "javax.xml.catalog.resolve";
  56 
  57     /* values of prefer feature */


  83     /*
  84      * Creates CatalogResolver with a set of catalogs.
  85      */
  86     static CatalogResolver catalogResolver(String... catalogName) {
  87         return catalogResolver(CatalogFeatures.defaults(), catalogName);
  88     }
  89 
  90     /*
  91      * Creates CatalogResolver with a feature and a set of catalogs.
  92      */
  93     static CatalogResolver catalogResolver(CatalogFeatures features,
  94             String... catalogName) {
  95         return (catalogName == null) ?
  96                 CatalogManager.catalogResolver(features) :
  97                 CatalogManager.catalogResolver(features, getCatalogPaths(catalogName));
  98     }
  99 
 100     /*
 101      * Creates catalogUriResolver with a set of catalogs.
 102      */
 103     static CatalogResolver catalogUriResolver(String... catalogName) {
 104         return catalogUriResolver(CatalogFeatures.defaults(), catalogName);
 105     }
 106 
 107     /*
 108      * Creates catalogUriResolver with a feature and a set of catalogs.
 109      */
 110     static CatalogResolver catalogUriResolver(
 111             CatalogFeatures features, String... catalogName) {
 112         return (catalogName == null) ?
 113                 CatalogManager.catalogResolver(features) :
 114                 CatalogManager.catalogResolver(features, getCatalogPaths(catalogName));
 115     }
 116 
 117     // Gets the paths of the specified catalogs.
 118     private static String[] getCatalogPaths(String... catalogNames) {
 119         return catalogNames == null
 120                 ? null
 121                 : Stream.of(catalogNames).map(
 122                         catalogName -> getCatalogPath(catalogName)).collect(
 123                                 Collectors.toList()).toArray(new String[0]);
 124     }
 125 
 126     // Gets the paths of the specified catalogs.
 127     static String getCatalogPath(String catalogName) {
 128         return catalogName == null
 129                 ? null
 130                 : JAXPTestUtilities.getPathByClassName(CatalogTestUtils.class, "catalogFiles")
 131                         + catalogName;
 132     }
 133 
 134     /* ********** jaxp.properties ********** */


< prev index next >