package hudson.plugins.git;

import hudson.EnvVars;
import hudson.model.TaskListener;
import hudson.tools.CommandInstaller;
import hudson.tools.InstallSourceProperty;
import hudson.util.StreamTaskListener;
import java.io.IOException;
import java.util.Collections;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

public class GitToolResolverTest {

    @Rule
    public JenkinsRule j = new JenkinsRule();

    private GitTool gitTool;

    @Before
    public void setUp() throws IOException {
        GitTool.onLoaded();
        gitTool = GitTool.getDefaultInstallation();
    }

    @Test
    public void shouldResolveToolsOnMaster() throws Exception {
        TaskListener log = StreamTaskListener.fromStdout();
        GitTool t = new GitTool("myGit", null, Collections.singletonList(
                new InstallSourceProperty(Collections.singletonList(
                        new CommandInstaller("master", "echo Hello", "TOOL_HOME")
                ))));
        t.getDescriptor().setInstallations(t);

        GitTool defaultTool = GitTool.getDefaultInstallation();
        GitTool resolved = (GitTool) defaultTool.translate(j.jenkins, new EnvVars(), TaskListener.NULL);
        assertThat(resolved.getGitExe(), org.hamcrest.CoreMatchers.containsString("TOOL_HOME"));
    }
}

@@ -75,24 +75,113 @@
 skListener;%0A
+import hudson.tools.AbstractCommandInstaller;%0Aimport hudson.tools.BatchCommandInstaller;%0A
 import hudso
@@ -260,38 +260,20 @@
 ort 
-hudson.util.StreamTaskListener
+java.io.File
 ;%0Aim
@@ -830,59 +830,533 @@
     
-TaskListener log = StreamTaskListener.fromStdout();
+final String label = %22master%22;%0A        final String command = %22echo Hello%22;%0A        final String toolHome = %22TOOL_HOME%22;%0A        AbstractCommandInstaller installer;%0A        String expectedSubstring;%0A        if (isWindows()) %7B%0A            installer = new BatchCommandInstaller(label, command, toolHome);%0A            expectedSubstring = System.getProperty(%22java.io.tmpdir%22, %22C:%5C%5CTemp%22);%0A        %7D else %7B%0A            installer = new CommandInstaller(label, command, toolHome);%0A            expectedSubstring = toolHome;%0A        %7D
 %0A   
@@ -1498,107 +1498,17 @@
 ist(
-%0A                        new CommandInstaller(%22master%22, %22echo Hello%22, %22TOOL_HOME%22)%0A                
+installer
 ))))
@@ -1812,21 +1812,114 @@
 ing(
-%22TOOL_HOME%22))
+expectedSubstring));%0A    %7D%0A%0A    private boolean isWindows() %7B%0A        return File.pathSeparatorChar == ';'
 ;%0A  

Add BatchCommandInstaller to shouldResolveToolsOnMaster test