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.CATALOG_PUBLIC;
27 import static catalog.CatalogTestUtils.CATALOG_SYSTEM;
28 import static catalog.CatalogTestUtils.CATALOG_URI;
29 import static catalog.CatalogTestUtils.catalogResolver;
30 import static catalog.CatalogTestUtils.catalogUriResolver;
31 import static catalog.ResolutionChecker.checkSysIdResolution;
32 import static catalog.ResolutionChecker.checkUriResolution;
33
34 import javax.xml.catalog.CatalogException;
35 import javax.xml.catalog.CatalogResolver;
36 import javax.xml.catalog.CatalogUriResolver;
37
38 import org.testng.annotations.DataProvider;
39 import org.testng.annotations.Test;
40
41 /*
42 * @test
43 * @bug 8077931
44 * @summary When catalog resolver loads catalog files, the current catalog file
45 * and the catalog files specified by the nextCatalog entries may not
46 * accessible. This case tests how does the resolver handle this issue.
47 * @compile ../../libs/catalog/CatalogTestUtils.java
48 * @compile ../../libs/catalog/ResolutionChecker.java
49 */
50 public class LoadCatalogTest {
51
52 private static final String CATALOG_LOADCATALOGFILES = "loadCatalogFiles.xml";
53 private static final String CATALOG_DUMMY = "dummy.xml";
54
55 private static final String ID_ALICE = "http://remote/dtd/alice/docAlice.dtd";
56 private static final String ID_DUMMY = "http://remote/dtd/doc.dtd";
57
58 @Test(dataProvider = "entityResolver")
59 public void testMatchOnEntityResolver(CatalogResolver resolver) {
60 checkSysIdResolution(resolver, ID_ALICE,
61 "http://local/dtd/docAliceSys.dtd");
62 }
63
64 @DataProvider(name = "entityResolver")
65 private Object[][] entityResolver() {
66 return new Object[][] {
67 // This EntityResolver loads multiple catalog files one by one.
68 // All of the files are available.
69 { catalogResolver(CATALOG_PUBLIC, CATALOG_URI,
|
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.CATALOG_PUBLIC;
27 import static catalog.CatalogTestUtils.CATALOG_SYSTEM;
28 import static catalog.CatalogTestUtils.CATALOG_URI;
29 import static catalog.CatalogTestUtils.catalogResolver;
30 import static catalog.CatalogTestUtils.catalogUriResolver;
31 import static catalog.ResolutionChecker.checkSysIdResolution;
32 import static catalog.ResolutionChecker.checkUriResolution;
33
34 import javax.xml.catalog.CatalogException;
35 import javax.xml.catalog.CatalogResolver;
36 import javax.xml.catalog.CatalogUriResolver;
37
38 import org.testng.annotations.DataProvider;
39 import org.testng.annotations.Listeners;
40 import org.testng.annotations.Test;
41
42 /*
43 * @test
44 * @bug 8077931
45 * @summary When catalog resolver loads catalog files, the current catalog file
46 * and the catalog files specified by the nextCatalog entries may not
47 * accessible. This case tests how does the resolver handle this issue.
48 * @compile ../../libs/catalog/CatalogTestUtils.java
49 * @compile ../../libs/catalog/ResolutionChecker.java
50 */
51 @Listeners({jaxp.library.FilePolicy.class})
52 public class LoadCatalogTest {
53
54 private static final String CATALOG_LOADCATALOGFILES = "loadCatalogFiles.xml";
55 private static final String CATALOG_DUMMY = "dummy.xml";
56
57 private static final String ID_ALICE = "http://remote/dtd/alice/docAlice.dtd";
58 private static final String ID_DUMMY = "http://remote/dtd/doc.dtd";
59
60 @Test(dataProvider = "entityResolver")
61 public void testMatchOnEntityResolver(CatalogResolver resolver) {
62 checkSysIdResolution(resolver, ID_ALICE,
63 "http://local/dtd/docAliceSys.dtd");
64 }
65
66 @DataProvider(name = "entityResolver")
67 private Object[][] entityResolver() {
68 return new Object[][] {
69 // This EntityResolver loads multiple catalog files one by one.
70 // All of the files are available.
71 { catalogResolver(CATALOG_PUBLIC, CATALOG_URI,
|