8078596: jaxp tests failed in modular jdk due to internal class access

Reviewed-by: alanb, lancea, joehw
This commit is contained in:
Frank Yuan 2015-05-15 16:26:03 -07:00 committed by Joe Wang
parent ef28a587f7
commit 2910c5e690
15 changed files with 118 additions and 71 deletions
jaxp/test/javax/xml/jaxp
functional/test/auctionportal
internaltest
libs/test/auctionportal
unittest
TEST.properties
javax/xml
common
stream/XMLStreamWriterTest
org/w3c/dom/ls

@ -22,8 +22,8 @@
*/
package test.auctionportal;
import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_LANGUAGE;
import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_SOURCE;
import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE;
import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_SOURCE;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

@ -22,10 +22,10 @@
*/
package test.auctionportal;
import static com.sun.org.apache.xerces.internal.impl.Constants.SP_ENTITY_EXPANSION_LIMIT;
import static com.sun.org.apache.xerces.internal.impl.Constants.SP_MAX_OCCUR_LIMIT;
import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_LANGUAGE;
import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_SOURCE;
import static test.auctionportal.HiBidConstants.SP_ENTITY_EXPANSION_LIMIT;
import static test.auctionportal.HiBidConstants.SP_MAX_OCCUR_LIMIT;
import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE;
import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_SOURCE;
import static org.testng.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;

@ -22,7 +22,7 @@
*/
package test.auctionportal;
import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_LANGUAGE;
import static test.auctionportal.HiBidConstants.JAXP_SCHEMA_LANGUAGE;
import static org.testng.Assert.assertFalse;
import java.io.FileOutputStream;
import java.nio.file.Files;

