Skip to content

Package: WSTestMojo

WSTestMojo

nameinstructionbranchcomplexitylinemethod
WSTestMojo()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
download(URL, File)
M: 34 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
execute()
M: 745 C: 0
0%
M: 124 C: 0
0%
M: 65 C: 0
0%
M: 159 C: 0
0%
M: 1 C: 0
0%
findImageRoot(File)
M: 30 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getCP(File, String[])
M: 53 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
getHarnessClassPath()
M: 34 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getHarnessLib()
M: 154 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 32 C: 0
0%
M: 1 C: 0
0%
getJavaExec()
M: 7 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getSdoCP(File)
M: 72 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getToplinkCP(File)
M: 68 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
isFastInfosetEnabled()
M: 11 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isJaxWsRIRoot(File)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isMetroRoot(File)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isSDO()
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isToplink()
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
prepareImage(URL, File)
M: 28 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
removeVmArg(String, String)
M: 53 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package com.sun.xml.ws.test;
12:
13: import java.io.File;
14: import java.io.FileOutputStream;
15: import java.io.IOException;
16: import java.net.MalformedURLException;
17: import java.net.URL;
18: import java.util.ArrayList;
19: import java.util.List;
20: import java.util.HashSet;
21: import java.util.Set;
22: import org.eclipse.aether.artifact.Artifact;
23: import org.apache.maven.plugin.AbstractMojo;
24: import org.apache.maven.plugin.MojoExecutionException;
25: import org.apache.maven.plugin.MojoFailureException;
26: import org.apache.maven.plugins.annotations.Component;
27: import org.apache.maven.plugins.annotations.LifecyclePhase;
28: import org.apache.maven.plugins.annotations.Mojo;
29: import org.apache.maven.plugins.annotations.Parameter;
30: import org.apache.maven.project.MavenProject;
31: import org.apache.maven.settings.Proxy;
32: import org.apache.maven.settings.Settings;
33: import org.codehaus.plexus.archiver.UnArchiver;
34: import org.codehaus.plexus.archiver.manager.ArchiverManager;
35: import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
36: import org.codehaus.plexus.util.IOUtil;
37: import org.codehaus.plexus.util.Os;
38: import org.codehaus.plexus.util.cli.CommandLineException;
39: import org.codehaus.plexus.util.cli.CommandLineUtils;
40: import org.codehaus.plexus.util.cli.Commandline;
41: import org.codehaus.plexus.util.cli.DefaultConsumer;
42: import org.codehaus.plexus.util.cli.StreamConsumer;
43:
44: import org.eclipse.aether.RepositorySystem;
45: import org.eclipse.aether.RepositorySystemSession;
46: import org.eclipse.aether.collection.CollectRequest;
47: import org.eclipse.aether.graph.Dependency;
48: import org.eclipse.aether.repository.RemoteRepository;
49: import org.eclipse.aether.resolution.ArtifactRequest;
50: import org.eclipse.aether.resolution.ArtifactResolutionException;
51: import org.eclipse.aether.resolution.ArtifactResult;
52: import org.eclipse.aether.resolution.DependencyRequest;
53: import org.eclipse.aether.resolution.DependencyResolutionException;
54: import org.eclipse.aether.resolution.DependencyResult;
55:
56: /**
57: * Executes tests written for WS Test Harness.
58: *
59: * @author lukas
60: */
61: @Mojo(name = "ws-test", defaultPhase = LifecyclePhase.TEST, requiresProject = false)
62: public class WSTestMojo extends AbstractMojo {
63:
64: private static final String HARNESS_GID = "org.glassfish.metro";
65: private static final String HARNESS_AID = "harness-lib";
66: private static final String TOPLINK_FACTORY = "com.sun.xml.ws.db.toplink.JAXBContextFactory";
67: private static final String SDO_FACTORY = "com.sun.xml.ws.db.sdo.SDOContextFactory";
68:
69: public enum Databinding {
70: DEFAULT, TOPLINK, SDO;
71: }
72:
73: public enum Container {
74: IN_VM, LWHS, TOMCAT, TOMCAT_LOCAL;
75: }
76:
77: public enum FI {
78: none, pessimistic, optimistic;
79: }
80:
81: /**
82: * Version of Test Harness library to use for running tests.
83: */
84: @Parameter(defaultValue = "3.0.0")
85: private String harnessVersion;
86:
87: /**
88: * Specify the target JAX-WS version being tested. This determines test
89: * exclusions.
90: */
91: @Parameter(defaultValue = "3.0.0")
92: private String version;
93:
94: /**
95: * Target folder for JUnit test report XMLs.
96: *
97: * Note: If used from command line (without pom.xml), default is set
98: * to <code>results</code> unless <code>-report</code> option is used.
99: */
100: @Parameter(defaultValue = "${project.build.directory}/surefire-reports")
101: private File resultsDirectory;
102:
103: /**
104: * Find test directories recursively.
105: */
106: @Parameter(defaultValue = "true")
107: private boolean recursive;
108:
109: /**
110: * Enable all transport dumps.
111: */
112: @Parameter(defaultValue = "false")
113: private boolean dump;
114:
115: /**
116: * Generate output for debugging harness.
117: */
118: @Parameter(property = "ws.debug", defaultValue = "false")
119: private boolean debug;
120:
121: /**
122: * Fail the build in case of test errors/failures.
123: */
124: @Parameter(property = "ws.failonerror", defaultValue = "true")
125: private boolean failonerror;
126:
127: /**
128: * Folder containing test(s).
129: */
130: @Parameter(property = "ws.test", defaultValue = "${project.basedir}/src/test/testcases")
131: private File tests;
132:
133: /**
134: * Define databinding mode to be used by tests.
135: *
136: * Supported values:
137: * <ul>
138: * <li><code>DEFAULT</code>
139: * <li><code>TOPLINK</code>
140: * </ul>
141: */
142: @Parameter(defaultValue = "DEFAULT")
143: private Databinding databinding;
144:
145: /**
146: * Define FastInfoset mode to be used by tests.
147: *
148: * Supported values:
149: * <ul>
150: * <li><code>none</code>
151: * <li><code>optimistic</code>
152: * <li><code>pessimistic</code>
153: * </ul>
154: */
155: @Parameter(defaultValue = "none")
156: private FI fastinfoset;
157:
158: /**
159: * Used when running without pom.xml on the command line.
160: * Comma (',') is used as a separator.
161: */
162: @Parameter(property = "args")
163: private List<String> args;
164:
165: /**
166: * Extra JVM options passed to JVM forked by the harness.
167: * Use this to pass debugging options to the harness from the command line.
168: */
169: @Parameter(property = "ws.jvmOpts")
170: private String extraVmArgs;
171:
172: /**
173: * Extra JVM options passed to JVM forked by the harness.
174: * Use this to pass options to the harness using plugin configuration in pom.xml.
175: */
176: @Parameter(property = "vmArgs")
177: private List<String> vmArgs;
178:
179: /**
180: * Directory containing harness extensions.
181: */
182: @Parameter(property = "ws.extDir", defaultValue = "${project.basedir}/lib/ext")
183: private File extDir;
184:
185: /**
186: * URL from where to get a binary artifact to be tested.
187: * This supersedes <code>localImage</code> setting if set.
188: */
189: @Parameter(property = "ws.imageUrl")
190: private String imageUrl;
191:
192: /**
193: * Path to local binary image to test.
194: * This supersedes workspace lookup process if set.
195: */
196: @Parameter(property = "ws.localImage", defaultValue = "${project.build.directory}/image")
197: private File localImage;
198:
199: /**
200: * Define container mode to be used by tests.
201: *
202: * Supported values:
203: * <ul>
204: * <li><code>IN_VM</code>
205: * <li><code>LWHS</code>
206: * <li><code>TOMCAT</code>
207: * </ul>
208: */
209: @Parameter(property = "ws.transport", defaultValue = "IN_VM")
210: private Container transport;
211:
212: /**
213: * URL from where to get a transport for <code>IN_VM</code> mode tests.
214: */
215: @Parameter(property = "ws.transportUrl")
216: private String transportUrl;
217:
218: /**
219: * Tomcat home, used only if <code>transport=TOMCAT</code> is set.
220: */
221: @Parameter(property = "tomcat.home")
222: private File tomcatHome;
223:
224: /**
225: * Misc files required by tests. For example JKSs for WSIT tests.
226: */
227: @Parameter(defaultValue = "${project.basedir}/misc")
228: private File wsitConf;
229:
230: @Parameter(defaultValue = "${project.remoteProjectRepositories}",
231: readonly = true)
232: private List<RemoteRepository> remoteRepos;
233:
234: @Parameter(defaultValue="${project}", readonly=true)
235: private MavenProject project;
236:
237: @Parameter(defaultValue="${settings}", readonly=true )
238: private Settings settings;
239:
240: @Component
241: private ArchiverManager archiverManager;
242:
243: /**
244: * The entry point to Aether.
245: */
246: @Component
247: private RepositorySystem repoSystem;
248:
249: /**
250: * The current repository/network configuration of Maven.
251: */
252: @Parameter(defaultValue = "${repositorySystemSession}",
253: readonly = true)
254: private RepositorySystemSession repoSession;
255:
256: private File imageRoot = null;
257:
258: @Override
259: public void execute() throws MojoExecutionException, MojoFailureException {
260: File imageFolder = new File(project.getBuild().getDirectory(), "tested-image");
261: try {
262: URL u = new URL(imageUrl);
263: try {
264: imageFolder.mkdirs();
265: imageRoot = prepareImage(u, imageFolder);
266: getLog().info("testing downloaded image (" + imageRoot.getPath() +")...");
267: } catch (NoSuchArchiverException ex) {
268: throw new MojoExecutionException(ex.getMessage(), ex);
269: } catch (IOException ex) {
270: throw new MojoFailureException(ex.getMessage(), ex);
271: }
272: } catch (MalformedURLException muex) {
273: }
274:• if (imageRoot == null) {
275:• if (localImage.exists() && localImage.isDirectory() && findImageRoot(localImage) != null) {
276: imageRoot = findImageRoot(localImage);
277: getLog().info("testing local image (" + imageRoot.getPath() +")...");
278: } else {
279: getLog().info("testing local workspace...");
280: }
281: } else {
282: getLog().info("testing local workspace...");
283: }
284:
285: Commandline cmd = new Commandline();
286: cmd.setExecutable(new File(new File(System.getProperty("java.home"), "bin"), getJavaExec()).getAbsolutePath());
287: cmd.setWorkingDirectory(project.getBasedir());
288:
289: // lukas:
290: // Some jar files on the classpath may be multi-release jars.
291: // To allow AntClassLoader (used by Harness) to find correct class files
292: // in these jars, either make sure that Ant 1.10.6+ is used at runtime
293: // or force JDK to always create JarFile instances with Runtime.Version
294: // of the JDK being used.
295: // Since the former requirement is hard to guarantee and to prevent false
296: // alarms when running tests, let's just force JDK to use the right
297: // JarFile constructor ourselves.
298: // for more details, see: https://bz.apache.org/bugzilla/show_bug.cgi?id=62952
299: // see also com.sun.xml.ws.test.Realm.getClassLoader()
300: cmd.createArg().setLine("-Djdk.util.jar.enableMultiRelease=force");
301:
302:• if (extDir != null && extDir.exists() && extDir.isDirectory()) {
303: cmd.createArg().setValue("-DHARNESS_EXT=" + extDir.getAbsolutePath());
304: } else {
305: getLog().info("'ext' directory not found");
306: }
307:
308:• if (System.getProperty("net.sourceforge.cobertura.datafile") != null) {
309: cmd.createArg().setValue("-Dnet.sourceforge.cobertura.datafile=" + System.getProperty("net.sourceforge.cobertura.datafile"));
310: }
311:
312:• if (wsitConf != null && wsitConf.exists() && wsitConf.isDirectory()) {
313: cmd.createArg().setValue("-DWSIT_HOME=" + wsitConf.getAbsolutePath());
314: }
315:
316:• if (isFastInfosetEnabled()) {
317:• switch (fastinfoset) {
318: case optimistic:
319: cmd.createArg().setLine("-Dcom.sun.xml.ws.client.ContentNegotiation=optimistic");
320: break;
321: case pessimistic:
322: cmd.createArg().setLine("-Dcom.sun.xml.ws.client.ContentNegotiation=pessimistic");
323: break;
324: default:
325: //none: cmd.createArg().setLine("-Dcom.sun.xml.ws.client.ContentNegotiation=none");
326: break;
327: }
328: }
329:
330:• if (isToplink()) {
331: cmd.createArg().setLine("-DBindingContextFactory=" + TOPLINK_FACTORY);
332:• } else if (isSDO()) {
333: cmd.createArg().setLine("-DBindingContextFactory=" + SDO_FACTORY);
334: }
335:
336:• if (extraVmArgs != null && extraVmArgs.trim().length() > 1) {
337: cmd.createArg().setLine(extraVmArgs);
338: }
339:
340:• if (settings != null) {
341:• for (Proxy p : settings.getProxies()) {
342:• if (p.isActive()) {
343: String protocol = p.getProtocol().trim();
344:• if (p.getHost() != null) {
345: StringBuilder sb = new StringBuilder();
346: sb.append("-D");
347: sb.append(protocol);
348: sb.append(".proxyHost=");
349: sb.append(p.getHost());
350: cmd.createArg().setLine(sb.toString());
351: }
352:• if (p.getPort() > -1) {
353: StringBuilder sb = new StringBuilder();
354: sb.append("-D");
355: sb.append(protocol);
356: sb.append(".proxyPort=");
357: sb.append(p.getPort());
358: cmd.createArg().setLine(sb.toString());
359: }
360:• if (p.getNonProxyHosts() != null) {
361: StringBuilder sb = new StringBuilder();
362: sb.append("-D");
363: sb.append(protocol);
364: sb.append(".nonProxyHosts=\"");
365: sb.append(p.getNonProxyHosts().trim());
366: sb.append("\"");
367: cmd.createArg().setValue(sb.toString());
368: }
369: }
370: }
371: }
372:
373:• if (vmArgs != null) {
374:• for (String arg : vmArgs) {
375:• if (arg.contains("-DBindingContextFactory=") && (isToplink() || isSDO())) {
376: String line = removeVmArg(arg, "BindingContextFactory");
377:• if (line != null) {
378: cmd.createArg().setLine(line.trim());
379: } else {
380: getLog().info("removing '" + arg + "' from default configuration.");
381: }
382:• } else if (arg.contains("-Dcom.sun.xml.ws.client.ContentNegotiation=") && isFastInfosetEnabled()) {
383: String line = removeVmArg(arg, "com.sun.xml.ws.client.ContentNegotiation");
384:• if (line != null) {
385: cmd.createArg().setLine(line.trim());
386: } else {
387: getLog().info("removing '" + arg + "' from default configuration.");
388: }
389: } else {
390: cmd.createArg().setLine(arg);
391: }
392: }
393: }
394:
395: cmd.createArg().setLine("-cp " + getHarnessClassPath());
396: cmd.createArg().setValue("com.sun.xml.ws.test.Main");
397:• if (project.getFile() != null) {
398: cmd.createArg().setLine("-report " + resultsDirectory.getAbsolutePath());
399:• } else if (args != null && !args.contains("-report")) {
400: cmd.createArg().setLine("-report results");
401: }
402:
403:• if (recursive) {
404: cmd.createArg().setValue("-r");
405: }
406:• if (debug) {
407: cmd.createArg().setValue("-debug");
408: }
409:• if (dump) {
410: cmd.createArg().setValue("-dump");
411: }
412:• if (version != null && version.trim().length() > 0) {
413: cmd.createArg().setLine("-version " + version);
414: }
415:
416:• switch (transport) {
417: case IN_VM:
418:• if (imageRoot != null) {
419: File transportFile;
420: try {
421: transportFile = download(new URL(transportUrl), imageFolder);
422: } catch (IOException ex) {
423: transportFile = new File(project.getBuild().getDirectory(), "test-lib/jaxws-local-transport.jar");
424:• if (!transportFile.exists()) {
425: throw new MojoExecutionException("Cannot find local transport jar. Set 'transportUrl' in plugin's configuration.", ex);
426: }
427: }
428: cmd.createArg().setLine("-transport " + transportFile.getAbsolutePath());
429: }
430: break;
431: case LWHS:
432: cmd.createArg().setLine("-lwhs");
433: break;
434: case TOMCAT:
435:• if (tomcatHome == null) {
436: throw new MojoExecutionException("'tomcat.home' is not set.");
437: }
438: cmd.createArg().setLine("-tomcat-embedded " + tomcatHome.getAbsolutePath());
439: break;
440: case TOMCAT_LOCAL:
441:• if (tomcatHome == null) {
442: throw new MojoExecutionException("'tomcat.home' is not set.");
443: }
444: cmd.createArg().setLine("-tomcat-local " + tomcatHome.getAbsolutePath());
445: break;
446: }
447:
448: List<String> filters = new ArrayList<String>();
449:• if (imageRoot != null) {
450:• if (isJaxWsRIRoot(imageRoot)) {
451: cmd.createArg().setLine("-cp:jaxws-image " + imageRoot.getAbsolutePath());
452:• } else if (isMetroRoot(imageRoot)) {
453: cmd.createArg().setLine("-cp:wsit-image " + imageRoot.getAbsolutePath());
454: } else {
455: throw new MojoExecutionException("Unknown/Unsupported image: " + imageRoot);
456: }
457:• if (isToplink()) {
458: cmd.createArg().setLine("-cp:override " + getToplinkCP(imageRoot));
459: filters.add("-cp:override");
460:• } else if (isSDO()) {
461: cmd.createArg().setLine("-cp:override " + getSdoCP(imageRoot));
462: filters.add("-cp:override");
463: }
464: filters.add("-cp:jaxws");
465: filters.add("-cp:wsit");
466: }
467:
468:• if (args != null) {
469:• for (String arg : args) {
470:• if (filters.isEmpty()) {
471: cmd.createArg().setLine(arg);
472: } else {
473: boolean found = false;
474:• for (String filter : filters) {
475:• if (arg.contains(filter)) {
476: getLog().info("removing '" + arg + "' from default configuration.");
477: found = true;
478: break;
479: }
480: }
481:• if (!found) {
482: cmd.createArg().setLine(arg);
483: }
484: }
485: }
486: }
487:
488: cmd.createArg().setLine(tests.getAbsolutePath());
489:
490:• if (debug) {
491: getLog().info(cmd.toString());
492: }
493: getLog().debug(cmd.toString());
494:
495: StreamConsumer sc = new DefaultConsumer();
496: try {
497: int i = CommandLineUtils.executeCommandLine(cmd, sc, sc);
498:• if (i > 0 && failonerror) {
499: throw new MojoFailureException(i + " test(s) failed");
500:• } else if (i < 0) {
501: throw new MojoExecutionException("Invalid command: " + cmd.toString());
502: }
503: } catch (CommandLineException ex) {
504: throw new MojoExecutionException(ex.getMessage(), ex);
505: }
506: }
507:
508: private File download(URL u, File destDir) throws IOException {
509: getLog().info("Downloading: " + u);
510: File imageZip = new File(destDir, new File(u.getFile()).getName());
511:• if (imageZip.createNewFile()) {
512: getLog().info("to: " + imageZip.getAbsolutePath());
513: IOUtil.copy(u.openStream(), new FileOutputStream(imageZip));
514: }
515: return imageZip;
516: }
517:
518: private File prepareImage(URL u, File destDir) throws IOException, NoSuchArchiverException {
519: File zip = download(u, destDir);
520: getLog().info("unpacking " + zip.getName() + "...");
521: UnArchiver unArchiver = archiverManager.getUnArchiver(zip);
522: unArchiver.setSourceFile(zip);
523: unArchiver.setDestDirectory(destDir);
524: unArchiver.extract();
525: return findImageRoot(destDir);
526: }
527:
528: private File findImageRoot(File dir) {
529: File f = new File(dir, "jaxws-ri");
530:• if (f.exists() && f.isDirectory()) {
531: return f;
532: }
533: f = new File(dir, "metro");
534:• if (f.exists() && f.isDirectory()) {
535: return f;
536: }
537: return null;
538: }
539:
540: private String getJavaExec() {
541:• return Os.isFamily(Os.FAMILY_WINDOWS) ? "java.exe" : "java";
542: }
543:
544: private String getHarnessClassPath() throws MojoExecutionException {
545: StringBuilder sb = new StringBuilder();
546:• for (Artifact a : getHarnessLib()) {
547: sb.append(a.getFile().getAbsolutePath());
548: sb.append(File.pathSeparator);
549: }
550: return sb.substring(0, sb.length() - 1);
551: }
552:
553: private Set<Artifact> getHarnessLib() throws MojoExecutionException {
554: org.eclipse.aether.artifact.DefaultArtifact harnessLib = new org.eclipse.aether.artifact.DefaultArtifact(HARNESS_GID,HARNESS_AID, null, "jar", harnessVersion);
555: Set<Artifact> result = new HashSet<>();
556: Set<ArtifactRequest> dependenciesRequest = new HashSet<>();
557: ArtifactRequest request = new ArtifactRequest();
558: request.setArtifact(harnessLib);
559: request.setRepositories(remoteRepos);
560: dependenciesRequest.add(request);
561:
562: List<ArtifactResult> resolvedDependencies;
563: try {
564: resolvedDependencies = repoSystem.resolveArtifacts(repoSession, dependenciesRequest);
565: } catch (ArtifactResolutionException ex) {
566: throw new MojoExecutionException(ex.getMessage(), ex);
567: }
568:
569: List<Dependency> artifacts = new ArrayList<>();
570:• for (ArtifactResult dependency : resolvedDependencies) {
571: Artifact a = dependency.getArtifact();
572: result.add(a);
573: artifacts.add(new Dependency(dependency.getArtifact(), "compile"));
574: }
575:
576: DependencyResult res = null;
577: try {
578: CollectRequest cr = new CollectRequest(artifacts.iterator().next(), remoteRepos);
579: DependencyRequest dr = new DependencyRequest();
580: dr.setCollectRequest(cr);
581: res = repoSystem.resolveDependencies(repoSession, dr);
582: } catch (DependencyResolutionException ex) {
583: throw new MojoExecutionException(ex.getMessage(), ex);
584: }
585:
586:• for (ArtifactResult dependency : res.getArtifactResults()) {
587: Artifact a = dependency.getArtifact();
588:• if (getLog().isDebugEnabled()) {
589: getLog().debug("got dependency: " + a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion());
590: }
591: result.add(dependency.getArtifact());
592: }
593:
594: return result;
595: }
596:
597: private boolean isToplink() {
598:• return Databinding.TOPLINK == databinding;
599: }
600:
601: private boolean isSDO() {
602:• return Databinding.SDO == databinding;
603: }
604:
605: private boolean isFastInfosetEnabled() {
606:• return fastinfoset != null && FI.none != fastinfoset;
607: }
608:
609: private String getCP(File root, String... paths) {
610: StringBuilder sb = new StringBuilder();
611:• for (String p : paths) {
612: File item = new File(root, p);
613:• if (!item.exists()) {
614: getLog().warn(item.getAbsolutePath() + " does not exist");
615: } else {
616: sb.append(item.getAbsolutePath());
617: sb.append(File.pathSeparatorChar);
618: }
619: }
620: return sb.substring(0, sb.length() - 1);
621: }
622:
623: private String getToplinkCP(File root) throws MojoExecutionException {
624:• if (isJaxWsRIRoot(root)) {
625: return getCP(root,
626: "lib/plugins/jaxws-eclipselink-plugin.jar",
627: "lib/plugins/org.eclipse.persistence.asm.jar",
628: "lib/plugins/org.eclipse.persistence.core.jar",
629: "lib/plugins/org.eclipse.persistence.moxy.jar",
630: "lib/plugins/eclipselink.jar"
631: );
632:• } else if (isMetroRoot(root)) {
633: return getCP(root, "lib/databinding/jaxws-eclipselink-plugin.jar") +
634: File.pathSeparatorChar +
635: getCP(new File(project.getBuild().getDirectory()), "test-lib/eclipselink.jar");
636: }
637: throw new MojoExecutionException("Unknown/Unsupported image: " + imageRoot);
638: }
639:
640: private String getSdoCP(File root) throws MojoExecutionException {
641:• if (isJaxWsRIRoot(root)) {
642: return getCP(root,
643: "lib/plugins/sdo-eclipselink-plugin.jar",
644: "lib/plugins/org.eclipse.persistence.asm.jar",
645: "lib/plugins/org.eclipse.persistence.core.jar",
646: "lib/plugins/org.eclipse.persistence.moxy.jar",
647: "lib/plugins/org.eclipse.persistence.sdo.jar",
648: "lib/plugins/eclipselink.jar"
649: );
650:• } else if (isMetroRoot(root)) {
651: return getCP(root, "lib/databinding/sdo-eclipselink-plugin.jar") +
652: File.pathSeparatorChar +
653: getCP(new File(project.getBuild().getDirectory()),
654: "test-lib/eclipselink.jar"
655: );
656: }
657: throw new MojoExecutionException("Unknown/Unsupported image: " + imageRoot);
658: }
659:
660: private boolean isJaxWsRIRoot(File root) {
661: return "jaxws-ri".equals(root.getName());
662: }
663:
664: private boolean isMetroRoot(File root) {
665: return "metro".equals(root.getName());
666: }
667:
668: private String removeVmArg(String line, String prop) {
669: String[] opts = line.split(" ");
670:• if (opts.length > 1) {
671: StringBuilder sb = new StringBuilder();
672:• for (String opt : opts) {
673:• if (opt.trim().startsWith("-D" + prop + "=")) {
674: getLog().info("removing '" + opt + "' from default configuration.");
675: continue;
676: }
677: sb.append(opt);
678: sb.append(" ");
679: }
680: return sb.toString();
681: }
682: return null;
683: }
684:
685: }