Converting to JUnit 4 thus fixing [JENKINS-14641] and also fixing test(Html)Escape which didn't ran previously because of wrong case

This commit is contained in:
Christoph Kutzinski committed 2012-08-26 23:25:13 +02:00
1 parent 9522c60f78
commit d5017813ec
1 file changed
+16 -7
+16 -7
View File
@@ -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<String,String> m = new HashMap<String,String>();
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("<br>", Util.escape("\n"));
assertEquals("&lt;a>", Util.escape("<a>"));
assertEquals("&quot;&#039;", Util.escape("'\""));
assertEquals("&#039;&quot;", Util.escape("'\""));
assertEquals("&nbsp; ", 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";