author | joehw |
Wed, 11 Jan 2017 13:06:04 -0800 | |
changeset 43121 | e73af7b6ce47 |
parent 40582 | 1dddef49982c |
permissions | -rw-r--r-- |
33543 | 1 |
/* |
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
33543 | 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 |
||
40223
64662417aa2d
8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents:
33543
diff
changeset
|
26 |
import static jaxp.library.JAXPTestUtilities.setSystemProperty; |
64662417aa2d
8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents:
33543
diff
changeset
|
27 |
|
33543 | 28 |
import static catalog.CatalogTestUtils.FEATURE_FILES; |
29 |
import static catalog.CatalogTestUtils.catalogResolver; |
|
30 |
import static catalog.CatalogTestUtils.catalogUriResolver; |
|
31 |
import static catalog.CatalogTestUtils.getCatalogPath; |
|
32 |
import static catalog.ResolutionChecker.checkSysIdResolution; |
|
33 |
import static catalog.ResolutionChecker.checkUriResolution; |
|
34 |
import static javax.xml.catalog.CatalogFeatures.builder; |
|
35 |
import static javax.xml.catalog.CatalogFeatures.Feature.FILES; |
|
36 |
||
37 |
import javax.xml.catalog.CatalogFeatures; |
|
38 |
import javax.xml.catalog.CatalogResolver; |
|
39 |
||
40223
64662417aa2d
8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents:
33543
diff
changeset
|
40 |
import org.testng.annotations.Listeners; |
33543 | 41 |
import org.testng.annotations.Test; |
42 |
||
43 |
/* |
|
44 |
* @test |
|
45 |
* @bug 8077931 |
|
40223
64662417aa2d
8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents:
33543
diff
changeset
|
46 |
* @library /javax/xml/jaxp/libs |
64662417aa2d
8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents:
33543
diff
changeset
|
47 |
* @run testng/othervm -DrunSecMngr=true catalog.SpecifyCatalogTest |
64662417aa2d
8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents:
33543
diff
changeset
|
48 |
* @run testng/othervm catalog.SpecifyCatalogTest |
33543 | 49 |
* @summary This case tests how to specify the catalog files. |
50 |
*/ |
|
40223
64662417aa2d
8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents:
33543
diff
changeset
|
51 |
@Listeners({jaxp.library.FilePolicy.class}) |
33543 | 52 |
public class SpecifyCatalogTest { |
53 |
||
54 |
private static final String ID_URI = "http://remote/dtd/uri/doc.dtd"; |
|
55 |
private static final String ID_SYS = "http://remote/dtd/sys/doc.dtd"; |
|
56 |
||
57 |
private static final CatalogFeatures FILES_FEATURE = createFeature( |
|
58 |
"specifyCatalog-feature.xml"); |
|
59 |
||
60 |
/* |
|
61 |
* CatalogResolver specifies catalog via feature javax.xml.catalog.files. |
|
62 |
*/ |
|
63 |
@Test |
|
64 |
public void specifyCatalogOnEntityResolver() { |
|
65 |
checkSysIdResolution(catalogResolver(FILES_FEATURE, (String[]) null), |
|
66 |
ID_SYS, "http://local/base/dtd/docFeatureSys.dtd"); |
|
67 |
} |
|
68 |
||
69 |
/* |
|
40582
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
40223
diff
changeset
|
70 |
* CatalogResolver specifies catalog via feature javax.xml.catalog.files. |
33543 | 71 |
*/ |
72 |
@Test |
|
73 |
public void specifyCatalogOnUriResolver() { |
|
74 |
checkUriResolution(catalogUriResolver(FILES_FEATURE, (String[]) null), |
|
75 |
ID_URI, "http://local/base/dtd/docFeatureURI.dtd"); |
|
76 |
} |
|
77 |
||
78 |
/* |
|
79 |
* Resolver specifies catalog via system property javax.xml.catalog.files. |
|
80 |
*/ |
|
81 |
@Test |
|
82 |
public void specifyCatalogViaSysProps() { |
|
40223
64662417aa2d
8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents:
33543
diff
changeset
|
83 |
setSystemProperty(FEATURE_FILES, |
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
84 |
getCatalogPath("specifyCatalog-sysProps.xml").toASCIIString()); |
33543 | 85 |
|
86 |
checkResolutionOnEntityResolver(catalogResolver((String[]) null), |
|
87 |
"http://local/base/dtd/docSysPropsSys.dtd"); |
|
88 |
checkResolutionOnEntityResolver( |
|
89 |
catalogResolver(FILES_FEATURE, "specifyCatalog-api.xml"), |
|
90 |
"http://local/base/dtd/docAPISys.dtd"); |
|
91 |
||
92 |
checkResolutionOnUriResolver(catalogUriResolver((String[]) null), |
|
93 |
"http://local/base/dtd/docSysPropsURI.dtd"); |
|
94 |
checkResolutionOnUriResolver( |
|
95 |
catalogUriResolver(FILES_FEATURE, "specifyCatalog-api.xml"), |
|
96 |
"http://local/base/dtd/docAPIURI.dtd"); |
|
97 |
} |
|
98 |
||
99 |
private void checkResolutionOnEntityResolver(CatalogResolver resolver, |
|
100 |
String matchedUri) { |
|
101 |
checkSysIdResolution(resolver, ID_SYS, matchedUri); |
|
102 |
} |
|
103 |
||
40582
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
40223
diff
changeset
|
104 |
private void checkResolutionOnUriResolver(CatalogResolver resolver, |
33543 | 105 |
String matchedUri) { |
106 |
checkUriResolution(resolver, ID_URI, matchedUri); |
|
107 |
} |
|
108 |
||
109 |
private static CatalogFeatures createFeature(String catalogName) { |
|
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
110 |
return builder().with(FILES, getCatalogPath(catalogName).toASCIIString()).build(); |
33543 | 111 |
} |
112 |
} |