hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1100965 [6/9] - in /httpcomponents/httpcore/trunk: httpcore-nio/src/test/java/org/apache/http/ httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/ httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/ httpcore-nio/src/test/j...
Date Mon, 09 May 2011 11:27:00 GMT
Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueFormatter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueFormatter.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueFormatter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueFormatter.java Mon May  9 11:26:57 2011
@@ -29,25 +29,19 @@
 
 package org.apache.http.message;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for header value formatting.
  *
  *
  */
-public class TestBasicHeaderValueFormatter extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestBasicHeaderValueFormatter(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestBasicHeaderValueFormatter {
 
+    @Test
     public void testNVPFormatting() throws Exception {
         NameValuePair param1 = new BasicNameValuePair("param", "regular_stuff");
         NameValuePair param2 = new BasicNameValuePair("param", "this\\that");
@@ -58,65 +52,67 @@ public class TestBasicHeaderValueFormatt
         NameValuePair param7 = new BasicNameValuePair("param", null);
 
 
-        assertEquals("param=regular_stuff",
+        Assert.assertEquals("param=regular_stuff",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param1, false, null));
-        assertEquals("param=\"this\\\\that\"",
+        Assert.assertEquals("param=\"this\\\\that\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param2, false, null));
-        assertEquals("param=\"this,that\"",
+        Assert.assertEquals("param=\"this,that\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param3, false, null));
-        assertEquals("param=\"quote marks (\\\") must be escaped\"",
+        Assert.assertEquals("param=\"quote marks (\\\") must be escaped\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param4, false, null));
-        assertEquals("param=\"back slash (\\\\) must be escaped too\"",
+        Assert.assertEquals("param=\"back slash (\\\\) must be escaped too\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param5, false, null));
-        assertEquals("param=\"values with\tblanks must always be quoted\"",
+        Assert.assertEquals("param=\"values with\tblanks must always be quoted\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param6, false, null));
-        assertEquals("param", BasicHeaderValueFormatter.formatNameValuePair
+        Assert.assertEquals("param", BasicHeaderValueFormatter.formatNameValuePair
                      (param7, false, null));
 
-        assertEquals("param=\"regular_stuff\"",
+        Assert.assertEquals("param=\"regular_stuff\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param1, true, null));
-        assertEquals("param=\"this\\\\that\"",
+        Assert.assertEquals("param=\"this\\\\that\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param2, true, null));
-        assertEquals("param=\"this,that\"",
+        Assert.assertEquals("param=\"this,that\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param3, true, null));
-        assertEquals("param=\"quote marks (\\\") must be escaped\"",
+        Assert.assertEquals("param=\"quote marks (\\\") must be escaped\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param4, true, null));
-        assertEquals("param=\"back slash (\\\\) must be escaped too\"",
+        Assert.assertEquals("param=\"back slash (\\\\) must be escaped too\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param5, true, null));
-        assertEquals("param=\"values with\tblanks must always be quoted\"",
+        Assert.assertEquals("param=\"values with\tblanks must always be quoted\"",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param6, true, null));
-        assertEquals("param",
+        Assert.assertEquals("param",
                      BasicHeaderValueFormatter.formatNameValuePair
                      (param7, false, null));
     }
 
 
 
+    @Test
     public void testParamsFormatting() throws Exception {
         NameValuePair param1 = new BasicNameValuePair("param", "regular_stuff");
         NameValuePair param2 = new BasicNameValuePair("param", "this\\that");
         NameValuePair param3 = new BasicNameValuePair("param", "this,that");
         NameValuePair[] params = new NameValuePair[] {param1, param2, param3};
-        assertEquals("param=regular_stuff; param=\"this\\\\that\"; param=\"this,that\"",
+        Assert.assertEquals("param=regular_stuff; param=\"this\\\\that\"; param=\"this,that\"",
                      BasicHeaderValueFormatter.formatParameters(params, false, null));
-        assertEquals("param=\"regular_stuff\"; param=\"this\\\\that\"; param=\"this,that\"",
+        Assert.assertEquals("param=\"regular_stuff\"; param=\"this\\\\that\"; param=\"this,that\"",
                      BasicHeaderValueFormatter.formatParameters(params, true, null));
     }
 
 
 
+    @Test
     public void testHEFormatting() throws Exception {
         NameValuePair param1 = new BasicNameValuePair("param", "regular_stuff");
         NameValuePair param2 = new BasicNameValuePair("param", "this\\that");
@@ -125,10 +121,11 @@ public class TestBasicHeaderValueFormatt
         NameValuePair[] params = new NameValuePair[] {param1, param2, param3, param4};
         HeaderElement element = new BasicHeaderElement("name", "value", params);
 
-        assertEquals("name=value; param=regular_stuff; param=\"this\\\\that\"; param=\"this,that\"; param",
+        Assert.assertEquals("name=value; param=regular_stuff; param=\"this\\\\that\"; param=\"this,that\"; param",
                      BasicHeaderValueFormatter.formatHeaderElement(element, false, null));
     }
 
+    @Test
     public void testElementsFormatting() throws Exception {
         NameValuePair param1 = new BasicNameValuePair("param", "regular_stuff");
         NameValuePair param2 = new BasicNameValuePair("param", "this\\that");
@@ -141,7 +138,7 @@ public class TestBasicHeaderValueFormatt
         HeaderElement element5 = new BasicHeaderElement("name5", null);
         HeaderElement[] elements = new HeaderElement[] {element1, element2, element3, element4, element5};
 
-        assertEquals
+        Assert.assertEquals
             ("name1=value1; param=regular_stuff, name2=value2; " +
              "param=\"this\\\\that\", name3=value3; param=\"this,that\", " +
              "name4=value4; param, name5",
@@ -149,12 +146,13 @@ public class TestBasicHeaderValueFormatt
     }
 
 
+    @Test
     public void testInvalidHEArguments() throws Exception {
         try {
             BasicHeaderValueFormatter.formatHeaderElement
                 ((HeaderElement) null, false,
                  BasicHeaderValueFormatter.DEFAULT);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
@@ -163,19 +161,20 @@ public class TestBasicHeaderValueFormatt
             BasicHeaderValueFormatter.formatElements
                 ((HeaderElement[]) null, false,
                  BasicHeaderValueFormatter.DEFAULT);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
 
+    @Test
     public void testInvalidNVArguments() throws Exception {
 
         try {
             BasicHeaderValueFormatter.formatNameValuePair
                 ((NameValuePair) null, true, null);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
@@ -184,7 +183,7 @@ public class TestBasicHeaderValueFormatt
             BasicHeaderValueFormatter.formatParameters
                 ((NameValuePair[]) null, true,
                  BasicHeaderValueFormatter.DEFAULT);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueParser.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueParser.java Mon May  9 11:26:57 2011
@@ -29,90 +29,89 @@
 
 package org.apache.http.message;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HeaderElement;
 import org.apache.http.NameValuePair;
 import org.apache.http.util.CharArrayBuffer;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for header value parsing.
  *
  * @version $Id$
  */
-public class TestBasicHeaderValueParser extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestBasicHeaderValueParser(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestBasicHeaderValueParser {
 
+    @Test
     public void testParseHeaderElements() throws Exception {
         String headerValue = "name1 = value1; name2; name3=\"value3\" , name4=value4; " +
             "name5=value5, name6= ; name7 = value7; name8 = \" value8\"";
         HeaderElement[] elements = BasicHeaderValueParser.parseElements(headerValue, null);
         // there are 3 elements
-        assertEquals(3,elements.length);
+        Assert.assertEquals(3,elements.length);
         // 1st element
-        assertEquals("name1",elements[0].getName());
-        assertEquals("value1",elements[0].getValue());
+        Assert.assertEquals("name1",elements[0].getName());
+        Assert.assertEquals("value1",elements[0].getValue());
         // 1st element has 2 getParameters()
-        assertEquals(2,elements[0].getParameters().length);
-        assertEquals("name2",elements[0].getParameters()[0].getName());
-        assertEquals(null, elements[0].getParameters()[0].getValue());
-        assertEquals("name3",elements[0].getParameters()[1].getName());
-        assertEquals("value3",elements[0].getParameters()[1].getValue());
+        Assert.assertEquals(2,elements[0].getParameters().length);
+        Assert.assertEquals("name2",elements[0].getParameters()[0].getName());
+        Assert.assertEquals(null, elements[0].getParameters()[0].getValue());
+        Assert.assertEquals("name3",elements[0].getParameters()[1].getName());
+        Assert.assertEquals("value3",elements[0].getParameters()[1].getValue());
         // 2nd element
-        assertEquals("name4",elements[1].getName());
-        assertEquals("value4",elements[1].getValue());
+        Assert.assertEquals("name4",elements[1].getName());
+        Assert.assertEquals("value4",elements[1].getValue());
         // 2nd element has 1 parameter
-        assertEquals(1,elements[1].getParameters().length);
-        assertEquals("name5",elements[1].getParameters()[0].getName());
-        assertEquals("value5",elements[1].getParameters()[0].getValue());
+        Assert.assertEquals(1,elements[1].getParameters().length);
+        Assert.assertEquals("name5",elements[1].getParameters()[0].getName());
+        Assert.assertEquals("value5",elements[1].getParameters()[0].getValue());
         // 3rd element
-        assertEquals("name6",elements[2].getName());
-        assertEquals("",elements[2].getValue());
+        Assert.assertEquals("name6",elements[2].getName());
+        Assert.assertEquals("",elements[2].getValue());
         // 3rd element has 2 getParameters()
-        assertEquals(2,elements[2].getParameters().length);
-        assertEquals("name7",elements[2].getParameters()[0].getName());
-        assertEquals("value7",elements[2].getParameters()[0].getValue());
-        assertEquals("name8",elements[2].getParameters()[1].getName());
-        assertEquals(" value8",elements[2].getParameters()[1].getValue());
+        Assert.assertEquals(2,elements[2].getParameters().length);
+        Assert.assertEquals("name7",elements[2].getParameters()[0].getName());
+        Assert.assertEquals("value7",elements[2].getParameters()[0].getValue());
+        Assert.assertEquals("name8",elements[2].getParameters()[1].getName());
+        Assert.assertEquals(" value8",elements[2].getParameters()[1].getValue());
     }
 
+    @Test
     public void testParseHEEscaped() {
         String s =
           "test1 =  \"\\\"stuff\\\"\", test2= \"\\\\\", test3 = \"stuff, stuff\"";
         HeaderElement[] elements = BasicHeaderValueParser.parseElements(s, null);
-        assertEquals(3, elements.length);
-        assertEquals("test1", elements[0].getName());
-        assertEquals("\\\"stuff\\\"", elements[0].getValue());
-        assertEquals("test2", elements[1].getName());
-        assertEquals("\\\\", elements[1].getValue());
-        assertEquals("test3", elements[2].getName());
-        assertEquals("stuff, stuff", elements[2].getValue());
+        Assert.assertEquals(3, elements.length);
+        Assert.assertEquals("test1", elements[0].getName());
+        Assert.assertEquals("\\\"stuff\\\"", elements[0].getValue());
+        Assert.assertEquals("test2", elements[1].getName());
+        Assert.assertEquals("\\\\", elements[1].getValue());
+        Assert.assertEquals("test3", elements[2].getName());
+        Assert.assertEquals("stuff, stuff", elements[2].getValue());
     }
 
+    @Test
     public void testHEFringeCase1() throws Exception {
         String headerValue = "name1 = value1,";
         HeaderElement[] elements = BasicHeaderValueParser.parseElements(headerValue, null);
-        assertEquals("Number of elements", 1, elements.length);
+        Assert.assertEquals("Number of elements", 1, elements.length);
     }
 
+    @Test
     public void testHEFringeCase2() throws Exception {
         String headerValue = "name1 = value1, ";
         HeaderElement[] elements = BasicHeaderValueParser.parseElements(headerValue, null);
-        assertEquals("Number of elements", 1, elements.length);
+        Assert.assertEquals("Number of elements", 1, elements.length);
     }
 
+    @Test
     public void testHEFringeCase3() throws Exception {
         String headerValue = ",, ,, ,";
         HeaderElement[] elements = BasicHeaderValueParser.parseElements(headerValue, null);
-        assertEquals("Number of elements", 0, elements.length);
+        Assert.assertEquals("Number of elements", 0, elements.length);
     }
 
+    @Test
     public void testNVParseUsingCursor() {
 
         HeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
@@ -123,10 +122,10 @@ public class TestBasicHeaderValueParser 
         ParserCursor cursor = new ParserCursor(0, s.length());
 
         NameValuePair param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("test", param.getName());
-        assertEquals(null, param.getValue());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals(null, param.getValue());
+        Assert.assertEquals(s.length(), cursor.getPos());
+        Assert.assertTrue(cursor.atEnd());
 
         s = "test;";
         buffer = new CharArrayBuffer(16);
@@ -134,10 +133,10 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("test", param.getName());
-        assertEquals(null, param.getValue());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals(null, param.getValue());
+        Assert.assertEquals(s.length(), cursor.getPos());
+        Assert.assertTrue(cursor.atEnd());
 
         s = "test  ,12";
         buffer = new CharArrayBuffer(16);
@@ -145,10 +144,10 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("test", param.getName());
-        assertEquals(null, param.getValue());
-        assertEquals(s.length() - 2, cursor.getPos());
-        assertFalse(cursor.atEnd());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals(null, param.getValue());
+        Assert.assertEquals(s.length() - 2, cursor.getPos());
+        Assert.assertFalse(cursor.atEnd());
 
         s = "test=stuff";
         buffer = new CharArrayBuffer(16);
@@ -156,10 +155,10 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals("stuff", param.getValue());
+        Assert.assertEquals(s.length(), cursor.getPos());
+        Assert.assertTrue(cursor.atEnd());
 
         s = "   test  =   stuff ";
         buffer = new CharArrayBuffer(16);
@@ -167,10 +166,10 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals("stuff", param.getValue());
+        Assert.assertEquals(s.length(), cursor.getPos());
+        Assert.assertTrue(cursor.atEnd());
 
         s = "   test  =   stuff ;1234";
         buffer = new CharArrayBuffer(16);
@@ -178,10 +177,10 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
-        assertEquals(s.length() - 4, cursor.getPos());
-        assertFalse(cursor.atEnd());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals("stuff", param.getValue());
+        Assert.assertEquals(s.length() - 4, cursor.getPos());
+        Assert.assertFalse(cursor.atEnd());
 
         s = "test  = \"stuff\"";
         buffer = new CharArrayBuffer(16);
@@ -189,8 +188,8 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals("stuff", param.getValue());
 
         s = "test  = \"  stuff\\\"\"";
         buffer = new CharArrayBuffer(16);
@@ -198,8 +197,8 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("test", param.getName());
-        assertEquals("  stuff\\\"", param.getValue());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals("  stuff\\\"", param.getValue());
 
         s = "  test";
         buffer = new CharArrayBuffer(16);
@@ -207,8 +206,8 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("test", param.getName());
-        assertEquals(null, param.getValue());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals(null, param.getValue());
 
         s = "  ";
         buffer = new CharArrayBuffer(16);
@@ -216,8 +215,8 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("", param.getName());
-        assertEquals(null, param.getValue());
+        Assert.assertEquals("", param.getName());
+        Assert.assertEquals(null, param.getValue());
 
         s = " = stuff ";
         buffer = new CharArrayBuffer(16);
@@ -225,53 +224,55 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         param = parser.parseNameValuePair(buffer, cursor);
-        assertEquals("", param.getName());
-        assertEquals("stuff", param.getValue());
+        Assert.assertEquals("", param.getName());
+        Assert.assertEquals("stuff", param.getValue());
     }
 
+    @Test
     public void testNVParse() {
         String s = "test";
         NameValuePair param =
             BasicHeaderValueParser.parseNameValuePair(s, null);
-        assertEquals("test", param.getName());
-        assertEquals(null, param.getValue());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals(null, param.getValue());
 
         s = "test=stuff";
         param = BasicHeaderValueParser.parseNameValuePair(s, null);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals("stuff", param.getValue());
 
         s = "   test  =   stuff ";
         param = BasicHeaderValueParser.parseNameValuePair(s, null);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals("stuff", param.getValue());
 
         s = "test  = \"stuff\"";
         param = BasicHeaderValueParser.parseNameValuePair(s, null);
-        assertEquals("test", param.getName());
-        assertEquals("stuff", param.getValue());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals("stuff", param.getValue());
 
         s = "test  = \"  stuff\\\"\"";
         param = BasicHeaderValueParser.parseNameValuePair(s, null);
-        assertEquals("test", param.getName());
-        assertEquals("  stuff\\\"", param.getValue());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals("  stuff\\\"", param.getValue());
 
         s = "  test";
         param = BasicHeaderValueParser.parseNameValuePair(s, null);
-        assertEquals("test", param.getName());
-        assertEquals(null, param.getValue());
+        Assert.assertEquals("test", param.getName());
+        Assert.assertEquals(null, param.getValue());
 
         s = "  ";
         param = BasicHeaderValueParser.parseNameValuePair(s, null);
-        assertEquals("", param.getName());
-        assertEquals(null, param.getValue());
+        Assert.assertEquals("", param.getName());
+        Assert.assertEquals(null, param.getValue());
 
         s = " = stuff ";
         param = BasicHeaderValueParser.parseNameValuePair(s, null);
-        assertEquals("", param.getName());
-        assertEquals("stuff", param.getValue());
+        Assert.assertEquals("", param.getName());
+        Assert.assertEquals("stuff", param.getValue());
     }
 
+    @Test
     public void testNVParseAllWithCursor() {
         HeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
 
@@ -282,16 +283,16 @@ public class TestBasicHeaderValueParser 
         ParserCursor cursor = new ParserCursor(0, s.length());
 
         NameValuePair[] params = parser.parseParameters(buffer, cursor);
-        assertEquals("test", params[0].getName());
-        assertEquals(null, params[0].getValue());
-        assertEquals("test1", params[1].getName());
-        assertEquals("stuff", params[1].getValue());
-        assertEquals("test2", params[2].getName());
-        assertEquals("stuff; stuff", params[2].getValue());
-        assertEquals("test3", params[3].getName());
-        assertEquals("\"stuff", params[3].getValue());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        Assert.assertEquals("test", params[0].getName());
+        Assert.assertEquals(null, params[0].getValue());
+        Assert.assertEquals("test1", params[1].getName());
+        Assert.assertEquals("stuff", params[1].getValue());
+        Assert.assertEquals("test2", params[2].getName());
+        Assert.assertEquals("stuff; stuff", params[2].getValue());
+        Assert.assertEquals("test3", params[3].getName());
+        Assert.assertEquals("\"stuff", params[3].getValue());
+        Assert.assertEquals(s.length(), cursor.getPos());
+        Assert.assertTrue(cursor.atEnd());
 
         s =
             "test; test1 =  stuff   ; test2 =  \"stuff; stuff\"; test3=\"stuff\",123";
@@ -300,56 +301,58 @@ public class TestBasicHeaderValueParser 
         cursor = new ParserCursor(0, s.length());
 
         params = parser.parseParameters(buffer, cursor);
-        assertEquals("test", params[0].getName());
-        assertEquals(null, params[0].getValue());
-        assertEquals("test1", params[1].getName());
-        assertEquals("stuff", params[1].getValue());
-        assertEquals("test2", params[2].getName());
-        assertEquals("stuff; stuff", params[2].getValue());
-        assertEquals("test3", params[3].getName());
-        assertEquals("stuff", params[3].getValue());
-        assertEquals(s.length() - 3, cursor.getPos());
-        assertFalse(cursor.atEnd());
+        Assert.assertEquals("test", params[0].getName());
+        Assert.assertEquals(null, params[0].getValue());
+        Assert.assertEquals("test1", params[1].getName());
+        Assert.assertEquals("stuff", params[1].getValue());
+        Assert.assertEquals("test2", params[2].getName());
+        Assert.assertEquals("stuff; stuff", params[2].getValue());
+        Assert.assertEquals("test3", params[3].getName());
+        Assert.assertEquals("stuff", params[3].getValue());
+        Assert.assertEquals(s.length() - 3, cursor.getPos());
+        Assert.assertFalse(cursor.atEnd());
 
         s = "  ";
         buffer = new CharArrayBuffer(16);
         buffer.append(s);
         cursor = new ParserCursor(0, s.length());
         params = parser.parseParameters(buffer, cursor);
-        assertEquals(0, params.length);
+        Assert.assertEquals(0, params.length);
     }
 
+    @Test
     public void testNVParseAll() {
         String s =
           "test; test1 =  stuff   ; test2 =  \"stuff; stuff\"; test3=\"stuff";
         NameValuePair[] params =
             BasicHeaderValueParser.parseParameters(s, null);
-        assertEquals("test", params[0].getName());
-        assertEquals(null, params[0].getValue());
-        assertEquals("test1", params[1].getName());
-        assertEquals("stuff", params[1].getValue());
-        assertEquals("test2", params[2].getName());
-        assertEquals("stuff; stuff", params[2].getValue());
-        assertEquals("test3", params[3].getName());
-        assertEquals("\"stuff", params[3].getValue());
+        Assert.assertEquals("test", params[0].getName());
+        Assert.assertEquals(null, params[0].getValue());
+        Assert.assertEquals("test1", params[1].getName());
+        Assert.assertEquals("stuff", params[1].getValue());
+        Assert.assertEquals("test2", params[2].getName());
+        Assert.assertEquals("stuff; stuff", params[2].getValue());
+        Assert.assertEquals("test3", params[3].getName());
+        Assert.assertEquals("\"stuff", params[3].getValue());
 
         s = "  ";
         params = BasicHeaderValueParser.parseParameters(s, null);
-        assertEquals(0, params.length);
+        Assert.assertEquals(0, params.length);
     }
 
+    @Test
     public void testNVParseEscaped() {
         String s =
           "test1 =  \"\\\"stuff\\\"\"; test2= \"\\\\\"; test3 = \"stuff; stuff\"";
         NameValuePair[] params =
             BasicHeaderValueParser.parseParameters(s, null);
-        assertEquals(3, params.length);
-        assertEquals("test1", params[0].getName());
-        assertEquals("\\\"stuff\\\"", params[0].getValue());
-        assertEquals("test2", params[1].getName());
-        assertEquals("\\\\", params[1].getValue());
-        assertEquals("test3", params[2].getName());
-        assertEquals("stuff; stuff", params[2].getValue());
+        Assert.assertEquals(3, params.length);
+        Assert.assertEquals("test1", params[0].getName());
+        Assert.assertEquals("\\\"stuff\\\"", params[0].getValue());
+        Assert.assertEquals("test2", params[1].getName());
+        Assert.assertEquals("\\\\", params[1].getValue());
+        Assert.assertEquals("test3", params[2].getName());
+        Assert.assertEquals("stuff; stuff", params[2].getValue());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineFormatter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineFormatter.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineFormatter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineFormatter.java Mon May  9 11:26:57 2011
@@ -27,71 +27,66 @@
 
 package org.apache.http.message;
 
-import junit.framework.TestCase;
-
 import org.apache.http.Header;
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
 import org.apache.http.RequestLine;
 import org.apache.http.StatusLine;
 import org.apache.http.util.CharArrayBuffer;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for {@link BasicLineFormatter}.
- *
- *
  */
-public class TestBasicLineFormatter extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestBasicLineFormatter(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestBasicLineFormatter {
 
+    @Test
     public void testHttpVersionFormatting() throws Exception {
         String s = BasicLineFormatter.formatProtocolVersion
             (HttpVersion.HTTP_1_1, null);
-        assertEquals("HTTP/1.1", s);
+        Assert.assertEquals("HTTP/1.1", s);
     }
 
+    @Test
     public void testHttpVersionFormattingInvalidInput() throws Exception {
         try {
             BasicLineFormatter.formatProtocolVersion
                 (null, BasicLineFormatter.DEFAULT);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             BasicLineFormatter.DEFAULT.appendProtocolVersion
                 (new CharArrayBuffer(10), (HttpVersion) null);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
 
+    @Test
     public void testRLFormatting() throws Exception {
         RequestLine requestline = new BasicRequestLine("GET", "/stuff", HttpVersion.HTTP_1_1);
         String s = BasicLineFormatter.formatRequestLine(requestline, null);
-        assertEquals("GET /stuff HTTP/1.1", s);
+        Assert.assertEquals("GET /stuff HTTP/1.1", s);
     }
 
+    @Test
     public void testRLFormattingInvalidInput() throws Exception {
         try {
             BasicLineFormatter.formatRequestLine
                 (null, BasicLineFormatter.DEFAULT);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             BasicLineFormatter.DEFAULT.formatRequestLine
                 (new CharArrayBuffer(10), (RequestLine) null);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
@@ -99,56 +94,60 @@ public class TestBasicLineFormatter exte
 
 
 
+    @Test
     public void testSLFormatting() throws Exception {
         StatusLine statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         String s = BasicLineFormatter.formatStatusLine(statusline, null);
-        assertEquals("HTTP/1.1 200 OK", s);
+        Assert.assertEquals("HTTP/1.1 200 OK", s);
         statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null);
         s = BasicLineFormatter.formatStatusLine(statusline, null);
-        assertEquals("HTTP/1.1 200 ", s);
+        Assert.assertEquals("HTTP/1.1 200 ", s);
         // see "testSLParseSuccess" in TestBasicLineParser:
         // trailing space is correct
     }
 
+    @Test
     public void testSLFormattingInvalidInput() throws Exception {
         try {
             BasicLineFormatter.formatStatusLine
                 (null, BasicLineFormatter.DEFAULT);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             BasicLineFormatter.DEFAULT.formatStatusLine
                 (new CharArrayBuffer(10), (StatusLine) null);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
 
+    @Test
     public void testHeaderFormatting() throws Exception {
         Header header1 = new BasicHeader("name", "value");
         String s = BasicLineFormatter.formatHeader(header1, null);
-        assertEquals("name: value", s);
+        Assert.assertEquals("name: value", s);
         Header header2 = new BasicHeader("name", null);
         s = BasicLineFormatter.formatHeader(header2, null);
-        assertEquals("name: ", s);
+        Assert.assertEquals("name: ", s);
     }
 
+    @Test
     public void testHeaderFormattingInvalidInput() throws Exception {
         try {
             BasicLineFormatter.formatHeader
                 (null, BasicLineFormatter.DEFAULT);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             BasicLineFormatter.DEFAULT.formatHeader
                 (new CharArrayBuffer(10), (Header) null);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineParser.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineParser.java Mon May  9 11:26:57 2011
@@ -27,204 +27,202 @@
 
 package org.apache.http.message;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpVersion;
 import org.apache.http.ParseException;
 import org.apache.http.RequestLine;
 import org.apache.http.StatusLine;
 import org.apache.http.util.CharArrayBuffer;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for {@link BasicLineParser}.
  *
- *
  */
-public class TestBasicLineParser extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestBasicLineParser(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestBasicLineParser {
 
+    @Test
     public void testRLParseSuccess() throws Exception {
         //typical request line
         RequestLine requestline = BasicLineParser.parseRequestLine
             ("GET /stuff HTTP/1.1", null);
-        assertEquals("GET /stuff HTTP/1.1", requestline.toString());
-        assertEquals("GET", requestline.getMethod());
-        assertEquals("/stuff", requestline.getUri());
-        assertEquals(HttpVersion.HTTP_1_1, requestline.getProtocolVersion());
+        Assert.assertEquals("GET /stuff HTTP/1.1", requestline.toString());
+        Assert.assertEquals("GET", requestline.getMethod());
+        Assert.assertEquals("/stuff", requestline.getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, requestline.getProtocolVersion());
 
         //Lots of blanks
         requestline = BasicLineParser.parseRequestLine
             ("  GET    /stuff   HTTP/1.1   ", null);
-        assertEquals("GET /stuff HTTP/1.1", requestline.toString());
-        assertEquals("GET", requestline.getMethod());
-        assertEquals("/stuff", requestline.getUri());
-        assertEquals(HttpVersion.HTTP_1_1, requestline.getProtocolVersion());
+        Assert.assertEquals("GET /stuff HTTP/1.1", requestline.toString());
+        Assert.assertEquals("GET", requestline.getMethod());
+        Assert.assertEquals("/stuff", requestline.getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, requestline.getProtocolVersion());
 
         //this is not strictly valid, but is lenient
         requestline = BasicLineParser.parseRequestLine
             ("\rGET /stuff HTTP/1.1", null);
-        assertEquals("GET", requestline.getMethod());
-        assertEquals("/stuff", requestline.getUri());
-        assertEquals(HttpVersion.HTTP_1_1, requestline.getProtocolVersion());
+        Assert.assertEquals("GET", requestline.getMethod());
+        Assert.assertEquals("/stuff", requestline.getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, requestline.getProtocolVersion());
     }
 
+    @Test
     public void testRLParseFailure() throws Exception {
         try {
             BasicLineParser.parseRequestLine("    ", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
 
         try {
             BasicLineParser.parseRequestLine("  GET", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
 
         try {
             BasicLineParser.parseRequestLine("GET /stuff", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
 
         try {
             BasicLineParser.parseRequestLine("GET/stuff HTTP/1.1", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
 
         try {
             BasicLineParser.parseRequestLine("GET /stuff HTTP/1.1 Oooooooooooppsie", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
     }
 
+    @Test
     public void testSLParseSuccess() throws Exception {
         //typical status line
         StatusLine statusLine = BasicLineParser.parseStatusLine
             ("HTTP/1.1 200 OK", null);
-        assertEquals("HTTP/1.1 200 OK", statusLine.toString());
-        assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion());
-        assertEquals(200, statusLine.getStatusCode());
-        assertEquals("OK", statusLine.getReasonPhrase());
+        Assert.assertEquals("HTTP/1.1 200 OK", statusLine.toString());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion());
+        Assert.assertEquals(200, statusLine.getStatusCode());
+        Assert.assertEquals("OK", statusLine.getReasonPhrase());
 
         //status line with multi word reason phrase
         statusLine = BasicLineParser.parseStatusLine
             ("HTTP/1.1 404 Not Found", null);
-        assertEquals(404, statusLine.getStatusCode());
-        assertEquals("Not Found", statusLine.getReasonPhrase());
+        Assert.assertEquals(404, statusLine.getStatusCode());
+        Assert.assertEquals("Not Found", statusLine.getReasonPhrase());
 
         //reason phrase can be anyting
         statusLine = BasicLineParser.parseStatusLine
             ("HTTP/1.1 404 Non Trouve", null);
-        assertEquals("Non Trouve", statusLine.getReasonPhrase());
+        Assert.assertEquals("Non Trouve", statusLine.getReasonPhrase());
 
         //its ok to end with a \n\r
         statusLine = BasicLineParser.parseStatusLine
             ("HTTP/1.1 404 Not Found\r\n", null);
-        assertEquals("Not Found", statusLine.getReasonPhrase());
+        Assert.assertEquals("Not Found", statusLine.getReasonPhrase());
 
         //this is valid according to the Status-Line BNF
         statusLine = BasicLineParser.parseStatusLine
             ("HTTP/1.1 200 ", null);
-        assertEquals(200, statusLine.getStatusCode());
-        assertEquals("", statusLine.getReasonPhrase());
+        Assert.assertEquals(200, statusLine.getStatusCode());
+        Assert.assertEquals("", statusLine.getReasonPhrase());
 
         //this is not strictly valid, but is lenient
         statusLine = BasicLineParser.parseStatusLine
             ("HTTP/1.1 200", null);
-        assertEquals(200, statusLine.getStatusCode());
-        assertEquals("", statusLine.getReasonPhrase());
+        Assert.assertEquals(200, statusLine.getStatusCode());
+        Assert.assertEquals("", statusLine.getReasonPhrase());
 
         //this is not strictly valid, but is lenient
         statusLine = BasicLineParser.parseStatusLine
             ("HTTP/1.1     200 OK", null);
-        assertEquals(200, statusLine.getStatusCode());
-        assertEquals("OK", statusLine.getReasonPhrase());
+        Assert.assertEquals(200, statusLine.getStatusCode());
+        Assert.assertEquals("OK", statusLine.getReasonPhrase());
 
         //this is not strictly valid, but is lenient
         statusLine = BasicLineParser.parseStatusLine
             ("\rHTTP/1.1 200 OK", null);
-        assertEquals(200, statusLine.getStatusCode());
-        assertEquals("OK", statusLine.getReasonPhrase());
-        assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion());
+        Assert.assertEquals(200, statusLine.getStatusCode());
+        Assert.assertEquals("OK", statusLine.getReasonPhrase());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion());
 
         //this is not strictly valid, but is lenient
         statusLine = BasicLineParser.parseStatusLine
             ("  HTTP/1.1 200 OK", null);
-        assertEquals(200, statusLine.getStatusCode());
-        assertEquals("OK", statusLine.getReasonPhrase());
-        assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion());
+        Assert.assertEquals(200, statusLine.getStatusCode());
+        Assert.assertEquals("OK", statusLine.getReasonPhrase());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, statusLine.getProtocolVersion());
     }
 
+    @Test
     public void testSLParseFailure() throws Exception {
         try {
             BasicLineParser.parseStatusLine("xxx 200 OK", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
 
         try {
             BasicLineParser.parseStatusLine("HTTP/1.1 xxx OK", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
 
         try {
             BasicLineParser.parseStatusLine("HTTP/1.1    ", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
 
         try {
             BasicLineParser.parseStatusLine("HTTP/1.1", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
 
         try {
             BasicLineParser.parseStatusLine("HTTP/1.1 -200 OK", null);
-            fail();
+            Assert.fail();
         } catch (ParseException e) {
             // expected
         }
     }
 
+    @Test
     public void testHttpVersionParsing() throws Exception {
 
         String s = "HTTP/1.1";
         HttpVersion version = (HttpVersion)
             BasicLineParser.parseProtocolVersion(s, null);
-        assertEquals("HTTP protocol name", "HTTP", version.getProtocol());
-        assertEquals("HTTP major version number", 1, version.getMajor());
-        assertEquals("HTTP minor version number", 1, version.getMinor());
-        assertEquals("HTTP version number", s, version.toString());
+        Assert.assertEquals("HTTP protocol name", "HTTP", version.getProtocol());
+        Assert.assertEquals("HTTP major version number", 1, version.getMajor());
+        Assert.assertEquals("HTTP minor version number", 1, version.getMinor());
+        Assert.assertEquals("HTTP version number", s, version.toString());
 
         s = "HTTP/123.4567";
         version = (HttpVersion)
             BasicLineParser.parseProtocolVersion(s, null);
-        assertEquals("HTTP protocol name", "HTTP", version.getProtocol());
-        assertEquals("HTTP major version number", 123, version.getMajor());
-        assertEquals("HTTP minor version number", 4567, version.getMinor());
-        assertEquals("HTTP version number", s, version.toString());
+        Assert.assertEquals("HTTP protocol name", "HTTP", version.getProtocol());
+        Assert.assertEquals("HTTP major version number", 123, version.getMajor());
+        Assert.assertEquals("HTTP minor version number", 4567, version.getMinor());
+        Assert.assertEquals("HTTP version number", s, version.toString());
     }
 
+    @Test
     public void testHttpVersionParsingUsingCursor() throws Exception {
 
         String s = "HTTP/1.1";
@@ -235,12 +233,12 @@ public class TestBasicLineParser extends
         LineParser parser = BasicLineParser.DEFAULT;
 
         HttpVersion version = (HttpVersion) parser.parseProtocolVersion(buffer, cursor);
-        assertEquals("HTTP protocol name", "HTTP", version.getProtocol());
-        assertEquals("HTTP major version number", 1, version.getMajor());
-        assertEquals("HTTP minor version number", 1, version.getMinor());
-        assertEquals("HTTP version number", "HTTP/1.1", version.toString());
-        assertEquals(s.length(), cursor.getPos());
-        assertTrue(cursor.atEnd());
+        Assert.assertEquals("HTTP protocol name", "HTTP", version.getProtocol());
+        Assert.assertEquals("HTTP major version number", 1, version.getMajor());
+        Assert.assertEquals("HTTP minor version number", 1, version.getMinor());
+        Assert.assertEquals("HTTP version number", "HTTP/1.1", version.toString());
+        Assert.assertEquals(s.length(), cursor.getPos());
+        Assert.assertTrue(cursor.atEnd());
 
         s = "HTTP/1.123 123";
         buffer = new CharArrayBuffer(16);
@@ -248,82 +246,83 @@ public class TestBasicLineParser extends
         cursor = new ParserCursor(0, s.length());
 
         version = (HttpVersion) parser.parseProtocolVersion(buffer, cursor);
-        assertEquals("HTTP protocol name", "HTTP", version.getProtocol());
-        assertEquals("HTTP major version number", 1, version.getMajor());
-        assertEquals("HTTP minor version number", 123, version.getMinor());
-        assertEquals("HTTP version number", "HTTP/1.123", version.toString());
-        assertEquals(' ', buffer.charAt(cursor.getPos()));
-        assertEquals(s.length() - 4, cursor.getPos());
-        assertFalse(cursor.atEnd());
+        Assert.assertEquals("HTTP protocol name", "HTTP", version.getProtocol());
+        Assert.assertEquals("HTTP major version number", 1, version.getMajor());
+        Assert.assertEquals("HTTP minor version number", 123, version.getMinor());
+        Assert.assertEquals("HTTP version number", "HTTP/1.123", version.toString());
+        Assert.assertEquals(' ', buffer.charAt(cursor.getPos()));
+        Assert.assertEquals(s.length() - 4, cursor.getPos());
+        Assert.assertFalse(cursor.atEnd());
     }
 
+    @Test
     public void testInvalidHttpVersionParsing() throws Exception {
         try {
             BasicLineParser.parseProtocolVersion((String)null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException e) {
             //expected
         }
         try {
             BasicLineParser.parseProtocolVersion
                 ("    ", null);
-            fail("ParseException should have been thrown");
+            Assert.fail("ParseException should have been thrown");
         } catch (ParseException e) {
             //expected
         }
         try {
             BasicLineParser.parseProtocolVersion
                 ("HTT", null);
-            fail("ParseException should have been thrown");
+            Assert.fail("ParseException should have been thrown");
         } catch (ParseException e) {
             //expected
         }
         try {
             BasicLineParser.parseProtocolVersion
                 ("crap", null);
-            fail("ParseException should have been thrown");
+            Assert.fail("ParseException should have been thrown");
         } catch (ParseException e) {
             //expected
         }
         try {
             BasicLineParser.parseProtocolVersion
                 ("HTTP/crap", null);
-            fail("ParseException should have been thrown");
+            Assert.fail("ParseException should have been thrown");
         } catch (ParseException e) {
             //expected
         }
         try {
             BasicLineParser.parseProtocolVersion
                 ("HTTP/1", null);
-            fail("ParseException should have been thrown");
+            Assert.fail("ParseException should have been thrown");
         } catch (ParseException e) {
             //expected
         }
         try {
             BasicLineParser.parseProtocolVersion
                 ("HTTP/1234   ", null);
-            fail("ParseException should have been thrown");
+            Assert.fail("ParseException should have been thrown");
         } catch (ParseException e) {
             //expected
         }
         try {
             BasicLineParser.parseProtocolVersion
                 ("HTTP/1.", null);
-            fail("ParseException should have been thrown");
+            Assert.fail("ParseException should have been thrown");
         } catch (ParseException e) {
             //expected
         }
         try {
             BasicLineParser.parseProtocolVersion
                 ("HTTP/whatever.whatever whatever", null);
-            fail("ParseException should have been thrown");
+            Assert.fail("ParseException should have been thrown");
         } catch (ParseException e) {
             //expected
         }
         try {
             BasicLineParser.parseProtocolVersion
                 ("HTTP/1.whatever whatever", null);
-            fail("ParseException should have been thrown");
+            Assert.fail("ParseException should have been thrown");
         } catch (ParseException e) {
             //expected
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicMessages.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicMessages.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicMessages.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicMessages.java Mon May  9 11:26:57 2011
@@ -27,8 +27,6 @@
 
 package org.apache.http.message;
 
-import junit.framework.TestCase;
-
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpRequest;
@@ -37,140 +35,145 @@ import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
 import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.params.CoreProtocolPNames;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link Header}.
  *
  */
-public class TestBasicMessages extends TestCase {
-
-    public TestBasicMessages(String testName) {
-        super(testName);
-    }
+public class TestBasicMessages {
 
+    @Test
     public void testDefaultResponseConstructors() {
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_BAD_REQUEST, "Bad Request");
-        assertNotNull(response.getProtocolVersion());
-        assertEquals(HttpVersion.HTTP_1_0, response.getProtocolVersion());
-        assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
+        Assert.assertNotNull(response.getProtocolVersion());
+        Assert.assertEquals(HttpVersion.HTTP_1_0, response.getProtocolVersion());
+        Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
 
         response = new BasicHttpResponse(new BasicStatusLine(
                 HttpVersion.HTTP_1_1, HttpStatus.SC_INTERNAL_SERVER_ERROR, "whatever"));
-        assertNotNull(response.getProtocolVersion());
-        assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
-        assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatusLine().getStatusCode());
-        assertEquals("whatever", response.getStatusLine().getReasonPhrase());
+        Assert.assertNotNull(response.getProtocolVersion());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
+        Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("whatever", response.getStatusLine().getReasonPhrase());
     }
 
+    @Test
     public void testSetResponseStatus() {
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        assertNotNull(response.getProtocolVersion());
-        assertNotNull(response.getStatusLine());
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        Assert.assertNotNull(response.getProtocolVersion());
+        Assert.assertNotNull(response.getStatusLine());
+        Assert.assertEquals(200, response.getStatusLine().getStatusCode());
 
         response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_BAD_REQUEST, "Bad Request");
-        assertNotNull(response.getProtocolVersion());
-        assertEquals(HttpVersion.HTTP_1_0, response.getProtocolVersion());
-        assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
+        Assert.assertNotNull(response.getProtocolVersion());
+        Assert.assertEquals(HttpVersion.HTTP_1_0, response.getProtocolVersion());
+        Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
 
         response = new BasicHttpResponse(new BasicStatusLine(
                 HttpVersion.HTTP_1_1, HttpStatus.SC_INTERNAL_SERVER_ERROR, "whatever"));
-        assertNotNull(response.getProtocolVersion());
-        assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
-        assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatusLine().getStatusCode());
-        assertEquals("whatever", response.getStatusLine().getReasonPhrase());
+        Assert.assertNotNull(response.getProtocolVersion());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
+        Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("whatever", response.getStatusLine().getReasonPhrase());
 
         response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         try {
             response.setStatusCode(-23);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         try {
             response.setStatusLine(null, 200);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         try {
             response.setStatusLine(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testSetResponseEntity() {
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
-        assertNull(response.getEntity());
+        Assert.assertNull(response.getEntity());
 
         HttpEntity entity = new BasicHttpEntity();
         response.setEntity(entity);
-        assertTrue(entity == response.getEntity());
+        Assert.assertTrue(entity == response.getEntity());
     }
 
+    @Test
     public void testDefaultRequestConstructors() {
         HttpRequest request = new BasicHttpRequest("WHATEVER", "/");
-        assertNotNull(request.getProtocolVersion());
-        assertEquals("WHATEVER", request.getRequestLine().getMethod());
-        assertEquals("/", request.getRequestLine().getUri());
+        Assert.assertNotNull(request.getProtocolVersion());
+        Assert.assertEquals("WHATEVER", request.getRequestLine().getMethod());
+        Assert.assertEquals("/", request.getRequestLine().getUri());
 
         request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_0);
-        assertEquals(HttpVersion.HTTP_1_0, request.getProtocolVersion());
-        assertEquals("GET", request.getRequestLine().getMethod());
-        assertEquals("/", request.getRequestLine().getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_0, request.getProtocolVersion());
+        Assert.assertEquals("GET", request.getRequestLine().getMethod());
+        Assert.assertEquals("/", request.getRequestLine().getUri());
 
         try {
             new BasicHttpRequest(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             new BasicHttpRequest("GET", null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             new BasicHttpRequest(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testDefaultEntityEnclosingRequestConstructors() {
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("GET", "/");
-        assertNotNull(request.getProtocolVersion());
-        assertEquals("GET", request.getRequestLine().getMethod());
-        assertEquals("/", request.getRequestLine().getUri());
+        Assert.assertNotNull(request.getProtocolVersion());
+        Assert.assertEquals("GET", request.getRequestLine().getMethod());
+        Assert.assertEquals("/", request.getRequestLine().getUri());
 
         request = new BasicHttpEntityEnclosingRequest("GET", "/", HttpVersion.HTTP_1_0);
-        assertEquals(HttpVersion.HTTP_1_0, request.getProtocolVersion());
-        assertEquals("GET", request.getRequestLine().getMethod());
-        assertEquals("/", request.getRequestLine().getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_0, request.getProtocolVersion());
+        Assert.assertEquals("GET", request.getRequestLine().getMethod());
+        Assert.assertEquals("/", request.getRequestLine().getUri());
     }
 
+    @Test
     public void testSetRequestEntity() {
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("GET", "/");
-        assertNull(request.getEntity());
+        Assert.assertNull(request.getEntity());
 
         HttpEntity entity = new BasicHttpEntity();
         request.setEntity(entity);
-        assertTrue(entity == request.getEntity());
+        Assert.assertTrue(entity == request.getEntity());
     }
 
+    @Test
     public void testExpectContinue() {
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("GET", "/");
-        assertFalse(request.expectContinue());
+        Assert.assertFalse(request.expectContinue());
         request.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
-        assertFalse(request.expectContinue());
+        Assert.assertFalse(request.expectContinue());
         request.addHeader("Expect", "100-Continue");
-        assertTrue(request.expectContinue());
+        Assert.assertTrue(request.expectContinue());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicTokenIterator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicTokenIterator.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicTokenIterator.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicTokenIterator.java Mon May  9 11:26:57 2011
@@ -29,27 +29,21 @@ package org.apache.http.message;
 
 import java.util.NoSuchElementException;
 
-import junit.framework.TestCase;
-
 import org.apache.http.Header;
 import org.apache.http.HeaderIterator;
 import org.apache.http.ParseException;
 import org.apache.http.TokenIterator;
+import org.junit.Assert;
+import org.junit.Test;
 
 
 /**
  * Tests for {@link BasicTokenIterator}.
  *
  */
-public class TestBasicTokenIterator extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestBasicTokenIterator(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestBasicTokenIterator {
 
+    @Test
     public void testSingleHeader() {
         Header[] headers = new Header[]{
             new BasicHeader("Name", "token0,token1, token2 , token3")
@@ -57,15 +51,15 @@ public class TestBasicTokenIterator exte
         HeaderIterator hit = new BasicHeaderIterator(headers, null);
         TokenIterator  ti  = new BasicTokenIterator(hit);
 
-        assertTrue(ti.hasNext());
-        assertEquals("token0", "token0", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token1", "token1", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token2", "token2", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token3", "token3", ti.nextToken());
-        assertFalse(ti.hasNext());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token0", "token0", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token1", "token1", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token2", "token2", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token3", "token3", ti.nextToken());
+        Assert.assertFalse(ti.hasNext());
 
 
         headers = new Header[]{
@@ -74,12 +68,13 @@ public class TestBasicTokenIterator exte
         hit = new BasicHeaderIterator(headers, null);
         ti  = new BasicTokenIterator(hit);
 
-        assertTrue(ti.hasNext());
-        assertEquals("token0", "token0", ti.nextToken());
-        assertFalse(ti.hasNext());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token0", "token0", ti.nextToken());
+        Assert.assertFalse(ti.hasNext());
     }
 
 
+    @Test
     public void testMultiHeader() {
         Header[] headers = new Header[]{
             new BasicHeader("Name", "token0,token1"),
@@ -93,20 +88,21 @@ public class TestBasicTokenIterator exte
         HeaderIterator hit = new BasicHeaderIterator(headers, null);
         TokenIterator  ti  = new BasicTokenIterator(hit);
 
-        assertTrue(ti.hasNext());
-        assertEquals("token0", "token0", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token1", "token1", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token2", "token2", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token3", "token3", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token4", "token4", ti.nextToken());
-        assertFalse(ti.hasNext());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token0", "token0", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token1", "token1", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token2", "token2", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token3", "token3", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token4", "token4", ti.nextToken());
+        Assert.assertFalse(ti.hasNext());
     }
 
 
+    @Test
     public void testEmpty() {
         Header[] headers = new Header[]{
             new BasicHeader("Name", " "),
@@ -117,16 +113,17 @@ public class TestBasicTokenIterator exte
         HeaderIterator hit = new BasicHeaderIterator(headers, null);
         TokenIterator  ti  = new BasicTokenIterator(hit);
 
-        assertFalse(ti.hasNext());
+        Assert.assertFalse(ti.hasNext());
 
 
         hit = new BasicHeaderIterator(headers, "empty");
         ti  = new BasicTokenIterator(hit);
 
-        assertFalse(ti.hasNext());
+        Assert.assertFalse(ti.hasNext());
     }
 
 
+    @Test
     public void testValueStart() {
         Header[] headers = new Header[]{
             new BasicHeader("Name", "token0"),
@@ -139,22 +136,23 @@ public class TestBasicTokenIterator exte
         HeaderIterator hit = new BasicHeaderIterator(headers, null);
         TokenIterator  ti  = new BasicTokenIterator(hit);
 
-        assertTrue(ti.hasNext());
-        assertEquals("token0", "token0", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token1", "token1", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token2", "token2", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token3", "token3", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token4", "token4", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token5", "token5", ti.nextToken());
-        assertFalse(ti.hasNext());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token0", "token0", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token1", "token1", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token2", "token2", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token3", "token3", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token4", "token4", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token5", "token5", ti.nextToken());
+        Assert.assertFalse(ti.hasNext());
     }
 
 
+    @Test
     public void testValueEnd() {
         Header[] headers = new Header[]{
             new BasicHeader("Name", "token0"),
@@ -167,22 +165,23 @@ public class TestBasicTokenIterator exte
         HeaderIterator hit = new BasicHeaderIterator(headers, null);
         TokenIterator  ti  = new BasicTokenIterator(hit);
 
-        assertTrue(ti.hasNext());
-        assertEquals("token0", "token0", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token1", "token1", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token2", "token2", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token3", "token3", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token4", "token4", ti.nextToken());
-        assertTrue(ti.hasNext());
-        assertEquals("token5", "token5", ti.nextToken());
-        assertFalse(ti.hasNext());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token0", "token0", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token1", "token1", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token2", "token2", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token3", "token3", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token4", "token4", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token5", "token5", ti.nextToken());
+        Assert.assertFalse(ti.hasNext());
     }
 
 
+    @Test
     public void testTokenChar() {
         Header[] headers = new Header[]{
             new BasicHeader("Name", "token0")
@@ -190,13 +189,14 @@ public class TestBasicTokenIterator exte
         HeaderIterator     hit = new BasicHeaderIterator(headers, null);
         BasicTokenIterator bti = new BasicTokenIterator(hit);
 
-        assertTrue ("letter"   , bti.isTokenChar('j'));
-        assertFalse("control"  , bti.isTokenChar('\b'));
-        assertFalse("separator", bti.isTokenChar('?'));
-        assertTrue ("other"    , bti.isTokenChar('-'));
+        Assert.assertTrue ("letter"   , bti.isTokenChar('j'));
+        Assert.assertFalse("control"  , bti.isTokenChar('\b'));
+        Assert.assertFalse("separator", bti.isTokenChar('?'));
+        Assert.assertTrue ("other"    , bti.isTokenChar('-'));
     }
 
 
+    @Test
     public void testInvalid() {
         Header[] headers = new Header[]{
             new BasicHeader("in", "token0=token1"),
@@ -208,10 +208,10 @@ public class TestBasicTokenIterator exte
         TokenIterator  ti  = new BasicTokenIterator(hit);
 
         // constructor located token0
-        assertTrue(ti.hasNext());
+        Assert.assertTrue(ti.hasNext());
         try {
             ti.nextToken();
-            fail("invalid infix character not detected");
+            Assert.fail("invalid infix character not detected");
         } catch (ParseException px) {
             // expected
         }
@@ -220,10 +220,10 @@ public class TestBasicTokenIterator exte
         // constructor located token0
         hit = new BasicHeaderIterator(headers, "no");
         ti  = new BasicTokenIterator(hit);
-        assertTrue(ti.hasNext());
+        Assert.assertTrue(ti.hasNext());
         try {
             ti.nextToken();
-            fail("missing token separator not detected");
+            Assert.fail("missing token separator not detected");
         } catch (ParseException px) {
             // expected
         }
@@ -233,7 +233,7 @@ public class TestBasicTokenIterator exte
         hit = new BasicHeaderIterator(headers, "pre");
         try {
             new BasicTokenIterator(hit);
-            fail("invalid prefix character not detected");
+            Assert.fail("invalid prefix character not detected");
         } catch (ParseException px) {
             // expected
         }
@@ -242,24 +242,25 @@ public class TestBasicTokenIterator exte
         hit = new BasicHeaderIterator(headers, "post");
         ti  = new BasicTokenIterator(hit);
 
-        assertTrue(ti.hasNext());
-        assertEquals("token0", "token0", ti.nextToken());
-        assertTrue(ti.hasNext());
+        Assert.assertTrue(ti.hasNext());
+        Assert.assertEquals("token0", "token0", ti.nextToken());
+        Assert.assertTrue(ti.hasNext());
         // failure after the last must not go unpunished
         try {
             ti.nextToken();
-            fail("invalid postfix character not detected");
+            Assert.fail("invalid postfix character not detected");
         } catch (ParseException px) {
             // expected
         }
     }
 
 
+    @Test
     public void testWrongPublic() {
 
         try {
             new BasicTokenIterator(null);
-            fail("null argument not detected");
+            Assert.fail("null argument not detected");
         } catch (IllegalArgumentException iax) {
             // expected
         }
@@ -276,20 +277,21 @@ public class TestBasicTokenIterator exte
         try {
             // call next() instead of nextToken() to get that covered, too
             ti.next();
-            fail("next after end not detected");
+            Assert.fail("next after end not detected");
         } catch (NoSuchElementException nsx) {
             // expected
         }
 
         try {
             ti.remove();
-            fail("unsupported remove not detected");
+            Assert.fail("unsupported remove not detected");
         } catch (UnsupportedOperationException uox) {
             // expected
         }
     }
 
 
+    @Test
     public void testWrongProtected() {
 
         Header[] headers = new Header[]{
@@ -300,21 +302,21 @@ public class TestBasicTokenIterator exte
 
         try {
             bti.findTokenStart(-1);
-            fail("tokenStart: negative index not detected");
+            Assert.fail("tokenStart: negative index not detected");
         } catch (IllegalArgumentException iax) {
             // expected
         }
 
         try {
             bti.findTokenSeparator(-1);
-            fail("tokenSeparator: negative index not detected");
+            Assert.fail("tokenSeparator: negative index not detected");
         } catch (IllegalArgumentException iax) {
             // expected
         }
 
         try {
             bti.findTokenEnd(-1);
-            fail("tokenEnd: negative index not detected");
+            Assert.fail("tokenEnd: negative index not detected");
         } catch (IllegalArgumentException iax) {
             // expected
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java Mon May  9 11:26:57 2011
@@ -32,65 +32,66 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HeaderElement;
 import org.apache.http.util.CharArrayBuffer;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link BufferedHeader}.
  *
  */
-public class TestBufferedHeader extends TestCase {
-
-    public TestBufferedHeader(String testName) {
-        super(testName);
-    }
+public class TestBufferedHeader {
 
+    @Test
     public void testBasicConstructor() {
         CharArrayBuffer buf = new CharArrayBuffer(32);
         buf.append("name: value");
         BufferedHeader header = new BufferedHeader(buf);
-        assertEquals("name", header.getName());
-        assertEquals("value", header.getValue());
-        assertSame(buf, header.getBuffer());
-        assertEquals(5, header.getValuePos());
+        Assert.assertEquals("name", header.getName());
+        Assert.assertEquals("value", header.getValue());
+        Assert.assertSame(buf, header.getBuffer());
+        Assert.assertEquals(5, header.getValuePos());
     }
 
+    @Test
     public void testInvalidName() {
         try {
             new BufferedHeader(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
     }
 
+    @Test
     public void testHeaderElements() {
         CharArrayBuffer buf = new CharArrayBuffer(32);
         buf.append("name: element1 = value1, element2; param1 = value1, element3");
         BufferedHeader header = new BufferedHeader(buf);
         HeaderElement[] elements = header.getElements();
-        assertNotNull(elements);
-        assertEquals(3, elements.length);
-        assertEquals("element1", elements[0].getName());
-        assertEquals("value1", elements[0].getValue());
-        assertEquals("element2", elements[1].getName());
-        assertEquals(null, elements[1].getValue());
-        assertEquals("element3", elements[2].getName());
-        assertEquals(null, elements[2].getValue());
-        assertEquals(1, elements[1].getParameters().length);
+        Assert.assertNotNull(elements);
+        Assert.assertEquals(3, elements.length);
+        Assert.assertEquals("element1", elements[0].getName());
+        Assert.assertEquals("value1", elements[0].getValue());
+        Assert.assertEquals("element2", elements[1].getName());
+        Assert.assertEquals(null, elements[1].getValue());
+        Assert.assertEquals("element3", elements[2].getName());
+        Assert.assertEquals(null, elements[2].getValue());
+        Assert.assertEquals(1, elements[1].getParameters().length);
     }
 
+    @Test
     public void testCloning() throws Exception {
         CharArrayBuffer buf = new CharArrayBuffer(32);
         buf.append("name: value");
         BufferedHeader orig = new BufferedHeader(buf);
         BufferedHeader clone = (BufferedHeader) orig.clone();
-        assertEquals(orig.getName(), clone.getName());
-        assertEquals(orig.getValue(), clone.getValue());
+        Assert.assertEquals(orig.getName(), clone.getName());
+        Assert.assertEquals(orig.getValue(), clone.getValue());
     }
 
+    @Test
     public void testSerialization() throws Exception {
         CharArrayBuffer buf = new CharArrayBuffer(32);
         buf.append("name: value");
@@ -103,8 +104,8 @@ public class TestBufferedHeader extends 
         ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
         ObjectInputStream instream = new ObjectInputStream(inbuffer);
         BufferedHeader clone = (BufferedHeader) instream.readObject();
-        assertEquals(orig.getName(), clone.getName());
-        assertEquals(orig.getValue(), clone.getValue());
+        Assert.assertEquals(orig.getName(), clone.getName());
+        Assert.assertEquals(orig.getValue(), clone.getValue());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeader.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeader.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeader.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeader.java Mon May  9 11:26:57 2011
@@ -32,75 +32,77 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link Header}.
- *
  */
-public class TestHeader extends TestCase {
-
-    public TestHeader(String testName) {
-        super(testName);
-    }
+public class TestHeader {
 
+    @Test
     public void testBasicConstructor() {
         Header header = new BasicHeader("name", "value");
-        assertEquals("name", header.getName());
-        assertEquals("value", header.getValue());
+        Assert.assertEquals("name", header.getName());
+        Assert.assertEquals("value", header.getValue());
     }
 
+    @Test
     public void testBasicConstructorNullValue() {
         Header header = new BasicHeader("name", null);
-        assertEquals("name", header.getName());
-        assertEquals(null, header.getValue());
+        Assert.assertEquals("name", header.getName());
+        Assert.assertEquals(null, header.getValue());
     }
 
+    @Test
     public void testInvalidName() {
         try {
             new BasicHeader(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
     }
 
+    @Test
     public void testToString() {
         Header header1 = new BasicHeader("name1", "value1");
-        assertEquals("name1: value1", header1.toString());
+        Assert.assertEquals("name1: value1", header1.toString());
         Header header2 = new BasicHeader("name2", null);
-        assertEquals("name2: ", header2.toString());
+        Assert.assertEquals("name2: ", header2.toString());
     }
 
+    @Test
     public void testHeaderElements() {
         Header header = new BasicHeader("name", "element1 = value1, element2; param1 = value1, element3");
         HeaderElement[] elements = header.getElements();
-        assertNotNull(elements);
-        assertEquals(3, elements.length);
-        assertEquals("element1", elements[0].getName());
-        assertEquals("value1", elements[0].getValue());
-        assertEquals("element2", elements[1].getName());
-        assertEquals(null, elements[1].getValue());
-        assertEquals("element3", elements[2].getName());
-        assertEquals(null, elements[2].getValue());
-        assertEquals(1, elements[1].getParameters().length);
+        Assert.assertNotNull(elements);
+        Assert.assertEquals(3, elements.length);
+        Assert.assertEquals("element1", elements[0].getName());
+        Assert.assertEquals("value1", elements[0].getValue());
+        Assert.assertEquals("element2", elements[1].getName());
+        Assert.assertEquals(null, elements[1].getValue());
+        Assert.assertEquals("element3", elements[2].getName());
+        Assert.assertEquals(null, elements[2].getValue());
+        Assert.assertEquals(1, elements[1].getParameters().length);
 
         header = new BasicHeader("name", null);
         elements = header.getElements();
-        assertNotNull(elements);
-        assertEquals(0, elements.length);
+        Assert.assertNotNull(elements);
+        Assert.assertEquals(0, elements.length);
     }
 
+    @Test
     public void testCloning() throws Exception {
         BasicHeader orig = new BasicHeader("name1", "value1");
         BasicHeader clone = (BasicHeader) orig.clone();
-        assertEquals(orig.getName(), clone.getName());
-        assertEquals(orig.getValue(), clone.getValue());
+        Assert.assertEquals(orig.getName(), clone.getName());
+        Assert.assertEquals(orig.getValue(), clone.getValue());
     }
 
+    @Test
     public void testSerialization() throws Exception {
         BasicHeader orig = new BasicHeader("name1", "value1");
         ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
@@ -111,8 +113,8 @@ public class TestHeader extends TestCase
         ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
         ObjectInputStream instream = new ObjectInputStream(inbuffer);
         BasicHeader clone = (BasicHeader) instream.readObject();
-        assertEquals(orig.getName(), clone.getName());
-        assertEquals(orig.getValue(), clone.getValue());
+        Assert.assertEquals(orig.getName(), clone.getName());
+        Assert.assertEquals(orig.getValue(), clone.getValue());
     }
 
 }



Mime
View raw message