Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8264454 : Jaxp unit test from open jdk needs to be improved #3274

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -44,6 +44,7 @@

@Test
public void testSAXParserFactory() {
// This test run in othervm so change in environment need not to be recovered at the end of test.
runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));

This comment has been minimized.

@JoeWang-Java

JoeWang-Java Mar 31, 2021
Member

To address item 4 (the environment is changed), a note, something like "this test runs in othervm" can be added here or to the summary.

This comment has been minimized.

@mahendrachhipa

mahendrachhipa Apr 6, 2021
Author Contributor

Added the comment

if (Bug6350682.class.getClassLoader() == null) {
System.out.println("this class loader is NULL");
@@ -56,6 +57,7 @@ public void testSAXParserFactory() {

@Test
public void testTransformerFactory() {
// This test run in othervm so change in environment need not to be recovered at the end of test.
runWithAllPerm(() -> Thread.currentThread().setContextClassLoader(null));
TransformerFactory factory = TransformerFactory.newInstance();
Assert.assertNotNull(factory, "Failed to get an instance of a TransformerFactory");
@@ -45,7 +45,7 @@
private static final String ERR_MSG = "org.apache.xerces.jaxp.SAXParserFactoryImpl not found";

This comment has been minimized.

@JoeWang-Java

JoeWang-Java Mar 31, 2021
Member

This test currently doesn't verify anything since there's no org.apache.xerces.jaxp.SAXParserFactoryImpl on the classpath. Post JDK 9, such test would require creating a dummy module.


@Test
public void testSAXParserFactoryCreationWithDefaultContextClassLoader() {
public void testWithDefaultContextClassLoader() {
try {
SAXParserFactory.newInstance();
} catch (Exception e) {
@@ -56,7 +56,7 @@ public void testSAXParserFactoryCreationWithDefaultContextClassLoader() {
}

@Test
public void testSAXParserFactoryCreationWithGivenURLContextClassLoader() {
public void testWithGivenURLContextClassLoader() {
try {
System.out.println(Thread.currentThread().getContextClassLoader());
System.out.println(ClassLoader.getSystemClassLoader().getParent());
@@ -56,15 +56,10 @@
*/
private static final String TEST_VALUE_FAIL = "*FAIL*";

This comment has been minimized.

@JoeWang-Java

JoeWang-Java Mar 31, 2021
Member

I don't see this in the expected values. It, along with the related assertions, may be removed.


private static final String FIELD_UNDEFINED = "FIELD_UNDEFINED";
private static final DatatypeConstants.Field[] FIELDS = { DatatypeConstants.YEARS, DatatypeConstants.MONTHS, DatatypeConstants.DAYS, DatatypeConstants.HOURS,
DatatypeConstants.MINUTES, DatatypeConstants.SECONDS };

@Test
public void test() throws DatatypeConfigurationException {
DatatypeFactory dtf = DatatypeFactory.newInstance();
Duration d = dtf.newDurationYearMonth("P20Y15M");
int years = d.getYears();
System.out.println(d.getYears() == 21 ? "pass" : "fail");
}

@@ -182,41 +177,34 @@ public void testNewDurationYearMonthLexicalRepresentation1(String actualLex, Str
}

// was this expected to fail?
if (expectedLex.equals(TEST_VALUE_FAIL)) {
Assert.fail("the value \"" + actualLex + "\" is invalid yet it created the Duration \"" + duration.toString() + "\"");
}
Assert.assertNotEquals(expectedLex, TEST_VALUE_FAIL, "the value \"" + actualLex + "\" is invalid " +
"yet it created the Duration \"" + duration.toString() + "\"" );

// right XMLSchemaType?
// TODO: enable test, it should pass, it fails with Exception(s)
// for now due to a bug
try {
QName xmlSchemaType = duration.getXMLSchemaType();
if (!xmlSchemaType.equals(DatatypeConstants.DURATION_YEARMONTH)) {
Assert.fail("Duration created with XMLSchemaType of\"" + xmlSchemaType + "\" was expected to be \""
+ DatatypeConstants.DURATION_YEARMONTH + "\" and has the value \"" + duration.toString() + "\"");
}
Assert.assertEquals(xmlSchemaType, DatatypeConstants.DURATION_YEARMONTH, "Duration created with " +
"XMLSchemaType of\"" + xmlSchemaType + "\" was expected to be \""
+ DatatypeConstants.DURATION_YEARMONTH + "\" and has the value \"" + duration.toString() + "\"");
} catch (IllegalStateException illegalStateException) {
// TODO; this test really should pass
System.err.println("Please fix this bug that is being ignored, for now: " + illegalStateException.getMessage());

This comment has been minimized.

@JoeWang-Java

JoeWang-Java Mar 31, 2021
Member

Do we still have such a bug?

This comment has been minimized.

@mahendrachhipa

mahendrachhipa Apr 6, 2021
Author Contributor

Yes, test is still trowing IllegalStateException.

}

// does it have the right value?
if (!expectedLex.equals(duration.toString())) {
Assert.fail("Duration created with \"" + actualLex + "\" was expected to be \""
+ expectedLex + "\" and has the value \"" + duration.toString() + "\"");
}

Assert.assertEquals(duration.toString(), expectedLex, "Duration created with \"" + actualLex +
"\" was expected to be \"" + expectedLex + "\" and has the value \"" + duration.toString() + "\"");
// Duration created with correct value
} catch (Exception exception) {

if (DEBUG) {
System.err.println("Exception in creating duration: \"" + exception.toString() + "\"");
}

// was this expected to succed?
if (!expectedLex.equals(TEST_VALUE_FAIL)) {
Assert.fail("the value \"" + actualLex + "\" is valid yet it failed with \"" + exception.toString() + "\"");
}
Assert.assertEquals(TEST_VALUE_FAIL, expectedLex, "the value \"" + actualLex + "\" is valid yet " +
"it failed with \"" + exception.toString() + "\"");
// expected failure
}
}
@@ -297,7 +285,7 @@ public void testNewDurationDayTime005(String lex, boolean isPositive, BigInteger
+ seconds + "\'");
}
}
if (result.length() > 0) {
if(result.length() > 0) {
Assert.fail(result.substring(2));
}
System.out.println("OK");
ProTip! Use n and p to navigate between commits in a pull request.