package hudson.plugins.git;

import hudson.EnvVars;
import hudson.model.Node;
import hudson.model.TaskListener;
import hudson.slaves.DumbSlave;
import hudson.util.StreamTaskListener;
import java.io.IOException;
import org.apache.commons.lang.SystemUtils;
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 GitToolTest {

    @Rule public JenkinsRule j = new JenkinsRule();

    private GitTool gitTool;
    
    @Before
    public void setUp() throws IOException {
        GitTool.onLoaded();
        gitTool = GitTool.getDefaultInstallation();
    }
    
    @Test
    public void testGetGitExe() {
        assertEquals(SystemUtils.IS_OS_WINDOWS ? "git.exe" : "git", gitTool.getGitExe());
    }

    /* @Test - Need to find a way to create a Node in a unit test */
    public void testForNode() throws Exception {
        DumbSlave s = j.createSlave();
        Node node = null;
        TaskListener log = StreamTaskListener.fromStdout();
        GitTool newTool = gitTool.forNode(node, log);
        assertEquals(gitTool.getGitExe(), newTool.getGitExe());
    }

    @Test
    public void testForEnvironment() {
        EnvVars environment = new EnvVars();
        GitTool newTool = gitTool.forEnvironment(environment);
        assertEquals(gitTool.getGitExe(), newTool.getGitExe());
    }

    @Test
    public void testGetDescriptor() {
        GitTool.DescriptorImpl descriptor = gitTool.getDescriptor();
        assertEquals("Git", descriptor.getDisplayName());
    }
    
}

@@ -506,20 +506,16 @@
 itTool;%0A
-    
 %0A    @Be
@@ -650,20 +650,16 @@
 ;%0A    %7D%0A
-    
 %0A    @Te
@@ -799,73 +799,14 @@
 %0A   
- /*
  @Test
- - Need to find a way to create a Node in a unit test */
 %0A   
@@ -870,16 +870,20 @@
 bSlave s
+lave
  = j.cre
@@ -906,24 +906,42 @@
     
+slave.setMode(
 Node
- node = null
+.Mode.EXCLUSIVE)
 ;%0A  
@@ -1044,11 +1044,12 @@
 ode(
-nod
+slav
 e, l
@@ -1533,15 +1533,11 @@
 ;%0A    %7D%0A
-    
 %0A%7D%0A

Add GitTool.forNode test