11package com .lazerycode .selenium ;
22
33import com .lazerycode .selenium .download .DownloadHandler ;
4- import com .lazerycode .selenium .repository .DriverContext ;
5- import com .lazerycode .selenium .repository .DriverDetails ;
6- import com .lazerycode .selenium .repository .DriverMap ;
7- import static com .lazerycode .selenium .repository .FileRepository .buildDownloadableFileRepository ;
8- import com .lazerycode .selenium .repository .OperatingSystem ;
9- import static com .lazerycode .selenium .repository .OperatingSystem .getOperatingSystem ;
10- import com .lazerycode .selenium .repository .SystemArchitecture ;
11- import static com .lazerycode .selenium .repository .SystemArchitecture .getCurrentSystemArcitecture ;
12- import com .lazerycode .selenium .repository .XMLParser ;
13- import java .io .File ;
14- import java .io .IOException ;
15- import java .io .InputStream ;
16- import java .net .URISyntaxException ;
17- import java .net .URL ;
18- import java .util .ArrayList ;
19- import java .util .HashMap ;
20- import java .util .HashSet ;
21- import java .util .Map ;
22- import java .util .Set ;
23- import javax .xml .XMLConstants ;
24- import javax .xml .bind .JAXBException ;
25- import javax .xml .transform .Source ;
26- import javax .xml .transform .stream .StreamSource ;
27- import javax .xml .validation .Schema ;
28- import javax .xml .validation .SchemaFactory ;
29- import javax .xml .validation .Validator ;
30- import javax .xml .xpath .XPathExpressionException ;
4+ import com .lazerycode .selenium .repository .*;
315import org .apache .log4j .BasicConfigurator ;
326import org .apache .log4j .Logger ;
337import org .apache .maven .plugin .AbstractMojo ;
4317import org .codehaus .plexus .resource .loader .ResourceNotFoundException ;
4418import org .xml .sax .SAXException ;
4519
20+ import javax .xml .XMLConstants ;
21+ import javax .xml .bind .JAXBException ;
22+ import javax .xml .transform .Source ;
23+ import javax .xml .transform .stream .StreamSource ;
24+ import javax .xml .validation .Schema ;
25+ import javax .xml .validation .SchemaFactory ;
26+ import javax .xml .validation .Validator ;
27+ import javax .xml .xpath .XPathExpressionException ;
28+ import java .io .File ;
29+ import java .io .IOException ;
30+ import java .io .InputStream ;
31+ import java .net .URISyntaxException ;
32+ import java .net .URL ;
33+ import java .util .*;
34+
35+ import static com .lazerycode .selenium .repository .FileRepository .buildDownloadableFileRepository ;
36+ import static com .lazerycode .selenium .repository .OperatingSystem .getOperatingSystem ;
37+ import static com .lazerycode .selenium .repository .SystemArchitecture .getCurrentSystemArcitecture ;
38+
4639/**
4740 * Selenium Standalone Server Maven Plugin
4841 *
@@ -254,9 +247,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
254247 throw new MojoExecutionException ("Failed to download all of the standalone executables: " + e .getLocalizedMessage ());
255248 } catch (URISyntaxException e ) {
256249 throw new MojoExecutionException ("Invalid URI detected: " + e .getLocalizedMessage ());
257- } catch (XPathExpressionException rethrow ) {
258- throw new MojoExecutionException (rethrow .getMessage ());
259- } catch (JAXBException rethrow ) {
250+ } catch (XPathExpressionException | JAXBException rethrow ) {
260251 throw new MojoExecutionException (rethrow .getMessage ());
261252 }
262253
@@ -284,12 +275,12 @@ protected void setSystemProperties(DriverMap driverRepository) {
284275 }
285276
286277 private File getRepositoryMapFile (String customRepositoryMap ) {
287- File repositoryMap = null ;
278+ File repositoryMap ;
288279 try {
289280 repositoryMap = locator .getResourceAsFile (customRepositoryMap );
290- } catch (ResourceNotFoundException e ) {
291- LOG .info ("Unable to access the specified custom repository map, defaulting to bundled version ...\n " );
292- } catch ( FileResourceCreationException e ) {
281+ } catch (ResourceNotFoundException | FileResourceCreationException e ) {
282+ LOG .info ("Unable to find the specified custom repository map, attempting to use value as a file path ...\n " );
283+ repositoryMap = new File ( customRepositoryMap );
293284 }
294285 return repositoryMap ;
295286 }
@@ -331,12 +322,8 @@ protected void checkRepositoryMapIsValid(File repositoryMap) throws MojoExecutio
331322 validator .validate (xmlFile );
332323 LOG .info (" " + xmlFile .getSystemId () + " is valid" );
333324 LOG .info (" " );
334- } catch (SAXException saxe ) {
335- throw new MojoExecutionException (repositoryMap .getName () + " is not valid: " + saxe .getLocalizedMessage ());
336- } catch (IOException ioe ) {
337- //Assume it doesn't exist, set to null so that we default to packaged version
338- this .customRepositoryMap = null ;
325+ } catch (SAXException | IOException ex ) {
326+ throw new MojoExecutionException (repositoryMap .getName () + " is not valid: " + ex .getLocalizedMessage ());
339327 }
340328 }
341-
342329}
0 commit comments