@ -0,0 +1,3 @@
# jaxp test uses TestNG
TestNG.dirs = javax/xml/common/bug6979306 javax/xml/parsers/bug8003147 javax/xml/transform/bug6551616 javax/xml/transform/cli

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, 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
@ -21,16 +21,19 @@
* questions.
*/
package javax.xml.common;
/*
* @test
* @modules java.xml/com.sun.org.apache.xerces.internal.impl
* java.xml/com.sun.org.apache.xalan.internal
* java.xml/com.sun.org.apache.xalan.internal.xslt
* @bug 6979306
* @summary Test JAXP component version.
*/
import org.testng.annotations.Test;
import com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck;
/*
* @bug 6979306
* @summary Test JAXP component version.
*/
public class Bug6979306Test {
@Test

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, 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
@ -21,7 +21,13 @@
* questions.
*/
package javax.xml.parsers;
/*
* @test
* @modules java.xml/com.sun.org.apache.bcel.internal.classfile
* java.xml/com.sun.org.apache.bcel.internal.generic
* @bug 8003147
* @summary Test port fix for BCEL bug 39695.
*/
import java.io.FileOutputStream;
import java.util.ArrayList;
@ -38,10 +44,6 @@ import com.sun.org.apache.bcel.internal.classfile.Method;
import com.sun.org.apache.bcel.internal.generic.ClassGen;
import com.sun.org.apache.bcel.internal.generic.MethodGen;
/*
* @bug 8003147
* @summary Test port fix for BCEL bug 39695.
*/
public class Bug8003147Test {
@Test
@ -51,7 +53,7 @@ public class Bug8003147Test {
// rename class
ConstantPool cp = jc.getConstantPool();
int cpIndex = ((ConstantClass) cp.getConstant(jc.getClassNameIndex())).getNameIndex();
cp.setConstant(cpIndex, new ConstantUtf8("javax/xml/parsers/Bug8003147TestPrime"));
cp.setConstant(cpIndex, new ConstantUtf8("Bug8003147TestPrime"));
ClassGen gen = new ClassGen(jc);
Method[] methods = jc.getMethods();
int index;
@ -67,7 +69,7 @@ public class Bug8003147Test {
gen.getJavaClass().dump(new FileOutputStream(path));
try {
Class.forName("javax.xml.parsers.Bug8003147TestPrime");
Class.forName("Bug8003147TestPrime");
} catch (ClassFormatError cfe) {
cfe.printStackTrace();
Assert.fail("modified version of class does not pass verification");

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, 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
@ -21,24 +21,23 @@
* questions.
*/
package javax.xml.transform;
/*
* @test
* @modules java.xml/com.sun.org.apache.xalan.internal.xsltc.trax
* @bug 6551616
* @summary Test SAX2StAXEventWriter.
*/
import java.io.File;
import java.io.InputStream;
import java.io.StringBufferInputStream;
import java.security.Policy;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLOutputFactory;
import com.sun.org.apache.xalan.internal.xsltc.trax.SAX2StAXEventWriter;
import org.testng.annotations.Test;
/*
* @bug 6551616
* @summary Test SAX2StAXEventWriter.
*/
import com.sun.org.apache.xalan.internal.xsltc.trax.SAX2StAXEventWriter;
public class Bug6551616 {
String _cache = "";

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, 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
@ -21,14 +21,15 @@
* questions.
*/
package javax.xml.transform;
/*
* @test
* @modules java.xml/com.sun.org.apache.xalan.internal.xslt
* @summary Test internal transform CLI.
*/
import org.testng.Assert;
import org.testng.annotations.Test;
/*
* @summary Test internal transform CLI.
*/
public class CLITest {
@Test

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:document xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style" office:class="text" office:version="1.0">
<office:styles>
<style:default-style style:family="graphics"/>
<style:default-style style:family="paragraph"/>
</office:styles>
</office:document>

@ -0,0 +1,21 @@
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:office="http://openoffice.org/2000/office"
xmlns:style="http://openoffice.org/2000/style">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:variable name="copyData">
<xsl:call-template name="copy-by-template" />
</xsl:variable>
<test>
<xsl:copy-of select="$copyData"/>
</test>
</xsl:template>
<xsl:template name="copy-by-template">
<xsl:copy-of select="/"/>
</xsl:template>
</xsl:stylesheet>

@ -42,4 +42,24 @@ public class HiBidConstants {
* Name space for account operation.
*/
public static final String PORTAL_ACCOUNT_NS = "http://www.auctionportal.org/Accounts";
/**
* JAXP schema language property name.
*/
public static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
/**
* JAXP schema source property name.
*/
public static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
/**
* Name of system property JDK entity expansion limit
*/
public static final String SP_ENTITY_EXPANSION_LIMIT = "jdk.xml.entityExpansionLimit";
/**
* Name of system property JDK maxOccur limit
*/
public static final String SP_MAX_OCCUR_LIMIT = "jdk.xml.maxOccurLimit";
}

@ -1,3 +1,3 @@
# jaxp test uses TestNG
TestNG.dirs = unittest
TestNG.dirs = .

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, 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
@ -76,7 +76,7 @@ public class Bug7143711Test {
}
@Test
@Test(enabled=false) //skipped due to bug JDK-8080097
public void testTransform_DOM_withSM() {
System.out.println("Transform using DOM Source; Security Manager is set:");
@ -89,7 +89,7 @@ public class Bug7143711Test {
TransformerFactory factory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
TransformerFactory.class.getClassLoader());
factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, true);
if (((com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl) factory).useServicesMechnism()) {
if ((boolean) factory.getFeature(ORACLE_FEATURE_SERVICE_MECHANISM)) {
Assert.fail("should not override in secure mode");
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, 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
@ -24,20 +24,16 @@
package javax.xml.stream.XMLStreamWriterTest;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.xml.XMLConstants;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.stream.StreamResult;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.sun.xml.internal.stream.writers.XMLStreamWriterImpl;
/*
* @summary Test the writing of Namespaces.
*/
@ -80,15 +76,10 @@ public class NamespaceTest {
private void resetWriter() {
// reset the Writer
try {
xmlStreamWriter.flush();
xmlStreamWriter.close();
((XMLStreamWriterImpl) xmlStreamWriter).reset();
byteArrayOutputStream.reset();
((XMLStreamWriterImpl) xmlStreamWriter).setOutput(new StreamResult(byteArrayOutputStream), "utf-8");
xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(byteArrayOutputStream, "utf-8");
} catch (XMLStreamException xmlStreamException) {
Assert.fail(xmlStreamException.toString());
} catch (IOException ioException) {
Assert.fail(ioException.toString());
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2015, 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
@ -42,12 +42,12 @@ import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.sun.org.apache.xerces.internal.impl.Constants;
/*
* @summary Test LSSerializer.
*/
public class LSSerializerTest {
private static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print";
class DOMErrorHandlerImpl implements DOMErrorHandler {
@ -192,47 +192,47 @@ public class LSSerializerTest {
DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
// query current configuration
Boolean defaultFormatPrettyPrint = (Boolean) domConfiguration.getParameter(Constants.DOM_FORMAT_PRETTY_PRINT);
Boolean canSetFormatPrettyPrintFalse = (Boolean) domConfiguration.canSetParameter(Constants.DOM_FORMAT_PRETTY_PRINT, Boolean.FALSE);
Boolean canSetFormatPrettyPrintTrue = (Boolean) domConfiguration.canSetParameter(Constants.DOM_FORMAT_PRETTY_PRINT, Boolean.TRUE);
Boolean defaultFormatPrettyPrint = (Boolean) domConfiguration.getParameter(DOM_FORMAT_PRETTY_PRINT);
Boolean canSetFormatPrettyPrintFalse = (Boolean) domConfiguration.canSetParameter(DOM_FORMAT_PRETTY_PRINT, Boolean.FALSE);
Boolean canSetFormatPrettyPrintTrue = (Boolean) domConfiguration.canSetParameter(DOM_FORMAT_PRETTY_PRINT, Boolean.TRUE);
System.out.println(Constants.DOM_FORMAT_PRETTY_PRINT + " default/can set false/can set true = " + defaultFormatPrettyPrint + "/"
System.out.println(DOM_FORMAT_PRETTY_PRINT + " default/can set false/can set true = " + defaultFormatPrettyPrint + "/"
+ canSetFormatPrettyPrintFalse + "/" + canSetFormatPrettyPrintTrue);
// test values
Assert.assertEquals(defaultFormatPrettyPrint, Boolean.FALSE, "Default value of " + Constants.DOM_FORMAT_PRETTY_PRINT + " should be " + Boolean.FALSE);
Assert.assertEquals(defaultFormatPrettyPrint, Boolean.FALSE, "Default value of " + DOM_FORMAT_PRETTY_PRINT + " should be " + Boolean.FALSE);
Assert.assertEquals(canSetFormatPrettyPrintFalse, Boolean.TRUE, "Can set " + Constants.DOM_FORMAT_PRETTY_PRINT + " to " + Boolean.FALSE + " should be "
Assert.assertEquals(canSetFormatPrettyPrintFalse, Boolean.TRUE, "Can set " + DOM_FORMAT_PRETTY_PRINT + " to " + Boolean.FALSE + " should be "
+ Boolean.TRUE);
Assert.assertEquals(canSetFormatPrettyPrintTrue, Boolean.TRUE, "Can set " + Constants.DOM_FORMAT_PRETTY_PRINT + " to " + Boolean.TRUE + " should be "
Assert.assertEquals(canSetFormatPrettyPrintTrue, Boolean.TRUE, "Can set " + DOM_FORMAT_PRETTY_PRINT + " to " + Boolean.TRUE + " should be "
+ Boolean.TRUE);
// get default serialization
String prettyPrintDefault = lsSerializer.writeToString(document);
System.out.println("(default) " + Constants.DOM_FORMAT_PRETTY_PRINT + "==" + (Boolean) domConfiguration.getParameter(Constants.DOM_FORMAT_PRETTY_PRINT)
System.out.println("(default) " + DOM_FORMAT_PRETTY_PRINT + "==" + (Boolean) domConfiguration.getParameter(DOM_FORMAT_PRETTY_PRINT)
+ ": \n\"" + prettyPrintDefault + "\"");
Assert.assertEquals(XML_DOCUMENT_DEFAULT_PRINT, prettyPrintDefault, "Invalid serialization with default value, " + Constants.DOM_FORMAT_PRETTY_PRINT + "=="
+ (Boolean) domConfiguration.getParameter(Constants.DOM_FORMAT_PRETTY_PRINT));
Assert.assertEquals(XML_DOCUMENT_DEFAULT_PRINT, prettyPrintDefault, "Invalid serialization with default value, " + DOM_FORMAT_PRETTY_PRINT + "=="
+ (Boolean) domConfiguration.getParameter(DOM_FORMAT_PRETTY_PRINT));
// configure LSSerializer to not format-pretty-print
domConfiguration.setParameter(Constants.DOM_FORMAT_PRETTY_PRINT, Boolean.FALSE);
domConfiguration.setParameter(DOM_FORMAT_PRETTY_PRINT, Boolean.FALSE);
String prettyPrintFalse = lsSerializer.writeToString(document);
System.out.println("(FALSE) " + Constants.DOM_FORMAT_PRETTY_PRINT + "==" + (Boolean) domConfiguration.getParameter(Constants.DOM_FORMAT_PRETTY_PRINT)
System.out.println("(FALSE) " + DOM_FORMAT_PRETTY_PRINT + "==" + (Boolean) domConfiguration.getParameter(DOM_FORMAT_PRETTY_PRINT)
+ ": \n\"" + prettyPrintFalse + "\"");
Assert.assertEquals(XML_DOCUMENT_DEFAULT_PRINT, prettyPrintFalse, "Invalid serialization with FALSE value, " + Constants.DOM_FORMAT_PRETTY_PRINT + "=="
+ (Boolean) domConfiguration.getParameter(Constants.DOM_FORMAT_PRETTY_PRINT));
Assert.assertEquals(XML_DOCUMENT_DEFAULT_PRINT, prettyPrintFalse, "Invalid serialization with FALSE value, " + DOM_FORMAT_PRETTY_PRINT + "=="
+ (Boolean) domConfiguration.getParameter(DOM_FORMAT_PRETTY_PRINT));
// configure LSSerializer to format-pretty-print
domConfiguration.setParameter(Constants.DOM_FORMAT_PRETTY_PRINT, Boolean.TRUE);
domConfiguration.setParameter(DOM_FORMAT_PRETTY_PRINT, Boolean.TRUE);
String prettyPrintTrue = lsSerializer.writeToString(document);
System.out.println("(TRUE) " + Constants.DOM_FORMAT_PRETTY_PRINT + "==" + (Boolean) domConfiguration.getParameter(Constants.DOM_FORMAT_PRETTY_PRINT)
System.out.println("(TRUE) " + DOM_FORMAT_PRETTY_PRINT + "==" + (Boolean) domConfiguration.getParameter(DOM_FORMAT_PRETTY_PRINT)
+ ": \n\"" + prettyPrintTrue + "\"");
Assert.assertEquals(XML_DOCUMENT_PRETTY_PRINT, prettyPrintTrue, "Invalid serialization with TRUE value, " + Constants.DOM_FORMAT_PRETTY_PRINT + "=="
+ (Boolean) domConfiguration.getParameter(Constants.DOM_FORMAT_PRETTY_PRINT));
Assert.assertEquals(XML_DOCUMENT_PRETTY_PRINT, prettyPrintTrue, "Invalid serialization with TRUE value, " + DOM_FORMAT_PRETTY_PRINT + "=="
+ (Boolean) domConfiguration.getParameter(DOM_FORMAT_PRETTY_PRINT));
}
@Test