Skip to content

Commit 99a2273

Browse files
committed
Fix #58 Add support for downloading geckodriver arm binaries.
1 parent 31b9702 commit 99a2273

File tree

8 files changed

+57
-14
lines changed

8 files changed

+57
-14
lines changed

src/main/java/com/lazerycode/selenium/SeleniumServerMojo.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ public class SeleniumServerMojo extends AbstractMojo {
101101
@Parameter(defaultValue = "false")
102102
protected boolean sixtyFourBitBinaries;
103103

104+
/**
105+
* <h3>Force download of arm standalone executable</h3>.
106+
* <p>&lt;armBinaries&gt;true&lt;/armBinaries&gt;</p>
107+
*/
108+
@Parameter(defaultValue = "false")
109+
protected boolean armBinaries;
110+
104111
/**
105112
* <h3>Only get the latest version of each standalone executable in RepositoryMap.xml</h3>
106113
* <p>&lt;onlyGetLatestVersions&gt;true&lt;/onlyGetLatestVersions&gt;</p>
@@ -219,10 +226,12 @@ public void execute() throws MojoExecutionException, MojoFailureException {
219226
}
220227

221228
//Calculate system architecture
222-
if (!thirtyTwoBitBinaries && !sixtyFourBitBinaries) {
229+
if (!thirtyTwoBitBinaries && !sixtyFourBitBinaries && !armBinaries) {
223230
//TODO clean this up, maybe pass in a list of valid architectures later on
224231
if (getCurrentSystemArcitecture().equals(SystemArchitecture.ARCHITECTURE_64_BIT)) {
225232
sixtyFourBitBinaries = true;
233+
} else if (getCurrentSystemArcitecture().equals(SystemArchitecture.ARCHITECTURE_ARM)) {
234+
armBinaries = true;
226235
} else {
227236
thirtyTwoBitBinaries = true;
228237
}
@@ -237,7 +246,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
237246
this.fileDownloadRetryAttempts,
238247
this.fileDownloadConnectTimeout,
239248
this.fileDownloadReadTimeout,
240-
buildDownloadableFileRepository(parser.getAllNodesInScope(), thirtyTwoBitBinaries, sixtyFourBitBinaries),
249+
buildDownloadableFileRepository(parser.getAllNodesInScope(), thirtyTwoBitBinaries, sixtyFourBitBinaries, armBinaries),
241250
this.overwriteFilesThatExist,
242251
this.checkFileHashes,
243252
this.useSystemProxy,
@@ -267,6 +276,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
267276
*/
268277
protected void setSystemProperties(DriverMap driverRepository) {
269278
ArrayList<DriverContext> driverContextsForCurrentOperatingSystem = driverRepository.getDriverContextsForCurrentOperatingSystem();
279+
if (driverContextsForCurrentOperatingSystem.size() == 0) {
280+
LOG.warn("No driver contexts detected for the current operating system, no maven properties set!");
281+
}
270282
for (DriverContext driverContext : driverContextsForCurrentOperatingSystem) {
271283
DriverDetails driverDetails = driverRepository.getDetailsForLatestVersionOfDriverContext(driverContext);
272284
LOG.info("Setting maven property - ${" + driverContext.getBinaryTypeForContext().getDriverSystemProperty() + "} = " + driverDetails.extractedLocation);

src/main/java/com/lazerycode/selenium/repository/FileRepository.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
import javax.xml.bind.JAXBException;
88
import javax.xml.bind.Unmarshaller;
99

10-
import static com.lazerycode.selenium.repository.SystemArchitecture.ARCHITECTURE_32_BIT;
11-
import static com.lazerycode.selenium.repository.SystemArchitecture.ARCHITECTURE_64_BIT;
10+
import static com.lazerycode.selenium.repository.SystemArchitecture.*;
1211

1312
public class FileRepository {
1413

15-
public static DriverMap buildDownloadableFileRepository(NodeList nodesFound, boolean useThirtyTwoBitBinaries, boolean useSixtyFourBitBinaries) throws JAXBException {
14+
public static DriverMap buildDownloadableFileRepository(NodeList nodesFound, boolean useThirtyTwoBitBinaries, boolean useSixtyFourBitBinaries, boolean useArmBinaries) throws JAXBException {
1615
DriverMap driverMap = new DriverMap();
1716
Unmarshaller unmarshaller = JAXBContext.newInstance(DriverDetails.class).createUnmarshaller();
1817
unmarshaller.setEventHandler(new unmarshallingEventHandler());
@@ -23,6 +22,7 @@ public static DriverMap buildDownloadableFileRepository(NodeList nodesFound, boo
2322
String version = node.getParentNode().getAttributes().getNamedItem("id").getNodeValue();
2423
boolean thisIs64Bit = false;
2524
boolean thisIs32Bit = false;
25+
boolean thisIsArm = false;
2626
if (useThirtyTwoBitBinaries && node.getAttributes().getNamedItem("thirtytwobit") != null) {
2727
if (Boolean.valueOf(node.getAttributes().getNamedItem("thirtytwobit").getNodeValue())) {
2828
thisIs32Bit = true;
@@ -33,6 +33,11 @@ public static DriverMap buildDownloadableFileRepository(NodeList nodesFound, boo
3333
thisIs64Bit = true;
3434
}
3535
}
36+
if (useArmBinaries && node.getAttributes().getNamedItem("arm") != null) {
37+
if (Boolean.valueOf(node.getAttributes().getNamedItem("arm").getNodeValue())) {
38+
thisIsArm = true;
39+
}
40+
}
3641

3742
DriverDetails driverDetails = unmarshaller.unmarshal(node, DriverDetails.class).getValue();
3843
if (thisIs32Bit) {
@@ -41,6 +46,9 @@ public static DriverMap buildDownloadableFileRepository(NodeList nodesFound, boo
4146
if (thisIs64Bit) {
4247
driverMap.getMapForDriverContext(DriverContext.binaryDataFor(operatingSystem, driver, ARCHITECTURE_64_BIT)).put(version, driverDetails);
4348
}
49+
if (thisIsArm) {
50+
driverMap.getMapForDriverContext(DriverContext.binaryDataFor(operatingSystem, driver, ARCHITECTURE_ARM)).put(version, driverDetails);
51+
}
4452
}
4553

4654
return driverMap;

src/main/java/com/lazerycode/selenium/repository/SystemArchitecture.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
public enum SystemArchitecture {
77

88
ARCHITECTURE_64_BIT("64bit"),
9-
ARCHITECTURE_32_BIT("32bit");
9+
ARCHITECTURE_32_BIT("32bit"),
10+
ARCHITECTURE_ARM("arm");
1011

1112
private String systemArchitectureName;
1213

@@ -20,6 +21,7 @@ public String getSystemArchitectureType() {
2021

2122
public static final SystemArchitecture defaultSystemArchitecture = ARCHITECTURE_32_BIT;
2223
private static List<String> architecture64bitNames = Arrays.asList("amd64", "x86_64");
24+
private static List<String> architectureArmNames = Arrays.asList("arm", "armv41");
2325

2426
public static SystemArchitecture getSystemArchitecture(String currentArchitecture) {
2527
SystemArchitecture result = defaultSystemArchitecture;
@@ -28,6 +30,10 @@ public static SystemArchitecture getSystemArchitecture(String currentArchitectur
2830
result = ARCHITECTURE_64_BIT;
2931
}
3032

33+
if (architectureArmNames.contains(currentArchitecture)) {
34+
result = ARCHITECTURE_ARM;
35+
}
36+
3137
return result;
3238
}
3339

src/main/resources/RepositoryMap.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@
140140
<hash>95276285b65987b6e94e57be55fdc60b95423016</hash>
141141
<hashtype>sha1</hashtype>
142142
</bitrate>
143+
<bitrate arm="true">
144+
<filelocation>https://github.com/mozilla/geckodriver/releases/download/v0.16.1/geckodriver-v0.16.1-arm7hf.tar.gz</filelocation>
145+
<hash>6f013de184c8f3dba3ec39ea49de2a166cb18efb</hash>
146+
<hashtype>sha1</hashtype>
147+
</bitrate>
143148
</version>
144149
</driver>
145150
</linux>

src/main/resources/RepositoryMap.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</xs:sequence>
2727
<xs:attribute type="xs:string" name="sixtyfourbit" use="optional"/>
2828
<xs:attribute type="xs:string" name="thirtytwobit" use="optional"/>
29+
<xs:attribute type="xs:string" name="arm" use="optional"/>
2930
</xs:complexType>
3031
<xs:complexType name="rootType">
3132
<xs:sequence>

src/test/java/com/lazerycode/selenium/SeleniumServerMojoTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class SeleniumServerMojoTest {
3131
private static String rootStandaloneServerDirectoryPath;
3232
private static boolean getThirtyTwoBitBinaries = false;
3333
private static boolean getSixtyFourBitBinaries = false;
34+
private static boolean getArmBinaries = false;
3435
private final int oneRetryAttempt = 1;
3536
private final int connectTimeout = 15000;
3637
private final int readTimeout = 15000;
@@ -73,7 +74,7 @@ public void systemPropertiesAreSet() throws Exception {
7374
String relativeExecutablePath = File.separator + currentOperatingSystem + File.separator + "phantomjs" + File.separator + currentArchitecture + File.separator + "phantomjs";
7475
InputStream xmlRepositoryMap = this.getClass().getResourceAsStream("/TestRepoMap2.xml");
7576
XMLParser parser = new XMLParser(xmlRepositoryMap, OperatingSystem.getCurrentOperatingSystemAsAHashSet(), null, getThirtyTwoBitBinaries, getSixtyFourBitBinaries);
76-
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), getThirtyTwoBitBinaries, getSixtyFourBitBinaries);
77+
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), getThirtyTwoBitBinaries, getSixtyFourBitBinaries, getArmBinaries);
7778
DownloadHandler standaloneExecutableDownloader = new DownloadHandler(
7879
new File(rootStandaloneServerDirectoryPath),
7980
new File(downloadDirectoryPath),

src/test/java/com/lazerycode/selenium/repository/FileRepositoryTest.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818
public class FileRepositoryTest {
1919

2020
@Test
21-
public void listOfStuffReturnedWhenPassingInARepositoryMapWithout32Or64() throws XPathExpressionException, MojoFailureException, JAXBException, MalformedURLException {
21+
public void listOfStuffReturnedWhenPassingInARepositoryMapWithout32Or64OrArm() throws XPathExpressionException, MojoFailureException, JAXBException, MalformedURLException {
2222
InputStream xmlRepositoryMap = this.getClass().getResourceAsStream("/TestRepoMap.xml");
2323
XMLParser parser = new XMLParser(xmlRepositoryMap, new HashSet<OperatingSystem>(), new HashMap<String, String>(), false, false);
24-
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), false, false);
24+
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), false, false, false);
2525

2626
assertThat(driverMap.repository.size(),
2727
is(equalTo(0)));
2828
}
2929

3030
@Test
31-
public void listOfStuffReturnedWhenPassingInARepositoryMapWith32And64() throws XPathExpressionException, MojoFailureException, JAXBException, MalformedURLException {
31+
public void listOfStuffReturnedWhenPassingInARepositoryMapWith32And64ButNotArm() throws XPathExpressionException, MojoFailureException, JAXBException, MalformedURLException {
3232
InputStream xmlRepositoryMap = this.getClass().getResourceAsStream("/TestRepoMap.xml");
3333
XMLParser parser = new XMLParser(xmlRepositoryMap, new HashSet<OperatingSystem>(), new HashMap<String, String>(), false, false);
34-
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), true, true);
34+
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), true, true, false);
3535

3636
assertThat(driverMap.repository.size(),
3737
is(equalTo(7)));
@@ -41,7 +41,7 @@ public void listOfStuffReturnedWhenPassingInARepositoryMapWith32And64() throws X
4141
public void listOfStuffReturnedWhenPassingInARepositoryMapWith32ButNot64() throws XPathExpressionException, MojoFailureException, JAXBException, MalformedURLException {
4242
InputStream xmlRepositoryMap = this.getClass().getResourceAsStream("/TestRepoMap.xml");
4343
XMLParser parser = new XMLParser(xmlRepositoryMap, new HashSet<OperatingSystem>(), new HashMap<String, String>(), false, false);
44-
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), true, false);
44+
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), true, false, false);
4545

4646
assertThat(driverMap.repository.size(),
4747
is(equalTo(4)));
@@ -51,9 +51,19 @@ public void listOfStuffReturnedWhenPassingInARepositoryMapWith32ButNot64() throw
5151
public void listOfStuffReturnedWhenPassingInARepositoryMapWith64ButNot32() throws XPathExpressionException, MojoFailureException, JAXBException, MalformedURLException {
5252
InputStream xmlRepositoryMap = this.getClass().getResourceAsStream("/TestRepoMap.xml");
5353
XMLParser parser = new XMLParser(xmlRepositoryMap, new HashSet<OperatingSystem>(), new HashMap<String, String>(), false, false);
54-
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), false, true);
54+
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), false, true, false);
5555

