3131import org .apache .maven .plugin .MojoExecutionException ;
3232import org .apache .maven .plugin .testing .AbstractMojoTestCase ;
3333import org .apache .maven .toolchain .ToolchainManager ;
34+ import org .eclipse .aether .RepositorySystem ;
3435
3536import static java .util .Collections .emptyMap ;
3637import static org .mockito .ArgumentMatchers .any ;
4546public class ExecMojoTest extends AbstractMojoTestCase {
4647 private MavenSession session = mock (MavenSession .class );
4748 private ToolchainManager toolchainManager = mock (ToolchainManager .class );
49+ private RepositorySystem repositorySystem = mock (RepositorySystem .class );
4850
4951 private static final File LOCAL_REPO = new File ("src/test/repository" );
5052
@@ -65,6 +67,10 @@ static class MockExecMojo extends ExecMojo {
6567
6668 public Map <String , String > systemProperties = new HashMap <>();
6769
70+ protected MockExecMojo (RepositorySystem repositorySystem , ToolchainManager toolchainManager ) {
71+ super (repositorySystem , toolchainManager );
72+ }
73+
6874 protected int executeCommandLine (
6975 Executor exec , CommandLine commandLine , Map enviro , OutputStream out , OutputStream err )
7076 throws ExecuteException {
@@ -90,7 +96,7 @@ CommandLine getExecutedCommandline(int index) {
9096
9197 public void setUp () throws Exception {
9298 super .setUp ();
93- mojo = new MockExecMojo ();
99+ mojo = new MockExecMojo (repositorySystem , toolchainManager );
94100 // note: most of the tests below assume that the specified
95101 // executable path is not fully specicied. See ExecMojo#getExecutablePath
96102 mojo .setExecutable (SOME_EXECUTABLE );
@@ -121,7 +127,7 @@ public void testRunOK() throws MojoExecutionException {
121127 // MEXEC-12, MEXEC-72
122128 public void testGetExecutablePath () throws IOException {
123129
124- ExecMojo realMojo = new ExecMojo ();
130+ ExecMojo realMojo = new ExecMojo (repositorySystem , toolchainManager );
125131
126132 File workdir = new File (System .getProperty ("user.dir" ));
127133 Map <String , String > enviro = new HashMap <>();
@@ -177,7 +183,7 @@ public void testGetExecutablePathPreferExecutableExtensionsOnWindows() throws IO
177183 if (!OS .isFamilyWindows ()) {
178184 return ;
179185 }
180- final ExecMojo realMojo = new ExecMojo ();
186+ final ExecMojo realMojo = new ExecMojo (repositorySystem , toolchainManager );
181187
182188 final String tmp = System .getProperty ("java.io.tmpdir" );
183189 final File workdir = new File (tmp , "testGetExecutablePathPreferExecutableExtensionsOnWindows" );
@@ -251,7 +257,7 @@ public void testOverrides3() throws MojoExecutionException {
251257 }
252258
253259 public void testIsResultCodeAFailure () {
254- ExecMojo execMojo = new ExecMojo ();
260+ ExecMojo execMojo = new ExecMojo (repositorySystem , toolchainManager );
255261 assertTrue (execMojo .isResultCodeAFailure (1 ));
256262 assertFalse (execMojo .isResultCodeAFailure (0 ));
257263
@@ -268,7 +274,7 @@ public void testIsResultCodeAFailure() {
268274
269275 // MEXEC-81
270276 public void testParseCommandlineOSWin () throws Exception {
271- ExecMojo execMojo = new ExecMojo ();
277+ ExecMojo execMojo = new ExecMojo (repositorySystem , toolchainManager );
272278 final String javaHome = "C:\\ Java\\ jdk1.5.0_15" ;
273279 // can only be set by expression or plugin-configuration
274280 setVariableValueToObject (execMojo , "commandlineArgs" , javaHome );
@@ -278,7 +284,7 @@ public void testParseCommandlineOSWin() throws Exception {
278284
279285 public void test_exec_receives_all_parameters () throws MojoExecutionException {
280286 // given
281- ExecMojo execMojo = new ExecMojo ();
287+ ExecMojo execMojo = new ExecMojo (repositorySystem , toolchainManager );
282288 execMojo .setExecutable ("mkdir" );
283289 execMojo .setArguments (Arrays .asList ("-p" , "dist/mails" ));
284290 execMojo .setBasedir (new File ("target" ));
@@ -358,7 +364,7 @@ private String getCommandLineAsString(CommandLine commandline) {
358364 }
359365
360366 public void testGetShebang () throws Exception {
361- ExecMojo execMojo = new ExecMojo ();
367+ ExecMojo execMojo = new ExecMojo (repositorySystem , toolchainManager );
362368
363369 // without shebang
364370 File noShebang = Files .createTempFile ("noShebang" , ".sh" ).toFile ();
@@ -384,7 +390,7 @@ public void testGetShebang() throws Exception {
384390 }
385391
386392 public void testCreateEnvWrapperFile () throws Exception {
387- ExecMojo execMojo = new ExecMojo ();
393+ ExecMojo execMojo = new ExecMojo (repositorySystem , toolchainManager );
388394
389395 // without shebang
390396 File envScript = Files .createTempFile ("envScript" , ".sh" ).toFile ();
0 commit comments