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.catalogResolver;
27 import static catalog.ResolutionChecker.checkExtIdResolution;
28
29 import javax.xml.catalog.CatalogResolver;
30
31 import org.testng.annotations.DataProvider;
32 import org.testng.annotations.Test;
33
34 /*
35 * @test
36 * @bug 8077931
37 * @summary Get matched URIs from system and public family entries, which
38 * specify the prefer attribute. It tests how does the prefer attribute
39 * affect the resolution procedure. The test rule is based on OASIS
40 * Standard V1.1 section 4.1.1. "The prefer attribute".
41 * @compile ../../libs/catalog/CatalogTestUtils.java
42 * @compile ../../libs/catalog/ResolutionChecker.java
43 */
44 public class PreferTest {
45
46 @Test(dataProvider = "publicId-systemId-matchedUri")
47 public void testPrefer(String publicId, String systemId,
48 String expected) {
49 checkExtIdResolution(createResolver(), publicId, systemId, expected);
50 }
51
52 @DataProvider(name = "publicId-systemId-matchedUri")
53 private Object[][] data() {
54 return new Object[][] {
55 // The prefer attribute is public. Both of the specified public
56 // id and system id have matches in the catalog file. But
57 // finally, the returned URI is the system match.
58 { "-//REMOTE//DTD ALICE DOCALICE XML//EN",
59 "http://remote/dtd/alice/docAlice.dtd",
60 "http://local/base/dtd/docAliceSys.dtd" },
61
62 // The prefer attribute is public, and only the specified system
63 // id has match. The returned URI is the system match.
|
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.catalogResolver;
27 import static catalog.ResolutionChecker.checkExtIdResolution;
28
29 import javax.xml.catalog.CatalogResolver;
30
31 import org.testng.annotations.DataProvider;
32 import org.testng.annotations.Listeners;
33 import org.testng.annotations.Test;
34
35 /*
36 * @test
37 * @bug 8077931
38 * @summary Get matched URIs from system and public family entries, which
39 * specify the prefer attribute. It tests how does the prefer attribute
40 * affect the resolution procedure. The test rule is based on OASIS
41 * Standard V1.1 section 4.1.1. "The prefer attribute".
42 * @compile ../../libs/catalog/CatalogTestUtils.java
43 * @compile ../../libs/catalog/ResolutionChecker.java
44 */
45 @Listeners({jaxp.library.FilePolicy.class})
46 public class PreferTest {
47
48 @Test(dataProvider = "publicId-systemId-matchedUri")
49 public void testPrefer(String publicId, String systemId,
50 String expected) {
51 checkExtIdResolution(createResolver(), publicId, systemId, expected);
52 }
53
54 @DataProvider(name = "publicId-systemId-matchedUri")
55 private Object[][] data() {
56 return new Object[][] {
57 // The prefer attribute is public. Both of the specified public
58 // id and system id have matches in the catalog file. But
59 // finally, the returned URI is the system match.
60 { "-//REMOTE//DTD ALICE DOCALICE XML//EN",
61 "http://remote/dtd/alice/docAlice.dtd",
62 "http://local/base/dtd/docAliceSys.dtd" },
63
64 // The prefer attribute is public, and only the specified system
65 // id has match. The returned URI is the system match.
|