1 /*
2 * Copyright (c) 2014, 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 parsers;
25
26 import java.io.IOException;
27
28 import javax.xml.parsers.DocumentBuilder;
29 import javax.xml.parsers.DocumentBuilderFactory;
30 import javax.xml.parsers.ParserConfigurationException;
31
32 import org.testng.Assert;
33 import org.testng.annotations.Test;
34 import org.w3c.dom.Document;
35 import org.xml.sax.SAXException;
36
37 /*
38 * @bug 7166896
39 * @summary Test DocumentBuilder.parse(String uri) supports IPv6 format.
40 */
41 public class Bug7166896Test {
42
43 @Test
44 public void test() throws Exception {
45 final String url = "http://[fe80::la03:73ff:fead:f7b0]/note.xml";
46 final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
47 domFactory.setNamespaceAware(true);
48 DocumentBuilder builder;
49 Document doc = null;
50 System.out.println("URL is " + url);
51 try {
52 builder = domFactory.newDocumentBuilder();
53 // here comes the MalformedURLException. With Java6 / 7 it looks
54 // like this:
55 // java.net.MalformedURLException: For input string:
56 // ":la03:73ff:fead:f7b0%5D"
57 // which is not fine.
58 // with xerces 2.11.0 it complains about a non-existing host, which
59 // is fine
60 System.out.println("passing URL to DocumentBuilder.parse()");
|
1 /*
2 * Copyright (c) 2014, 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 parsers;
25
26 import java.io.IOException;
27
28 import javax.xml.parsers.DocumentBuilder;
29 import javax.xml.parsers.DocumentBuilderFactory;
30 import javax.xml.parsers.ParserConfigurationException;
31
32 import org.testng.Assert;
33 import org.testng.annotations.Listeners;
34 import org.testng.annotations.Test;
35 import org.w3c.dom.Document;
36 import org.xml.sax.SAXException;
37
38 /*
39 * @bug 7166896
40 * @summary Test DocumentBuilder.parse(String uri) supports IPv6 format.
41 */
42 @Listeners({jaxp.library.BasePolicy.class})
43 public class Bug7166896Test {
44
45 @Test
46 public void test() throws Exception {
47 final String url = "http://[fe80::la03:73ff:fead:f7b0]/note.xml";
48 final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
49 domFactory.setNamespaceAware(true);
50 DocumentBuilder builder;
51 Document doc = null;
52 System.out.println("URL is " + url);
53 try {
54 builder = domFactory.newDocumentBuilder();
55 // here comes the MalformedURLException. With Java6 / 7 it looks
56 // like this:
57 // java.net.MalformedURLException: For input string:
58 // ":la03:73ff:fead:f7b0%5D"
59 // which is not fine.
60 // with xerces 2.11.0 it complains about a non-existing host, which
61 // is fine
62 System.out.println("passing URL to DocumentBuilder.parse()");
|