/*
 * (C) Copyright 2017 Boni Garcia (http://bonigarcia.github.io/)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */
package io.github.bonigarcia.wdm.test;

import static java.lang.System.setProperty;
import static java.lang.invoke.MethodHandles.lookup;
import static java.nio.file.Files.createTempDirectory;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
import java.nio.file.Path;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;

import io.github.bonigarcia.wdm.ChromeDriverManager;

/**
 * Test for custom target.
 *
 * @author Boni Garcia (boni.gg@gmail.com)
 * @since 1.7.2
 */
public class CustomTargetTest {

    final Logger log = getLogger(lookup().lookupClass());

    Path tmpFolder;

    @Before
    public void setup() throws IOException {
        tmpFolder = createTempDirectory("");
        log.info("Using temporal folder {} as cache", tmpFolder);
    }

    @Test
    public void testTargetPath() {
        String cacheFolder = tmpFolder.toString();
        setProperty("wdm.targetPath", cacheFolder);
        ChromeDriverManager.getInstance().setup();

        String binaryPath = ChromeDriverManager.getInstance().getBinaryPath();
        log.info("Binary path {}", binaryPath);

        assertThat(binaryPath, startsWith(cacheFolder));
    }

    @After
    public void teardown() throws IOException {
        log.info("Deleting temporal folder {}", tmpFolder);
        deleteDirectory(tmpFolder.toFile());
    }

}

@@ -637,16 +637,60 @@
 .test;%0A%0A
+import static java.lang.System.getProperty;%0A
 import s
@@ -1561,16 +1561,77 @@
 ry(%22%22);%0A
+        setProperty(%22wdm.targetPath%22, tmpFolder.toString());%0A
         
@@ -1673,16 +1673,21 @@
 as cache
+ %5B%7B%7D%5D
 %22, tmpFo
@@ -1694,49 +1694,44 @@
 lder
-);%0A
+,%0A 
     
-%7D%0A%0A
     
-@Test%0A    public void testT
+       getProperty(%22wdm.t
 arge
@@ -1739,115 +1739,64 @@
 Path
-() %7B
+%22));
 %0A    
+%7D%0A%0A
     
-String cacheFolder = tmpFolder.toString();%0A        setProperty(%22wdm.targetPath%22, cacheFolder);
+@Test%0A    public void testTargetPath() %7B
 %0A   
@@ -1843,17 +1843,16 @@
 etup();%0A
-%0A
         
@@ -1970,17 +1970,16 @@
 yPath);%0A
-%0A
         
@@ -2016,19 +2016,28 @@
 ith(
-cache
+tmp
 Folder
+.toString()
 ));%0A

Include more logging traces in custom target test