5656
assertThat(driverMap.repository.size(),
5757
is(equalTo(3)));
5858
}
59+
60+
@Test
61+
public void listOfStuffReturnedWhenPassingInARepositoryMapWith64AndArmButNot32() throws XPathExpressionException, MojoFailureException, JAXBException, MalformedURLException {
62+
InputStream xmlRepositoryMap = this.getClass().getResourceAsStream("/TestRepoMap.xml");
63+
XMLParser parser = new XMLParser(xmlRepositoryMap, new HashSet<OperatingSystem>(), new HashMap<String, String>(), false, false);
64+
DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), false, true, true);
65+
66+
assertThat(driverMap.repository.size(),
67+
is(equalTo(4)));
68+
}
5969
}

src/test/resources/TestRepoMap.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<hash>1a559a110751e40a2719d277436d1a039596026b</hash>
6565
<hashtype>sha1</hashtype>
6666
</bitrate>
67-
<bitrate thirtytwobit="true">
67+
<bitrate thirtytwobit="true" arm="true">
6868
<filelocation>http://chromedriver.googlecode.com/files/chromedriver_bitrate32_20.0.1133.0.zip</filelocation>
6969
<hash>2d7c775ce163576cfe595d55820d0f3a562ab373</hash>
7070
<hashtype>sha1</hashtype>

0 commit comments

Comments
 (0)