SeleniumServerMojo extends AbstractMojo { protected void setSystemProperties(DriverMap driverRepository) { ArrayList<DriverContext> driverContextsForCurrentOperatingSystem = driverRepository.getDriverContextsForCurrentOperatingSystem(); if (driverContextsForCurrentOperatingSystem.size() == 0) { LOG.warn("No driver contexts detected for the current operating system, no maven properties set!"); } for (DriverContext driverContext : driverContextsForCurrentOperatingSystem) { DriverDetails driverDetails = driverRepository.getDetailsForLatestVersionOfDriverContext(driverContext); LOG.info("Setting maven property - ${" + driverContext.getBinaryTypeForContext().getDriverSystemProperty() + "} = " + driverDetails.extractedLocation); project.getProperties().setProperty(driverContext.getBinaryTypeForContext().getDriverSystemProperty(), driverDetails.extractedLocation); } }  @Override void execute();  }
@Ignore @Test public void systemPropertiesAreSet() throws Exception { SeleniumServerMojo mojo = new SeleniumServerMojo(); String currentOperatingSystem = getCurrentOperatingSystem().toString().toLowerCase(); String currentArchitecture = getCurrentSystemArcitecture().getSystemArchitectureType(); String relativeExecutablePath = File.separator + currentOperatingSystem + File.separator + "phantomjs" + File.separator + currentArchitecture + File.separator + "phantomjs"; InputStream xmlRepositoryMap = this.getClass().getResourceAsStream("/TestRepoMap2.xml"); XMLParser parser = new XMLParser(xmlRepositoryMap, OperatingSystem.getCurrentOperatingSystemAsAHashSet(), null, getThirtyTwoBitBinaries, getSixtyFourBitBinaries); DriverMap driverMap = buildDownloadableFileRepository(parser.getAllNodesInScope(), getThirtyTwoBitBinaries, getSixtyFourBitBinaries, getArmBinaries); DownloadHandler standaloneExecutableDownloader = new DownloadHandler( new File(rootStandaloneServerDirectoryPath), new File(downloadDirectoryPath), oneRetryAttempt, connectTimeout, readTimeout, driverMap, overwriteFilesThatExist, checkFileHashes, doNotUseSystemProxy, getAllVersions); DriverMap driverRepository = standaloneExecutableDownloader.ensureStandaloneExecutableFilesExist(); mojo.setSystemProperties(driverRepository); assertThat(System.getProperty("phantomjs.binary.path"), is(equalTo(rootStandaloneServerDirectoryPath + relativeExecutablePath))); }