1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.cloud.contract.maven.verifier.stubrunner;
18
19 import javax.inject.Inject;
20 import javax.inject.Named;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.eclipse.aether.RepositorySystemSession;
25
26 import org.springframework.cloud.contract.stubrunner.BatchStubRunner;
27 import org.springframework.cloud.contract.stubrunner.BatchStubRunnerFactory;
28 import org.springframework.cloud.contract.stubrunner.RunningStubs;
29 import org.springframework.cloud.contract.stubrunner.StubDownloader;
30 import org.springframework.cloud.contract.stubrunner.StubRunnerOptions;
31
32
33
34
35
36
37 @Named
38 public class RemoteStubRunner {
39
40 private static final Log log = LogFactory.getLog(RemoteStubRunner.class);
41
42 private final AetherStubDownloaderFactory aetherStubDownloaderFactory;
43
44 @Inject
45 public RemoteStubRunner(AetherStubDownloaderFactory aetherStubDownloaderFactory) {
46 this.aetherStubDownloaderFactory = aetherStubDownloaderFactory;
47 }
48
49 public BatchStubRunner run(StubRunnerOptions options, RepositorySystemSession repositorySystemSession) {
50 StubDownloader stubDownloader = this.aetherStubDownloaderFactory.build(repositorySystemSession).build(options);
51 try {
52 if (log.isDebugEnabled()) {
53 log.debug("Launching StubRunner with args: " + options);
54 }
55 BatchStubRunner stubRunner = new BatchStubRunnerFactory(options, stubDownloader).buildBatchStubRunner();
56 RunningStubs runningCollaborators = stubRunner.runStubs();
57 log.info(runningCollaborators.toString());
58 return stubRunner;
59 }
60 catch (Exception e) {
61 log.error("An exception occurred while trying to execute the stubs: " + e.getMessage());
62 throw e;
63 }
64
65 }
66
67 }