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 sax;
25
26 import java.io.IOException;
27 import java.io.StringReader;
28
29 import javax.xml.parsers.ParserConfigurationException;
30 import javax.xml.parsers.SAXParserFactory;
31
32 import org.testng.Assert;
33 import org.testng.annotations.Test;
34 import org.xml.sax.InputSource;
35 import org.xml.sax.SAXException;
36 import org.xml.sax.helpers.DefaultHandler;
37
38 /*
39 * @bug 6889654
40 * @summary Test SAXException includes whole information.
41 */
42 public class Bug6889654Test {
43
44 final String MSG = "Failed to parse XML";
45
46 @Test
47 public void testException() {
48 try {
49 parse();
50 } catch (SAXException e) {
51 // e.printStackTrace();
52 String msg = e.toString();
53 if (msg.indexOf("systemId") == -1) {
54 Assert.fail("CR6889654 -- details should be returned.");
55 }
56 if (msg.indexOf(MSG) == -1) {
57 Assert.fail("CR6889649 -- additional error message not returned.");
58 }
59 System.out.println("error message:\n" + msg);
60 }
61 }
|
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 sax;
25
26 import java.io.IOException;
27 import java.io.StringReader;
28
29 import javax.xml.parsers.ParserConfigurationException;
30 import javax.xml.parsers.SAXParserFactory;
31
32 import org.testng.Assert;
33 import org.testng.annotations.Listeners;
34 import org.testng.annotations.Test;
35 import org.xml.sax.InputSource;
36 import org.xml.sax.SAXException;
37 import org.xml.sax.helpers.DefaultHandler;
38
39 /*
40 * @bug 6889654
41 * @summary Test SAXException includes whole information.
42 */
43 @Listeners({jaxp.library.BasePolicy.class})
44 public class Bug6889654Test {
45
46 final String MSG = "Failed to parse XML";
47
48 @Test
49 public void testException() {
50 try {
51 parse();
52 } catch (SAXException e) {
53 // e.printStackTrace();
54 String msg = e.toString();
55 if (msg.indexOf("systemId") == -1) {
56 Assert.fail("CR6889654 -- details should be returned.");
57 }
58 if (msg.indexOf(MSG) == -1) {
59 Assert.fail("CR6889649 -- additional error message not returned.");
60 }
61 System.out.println("error message:\n" + msg);
62 }
63 }
|