diff --git a/core/src/test/java/hudson/UtilTest.java b/core/src/test/java/hudson/UtilTest.java index d912ab3d74..b3b46b241a 100644 --- a/core/src/test/java/hudson/UtilTest.java +++ b/core/src/test/java/hudson/UtilTest.java @@ -24,8 +24,6 @@ */ package hudson; -import junit.framework.TestCase; - import java.util.Map; import java.util.HashMap; import java.util.Locale; @@ -33,7 +31,9 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import static org.junit.Assert.*; import org.junit.Assume; +import org.junit.Test; import org.jvnet.hudson.test.Bug; import hudson.util.StreamTaskListener; @@ -41,7 +41,8 @@ import hudson.util.StreamTaskListener; /** * @author Kohsuke Kawaguchi */ -public class UtilTest extends TestCase { +public class UtilTest { + @Test public void testReplaceMacro() { Map m = new HashMap(); m.put("A","a"); @@ -71,7 +72,7 @@ public class UtilTest extends TestCase { assertEquals("$$aa$Ba${A}$it", Util.replaceMacro("$$$DOLLAR${AA}$$B${ENCLOSED}$it",m)); } - + @Test public void testTimeSpanString() { // Check that amounts less than 365 days are not rounded up to a whole year. // In the previous implementation there were 360 days in a year. @@ -115,6 +116,7 @@ public class UtilTest extends TestCase { /** * Test that Strings that contain spaces are correctly URL encoded. */ + @Test public void testEncodeSpaces() { final String urlWithSpaces = "http://hudson/job/Hudson Job"; String encoded = Util.encode(urlWithSpaces); @@ -124,6 +126,7 @@ public class UtilTest extends TestCase { /** * Test that Strings that contain ampersand are correctly URL encoded. */ + @Test public void testEncodeAmpersand() { final String urlWithAmpersand = "http://hudson/job/Hudson-job/label1&&label2"; String encoded = Util.encode(urlWithAmpersand); @@ -133,6 +136,7 @@ public class UtilTest extends TestCase { /** * Test the rawEncode() method. */ + @Test public void testRawEncode() { String[] data = { // Alternating raw,encoded "abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", @@ -150,6 +154,7 @@ public class UtilTest extends TestCase { /** * Test the tryParseNumber() method. */ + @Test public void testTryParseNumber() { assertEquals("Successful parse did not return the parsed value", 20, Util.tryParseNumber("20", 10).intValue()); assertEquals("Failed parse did not return the default value", 10, Util.tryParseNumber("ss", 10).intValue()); @@ -157,8 +162,9 @@ public class UtilTest extends TestCase { assertEquals("Parsing null string did not return the default value", 10, Util.tryParseNumber(null, 10).intValue()); } + @Test public void testSymlink() throws Exception { - if (Functions.isWindows()) return; + Assume.assumeTrue(!Functions.isWindows()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamTaskListener l = new StreamTaskListener(baos); @@ -195,6 +201,7 @@ public class UtilTest extends TestCase { } } + @Test public void testIsSymlink() throws IOException, InterruptedException { Assume.assumeTrue(!Functions.isWindows()); @@ -224,10 +231,11 @@ public class UtilTest extends TestCase { } } - public void TestEscape() { + @Test + public void testHtmlEscape() { assertEquals("
", Util.escape("\n")); assertEquals("<a>", Util.escape("")); - assertEquals(""'", Util.escape("'\"")); + assertEquals("'"", Util.escape("'\"")); assertEquals("  ", Util.escape(" ")); } @@ -236,6 +244,7 @@ public class UtilTest extends TestCase { * to another digest. */ @Bug(10346) + @Test public void testDigestThreadSafety() throws InterruptedException { String a = "abcdefgh"; String b = "123456789";