Skip to content

Commit

Permalink
Merge pull request #76 from mpkorstanje/master
Browse files Browse the repository at this point in the history
Add explicit dependency on JaxB
  • Loading branch information
Ardesco authored Jan 15, 2018
2 parents 2be61e1 + df6afa7 commit e2021cd
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 34 deletions.
22 changes: 21 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@
</properties>

<dependencies>
<!--JaxB-->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>

<!--Maven -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
Expand All @@ -105,6 +123,8 @@
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
</dependency>

<!--Misc -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down Expand Up @@ -191,7 +211,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
<version>3.5</version>
<configuration>
<!-- TODO: workaround for http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<String> filenamesWeAreSearchingFor = possibleFilenames.getBinaryFilenames();
List<String> filenamesWeAreSearchingFor = possibleFilenames.getBinaryFilenames();
ZipFile zip = new ZipFile(downloadedCompressedFile);
try {
Enumeration<ZipArchiveEntry> zipFile = zip.getEntries();
Expand Down Expand Up @@ -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<String> filenamesWeAreSearchingFor = possibleFilenames.getBinaryFilenames();
List<String> filenamesWeAreSearchingFor = possibleFilenames.getBinaryFilenames();
ArchiveInputStream archiveInputStream = new TarArchiveInputStream(compressedFileInputStream);
try {
while ((currentFile = archiveInputStream.getNextEntry()) != null) {
Expand Down
58 changes: 30 additions & 28 deletions src/main/java/com/lazerycode/selenium/repository/BinaryType.java
Original file line number Diff line number Diff line change
@@ -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<String>() {{
add("IEDriverServer.exe");
}},
asList(
"IEDriverServer.exe"
),
"webdriver.ie.driver"),
GOOGLECHROME(
new ArrayList<String>() {{
add("chromedriver.exe");
add("chromedriver");
}},
asList(
"chromedriver.exe",
"chromedriver"
),
"webdriver.chrome.driver"),
PHANTOMJS(
new ArrayList<String>() {{
add("phantomjs.exe");
add("phantomjs");
}},
asList(
"phantomjs.exe",
"phantomjs"
),
"phantomjs.binary.path"),
OPERACHROMIUM(
new ArrayList<String>() {{
add("operadriver.exe");
add("operadriver");
}},
asList(
"operadriver.exe",
"operadriver"
),
"webdriver.opera.driver"),
MARIONETTE(
new ArrayList<String>() {{
add("wires");
add("wires.exe");
add("geckodriver");
add("geckodriver.exe");
}},
asList(
"wires",
"wires.exe",
"geckodriver",
"geckodriver.exe"
),
"webdriver.gecko.driver"),
EDGE(
new ArrayList<String>() {{
add("MicrosoftWebDriver.exe");
}},
asList(
"MicrosoftWebDriver.exe"
),
"webdriver.edge.driver");

private final ArrayList<String> binaryFilenames;
private final List<String> binaryFilenames;
private final String driverSystemProperty;

BinaryType(ArrayList<String> binaryFilenames, String driverSystemProperty) {
BinaryType(List<String> binaryFilenames, String driverSystemProperty) {
this.binaryFilenames = binaryFilenames;
this.driverSystemProperty = driverSystemProperty;
}

public ArrayList<String> getBinaryFilenames() {
public List<String> getBinaryFilenames() {
return binaryFilenames;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,7 +14,7 @@ public class BinaryTypeTest {

@Test
public void willReturnAListOfFilenameAssociatedWithBinary() {
ArrayList<String> binaryFilenames = PHANTOMJS.getBinaryFilenames();
List<String> binaryFilenames = PHANTOMJS.getBinaryFilenames();

assertThat(binaryFilenames.size(),
is(equalTo(2)));
Expand Down

0 comments on commit e2021cd

Please sign in to comment.