1
1
package com .lazerycode .selenium ;
2
2
3
3
import 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 .*;
31
5
import org .apache .log4j .BasicConfigurator ;
32
6
import org .apache .log4j .Logger ;
33
7
import org .apache .maven .plugin .AbstractMojo ;
43
17
import org .codehaus .plexus .resource .loader .ResourceNotFoundException ;
44
18
import org .xml .sax .SAXException ;
45
19
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
+
46
39
/**
47
40
* Selenium Standalone Server Maven Plugin
48
41
*
@@ -254,9 +247,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
254
247
throw new MojoExecutionException ("Failed to download all of the standalone executables: " + e .getLocalizedMessage ());
255
248
} catch (URISyntaxException e ) {
256
249
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 ) {
260
251
throw new MojoExecutionException (rethrow .getMessage ());
261
252
}
262
253
@@ -284,12 +275,12 @@ protected void setSystemProperties(DriverMap driverRepository) {
284
275
}
285
276
286
277
private File getRepositoryMapFile (String customRepositoryMap ) {
287
- File repositoryMap = null ;
278
+ File repositoryMap ;
288
279
try {
289
280
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 );
293
284
}
294
285
return repositoryMap ;
295
286
}
@@ -331,12 +322,8 @@ protected void checkRepositoryMapIsValid(File repositoryMap) throws MojoExecutio
331
322
validator .validate (xmlFile );
332
323
LOG .info (" " + xmlFile .getSystemId () + " is valid" );
333
324
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 ());
339
327
}
340
328
}
341
-
342
329
}
0 commit comments