package hudson.plugins.git;

import junit.framework.Assert;
import junit.framework.TestCase;

public class TestBranchSpec extends TestCase {
    public void testMatch() {
        BranchSpec l = new BranchSpec("master");
        Assert.assertTrue(l.matches("origin/master"));
        Assert.assertFalse(l.matches("origin/something/master"));
        Assert.assertFalse(l.matches("master"));
        Assert.assertFalse(l.matches("dev"));
        
        
        BranchSpec est = new BranchSpec("origin/*/dev");
        
        Assert.assertFalse(est.matches("origintestdev"));
        Assert.assertTrue(est.matches("origin/test/dev"));
        Assert.assertFalse(est.matches("origin/test/release"));
        Assert.assertFalse(est.matches("origin/test/somthing/release"));
        
        BranchSpec s = new BranchSpec("origin/*");
        
        Assert.assertTrue(s.matches("origin/master"));
      
        BranchSpec m = new BranchSpec("**/magnayn/*");
        
        Assert.assertTrue(m.matches("origin/magnayn/b1"));
        Assert.assertTrue(m.matches("remote/origin/magnayn/b1"));
      
        BranchSpec n = new BranchSpec("*/my.branch/*");
        
        Assert.assertTrue(n.matches("origin/my.branch/b1"));
        Assert.assertFalse(n.matches("origin/my-branch/b1"));
        Assert.assertFalse(n.matches("remote/origin/my.branch/b1"));
      
        BranchSpec o = new BranchSpec("**");
        
        Assert.assertTrue(o.matches("origin/my.branch/b1"));
        Assert.assertTrue(o.matches("origin/my-branch/b1"));
        Assert.assertTrue(o.matches("remote/origin/my.branch/b1"));
      
        BranchSpec p = new BranchSpec("*");

        Assert.assertTrue(p.matches("origin/x"));
        Assert.assertFalse(p.matches("origin/my-branch/b1"));
    }
}

@@ -1772,10 +1772,436 @@
 ;%0A    %7D%0A
+    %0A    public void testEmptyName() %7B%0A    %09BranchSpec branchSpec = new BranchSpec(%22%22);%0A    %09assertEquals(%22**%22,branchSpec.getName());%0A    %7D%0A    %0A    public void testNullName() %7B%0A    %09boolean correctExceptionThrown = false;%0A    %09try %7B%0A    %09%09BranchSpec branchSpec = new BranchSpec(null);%0A    %09%7D catch (IllegalArgumentException e) %7B%0A    %09%09correctExceptionThrown = true;%0A    %09%7D%0A    %09assertTrue(correctExceptionThrown);%0A    %7D%0A    %0A
 %7D%0A

Add unit tests for existing null/empty name handling.