author | aefimov |
Tue, 22 Jul 2014 22:06:52 +0400 | |
changeset 25665 | 0646dc563d47 |
child 30820 | 0d4717a011d3 |
permissions | -rw-r--r-- |
25665
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
1 |
/* |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
4 |
* |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
8 |
* |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
13 |
* accompanied this code). |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
14 |
* |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
18 |
* |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
21 |
* questions. |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
22 |
*/ |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
23 |
|
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
24 |
/* |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
25 |
* @test |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
26 |
* @bug 8029837 |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
27 |
* @summary Test simulates the partial call to xjc ant task that fails with |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
28 |
* NullPointer exception |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
29 |
* @run main/othervm PreParseGrammarTest |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
30 |
*/ |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
31 |
|
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
32 |
import com.sun.org.apache.xerces.internal.parsers.XMLGrammarPreparser; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
33 |
import com.sun.org.apache.xerces.internal.xni.XNIException; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
34 |
import com.sun.org.apache.xerces.internal.xni.grammars.Grammar; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
35 |
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
36 |
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
37 |
import java.io.BufferedInputStream; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
38 |
import java.io.File; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
39 |
import java.io.FileInputStream; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
40 |
import java.io.FileNotFoundException; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
41 |
import java.io.IOException; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
42 |
import java.io.InputStream; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
43 |
|
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
44 |
public class PreParseGrammarTest { |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
45 |
|
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
46 |
public static void main(String[] args) throws FileNotFoundException, XNIException, IOException { |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
47 |
File xsdf = new File(System.getProperty("test.src", ".") + "/test.xsd"); |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
48 |
InputStream is = new BufferedInputStream(new FileInputStream(xsdf)); |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
49 |
XMLInputSource xis = new XMLInputSource(null, null, null, is, null); |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
50 |
XMLGrammarPreparser gp = new XMLGrammarPreparser(); |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
51 |
gp.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null); |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
52 |
//The NullPointerException is observed on next call during ant task |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
53 |
// execution |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
54 |
Grammar res = gp.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, xis); |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
55 |
System.out.println("Grammar preparsed successfully:" + res); |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
56 |
return; |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
57 |
} |
0646dc563d47
8029837: NPE seen in XMLDocumentFragmentScannerImpl.setProperty since 7u40b33
aefimov
parents:
diff
changeset
|
58 |
} |