@@ -295,21 +295,31 @@ public void test_exec_receives_all_parameters() throws MojoExecutionException {
295
295
296
296
public void testToolchainJavaHomePropertySetWhenToolchainIsUsed () throws Exception {
297
297
// given
298
- String testJavaPath = "/path/to/java/home" ;
299
-
300
- File pom = new File (getBasedir (), "src/test/projects/project20/pom.xml" );
301
- ExecMojo mojo = (ExecMojo ) lookupMojo ("exec" , pom );
298
+ File basedir ;
299
+ String testJavaPath ;
300
+ File pom ;
301
+
302
+ if (OS .isFamilyWindows ()) {
303
+ testJavaPath = "\\ path\\ to\\ java\\ home" ;
304
+ pom = new File (getBasedir (), "src\\ test\\ projects\\ project21\\ pom.xml" );
305
+ when (toolchainManager .getToolchainFromBuildContext (any (), eq (session )))
306
+ .thenReturn (new DummyJdkToolchain (testJavaPath + "\\ bin\\ java" ));
307
+ } else {
308
+ testJavaPath = "/path/to/java/home" ;
309
+ pom = new File (getBasedir (), "src/test/projects/project20/pom.xml" );
310
+ when (toolchainManager .getToolchainFromBuildContext (any (), eq (session )))
311
+ .thenReturn (new DummyJdkToolchain (testJavaPath + "/bin/java" ));
312
+ }
302
313
303
- setVariableValueToObject (mojo , "session" , session );
304
- setVariableValueToObject (mojo , "toolchainManager" , toolchainManager );
305
- when (toolchainManager .getToolchainFromBuildContext (any (), eq (session )))
306
- .thenReturn (new DummyToolchain (testJavaPath + "/bin/java" ));
314
+ ExecMojo execMojo = (ExecMojo ) lookupMojo ("exec" , pom );
315
+ setVariableValueToObject (execMojo , "session" , session );
316
+ setVariableValueToObject (execMojo , "toolchainManager" , toolchainManager );
307
317
308
- File basedir = new File ("target" );
309
- mojo .setBasedir (basedir );
318
+ basedir = new File ("target" );
319
+ execMojo .setBasedir (basedir );
310
320
311
321
// when
312
- mojo .execute ();
322
+ execMojo .execute ();
313
323
314
324
// then
315
325
Path resultFilePath = basedir .toPath ().resolve ("testfile.txt" );
0 commit comments