Skip to content

Commit

Permalink
Add Java 16 to CI build action and fix test on JDK 16+
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeEdgar committed Jun 19, 2021
1 parent 0769cdd commit fbcb346
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8, 11]
java: [8, 11, 16]
name: Build with JDK ${{matrix.java}}

steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.logging.Logger;

import javax.xml.namespace.NamespaceContext;
import javax.xml.stream.StreamFilter;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
Expand Down Expand Up @@ -76,6 +77,7 @@
import io.xlate.edi.stream.EDIStreamValidationError;
import io.xlate.edi.stream.EDIStreamWriter;
import io.xlate.edi.stream.Location;
import io.xlate.edi.test.StaEDITestUtil;

@SuppressWarnings("resource")
class StaEDIXMLStreamReaderTest {
Expand Down Expand Up @@ -903,11 +905,18 @@ void testInvalidInput() throws Exception {
InputStream stream = new ByteArrayInputStream("{}".getBytes());
ediReader = factory.createEDIStreamReader(stream);
XMLStreamReader xmlReader = factory.createXMLStreamReader(ediReader);
XMLStreamReader filtered = XMLInputFactory.newFactory().createFilteredReader(xmlReader,
reader -> reader.getEventType() == XMLStreamConstants.START_ELEMENT &&
reader.getLocalName().equals("TRANSACTION"));
StreamFilter xmlFilter = reader -> reader.getEventType() == XMLStreamConstants.START_ELEMENT &&
reader.getLocalName().equals("TRANSACTION");
XMLStreamException thrown;

if (Integer.parseInt(StaEDITestUtil.getJavaVersion()[0]) >= 16) {
// See fix for JDK-8255918: https://github.com/openjdk/jdk/pull/1209
thrown = assertThrows(XMLStreamException.class, () -> XMLInputFactory.newFactory().createFilteredReader(xmlReader, xmlFilter));
} else {
XMLStreamReader filtered = XMLInputFactory.newFactory().createFilteredReader(xmlReader, xmlFilter);
thrown = assertThrows(XMLStreamException.class, () -> filtered.hasNext());
}

XMLStreamException thrown = assertThrows(XMLStreamException.class, () -> filtered.hasNext());
assertTrue(thrown.getCause() instanceof EDIStreamException);
String message = thrown.getCause().getMessage();
assertTrue(message.contains("EDIE003"));
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/io/xlate/edi/test/StaEDITestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ public boolean accept(EDIStreamReader reader) {
};
return factory.createFilteredReader(reader, filter);
}

public static String[] getJavaVersion() {
String versionString = System.getProperty("java.version");
return versionString.split("[\\._]");
}
}

0 comments on commit fbcb346

Please sign in to comment.