package hudson.plugins.git;

import hudson.Functions;
import hudson.model.Run;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import org.jvnet.hudson.test.HudsonTestCase;

/**
 * Unit tests of {@link GitChangeLogParser}
 */
public class GitChangeLogParserTest extends HudsonTestCase {

    @Override
    protected void tearDown() throws Exception
    {
        try { //Avoid test failures due to failed cleanup tasks
            super.tearDown();
        }
        catch (Exception e) {
            if (e instanceof IOException && Functions.isWindows()) {
                return;
            }
            e.printStackTrace();
        }
    }

    /**
     * Test duplicate changes filtered from parsed change set list.
     * 
     * @throws Exception
     */
    public void testDuplicatesFiltered() throws Exception {
        GitChangeLogParser parser = new GitChangeLogParser(true);
        File log = File.createTempFile(getClass().getName(), ".tmp");
        FileWriter writer = new FileWriter(log);
        writer.write("commit 123abc456def\n");
        writer.write("    first message\n");
        writer.write("commit 123abc456def\n");
        writer.write("    second message");
        writer.close();
        GitChangeSetList list = parser.parse((Run) null, null, log);
        assertNotNull(list);
        assertNotNull(list.getLogs());
        assertEquals(1, list.getLogs().size());
        GitChangeSet first = list.getLogs().get(0);
        assertNotNull(first);
        assertEquals("123abc456def", first.getId());
        assertEquals("first message", first.getMsg());
        assertTrue("Temp file delete failed for " + log, log.delete());
    }
}

@@ -33,644 +33,332 @@
 ort 
-hudson.Functions;%0Aimport hudson.model.Run;%0Aimport java.io.File;%0Aimport java.io.FileWriter;%0Aimport java.io.IOException;%0A%0Aimport org.jvnet.hudson.test.HudsonTestCase;%0A%0A/**%0A * Unit tests of %7B@link GitChangeLogParser%7D%0A */%0Apublic class GitChangeLogParserTest extends HudsonTestCase %7B%0A%0A    @Override%0A    protected void tearDown() throws Exception%0A    %7B%0A        try %7B //Avoid test failures due to failed cleanup tasks%0A            super.tearDown();%0A        %7D%0A        catch (Exception e) %7B%0A            if (e instanceof IOException && Functions.isWindows()) %7B%0A                return;%0A            %7D%0A            e.printStackTrace();%0A        %7D%0A    %7D
+java.io.File;%0Aimport java.io.FileWriter;%0Aimport static org.junit.Assert.*;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.TemporaryFolder;%0A%0A/**%0A * Unit tests of %7B@link GitChangeLogParser%7D%0A */%0Apublic class GitChangeLogParserTest %7B%0A%0A    @Rule%0A    public TemporaryFolder tmpFolder = new TemporaryFolder();
 %0A%0A  
@@ -437,17 +437,16 @@
 .%0A     *
- 
 %0A     * 
@@ -471,16 +471,26 @@
      */%0A
+    @Test%0A
     publ
@@ -630,56 +630,26 @@
 g = 
-File.createTempFile(getClass().getName(), %22.tmp%22
+tmpFolder.newFile(
 );%0A 
@@ -952,14 +952,8 @@
 rse(
-(Run) 
 null

Use JUnit 4 with GitChangeLogParserTest, simpler, faster, easier to read