Skip to content

Commit 554e38d

Browse files
committed
8359337: XML/JAXP tests that make network connections should ensure that no proxy is selected
Reviewed-by: dfuchs, iris, joehw Backport-of: 7583a7b
1 parent b5b0b3a commit 554e38d

File tree

5 files changed

+121
-31
lines changed

5 files changed

+121
-31
lines changed

test/jaxp/javax/xml/jaxp/unittest/common/catalog/DOMTest.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,8 +22,12 @@
2222
*/
2323
package common.catalog;
2424

25-
/**
26-
* @test @bug 8306055
25+
import java.net.ProxySelector;
26+
27+
/*
28+
* @test
29+
* @bug 8306055 8359337
30+
* @summary verifies DOM's support of the JDK Catalog.
2731
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
2832
* @modules java.xml/jdk.xml.internal
2933
* @run driver common.catalog.DOMTest 0 // verifies default setting catalog.resolve=allow
@@ -36,11 +40,18 @@
3640
* @run driver common.catalog.DOMTest 7 // verifies external DTD resolution with a custom Catalog while resolve=strict in API setting
3741
* @run driver common.catalog.DOMTest 8 // verifies external parameter are resolved with a custom Catalog though resolve=strict in API setting
3842
* @run driver common.catalog.DOMTest 9 // verifies XInclude are resolved with a custom Catalog though resolve=strict in API setting
39-
* @summary verifies DOM's support of the JDK Catalog.
4043
*/
4144
public class DOMTest extends CatalogTestBase {
42-
public static void main(String args[]) throws Exception {
43-
new DOMTest().run(args[0]);
45+
public static void main(String[] args) throws Exception {
46+
final ProxySelector previous = ProxySelector.getDefault();
47+
// disable proxy
48+
ProxySelector.setDefault(ProxySelector.of(null));
49+
try {
50+
new DOMTest().run(args[0]);
51+
} finally {
52+
// reset to the previous proxy selector
53+
ProxySelector.setDefault(previous);
54+
}
4455
}
4556

4657
public void run(String index) throws Exception {

test/jaxp/javax/xml/jaxp/unittest/common/catalog/SAXTest.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,8 +22,12 @@
2222
*/
2323
package common.catalog;
2424

25-
/**
26-
* @test @bug 8306055
25+
import java.net.ProxySelector;
26+
27+
/*
28+
* @test
29+
* @bug 8306055 8359337
30+
* @summary verifies DOM's support of the JDK Catalog.
2731
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
2832
* @modules java.xml/jdk.xml.internal
2933
* @run driver common.catalog.SAXTest 0 // verifies default setting catalog.resolve=allow
@@ -36,12 +40,18 @@
3640
* @run driver common.catalog.SAXTest 7 // verifies external DTD resolution with a custom Catalog while resolve=strict in API setting
3741
* @run driver common.catalog.SAXTest 8 // verifies external parameter are resolved with a custom Catalog though resolve=strict in API setting
3842
* @run driver common.catalog.SAXTest 9 // verifies XInclude are resolved with a custom Catalog though resolve=strict in API setting
39-
* @summary verifies DOM's support of the JDK Catalog.
40-
4143
*/
4244
public class SAXTest extends CatalogTestBase {
43-
public static void main(String args[]) throws Exception {
44-
new SAXTest().run(args[0]);
45+
public static void main(String[] args) throws Exception {
46+
final ProxySelector previous = ProxySelector.getDefault();
47+
// disable proxy
48+
ProxySelector.setDefault(ProxySelector.of(null));
49+
try {
50+
new SAXTest().run(args[0]);
51+
} finally {
52+
// reset to the previous proxy selector
53+
ProxySelector.setDefault(previous);
54+
}
4555
}
4656

4757
public void run(String index) throws Exception {

test/jaxp/javax/xml/jaxp/unittest/common/dtd/DOMTest.java

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3-
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
2+
* Copyright (c) 2023, 2025, 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.
422
*/
523
package common.dtd;
624

7-
/**
8-
* @test @bug 8306632
25+
import java.net.ProxySelector;
26+
27+
/*
28+
* @test
29+
* @bug 8306632 8359337
30+
* @summary verifies DOM's support of the property jdk.xml.dtd.support.
931
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
1032
* @modules java.xml/jdk.xml.internal
1133
* @run driver common.dtd.DOMTest 0 // verifies default setting dtd.support=allow
@@ -15,11 +37,18 @@
1537
* @run driver common.dtd.DOMTest 4 // verifies DTD=ignore
1638
* @run driver common.dtd.DOMTest 5 // verifies disallow-doctype-decl=false
1739
* @run driver common.dtd.DOMTest 6 // verifies disallow-doctype-decl=true
18-
* @summary verifies DOM's support of the property jdk.xml.dtd.support.
1940
*/
2041
public class DOMTest extends DTDTestBase {
21-
public static void main(String args[]) throws Exception {
22-
new DOMTest().run(args[0]);
42+
public static void main(String[] args) throws Exception {
43+
final ProxySelector previous = ProxySelector.getDefault();
44+
// disable proxy
45+
ProxySelector.setDefault(ProxySelector.of(null));
46+
try {
47+
new DOMTest().run(args[0]);
48+
} finally {
49+
// reset to the previous proxy selector
50+
ProxySelector.setDefault(previous);
51+
}
2352
}
2453

2554
public void run(String index) throws Exception {

test/jaxp/javax/xml/jaxp/unittest/common/dtd/SAXTest.java

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3-
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
2+
* Copyright (c) 2023, 2025, 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.
422
*/
523
package common.dtd;
624

25+
import java.net.ProxySelector;
26+
727
import common.util.TestBase;
828

9-
/**
10-
* @test @bug 8306632
29+
/*
30+
* @test
31+
* @bug 8306632 8359337
32+
* @summary verifies SAX's support of the property jdk.xml.dtd.support.
1133
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
1234
* @modules java.xml/jdk.xml.internal
1335
* @run driver common.dtd.SAXTest 0 // verifies default setting dtd.support=allow
@@ -17,11 +39,18 @@
1739
* @run driver common.dtd.SAXTest 4 // verifies DTD=ignore
1840
* @run driver common.dtd.SAXTest 5 // verifies disallow-doctype-decl=false
1941
* @run driver common.dtd.SAXTest 6 // verifies disallow-doctype-decl=true
20-
* @summary verifies SAX's support of the property jdk.xml.dtd.support.
2142
*/
2243
public class SAXTest extends DTDTestBase {
23-
public static void main(String args[]) throws Exception {
24-
new SAXTest().run(args[0]);
44+
public static void main(String[] args) throws Exception {
45+
final ProxySelector previous = ProxySelector.getDefault();
46+
// disable proxy
47+
ProxySelector.setDefault(ProxySelector.of(null));
48+
try {
49+
new SAXTest().run(args[0]);
50+
} finally {
51+
// reset to the previous proxy selector
52+
ProxySelector.setDefault(previous);
53+
}
2554
}
2655

2756
public void run(String index) throws Exception {

test/jaxp/javax/xml/jaxp/unittest/dom/DOMFeatureTest.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,13 @@
2525
import java.io.ByteArrayInputStream;
2626
import java.io.IOException;
2727
import java.io.InputStream;
28+
import java.net.ProxySelector;
29+
2830
import javax.xml.parsers.DocumentBuilder;
2931
import javax.xml.parsers.DocumentBuilderFactory;
3032
import javax.xml.parsers.ParserConfigurationException;
3133
import org.testng.Assert;
34+
import org.testng.annotations.BeforeClass;
3235
import org.testng.annotations.DataProvider;
3336
import org.testng.annotations.Test;
3437
import org.w3c.dom.Document;
@@ -40,10 +43,11 @@
4043

4144
/*
4245
* @test
43-
* @bug 8206132
44-
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
45-
* @run testng dom.DOMFeatureTest
46+
* @bug 8206132 8359337
4647
* @summary Tests DOM features.
48+
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
49+
* @comment we use othervm because the test configures a system wide ProxySelector
50+
* @run testng/othervm dom.DOMFeatureTest
4751
*/
4852
public class DOMFeatureTest {
4953

@@ -105,6 +109,13 @@ Object[][] getData1() throws Exception {
105109
{true, XML3},
106110
};
107111
}
112+
113+
@BeforeClass
114+
static void beforeClass() {
115+
// disable proxy
116+
ProxySelector.setDefault(ProxySelector.of(null));
117+
}
118+
108119
/**
109120
* Verifies the EntityExpansion feature.
110121
* @param caseNo the case number

0 commit comments

Comments
 (0)