8381882: Convert test/jaxp/javax/xml/jaxp/unittest/stream tests to JUnit#30643
8381882: Convert test/jaxp/javax/xml/jaxp/unittest/stream tests to JUnit#30643david-beaumont wants to merge 3 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back dbeaumont! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
@david-beaumont The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
david-beaumont
left a comment
There was a problem hiding this comment.
Some "preloaded" comments explaining non-trivial changes.
| Assert.assertEquals(s1.getEventType(), XMLStreamConstants.START_DOCUMENT); | ||
| s1.next(); | ||
| s1.next(); // advance to <TITLE> | ||
| Assert.assertTrue(s1.getLocalName().equals("TITLE")); |
There was a problem hiding this comment.
A lot of assertions have been rewritten to be idiomatic. Mostly this is handled via IntelliJ analysis, but not always.
| public class Bug6509774 { | ||
|
|
||
| @Test | ||
| public void test0() { |
There was a problem hiding this comment.
This test was obviously cut & pasted with alternating blank lines (making it much less readable), so I reformatted it to remove unwanted empty lines.
| } | ||
| } | ||
|
|
||
| public static/* synchronized */XMLStreamReader getReader(InputStream is) throws Exception { |
There was a problem hiding this comment.
No need for synchronization on factories.
| */ | ||
| public class CoalesceTest { | ||
|
|
||
| String countryElementContent = "START India CS}}}}}} India END"; |
There was a problem hiding this comment.
As well as making these constants, I could switch to UPPER_SNAKE_CASE. Your (reviewer) call.
| eventType = streamReader.next(); | ||
| if (eventType == XMLStreamConstants.CHARACTERS) { | ||
| String text = streamReader.getText(); | ||
| if (!text.equals(descriptionElementContent)) { |
There was a problem hiding this comment.
None of the debug output is needed if assertEquals() is used.
| public void testDuplicateNamespaceURI() throws Exception { | ||
|
|
||
| xmlStreamWriter.writeStartDocument(); | ||
| xmlStreamWriter.writeStartElement(new String(""), "localName", new String("nsUri")); |
There was a problem hiding this comment.
It's not clear why the new String() was being used here. I could revert it if it's felt likely to be important.
| public class NamespaceTest { | ||
|
|
||
| /** debug output? */ | ||
| private static final boolean DEBUG = true; |
There was a problem hiding this comment.
Debug output is extensive and unnecessary for unit tests. I've checked that no output was also affecting the test itself.
| } | ||
|
|
||
| Assert.assertTrue(actualOutput.equals(EXPECTED_OUTPUT) || actualOutput.equals(EXPECTED_OUTPUT_2), "Expected: " + EXPECTED_OUTPUT + "\n" + "Actual: " | ||
| assertTrue(actualOutput.equals(EXPECTED_OUTPUT) || actualOutput.equals(EXPECTED_OUTPUT_2), "Expected: " + EXPECTED_OUTPUT + "\n" + "Actual: " |
There was a problem hiding this comment.
I've left this in, but realistically only one or these sub-clauses will ever be true.
There was a problem hiding this comment.
A lot of removal of redundant catch clauses in this test... sorry!
| XMLStreamWriter w = xof.createXMLStreamWriter(sw); | ||
| w.writeStartDocument(); | ||
| w.writeStartElement("foo", "bar", "zot"); | ||
| w.writeDefaultNamespace(null); |
There was a problem hiding this comment.
Not actually asserting anything.
Webrevs
|
Convert and tidy-up unit tests in test/jaxp/javax/xml/jaxp/unittest/stream.
It is recommended to set the diff settings in github to hide whitespace (cog-wheel menu).
There are a lot of cases where manual catch blocks with explicit fail are removed to just allow the test to fail idiomatically by throwing the exception normally. This causes thousands of lines to be un-indented (with no other change).
About 200 explicit uses of
fail()were either removed or converted to appropriate JUnit asserts.There are also several non-trivial changes in this PR related to bad tests where, for example, catching and ignoring exceptions allowed the test to pass under all situations.
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30643/head:pull/30643$ git checkout pull/30643Update a local copy of the PR:
$ git checkout pull/30643$ git pull https://git.openjdk.org/jdk.git pull/30643/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 30643View PR using the GUI difftool:
$ git pr show -t 30643Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30643.diff
Using Webrev
Link to Webrev Comment