Merge
This commit is contained in:
commit
690e40f3a4
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -743,7 +743,7 @@ public class XMLDocumentScannerImpl
|
||||
// scan XMLDecl
|
||||
try {
|
||||
if (fEntityScanner.skipString(XMLDECL)) {
|
||||
if (fEntityScanner.peekChar() == ' ') {
|
||||
if (XMLChar.isSpace(fEntityScanner.peekChar())) {
|
||||
fMarkupDepth++;
|
||||
scanXMLDeclOrTextDecl(false);
|
||||
} else {
|
||||
|
@ -415,9 +415,15 @@ public class XML11Configuration extends ParserConfigurationSettings
|
||||
/** Current DTD scanner. */
|
||||
protected XMLDTDScanner fCurrentDTDScanner;
|
||||
|
||||
/** Flag indiciating whether XML11 components have been initialized. */
|
||||
/** Flag indicating whether XML11 components have been initialized. */
|
||||
private boolean f11Initialized = false;
|
||||
|
||||
/** Flag indicating whether the symbol table instance was specified during construction **/
|
||||
private boolean fSymbolTableProvided = false;
|
||||
|
||||
/** Flag indicating if the symbol table was initialized and never used before that **/
|
||||
private boolean fSymbolTableJustInitialized = true;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
@ -566,15 +572,18 @@ public class XML11Configuration extends ParserConfigurationSettings
|
||||
};
|
||||
addRecognizedProperties(recognizedProperties);
|
||||
|
||||
if (symbolTable == null) {
|
||||
symbolTable = new SymbolTable();
|
||||
// Remember if symbolTable was provided from outside
|
||||
fSymbolTableProvided = symbolTable != null;
|
||||
if (!fSymbolTableProvided) {
|
||||
fSymbolTable = new SymbolTable();
|
||||
} else {
|
||||
fSymbolTable = symbolTable;
|
||||
}
|
||||
fSymbolTable = symbolTable;
|
||||
fProperties.put(SYMBOL_TABLE, fSymbolTable);
|
||||
|
||||
fGrammarPool = grammarPool;
|
||||
if (fGrammarPool != null) {
|
||||
fProperties.put(XMLGRAMMAR_POOL, fGrammarPool);
|
||||
fProperties.put(XMLGRAMMAR_POOL, fGrammarPool);
|
||||
}
|
||||
|
||||
fEntityManager = new XMLEntityManager();
|
||||
@ -840,6 +849,7 @@ public class XML11Configuration extends ParserConfigurationSettings
|
||||
fValidationManager.reset();
|
||||
fVersionDetector.reset(this);
|
||||
fConfigUpdated = true;
|
||||
resetSymbolTable();
|
||||
resetCommon();
|
||||
|
||||
short version = fVersionDetector.determineDocVersion(fInputSource);
|
||||
@ -858,15 +868,7 @@ public class XML11Configuration extends ParserConfigurationSettings
|
||||
// resets and sets the pipeline.
|
||||
fVersionDetector.startDocumentParsing((XMLEntityHandler) fCurrentScanner, version);
|
||||
fInputSource = null;
|
||||
} catch (XNIException ex) {
|
||||
if (PRINT_EXCEPTION_STACK_TRACE)
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
} catch (IOException ex) {
|
||||
if (PRINT_EXCEPTION_STACK_TRACE)
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
} catch (RuntimeException ex) {
|
||||
} catch (IOException | RuntimeException ex) {
|
||||
if (PRINT_EXCEPTION_STACK_TRACE)
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
@ -879,15 +881,7 @@ public class XML11Configuration extends ParserConfigurationSettings
|
||||
|
||||
try {
|
||||
return fCurrentScanner.scanDocument(complete);
|
||||
} catch (XNIException ex) {
|
||||
if (PRINT_EXCEPTION_STACK_TRACE)
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
} catch (IOException ex) {
|
||||
if (PRINT_EXCEPTION_STACK_TRACE)
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
} catch (RuntimeException ex) {
|
||||
} catch (IOException | RuntimeException ex) {
|
||||
if (PRINT_EXCEPTION_STACK_TRACE)
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
@ -1589,6 +1583,23 @@ public class XML11Configuration extends ParserConfigurationSettings
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the symbol table if it wasn't provided during construction
|
||||
* and its not the first time when parse is called after initialization
|
||||
*/
|
||||
private void resetSymbolTable() {
|
||||
if (!fSymbolTableProvided) {
|
||||
if (fSymbolTableJustInitialized) {
|
||||
// Skip symbol table reallocation for the first parsing process
|
||||
fSymbolTableJustInitialized = false;
|
||||
} else {
|
||||
fSymbolTable = new SymbolTable();
|
||||
fProperties.put(SYMBOL_TABLE, fSymbolTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of a feature. This method calls getFeature()
|
||||
* on ParserConfigurationSettings, bypassing getFeature() on this
|
||||
|
@ -1385,7 +1385,7 @@ abstract public class ToStream extends SerializerBase {
|
||||
return;
|
||||
|
||||
final boolean shouldNotFormat = !shouldFormatOutput();
|
||||
if (m_elemContext.m_startTagOpen && shouldNotFormat)
|
||||
if (m_elemContext.m_startTagOpen)
|
||||
{
|
||||
closeStartTag();
|
||||
m_elemContext.m_startTagOpen = false;
|
||||
@ -1411,8 +1411,12 @@ abstract public class ToStream extends SerializerBase {
|
||||
|
||||
if (m_disableOutputEscapingStates.peekOrFalse() || (!m_escaping))
|
||||
{
|
||||
charactersRaw(chars, start, length);
|
||||
m_isprevtext = true;
|
||||
if (shouldNotFormat) {
|
||||
charactersRaw(chars, start, length);
|
||||
m_isprevtext = true;
|
||||
} else {
|
||||
m_charactersBuffer.addRawText(chars, start, length);
|
||||
}
|
||||
// time to fire off characters generation event
|
||||
if (m_tracer != null)
|
||||
super.fireCharEvent(chars, start, length);
|
||||
@ -1420,7 +1424,7 @@ abstract public class ToStream extends SerializerBase {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_elemContext.m_startTagOpen && shouldNotFormat)
|
||||
if (m_elemContext.m_startTagOpen)
|
||||
{
|
||||
closeStartTag();
|
||||
m_elemContext.m_startTagOpen = false;
|
||||
@ -1447,6 +1451,13 @@ abstract public class ToStream extends SerializerBase {
|
||||
return m_doIndent && !m_ispreserveSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if the content in current element should be formatted.
|
||||
*/
|
||||
public boolean getIndent() {
|
||||
return shouldFormatOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out the characters.
|
||||
*
|
||||
@ -1550,12 +1561,7 @@ abstract public class ToStream extends SerializerBase {
|
||||
*/
|
||||
final protected void flushCharactersBuffer() throws SAXException {
|
||||
try {
|
||||
if (shouldFormatOutput() && m_charactersBuffer.hasContent()) {
|
||||
if (m_elemContext.m_startTagOpen) {
|
||||
closeStartTag();
|
||||
m_elemContext.m_startTagOpen = false;
|
||||
}
|
||||
|
||||
if (shouldFormatOutput() && m_charactersBuffer.isAnyCharactersBuffered()) {
|
||||
if (m_elemContext.m_isCdataSection) {
|
||||
/*
|
||||
* due to cdata-section-elements atribute, we need this as
|
||||
@ -1567,11 +1573,16 @@ abstract public class ToStream extends SerializerBase {
|
||||
}
|
||||
|
||||
m_childNodeNum++;
|
||||
boolean skipBeginningNewlines = false;
|
||||
if (shouldIndentForText()) {
|
||||
indent();
|
||||
m_startNewLine = true;
|
||||
// newline has always been added here because if this is the
|
||||
// text before the first element, shouldIndent() won't
|
||||
// return true.
|
||||
skipBeginningNewlines = true;
|
||||
}
|
||||
m_charactersBuffer.flush();
|
||||
m_charactersBuffer.flush(skipBeginningNewlines);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new SAXException(e);
|
||||
@ -2915,7 +2926,7 @@ abstract public class ToStream extends SerializerBase {
|
||||
String value,
|
||||
boolean xslAttribute)
|
||||
{
|
||||
if (m_charactersBuffer.isNoCharactersBuffered()) {
|
||||
if (!m_charactersBuffer.isAnyCharactersBuffered()) {
|
||||
return doAddAttributeAlways(uri, localName, rawName, type, value, xslAttribute);
|
||||
} else {
|
||||
/*
|
||||
@ -3396,15 +3407,16 @@ abstract public class ToStream extends SerializerBase {
|
||||
*/
|
||||
private abstract class GenericCharacters {
|
||||
/**
|
||||
* @return True if having any character other than whitespace or
|
||||
* line feed.
|
||||
* @return True if all characters in this Text are newlines.
|
||||
*/
|
||||
abstract boolean hasContent();
|
||||
|
||||
abstract void flush() throws SAXException;
|
||||
abstract boolean flush(boolean skipBeginningNewlines) throws SAXException;
|
||||
|
||||
/**
|
||||
* Converts this GenericCharacters to a new character array.
|
||||
* Converts this GenericCharacters to a new character array. This
|
||||
* method is used to handle cdata-section-elements attribute in
|
||||
* xsl:output. Therefore it doesn't need to consider
|
||||
* skipBeginningNewlines because the text will be involved with CDATA
|
||||
* tag.
|
||||
*/
|
||||
abstract char[] toChars();
|
||||
}
|
||||
@ -3422,27 +3434,21 @@ abstract public class ToStream extends SerializerBase {
|
||||
text = Arrays.copyOfRange(chars, start, start + length);
|
||||
}
|
||||
|
||||
boolean hasContent() {
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
if (!isWhiteSpace(text[i])) {
|
||||
boolean flush(boolean skipBeginningNewlines) throws SAXException {
|
||||
int start = 0;
|
||||
while (skipBeginningNewlines && text[start] == '\n') {
|
||||
start++;
|
||||
if (start == text.length) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
outputCharacters(text, start, text.length - start);
|
||||
return false;
|
||||
}
|
||||
|
||||
void flush() throws SAXException {
|
||||
outputCharacters(text, 0, text.length);
|
||||
}
|
||||
|
||||
char[] toChars() {
|
||||
return text;
|
||||
}
|
||||
|
||||
boolean isWhiteSpace(char ch) {
|
||||
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -3451,12 +3457,22 @@ abstract public class ToStream extends SerializerBase {
|
||||
*/
|
||||
public void addEntityReference(String entityName) {
|
||||
bufferedCharacters.add(new GenericCharacters() {
|
||||
boolean hasContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void flush() throws SAXException {
|
||||
outputEntityReference(entityName);
|
||||
boolean flush(boolean skipBeginningNewlines) throws SAXException {
|
||||
if (m_elemContext.m_startTagOpen)
|
||||
{
|
||||
closeStartTag();
|
||||
m_elemContext.m_startTagOpen = false;
|
||||
}
|
||||
if (m_cdataTagOpen)
|
||||
closeCDATA();
|
||||
char[] cs = toChars();
|
||||
try {
|
||||
m_writer.write(cs, 0, cs.length);
|
||||
m_isprevtext = true;
|
||||
} catch (IOException e) {
|
||||
throw new SAXException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
char[] toChars() {
|
||||
@ -3466,31 +3482,56 @@ abstract public class ToStream extends SerializerBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if no GenericCharacters are buffered.
|
||||
* Append a raw text to the buffer. Used to handle raw characters event.
|
||||
*/
|
||||
public boolean isNoCharactersBuffered() {
|
||||
return bufferedCharacters.isEmpty();
|
||||
public void addRawText(final char chars[], final int start, final int length) {
|
||||
bufferedCharacters.add(new GenericCharacters() {
|
||||
char[] text;
|
||||
|
||||
{
|
||||
text = Arrays.copyOfRange(chars, start, start + length);
|
||||
}
|
||||
|
||||
boolean flush(boolean skipBeginningNewlines) throws SAXException {
|
||||
try {
|
||||
int start = 0;
|
||||
while (skipBeginningNewlines && text[start] == '\n') {
|
||||
start++;
|
||||
if (start == text.length) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
m_writer.write(text, start, text.length - start);
|
||||
m_isprevtext = true;
|
||||
} catch (IOException e) {
|
||||
throw new SAXException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
char[] toChars() {
|
||||
return text;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if any buffered GenericCharacters has content.
|
||||
* @return True if any GenericCharacters are buffered.
|
||||
*/
|
||||
public boolean hasContent() {
|
||||
for (GenericCharacters element : bufferedCharacters) {
|
||||
if (element.hasContent())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public boolean isAnyCharactersBuffered() {
|
||||
return bufferedCharacters.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush all buffered GenericCharacters.
|
||||
*/
|
||||
public void flush() throws SAXException {
|
||||
public void flush(boolean skipBeginningNewlines) throws SAXException {
|
||||
Iterator<GenericCharacters> itr = bufferedCharacters.iterator();
|
||||
|
||||
boolean continueSkipBeginningNewlines = skipBeginningNewlines;
|
||||
while (itr.hasNext()) {
|
||||
GenericCharacters element = itr.next();
|
||||
element.flush();
|
||||
continueSkipBeginningNewlines = element.flush(continueSkipBeginningNewlines);
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
|
@ -1024,7 +1024,8 @@ final class DOM3TreeWalker {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bDispatch) {
|
||||
if (bDispatch
|
||||
&& (!fSerializer.getIndent() || !node.getData().replace('\n', ' ').trim().isEmpty())) {
|
||||
dispatachChars(node);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,12 +55,6 @@ module java.xml {
|
||||
exports org.xml.sax;
|
||||
exports org.xml.sax.ext;
|
||||
exports org.xml.sax.helpers;
|
||||
exports com.sun.org.apache.xerces.internal.dom to
|
||||
java.xml.ws;
|
||||
exports com.sun.org.apache.xerces.internal.jaxp to
|
||||
java.xml.ws;
|
||||
exports com.sun.org.apache.xerces.internal.util to
|
||||
java.xml.ws;
|
||||
exports com.sun.org.apache.xml.internal.dtm to
|
||||
java.xml.crypto;
|
||||
exports com.sun.org.apache.xml.internal.utils to
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
package org.w3c.dom.ptests;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
import static jaxp.library.JAXPTestUtilities.compareWithGold;
|
||||
import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
@ -157,7 +158,7 @@ public class NodeTest {
|
||||
Element element = (Element) document.getElementsByTagName("sender").item(0);
|
||||
parentElement.insertBefore(createTestDocumentFragment(document), element);
|
||||
|
||||
String outputfile = "InsertBefore.out";
|
||||
String outputfile = USER_DIR + "InsertBefore.out";
|
||||
String goldfile = GOLDEN_DIR + "InsertBeforeGF.out";
|
||||
tryRunWithTmpPermission(() -> outputXml(document, outputfile), new PropertyPermission("user.dir", "read"));
|
||||
assertTrue(compareWithGold(goldfile, outputfile));
|
||||
@ -175,7 +176,7 @@ public class NodeTest {
|
||||
Element element = (Element) document.getElementsByTagName("sender").item(0);
|
||||
parentElement.replaceChild(createTestDocumentFragment(document), element);
|
||||
|
||||
String outputfile = "ReplaceChild3.out";
|
||||
String outputfile = USER_DIR + "ReplaceChild3.out";
|
||||
String goldfile = GOLDEN_DIR + "ReplaceChild3GF.out";
|
||||
tryRunWithTmpPermission(() -> outputXml(document, outputfile), new PropertyPermission("user.dir", "read"));
|
||||
assertTrue(compareWithGold(goldfile, outputfile));
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
package test.astro;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
import static jaxp.library.JAXPTestUtilities.filenameToURL;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
@ -130,7 +131,7 @@ public class DocumentLSTest {
|
||||
impl = (DOMImplementationLS) db.getDOMImplementation();
|
||||
LSSerializer domSerializer = impl.createLSSerializer();
|
||||
MyDOMOutput mydomoutput = new MyDOMOutput();
|
||||
try (OutputStream os = new FileOutputStream("test.out")) {
|
||||
try (OutputStream os = new FileOutputStream(USER_DIR + "test.out")) {
|
||||
mydomoutput.setByteStream(os);
|
||||
mydomoutput.setEncoding("UTF-8");
|
||||
assertTrue(domSerializer.write(doc, mydomoutput));
|
||||
|
@ -60,7 +60,7 @@ import org.xml.sax.SAXException;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6439439 8087303
|
||||
* @bug 6439439 8087303 8174025
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @run testng/othervm -DrunSecMngr=true common.prettyprint.PrettyPrintTest
|
||||
* @run testng/othervm common.prettyprint.PrettyPrintTest
|
||||
@ -69,29 +69,30 @@ import org.xml.sax.SAXException;
|
||||
@Listeners({jaxp.library.FilePolicy.class})
|
||||
public class PrettyPrintTest {
|
||||
/*
|
||||
* test CDATA, elements only, text and element, whitespace and element,
|
||||
* xml:space property and nested xml:space property, mixed node types.
|
||||
* test CDATA, elements only, text and element, xml:space property, mixed
|
||||
* node types.
|
||||
*/
|
||||
@DataProvider(name = "xml-data")
|
||||
public Object[][] xmlData() throws Exception {
|
||||
return new Object[][] {
|
||||
{ read("xmltest1.xml"), read("xmltest1.out") },
|
||||
{ read("xmltest2.xml"), read("xmltest2.out") },
|
||||
{ read("xmltest3.xml"), read("xmltest3.out") },
|
||||
{ read("xmltest4.xml"), read("xmltest4.out") },
|
||||
{ read("xmltest5.xml"), read("xmltest5.out") },
|
||||
{ read("xmltest6.xml"), read("xmltest6.out") },
|
||||
{ read("xmltest7.xml"), read("xmltest7.out") },
|
||||
{ read("xmltest8.xml"), read("xmltest8.out") } };
|
||||
{ "xmltest1.xml", "xmltest1.out" },
|
||||
{ "xmltest2.xml", "xmltest2.out" },
|
||||
{ "xmltest3.xml", "xmltest3.out" },
|
||||
{ "xmltest4.xml", "xmltest4.out" },
|
||||
{ "xmltest6.xml", "xmltest6.out" },
|
||||
{ "xmltest8.xml", "xmltest8.out" } };
|
||||
}
|
||||
|
||||
/*
|
||||
* @bug 8087303
|
||||
* Test the whitespace text nodes are serialized with pretty-print by LSSerializer and transformer correctly
|
||||
* Test the xml document are serialized with pretty-print by
|
||||
* LSSerializer and transformer correctly
|
||||
*
|
||||
*/
|
||||
@Test(dataProvider = "xml-data")
|
||||
public void testXMLPrettyPrint(String source, String expected) throws Exception {
|
||||
public void testXMLPrettyPrint(String sourceFile, String expectedFile) throws Exception {
|
||||
String source = read(sourceFile);
|
||||
String expected = read(expectedFile);
|
||||
// test it's no change if no pretty-print
|
||||
String result = serializerWrite(toXmlDocument(source), false);
|
||||
assertTrue(toXmlDocument(source).isEqualNode(toXmlDocument(result)), "The actual is: " + result);
|
||||
@ -104,40 +105,116 @@ public class PrettyPrintTest {
|
||||
assertEquals(transform(toXmlDocument(source), true).replaceAll("\r\n", "\n"), expected);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* test pure text content, and sequent Text nodes.
|
||||
* @bug 8087303
|
||||
* Test a single text node is serialized with pretty-print by
|
||||
* LSSerializer and transformer correctly
|
||||
*
|
||||
*/
|
||||
@DataProvider(name = "xml-node-data")
|
||||
public Object[][] xmlNodeData() throws Exception {
|
||||
return new Object[][] {
|
||||
{ newTextNode(read("nodetest1.txt")), read("nodetest1.out") },
|
||||
{ createDocWithSequentTextNodes(), read("nodetest2.out") } };
|
||||
@Test
|
||||
public void testSingleTextNode() throws Exception {
|
||||
Node xml = newTextNode(read("nodetest1.txt"));
|
||||
String expected = read("nodetest1.out");
|
||||
assertEquals(serializerWrite(xml, true), expected);
|
||||
assertEquals(transform(xml, true).replaceAll("\r\n", "\n"), expected);
|
||||
}
|
||||
|
||||
/*
|
||||
* @bug 8087303
|
||||
* Test the whitespace text nodes are serialized with pretty-print by LSSerializer and transformer correctly,
|
||||
* doesn't compare with the source because the test data is Node object
|
||||
* Test the transformer shall keep all whitespace text node in
|
||||
* sequent text nodes
|
||||
*
|
||||
*/
|
||||
@Test(dataProvider = "xml-node-data")
|
||||
public void testXMLNodePrettyPrint(Node xml, String expected) throws Exception {
|
||||
assertEquals(serializerWrite(xml, true), expected);
|
||||
@Test
|
||||
public void testSequentTextNodesWithTransformer() throws Exception {
|
||||
Node xml = createDocWithSequentTextNodes();
|
||||
String expected = read("nodetest2.out");
|
||||
assertEquals(transform(xml, true).replaceAll("\r\n", "\n"), expected);
|
||||
}
|
||||
|
||||
/*
|
||||
* @bug 8087303
|
||||
* Test LSSerializer shall eliminate the whitespace text node
|
||||
* in sequent text nodes
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testSequentTextNodesWithLSSerializer() throws Exception {
|
||||
Node xml = createDocWithSequentTextNodes();
|
||||
String expected = read("nodetest2ls.out");
|
||||
assertEquals(serializerWrite(xml, true), expected);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* test whitespace and element, nested xml:space property.
|
||||
*/
|
||||
@DataProvider(name = "xml-data-whitespace-ls")
|
||||
public Object[][] whitespaceLS() throws Exception {
|
||||
return new Object[][] {
|
||||
{ "xmltest5.xml", "xmltest5ls.out" },
|
||||
{ "xmltest7.xml", "xmltest7ls.out" } };
|
||||
}
|
||||
|
||||
/*
|
||||
* @bug 8087303
|
||||
* Test LSSerializer shall eliminate the whitespace text node
|
||||
* unless xml:space="preserve"
|
||||
*
|
||||
*/
|
||||
@Test(dataProvider = "xml-data-whitespace-ls")
|
||||
public void testWhitespaceWithLSSerializer(String sourceFile, String expectedFile) throws Exception {
|
||||
String source = read(sourceFile);
|
||||
String expected = read(expectedFile);
|
||||
// test it's no change if no pretty-print
|
||||
String result = serializerWrite(toXmlDocument(source), false);
|
||||
assertTrue(toXmlDocument(source).isEqualNode(toXmlDocument(result)), "The actual is: " + result);
|
||||
// test pretty-print
|
||||
assertEquals(serializerWrite(toXmlDocument(source), true), expected);
|
||||
}
|
||||
|
||||
/*
|
||||
* test whitespace and element, nested xml:space property.
|
||||
*/
|
||||
@DataProvider(name = "xml-data-whitespace-xslt")
|
||||
public Object[][] whitespaceXSLT() throws Exception {
|
||||
return new Object[][] {
|
||||
{ "xmltest5.xml", "xmltest5xslt.out" },
|
||||
{ "xmltest7.xml", "xmltest7xslt.out" } };
|
||||
}
|
||||
|
||||
/*
|
||||
* @bug 8087303
|
||||
* Test the transformer shall format the output but keep all
|
||||
* whitespace text node even if xml:space="preserve"
|
||||
*
|
||||
*/
|
||||
@Test(dataProvider = "xml-data-whitespace-xslt")
|
||||
public void testWhitespaceWithTransformer(String sourceFile, String expectedFile) throws Exception {
|
||||
String source = read(sourceFile);
|
||||
String expected = read(expectedFile);
|
||||
// test it's no change if no pretty-print
|
||||
String result = transform(toXmlDocument(source), false);
|
||||
assertTrue(toXmlDocument(source).isEqualNode(toXmlDocument(result)), "The actual is: " + result);
|
||||
// test pretty-print
|
||||
assertEquals(transform(toXmlDocument(source), true).replaceAll("\r\n", "\n"), expected);
|
||||
}
|
||||
|
||||
/*
|
||||
* test block element, inline element, text, and mixed elements.
|
||||
*/
|
||||
@DataProvider(name = "html-data")
|
||||
public Object[][] htmlData() throws Exception {
|
||||
return new Object[][] {
|
||||
{ read("htmltest1.xml"), read("htmltest1.out") },
|
||||
{ read("htmltest2.xml"), read("htmltest2.out") },
|
||||
{ read("htmltest3.xml"), read("htmltest3.out") },
|
||||
{ read("htmltest4.xml"), read("htmltest4.out") },
|
||||
{ read("htmltest5.xml"), read("htmltest5.out") },
|
||||
{ read("htmltest6.xml"), read("htmltest6.out") } };
|
||||
{ "htmltest1.xml", "htmltest1.out" },
|
||||
{ "htmltest2.xml", "htmltest2.out" },
|
||||
{ "htmltest3.xml", "htmltest3.out" },
|
||||
{ "htmltest4.xml", "htmltest4.out" },
|
||||
{ "htmltest5.xml", "htmltest5.out" },
|
||||
{ "htmltest6.xml", "htmltest6.out" },
|
||||
/* @bug 8174025, test whitespace between inline elements */
|
||||
{ "htmltest7.xml", "htmltest7.out" } };
|
||||
}
|
||||
|
||||
/*
|
||||
@ -146,7 +223,9 @@ public class PrettyPrintTest {
|
||||
*
|
||||
*/
|
||||
@Test(dataProvider = "html-data")
|
||||
public void testTransformToHTML(String source, String expected) throws Exception {
|
||||
public void testTransformToHTML(String sourceFile, String expectedFile) throws Exception {
|
||||
String source = read(sourceFile);
|
||||
String expected = read(expectedFile);
|
||||
// test it's no change if no pretty-print
|
||||
StringWriter writer = new StringWriter();
|
||||
getTransformer(true, false).transform(new StreamSource(new StringReader(source)), new StreamResult(writer));
|
||||
@ -158,6 +237,27 @@ public class PrettyPrintTest {
|
||||
assertEquals(writer.toString().replaceAll("\r\n", "\n"), expected);
|
||||
}
|
||||
|
||||
/*
|
||||
* @bug 8174025
|
||||
* Test the serializer can handle <xsl:text disable-output-escaping="yes"> correctly.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testDisableOutputEscaping() throws Exception {
|
||||
final String xsl ="generate-catalog.xsl";
|
||||
final String xml ="simple-entity-resolver-config.xml";
|
||||
final String expectedOutput ="simple-entity-resolver-config-transformed.xml";
|
||||
TransformerFactory factory = TransformerFactory.newInstance();
|
||||
Transformer transformer = factory.newTemplates(new StreamSource(new StringReader(read(xsl)))).newTransformer();
|
||||
|
||||
String key = "schemaBase";
|
||||
String value = "schemas";
|
||||
transformer.setParameter(key, value);
|
||||
StringWriter writer = new StringWriter();
|
||||
transformer.transform(new StreamSource(new StringReader(read(xml))), new StreamResult(writer));
|
||||
assertEquals(writer.toString().replaceAll("\r\n", "\n"), read(expectedOutput));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLSSerializerFormatPrettyPrint() {
|
||||
|
||||
@ -298,6 +398,9 @@ public class PrettyPrintTest {
|
||||
Document doc = db.newDocument();
|
||||
Node root = doc.createElement("root");
|
||||
doc.appendChild(root);
|
||||
root.appendChild(doc.createTextNode("\n"));
|
||||
root.appendChild(doc.createTextNode("\n"));
|
||||
root.appendChild(doc.createTextNode("\n"));
|
||||
root.appendChild(doc.createTextNode(" "));
|
||||
root.appendChild(doc.createTextNode("t"));
|
||||
root.appendChild(doc.createTextNode("\n"));
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Stylesheet for generating the entity-resolver document in XCatalog format -->
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:output method="xml" indent="yes"/>
|
||||
<xsl:param name="schemaBase"/>
|
||||
<xsl:template match="entity-resolver-config">
|
||||
<catalog xmlns="xmlns:xml:catalog"
|
||||
prefer="system"
|
||||
xml:base="{$schemaBase}" >
|
||||
|
||||
<xsl:for-each select="entity">
|
||||
|
||||
<!-- Generate System Id -->
|
||||
<xsl:text disable-output-escaping="yes"><system systemId="</xsl:text>
|
||||
<xsl:value-of select="system-id/text()"/>
|
||||
<xsl:text>" uri="</xsl:text>
|
||||
<xsl:value-of select="location/text()"/>
|
||||
<xsl:text disable-output-escaping="yes">" /> </xsl:text>
|
||||
</xsl:for-each>
|
||||
</catalog>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
@ -1 +1 @@
|
||||
<rss version="2.0"><channel xml:space="preserve"><title>Java Tutorials and Examples 1</title> <language>en-us</language></channel></rss>
|
||||
<rss version="2.0"><channel xml:space="preserve"><title>Java Tutorials and Examples 1</title><language>en-us</language></channel></rss>
|
@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
<span>this</span> <span>is</span> <span>a</span> <span>whitespace</span> <span>inline element</span> <span>test</span>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1 @@
|
||||
<html><body><p> <span>this</span> <span>is</span> <span>a</span> <span>whitespace</span> <span>inline element</span> <span>test</span> </p></body></html>
|
@ -1,19 +1,30 @@
|
||||
<root>
|
||||
t
|
||||
t
|
||||
<child1/>
|
||||
<child1>
|
||||
</child1>
|
||||
t
|
||||
<child2/>
|
||||
<child3/>
|
||||
<child4/>
|
||||
<child2> </child2>
|
||||
|
||||
<child3> </child3>
|
||||
|
||||
<child4> </child4>
|
||||
|
||||
<child5>
|
||||
t
|
||||
<child51>
|
||||
|
||||
<child511>t</child511>
|
||||
|
||||
</child51>
|
||||
t
|
||||
</child5>
|
||||
|
||||
<!-- test comment -->
|
||||
|
||||
|
||||
<!-- -->
|
||||
|
||||
<?target1 test?>
|
||||
|
||||
</root>
|
||||
|
@ -0,0 +1,18 @@
|
||||
<root>
|
||||
tt
|
||||
<child1/>
|
||||
t
|
||||
<child2/>
|
||||
<child3/>
|
||||
<child4/>
|
||||
<child5>
|
||||
t
|
||||
<child51>
|
||||
<child511>t</child511>
|
||||
</child51>
|
||||
t
|
||||
</child5>
|
||||
<!-- test comment -->
|
||||
<!-- -->
|
||||
<?target1 test?>
|
||||
</root>
|
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><catalog prefer="system" xml:base="schemas" xmlns="xmlns:xml:catalog"><system systemId="http://www.example.test/oracle/schema/example1.xsd" uri="META-INF/example1.xsd" />
|
||||
<system systemId="http://www.example.test/oracle/schema/example2.xsd" uri="META-INF/example2.xsd" />
|
||||
</catalog>
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<entity-resolver-config
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://www.example.test/schema.xsd"
|
||||
schema-major-version="1"
|
||||
schema-minor-version="1">
|
||||
|
||||
<entity>
|
||||
<description>Example 1 Schema Type library 10.0 </description>
|
||||
<public-id>>-//Oracle//Example 1 Schema Type library 10.0//EN</public-id>
|
||||
<system-id>http://www.example.test/oracle/schema/example1.xsd</system-id>
|
||||
<location>META-INF/example1.xsd</location>
|
||||
</entity>
|
||||
<entity>
|
||||
<description>Example 2 Schema Type library 10.0 </description>
|
||||
<public-id>>-//Oracle//Example 2 Schema Type library 10.0//EN</public-id>
|
||||
<system-id>http://www.example.test/oracle/schema/example2.xsd</system-id>
|
||||
<location>META-INF/example2.xsd</location>
|
||||
</entity>
|
||||
</entity-resolver-config>
|
@ -0,0 +1,15 @@
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
|
||||
<title>Java Tutorials and Examples 1</title>
|
||||
|
||||
<language>en-us</language>
|
||||
</channel>
|
||||
<a>
|
||||
<b> </b>
|
||||
</a>
|
||||
|
||||
<c>
|
||||
|
||||
</c>
|
||||
</rss>
|
@ -0,0 +1,17 @@
|
||||
<rss>
|
||||
<layer1 xml:space="preserve"> <title>Java </title> <layer2 xml:space="asfsa"> <layer3> <layer4 xml:space="default">
|
||||
|
||||
<l5>5</l5>
|
||||
|
||||
|
||||
</layer4> </layer3> </layer2> <layer2 xml:space="default">
|
||||
|
||||
<layer3>
|
||||
|
||||
<l4> </l4>
|
||||
|
||||
</layer3>
|
||||
|
||||
<layer3 xml:space="preserve"> <l4> </l4> </layer3>
|
||||
</layer2> </layer1>
|
||||
</rss>
|
@ -1,25 +1,20 @@
|
||||
<root>
|
||||
|
||||
t
|
||||
t
|
||||
<![CDATA[ ]]>
|
||||
|
||||
t
|
||||
t
|
||||
|
||||
<child1/>
|
||||
|
||||
t
|
||||
t
|
||||
<!-- test comment -->
|
||||
<child2/>
|
||||
<child5>
|
||||
|
||||
t
|
||||
t
|
||||
<?target1 test?>
|
||||
<child51>
|
||||
<child511>t</child511>
|
||||
</child51>
|
||||
<?target1 test?>
|
||||
|
||||
t
|
||||
t
|
||||
|
||||
</child5>
|
||||
</root>
|
||||
|
@ -2,14 +2,7 @@
|
||||
t<![CDATA[ ]]>
|
||||
t
|
||||
<child1/>
|
||||
t<!-- test comment -->
|
||||
<child2/>
|
||||
<child5>
|
||||
t<?target1 test?>
|
||||
<child51>
|
||||
<child511>t</child511>
|
||||
</child51><?target1 test?>
|
||||
t<!-- test comment --><child2/><child5>
|
||||
t<?target1 test?><child51><child511>t</child511></child51><?target1 test?>
|
||||
t
|
||||
</child5>
|
||||
|
||||
</root>
|
||||
</child5></root>
|
||||
|
@ -279,11 +279,11 @@ public class LSSerializerTest {
|
||||
"<author>\n" +
|
||||
" <a>&name1;Jo Smith</a>\n" +
|
||||
" <b>b &name2;Jo Smith &name1;Jo Smith b</b>\n" +
|
||||
" <c> &name;Jo Smith </c>\n" +
|
||||
" <c>&name;Jo Smith </c>\n" +
|
||||
" <d>&ele1;d</d>\n" +
|
||||
" <e> &ele2;eee </e>\n" +
|
||||
" <e>&ele2;eee </e>\n" +
|
||||
" <f><att></f>\n" +
|
||||
" <g> &ele; g</g>\n" +
|
||||
" <g>&ele; g</g>\n" +
|
||||
" <h>&ele2;</h>\n" +
|
||||
"</author>\n");
|
||||
|
||||
@ -301,7 +301,7 @@ public class LSSerializerTest {
|
||||
"<author>\n" +
|
||||
" <a>&name;Jo Smith</a>\n" +
|
||||
" <b>b &name;Jo Smith &name;Jo Smith b</b>\n" +
|
||||
" <c> &name;Jo Smith </c>\n" +
|
||||
" <c>&name;Jo Smith </c>\n" +
|
||||
" <d>\n" +
|
||||
" <aa>\n" +
|
||||
" <bb>text</bb>\n" +
|
||||
|
158
jaxp/test/javax/xml/jaxp/unittest/parsers/BaseParsingTest.java
Normal file
158
jaxp/test/javax/xml/jaxp/unittest/parsers/BaseParsingTest.java
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package parsers;
|
||||
|
||||
import java.io.StringReader;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Listeners;
|
||||
import org.testng.annotations.Test;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8169450
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @run testng/othervm -DrunSecMngr=true parsers.BaseParsingTest
|
||||
* @run testng/othervm parsers.BaseParsingTest
|
||||
* @summary Tests that verify base parsing
|
||||
*/
|
||||
@Listeners({jaxp.library.BasePolicy.class})
|
||||
public class BaseParsingTest {
|
||||
|
||||
@DataProvider(name = "xmlDeclarations")
|
||||
public static Object[][] xmlDeclarations() {
|
||||
return new Object[][]{
|
||||
{"<?xml version=\"1.0\"?><root><test>t</test></root>"},
|
||||
{"<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><test>t</test></root>"},
|
||||
{"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone='yes'?><root><test>t</test></root>"},
|
||||
{"<?xml\n"
|
||||
+ " version=\"1.0\"?>\n"
|
||||
+ "<root>\n"
|
||||
+ " <test>t</test>\n"
|
||||
+ "</root>"},
|
||||
{"<?xml\n"
|
||||
+ " version=\"1.0\"\n"
|
||||
+ " encoding=\"UTF-8\"?>\n"
|
||||
+ "<root>\n"
|
||||
+ " <test>t</test>\n"
|
||||
+ "</root>"},
|
||||
{"<?xml\n"
|
||||
+ " version=\"1.0\"\n"
|
||||
+ " encoding=\"UTF-8\"\n"
|
||||
+ " standalone=\"yes\"?>\n"
|
||||
+ "<root>\n"
|
||||
+ " <test>t</test>\n"
|
||||
+ "</root>"},
|
||||
{"<?xml\n"
|
||||
+ " version\n"
|
||||
+ "=\n"
|
||||
+ "\"1.0\"\n"
|
||||
+ " encoding\n"
|
||||
+ "=\n"
|
||||
+ "\"UTF-8\"\n"
|
||||
+ " standalone\n"
|
||||
+ "=\n"
|
||||
+ "\"yes\"?>\n"
|
||||
+ "<root>\n"
|
||||
+ " <test>t</test>\n"
|
||||
+ "</root>"},
|
||||
{"<?xml version=\"1.1\"?><root><test>t</test></root>"},
|
||||
{"<?xml version=\"1.1\" encoding=\"UTF-8\"?><root><test>t</test></root>"},
|
||||
{"<?xml version=\"1.1\" encoding=\"UTF-8\" standalone='yes'?><root><test>t</test></root>"},
|
||||
{"<?xml\n"
|
||||
+ " version=\"1.1\"?>\n"
|
||||
+ "<root>\n"
|
||||
+ " <test>t</test>\n"
|
||||
+ "</root>"},
|
||||
{"<?xml\n"
|
||||
+ " version=\"1.1\"\n"
|
||||
+ " encoding=\"UTF-8\"?>\n"
|
||||
+ "<root>\n"
|
||||
+ " <test>t</test>\n"
|
||||
+ "</root>"},
|
||||
{"<?xml\n"
|
||||
+ " version=\"1.1\"\n"
|
||||
+ " encoding=\"UTF-8\"\n"
|
||||
+ " standalone=\"yes\"?>\n"
|
||||
+ "<root>\n"
|
||||
+ " <test>t</test>\n"
|
||||
+ "</root>"},
|
||||
{"<?xml\n"
|
||||
+ " version\n"
|
||||
+ "=\n"
|
||||
+ "\"1.1\"\n"
|
||||
+ " encoding\n"
|
||||
+ "=\n"
|
||||
+ "\"UTF-8\"\n"
|
||||
+ " standalone\n"
|
||||
+ "=\n"
|
||||
+ "\"yes\"?>\n"
|
||||
+ "<root>\n"
|
||||
+ " <test>t</test>\n"
|
||||
+ "</root>"}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @bug 8169450
|
||||
* Verifies that the parser successfully parses the declarations provided in
|
||||
* xmlDeclarations. Exception would otherwise be thrown as reported in 8169450.
|
||||
*
|
||||
* XML Declaration according to https://www.w3.org/TR/REC-xml/#NT-XMLDecl
|
||||
* [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
|
||||
* [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
|
||||
* [25] Eq ::= S? '=' S? [26] VersionNum ::= '1.' [0-9]+
|
||||
*
|
||||
* @param xml the test xml
|
||||
* @throws Exception if the parser fails to parse the xml
|
||||
*/
|
||||
@Test(dataProvider = "xmlDeclarations")
|
||||
public void test(String xml) throws Exception {
|
||||
XMLInputFactory xif = XMLInputFactory.newDefaultFactory();
|
||||
XMLStreamReader xsr = xif.createXMLStreamReader(new StringReader(xml));
|
||||
while (xsr.hasNext()) {
|
||||
xsr.next();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @bug 8169450
|
||||
* This particular issue does not appear in DOM parsing since the spaces are
|
||||
* normalized during version detection. This test case then serves as a guard
|
||||
* against such an issue from occuring in the version detection.
|
||||
*
|
||||
* @param xml the test xml
|
||||
* @throws Exception if the parser fails to parse the xml
|
||||
*/
|
||||
@Test(dataProvider = "xmlDeclarations")
|
||||
public void testWithDOM(String xml) throws Exception {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
dbf.setValidating(true);
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
db.parse(new InputSource(new StringReader(xml)));
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@
|
||||
|
||||
package parsers;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
|
||||
|
||||
import java.io.File;
|
||||
@ -61,7 +62,7 @@ public class Bug6341770 {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
File dir = new File(ALPHA);
|
||||
File dir = new File(USER_DIR + ALPHA);
|
||||
dir.delete();
|
||||
dir.mkdir();
|
||||
File main = new File(dir, "main.xml");
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
package sax;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
import static jaxp.library.JAXPTestUtilities.getSystemProperty;
|
||||
import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
|
||||
|
||||
@ -69,7 +70,7 @@ public class Bug7057778Test {
|
||||
@Test
|
||||
public void testParse() {
|
||||
File src = new File(getClass().getResource(xml).getFile());
|
||||
File dst = new File(xml1);
|
||||
File dst = new File(USER_DIR + xml1);
|
||||
try {
|
||||
copyFile(src, dst);
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sax;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Listeners;
|
||||
import org.testng.annotations.Test;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8173390
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @run testng/othervm -DrunSecMngr=true sax.SymbolTableResetTest
|
||||
* @run testng/othervm sax.SymbolTableResetTest
|
||||
* @summary Test that SAXParser reallocates symbol table during
|
||||
* subsequent parse operations
|
||||
*/
|
||||
@Listeners({jaxp.library.BasePolicy.class})
|
||||
public class SymbolTableResetTest {
|
||||
|
||||
/*
|
||||
* Test mimics the SAXParser usage in SAAJ-RI that reuses the
|
||||
* parsers from the internal pool. To avoid memory leaks, symbol
|
||||
* table associated with the parser should be reallocated during each
|
||||
* parse() operation.
|
||||
*/
|
||||
@Test
|
||||
public void testReset() throws Exception {
|
||||
// Dummy xml input for parser
|
||||
String input = "<dummy>Test</dummy>";
|
||||
// Create SAXParser
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
SAXParser p = spf.newSAXParser();
|
||||
// First parse iteration
|
||||
p.parse(new InputSource(new StringReader(input)), new DefaultHandler());
|
||||
// Get first symbol table reference
|
||||
Object symTable1 = p.getProperty(SYMBOL_TABLE_PROPERTY);
|
||||
p.reset();
|
||||
// Second parse iteration
|
||||
p.parse(new InputSource(new StringReader(input)), new DefaultHandler());
|
||||
// Get second symbol table reference
|
||||
Object symTable2 = p.getProperty(SYMBOL_TABLE_PROPERTY);
|
||||
// Symbol table references should be different
|
||||
Assert.assertNotSame(symTable1, symTable2, "Symbol table references");
|
||||
}
|
||||
|
||||
// Symbol table property
|
||||
private static final String SYMBOL_TABLE_PROPERTY = "http://apache.org/xml/properties/internal/symbol-table";
|
||||
|
||||
}
|
@ -23,6 +23,8 @@
|
||||
|
||||
package stream;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
@ -67,15 +69,15 @@ public class Bug6688002Test {
|
||||
}
|
||||
|
||||
public class MyRunnable implements Runnable {
|
||||
final int no;
|
||||
final String no;
|
||||
|
||||
MyRunnable(int no) {
|
||||
this.no = no;
|
||||
this.no = String.valueOf(no);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream("" + no);
|
||||
FileOutputStream fos = new FileOutputStream(USER_DIR + no);
|
||||
XMLStreamWriter w = getWriter(fos);
|
||||
// System.out.println("Writer="+w+" Thread="+Thread.currentThread());
|
||||
w.writeStartDocument();
|
||||
@ -89,7 +91,7 @@ public class Bug6688002Test {
|
||||
w.close();
|
||||
fos.close();
|
||||
|
||||
FileInputStream fis = new FileInputStream("" + no);
|
||||
FileInputStream fis = new FileInputStream(USER_DIR + no);
|
||||
XMLStreamReader r = getReader(fis);
|
||||
while (r.hasNext()) {
|
||||
r.next();
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
package stream.XMLEventWriterTest;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -58,7 +60,7 @@ public class ReaderToWriterTest {
|
||||
private static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newInstance();
|
||||
|
||||
private static final String INPUT_FILE = "W2JDLR4002TestService.wsdl.data";
|
||||
private static final String OUTPUT_FILE = "Encoded.wsdl";
|
||||
private static final String OUTPUT_FILE = USER_DIR + "Encoded.wsdl";
|
||||
|
||||
/**
|
||||
* Unit test for writing namespaces when namespaceURI == null.
|
||||
@ -126,7 +128,7 @@ public class ReaderToWriterTest {
|
||||
|
||||
try {
|
||||
InputStream in = getClass().getResourceAsStream("ReaderToWriterTest.wsdl");
|
||||
OutputStream out = new FileOutputStream("ReaderToWriterTest-out.xml");
|
||||
OutputStream out = new FileOutputStream(USER_DIR + "ReaderToWriterTest-out.xml");
|
||||
|
||||
XMLEventReader reader = XML_INPUT_FACTORY.createXMLEventReader(in);
|
||||
XMLEventWriter writer = XML_OUTPUT_FACTORY.createXMLEventWriter(out, "UTF-8");
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
package stream.XMLStreamWriterTest;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -84,7 +86,7 @@ public class WriterTest {
|
||||
System.out.println("Test StreamWriter with out any namespace functionality");
|
||||
|
||||
try {
|
||||
String outputFile = files[0] + ".out";
|
||||
String outputFile = USER_DIR + files[0] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -98,7 +100,7 @@ public class WriterTest {
|
||||
xtw.flush();
|
||||
xtw.close();
|
||||
|
||||
Assert.assertTrue(checkResults(files[0] + ".out", files[0] + ".org"));
|
||||
Assert.assertTrue(checkResults(outputFile, files[0] + ".org"));
|
||||
|
||||
} catch (Exception ex) {
|
||||
Assert.fail("testOne Failed " + ex);
|
||||
@ -113,7 +115,7 @@ public class WriterTest {
|
||||
System.out.println("Test StreamWriter's Namespace Context");
|
||||
|
||||
try {
|
||||
String outputFile = files[1] + ".out";
|
||||
String outputFile = USER_DIR + files[1] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
|
||||
xtw = outputFactory.createXMLStreamWriter(System.out);
|
||||
@ -157,7 +159,7 @@ public class WriterTest {
|
||||
System.out.println("Test StreamWriter for proper element sequence.");
|
||||
|
||||
try {
|
||||
String outputFile = files[2] + ".out";
|
||||
String outputFile = USER_DIR + files[2] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -172,7 +174,7 @@ public class WriterTest {
|
||||
xtw.flush();
|
||||
xtw.close();
|
||||
|
||||
Assert.assertTrue(checkResults(files[2] + ".out", files[2] + ".org"));
|
||||
Assert.assertTrue(checkResults(outputFile, files[2] + ".org"));
|
||||
|
||||
} catch (Exception ex) {
|
||||
Assert.fail("testThree Failed " + ex);
|
||||
@ -188,7 +190,7 @@ public class WriterTest {
|
||||
|
||||
try {
|
||||
|
||||
String outputFile = files[3] + ".out";
|
||||
String outputFile = USER_DIR + files[3] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -205,7 +207,7 @@ public class WriterTest {
|
||||
xtw.flush();
|
||||
xtw.close();
|
||||
|
||||
Assert.assertTrue(checkResults(files[3] + ".out", files[3] + ".org"));
|
||||
Assert.assertTrue(checkResults(outputFile, files[3] + ".org"));
|
||||
|
||||
} catch (Exception ex) {
|
||||
Assert.fail("testFour Failed " + ex);
|
||||
@ -221,7 +223,7 @@ public class WriterTest {
|
||||
|
||||
try {
|
||||
|
||||
String outputFile = files[4] + ".out";
|
||||
String outputFile = USER_DIR + files[4] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
|
||||
xtw = outputFactory.createXMLStreamWriter(System.out);
|
||||
@ -265,7 +267,7 @@ public class WriterTest {
|
||||
xtw.writeEndDocument();
|
||||
xtw.flush();
|
||||
xtw.close();
|
||||
Assert.assertTrue(checkResults(files[4] + ".out", files[4] + ".org"));
|
||||
Assert.assertTrue(checkResults(outputFile, files[4] + ".org"));
|
||||
System.out.println("Done");
|
||||
} catch (Exception ex) {
|
||||
Assert.fail("testFive Failed " + ex);
|
||||
@ -281,7 +283,7 @@ public class WriterTest {
|
||||
|
||||
try {
|
||||
|
||||
String outputFile = files[5] + ".out";
|
||||
String outputFile = USER_DIR + files[5] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
|
||||
xtw = outputFactory.createXMLStreamWriter(System.out);
|
||||
@ -325,7 +327,7 @@ public class WriterTest {
|
||||
xtw.writeEndDocument();
|
||||
xtw.flush();
|
||||
xtw.close();
|
||||
Assert.assertTrue(checkResults(files[5] + ".out", files[5] + ".org"));
|
||||
Assert.assertTrue(checkResults(outputFile, files[5] + ".org"));
|
||||
System.out.println("Done");
|
||||
} catch (Exception ex) {
|
||||
Assert.fail("testSix Failed " + ex);
|
||||
@ -341,7 +343,7 @@ public class WriterTest {
|
||||
|
||||
try {
|
||||
|
||||
String outputFile = files[6] + ".out";
|
||||
String outputFile = USER_DIR + files[6] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -374,7 +376,7 @@ public class WriterTest {
|
||||
xtw.writeEndDocument();
|
||||
xtw.flush();
|
||||
xtw.close();
|
||||
Assert.assertTrue(checkResults(files[6] + ".out", files[6] + ".org"));
|
||||
Assert.assertTrue(checkResults(outputFile, files[6] + ".org"));
|
||||
System.out.println("Done");
|
||||
} catch (Exception ex) {
|
||||
Assert.fail("testSeven Failed " + ex);
|
||||
@ -390,7 +392,7 @@ public class WriterTest {
|
||||
|
||||
try {
|
||||
|
||||
String outputFile = files[7] + ".out";
|
||||
String outputFile = USER_DIR + files[7] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -424,7 +426,7 @@ public class WriterTest {
|
||||
xtw.flush();
|
||||
xtw.close();
|
||||
// check against testSeven.xml.org
|
||||
Assert.assertTrue(checkResults(files[7] + ".out", files[7] + ".org"));
|
||||
Assert.assertTrue(checkResults(outputFile, files[7] + ".org"));
|
||||
System.out.println("Done");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -442,7 +444,7 @@ public class WriterTest {
|
||||
|
||||
try {
|
||||
|
||||
String outputFile = files[8] + ".out";
|
||||
String outputFile = USER_DIR + files[8] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -476,7 +478,7 @@ public class WriterTest {
|
||||
xtw.flush();
|
||||
xtw.close();
|
||||
// check against testSeven.xml.org
|
||||
Assert.assertTrue(checkResults(files[8] + ".out", files[7] + ".org"));
|
||||
Assert.assertTrue(checkResults(outputFile, files[7] + ".org"));
|
||||
System.out.println("Done");
|
||||
} catch (Exception ex) {
|
||||
Assert.fail("testNine Failed " + ex);
|
||||
@ -491,7 +493,7 @@ public class WriterTest {
|
||||
System.out.println("Test StreamWriter supplied with no namespace information and" + "isRepairingNamespace is set to true.");
|
||||
try {
|
||||
|
||||
String outputFile = files[9] + ".out";
|
||||
String outputFile = USER_DIR + files[9] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -542,7 +544,7 @@ public class WriterTest {
|
||||
System.out.println("Test StreamWriter supplied with namespace information passed through startElement and" + "isRepairingNamespace is set to true.");
|
||||
try {
|
||||
|
||||
String outputFile = files[10] + ".out";
|
||||
String outputFile = USER_DIR + files[10] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -576,7 +578,7 @@ public class WriterTest {
|
||||
xtw.flush();
|
||||
xtw.close();
|
||||
// check against testSeven.xml.org
|
||||
Assert.assertTrue(checkResults(files[10] + ".out", files[7] + ".org"));
|
||||
Assert.assertTrue(checkResults(outputFile, files[7] + ".org"));
|
||||
System.out.println("Done");
|
||||
} catch (Exception ex) {
|
||||
Assert.fail("testEleven Failed " + ex);
|
||||
@ -592,7 +594,7 @@ public class WriterTest {
|
||||
|
||||
try {
|
||||
|
||||
String outputFile = files[11] + ".out";
|
||||
String outputFile = USER_DIR + files[11] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -643,7 +645,7 @@ public class WriterTest {
|
||||
|
||||
try {
|
||||
|
||||
String outputFile = files[12] + ".out";
|
||||
String outputFile = USER_DIR + files[12] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
@ -695,7 +697,7 @@ public class WriterTest {
|
||||
|
||||
try {
|
||||
|
||||
String outputFile = files[14] + ".out";
|
||||
String outputFile = USER_DIR + files[14] + ".out";
|
||||
System.out.println("Writing output to " + outputFile);
|
||||
outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
|
||||
xtw = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), ENCODING);
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
package transform;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -55,7 +57,7 @@ public class Bug4693341Test {
|
||||
// save dtd file to current working directory to avoid writing into source repository
|
||||
public void copyDTDtoWorkDir() throws IOException {
|
||||
try (FileInputStream dtdres = new FileInputStream(getClass().getResource("Bug4693341.dtd").getPath());
|
||||
FileOutputStream dtdwork = new FileOutputStream("Bug4693341.dtd");) {
|
||||
FileOutputStream dtdwork = new FileOutputStream(USER_DIR + "Bug4693341.dtd");) {
|
||||
int n;
|
||||
byte[] buffer = new byte[1024];
|
||||
while((n = dtdres.read(buffer)) > -1) {
|
||||
@ -71,7 +73,7 @@ public class Bug4693341Test {
|
||||
|
||||
copyDTDtoWorkDir();
|
||||
|
||||
File outf = new File("Bug4693341.out");
|
||||
File outf = new File(USER_DIR + "Bug4693341.out");
|
||||
StreamResult result = new StreamResult(new FileOutputStream(outf));
|
||||
|
||||
String in = getClass().getResource("Bug4693341.xml").getPath();
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
package transform;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
@ -58,7 +60,7 @@ public class Bug4892774 {
|
||||
|
||||
private final String XML_FILE = "catalog.xml";
|
||||
private final String XML10_FILE = "catalog_10.xml"; // 1.0 version document
|
||||
private final String TEMP_FILE = "tmp.xml";
|
||||
private final String TEMP_FILE = USER_DIR + "tmp.xml";
|
||||
private final String EXPECTED_VERSION = "1.1";
|
||||
static private Transformer idTransform = null;
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
package transform;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
import static jaxp.library.JAXPTestUtilities.runWithTmpPermission;
|
||||
|
||||
import java.io.File;
|
||||
@ -52,7 +53,7 @@ public class Bug6216226Test {
|
||||
@Test
|
||||
public final void test() {
|
||||
try {
|
||||
File test = new File("bug6216226.txt");
|
||||
File test = new File(USER_DIR + "bug6216226.txt");
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
Transformer xformer = tf.newTransformer();
|
||||
StringReader st = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?><doc></doc>");
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
package transform;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import javax.xml.transform.Result;
|
||||
@ -65,7 +67,7 @@ public class CR6935697Test {
|
||||
Transformer xformer = template.newTransformer();
|
||||
// Prepare the input and output files
|
||||
Source source = new StreamSource(getClass().getResourceAsStream(inFilename));
|
||||
Result result = new StreamResult(new FileOutputStream(outFilename));
|
||||
Result result = new StreamResult(new FileOutputStream(USER_DIR + outFilename));
|
||||
// Apply the xsl file to the source file and write the result to the
|
||||
// output file
|
||||
xformer.transform(source, result);
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
package transform;
|
||||
|
||||
import java.io.FilePermission;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
@ -46,6 +47,7 @@ import static org.testng.Assert.assertEquals;
|
||||
import static jaxp.library.JAXPTestUtilities.runWithAllPerm;
|
||||
import static jaxp.library.JAXPTestUtilities.clearSystemProperty;
|
||||
import static jaxp.library.JAXPTestUtilities.setSystemProperty;
|
||||
import static jaxp.library.JAXPTestUtilities.tryRunWithTmpPermission;
|
||||
import static jaxp.library.JAXPTestUtilities.getSystemProperty;
|
||||
|
||||
/*
|
||||
@ -77,7 +79,9 @@ public class XSLTFunctionsTest {
|
||||
Transformer t = tf.newTransformer(new StreamSource(new StringReader(xsl)));
|
||||
|
||||
//Transform the xml
|
||||
t.transform(new StreamSource(new StringReader(xml)), new StreamResult(new StringWriter()));
|
||||
tryRunWithTmpPermission(
|
||||
() -> t.transform(new StreamSource(new StringReader(xml)), new StreamResult(new StringWriter())),
|
||||
new FilePermission(output, "write"), new FilePermission(redirect, "write"));
|
||||
|
||||
// Verifies that the output is redirected successfully
|
||||
String userDir = getSystemProperty("user.dir");
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
package transform.util;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@ -34,7 +36,7 @@ public abstract class TransformerUtil {
|
||||
|
||||
protected String type;
|
||||
|
||||
protected final String TEMP_FILE = "tmp.xml";
|
||||
protected final String TEMP_FILE = USER_DIR + "tmp.xml";
|
||||
|
||||
public abstract Source prepareSource(InputStream is) throws Exception;
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
package validation;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
||||
@ -122,7 +124,7 @@ public class CR6708840Test {
|
||||
Validator schemaValidator = schemaGrammar.newValidator();
|
||||
|
||||
Source staxSrc = new StAXSource(staxReader);
|
||||
File resultFile = new File("gMonths.result.xml");
|
||||
File resultFile = new File(USER_DIR + "gMonths.result.xml");
|
||||
if (resultFile.exists()) {
|
||||
resultFile.delete();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
package validation;
|
||||
|
||||
import static jaxp.library.JAXPTestUtilities.USER_DIR;
|
||||
import static jaxp.library.JAXPTestUtilities.runWithTmpPermission;
|
||||
|
||||
import java.io.File;
|
||||
@ -61,7 +62,7 @@ public class ValidatorTest {
|
||||
|
||||
File resultFile = null;
|
||||
try {
|
||||
resultFile = new File("stax.result");
|
||||
resultFile = new File(USER_DIR + "stax.result");
|
||||
if (resultFile.exists()) {
|
||||
resultFile.delete();
|
||||
}
|
||||
@ -88,7 +89,7 @@ public class ValidatorTest {
|
||||
|
||||
File resultFile = null;
|
||||
try {
|
||||
resultFile = new File("stax.result");
|
||||
resultFile = new File(USER_DIR + "stax.result");
|
||||
if (resultFile.exists()) {
|
||||
resultFile.delete();
|
||||
}
|
||||
@ -117,7 +118,7 @@ public class ValidatorTest {
|
||||
// test valid gMonths
|
||||
File resultFile = null;
|
||||
try {
|
||||
resultFile = new File("gMonths.result.xml");
|
||||
resultFile = new File(USER_DIR + "gMonths.result.xml");
|
||||
if (resultFile.exists()) {
|
||||
resultFile.delete();
|
||||
}
|
||||
@ -144,7 +145,7 @@ public class ValidatorTest {
|
||||
// test invalid gMonths
|
||||
File invalidResultFile = null;
|
||||
try {
|
||||
invalidResultFile = new File("gMonths-invalid.result.xml");
|
||||
invalidResultFile = new File(USER_DIR + "gMonths-invalid.result.xml");
|
||||
if (invalidResultFile.exists()) {
|
||||
invalidResultFile.delete();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user