From df6afa74a252e68269d50ea7cb1f2a4cae94cf4f Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 14 Jan 2018 02:48:20 +0100 Subject: [PATCH] Add explicit dependency on JaxB Java 9 added the Jigsaw module system and moved `java.xml.bind` into a module. This module is not active by default. It can be be activated by running with `--add-modules java.xml.bind` however as it is scheduled to be removed in Java 10 it is prudent to migrate away from it now. As such the `jaxb-api`, glassfishes `jaxb-runtime` reference implementation and its dependency `javax.activation` have been added as maven dependencies. Additionally the `maven-plugin-plugin` failed to execute the help goal. This appeared to be caused by the initializer blocks of the anonymous subclass of the array list in BinaryType. This has been resolved by incrementing the plugin version and using `Arrays.asList` and replacing the use of `ArrayList` with the more general `List` interface where necessary. --- pom.xml | 22 ++++++- .../selenium/extract/FileExtractor.java | 6 +- .../selenium/repository/BinaryType.java | 58 ++++++++++--------- .../selenium/repository/BinaryTypeTest.java | 4 +- 4 files changed, 56 insertions(+), 34 deletions(-) diff --git a/pom.xml b/pom.xml index 9228c8c..14a78cb 100644 --- a/pom.xml +++ b/pom.xml @@ -90,6 +90,24 @@ + + + javax.xml.bind + jaxb-api + 2.3.0 + + + org.glassfish.jaxb + jaxb-runtime + 2.3.0 + + + javax.activation + activation + 1.1.1 + + + org.apache.maven maven-core @@ -105,6 +123,8 @@ maven-plugin-annotations 3.4 + + commons-io commons-io @@ -191,7 +211,7 @@ org.apache.maven.plugins maven-plugin-plugin - 3.3 + 3.5 true diff --git a/src/main/java/com/lazerycode/selenium/extract/FileExtractor.java b/src/main/java/com/lazerycode/selenium/extract/FileExtractor.java index dcea603..4c69758 100644 --- a/src/main/java/com/lazerycode/selenium/extract/FileExtractor.java +++ b/src/main/java/com/lazerycode/selenium/extract/FileExtractor.java @@ -16,8 +16,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; import java.util.Enumeration; +import java.util.List; import static com.lazerycode.selenium.extract.DownloadableFileType.TAR; @@ -81,7 +81,7 @@ public String extractFileFromArchive(File downloadedCompressedFile, String extra String unzipFile(File downloadedCompressedFile, String extractedToFilePath, BinaryType possibleFilenames) throws IOException, ExpectedFileNotFoundException { LOG.debug("Attempting to extract binary from .zip file..."); - ArrayList filenamesWeAreSearchingFor = possibleFilenames.getBinaryFilenames(); + List filenamesWeAreSearchingFor = possibleFilenames.getBinaryFilenames(); ZipFile zip = new ZipFile(downloadedCompressedFile); try { Enumeration zipFile = zip.getEntries(); @@ -114,7 +114,7 @@ String unzipFile(File downloadedCompressedFile, String extractedToFilePath, Bina private String untarFile(InputStream compressedFileInputStream, String extractedToFilePath, BinaryType possibleFilenames) throws IOException, ExpectedFileNotFoundException { LOG.debug("Attempting to extract binary from a .tar file..."); ArchiveEntry currentFile; - ArrayList filenamesWeAreSearchingFor = possibleFilenames.getBinaryFilenames(); + List filenamesWeAreSearchingFor = possibleFilenames.getBinaryFilenames(); ArchiveInputStream archiveInputStream = new TarArchiveInputStream(compressedFileInputStream); try { while ((currentFile = archiveInputStream.getNextEntry()) != null) { diff --git a/src/main/java/com/lazerycode/selenium/repository/BinaryType.java b/src/main/java/com/lazerycode/selenium/repository/BinaryType.java index 17cf15d..afe015a 100644 --- a/src/main/java/com/lazerycode/selenium/repository/BinaryType.java +++ b/src/main/java/com/lazerycode/selenium/repository/BinaryType.java @@ -1,54 +1,56 @@ package com.lazerycode.selenium.repository; -import java.util.ArrayList; +import java.util.List; + +import static java.util.Arrays.asList; public enum BinaryType { INTERNETEXPLORER( - new ArrayList() {{ - add("IEDriverServer.exe"); - }}, + asList( + "IEDriverServer.exe" + ), "webdriver.ie.driver"), GOOGLECHROME( - new ArrayList() {{ - add("chromedriver.exe"); - add("chromedriver"); - }}, + asList( + "chromedriver.exe", + "chromedriver" + ), "webdriver.chrome.driver"), PHANTOMJS( - new ArrayList() {{ - add("phantomjs.exe"); - add("phantomjs"); - }}, + asList( + "phantomjs.exe", + "phantomjs" + ), "phantomjs.binary.path"), OPERACHROMIUM( - new ArrayList() {{ - add("operadriver.exe"); - add("operadriver"); - }}, + asList( + "operadriver.exe", + "operadriver" + ), "webdriver.opera.driver"), MARIONETTE( - new ArrayList() {{ - add("wires"); - add("wires.exe"); - add("geckodriver"); - add("geckodriver.exe"); - }}, + asList( + "wires", + "wires.exe", + "geckodriver", + "geckodriver.exe" + ), "webdriver.gecko.driver"), EDGE( - new ArrayList() {{ - add("MicrosoftWebDriver.exe"); - }}, + asList( + "MicrosoftWebDriver.exe" + ), "webdriver.edge.driver"); - private final ArrayList binaryFilenames; + private final List binaryFilenames; private final String driverSystemProperty; - BinaryType(ArrayList binaryFilenames, String driverSystemProperty) { + BinaryType(List binaryFilenames, String driverSystemProperty) { this.binaryFilenames = binaryFilenames; this.driverSystemProperty = driverSystemProperty; } - public ArrayList getBinaryFilenames() { + public List getBinaryFilenames() { return binaryFilenames; } diff --git a/src/test/java/com/lazerycode/selenium/repository/BinaryTypeTest.java b/src/test/java/com/lazerycode/selenium/repository/BinaryTypeTest.java index 33ade1b..d43e0b2 100644 --- a/src/test/java/com/lazerycode/selenium/repository/BinaryTypeTest.java +++ b/src/test/java/com/lazerycode/selenium/repository/BinaryTypeTest.java @@ -2,7 +2,7 @@ import org.junit.Test; -import java.util.ArrayList; +import java.util.List; import static com.lazerycode.selenium.repository.BinaryType.GOOGLECHROME; import static com.lazerycode.selenium.repository.BinaryType.PHANTOMJS; @@ -14,7 +14,7 @@ public class BinaryTypeTest { @Test public void willReturnAListOfFilenameAssociatedWithBinary() { - ArrayList binaryFilenames = PHANTOMJS.getBinaryFilenames(); + List binaryFilenames = PHANTOMJS.getBinaryFilenames(); assertThat(binaryFilenames.size(), is(equalTo(2)));