hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1100965 [7/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/TestHeaderElement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderElement.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderElement.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderElement.java Mon May  9 11:26:57 2011
@@ -30,69 +30,65 @@
 
 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;
 
 /**
  * Simple tests for {@link HeaderElement}.
- *
- * @version $Id$
  */
-public class TestHeaderElement extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestHeaderElement(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestHeaderElement {
 
+    @Test
     public void testConstructor3() throws Exception {
         HeaderElement element = new BasicHeaderElement("name", "value",
                 new NameValuePair[] {
                     new BasicNameValuePair("param1", "value1"),
                     new BasicNameValuePair("param2", "value2")
                 } );
-        assertEquals("name", element.getName());
-        assertEquals("value", element.getValue());
-        assertEquals(2, element.getParameters().length);
-        assertEquals("value1", element.getParameterByName("param1").getValue());
-        assertEquals("value2", element.getParameterByName("param2").getValue());
+        Assert.assertEquals("name", element.getName());
+        Assert.assertEquals("value", element.getValue());
+        Assert.assertEquals(2, element.getParameters().length);
+        Assert.assertEquals("value1", element.getParameterByName("param1").getValue());
+        Assert.assertEquals("value2", element.getParameterByName("param2").getValue());
     }
 
+    @Test
     public void testConstructor2() throws Exception {
         HeaderElement element = new BasicHeaderElement("name", "value");
-        assertEquals("name", element.getName());
-        assertEquals("value", element.getValue());
-        assertEquals(0, element.getParameters().length);
+        Assert.assertEquals("name", element.getName());
+        Assert.assertEquals("value", element.getValue());
+        Assert.assertEquals(0, element.getParameters().length);
     }
 
 
+    @Test
     public void testInvalidName() {
         try {
             new BasicHeaderElement(null, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
     }
 
+    @Test
     public void testParamByName() throws Exception {
         String s = "name = value; param1 = value1; param2 = value2";
         HeaderElement element = BasicHeaderValueParser.parseHeaderElement(s, null);
-        assertEquals("value1", element.getParameterByName("param1").getValue());
-        assertEquals("value2", element.getParameterByName("param2").getValue());
-        assertNull(element.getParameterByName("param3"));
+        Assert.assertEquals("value1", element.getParameterByName("param1").getValue());
+        Assert.assertEquals("value2", element.getParameterByName("param2").getValue());
+        Assert.assertNull(element.getParameterByName("param3"));
         try {
             element.getParameterByName(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
     }
 
+    @Test
     public void testHashCode() {
         HeaderElement element1 = new BasicHeaderElement("name", "value",
                 new NameValuePair[] {
@@ -111,13 +107,14 @@ public class TestHeaderElement extends T
                     new BasicNameValuePair("param1", "value1"),
                     new BasicNameValuePair("param2", "value2")
                 } );
-        assertTrue(element1.hashCode() != element2.hashCode());
-        assertTrue(element1.hashCode() != element3.hashCode());
-        assertTrue(element2.hashCode() != element3.hashCode());
-        assertTrue(element3.hashCode() == element4.hashCode());
-        assertTrue(element1.hashCode() == element5.hashCode());
+        Assert.assertTrue(element1.hashCode() != element2.hashCode());
+        Assert.assertTrue(element1.hashCode() != element3.hashCode());
+        Assert.assertTrue(element2.hashCode() != element3.hashCode());
+        Assert.assertTrue(element3.hashCode() == element4.hashCode());
+        Assert.assertTrue(element1.hashCode() == element5.hashCode());
     }
 
+    @Test
     public void testEquals() {
         HeaderElement element1 = new BasicHeaderElement("name", "value",
                 new NameValuePair[] {
@@ -136,25 +133,27 @@ public class TestHeaderElement extends T
                     new BasicNameValuePair("param1", "value1"),
                     new BasicNameValuePair("param2", "value2")
                 } );
-        assertTrue(element1.equals(element1));
-        assertTrue(!element1.equals(element2));
-        assertTrue(!element1.equals(element3));
-        assertTrue(!element2.equals(element3));
-        assertTrue(element3.equals(element4));
-        assertTrue(element1.equals(element5));
-        assertFalse(element1.equals(null));
-        assertFalse(element1.equals("name = value; param1 = value1; param2 = value2"));
+        Assert.assertTrue(element1.equals(element1));
+        Assert.assertTrue(!element1.equals(element2));
+        Assert.assertTrue(!element1.equals(element3));
+        Assert.assertTrue(!element2.equals(element3));
+        Assert.assertTrue(element3.equals(element4));
+        Assert.assertTrue(element1.equals(element5));
+        Assert.assertFalse(element1.equals(null));
+        Assert.assertFalse(element1.equals("name = value; param1 = value1; param2 = value2"));
     }
 
+    @Test
     public void testToString() {
         String s = "name=value; param1=value1; param2=value2";
         HeaderElement element = BasicHeaderValueParser.parseHeaderElement(s, null);
-        assertEquals(s, element.toString());
+        Assert.assertEquals(s, element.toString());
         s = "name; param1=value1; param2=value2";
         element = BasicHeaderValueParser.parseHeaderElement(s, null);
-        assertEquals(s, element.toString());
+        Assert.assertEquals(s, element.toString());
     }
 
+    @Test
     public void testCloning() throws Exception {
         BasicHeaderElement orig = new BasicHeaderElement("name", "value",
                 new NameValuePair[] {
@@ -162,7 +161,7 @@ public class TestHeaderElement extends T
                     new BasicNameValuePair("param2", "value2")
                 } );
         BasicHeaderElement clone = (BasicHeaderElement) orig.clone();
-        assertEquals(orig, clone);
+        Assert.assertEquals(orig, clone);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java Mon May  9 11:26:57 2011
@@ -33,45 +33,45 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Iterator;
 
-import junit.framework.TestCase;
-
 import org.apache.http.Header;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link HeaderGroup}.
  *
  */
-public class TestHeaderGroup extends TestCase {
-
-    public TestHeaderGroup(String testName) {
-        super(testName);
-    }
+public class TestHeaderGroup {
 
+    @Test
     public void testConstructor() {
         HeaderGroup headergroup = new HeaderGroup();
-        assertNotNull(headergroup.getAllHeaders());
-        assertEquals(0, headergroup.getAllHeaders().length);
+        Assert.assertNotNull(headergroup.getAllHeaders());
+        Assert.assertEquals(0, headergroup.getAllHeaders().length);
     }
 
+    @Test
     public void testClear() {
         HeaderGroup headergroup = new HeaderGroup();
         headergroup.addHeader(new BasicHeader("name", "value"));
-        assertEquals(1, headergroup.getAllHeaders().length);
+        Assert.assertEquals(1, headergroup.getAllHeaders().length);
         headergroup.clear();
-        assertEquals(0, headergroup.getAllHeaders().length);
+        Assert.assertEquals(0, headergroup.getAllHeaders().length);
     }
 
+    @Test
     public void testAddRemoveHeader() {
         HeaderGroup headergroup = new HeaderGroup();
         Header header = new BasicHeader("name", "value");
         headergroup.addHeader(header);
         headergroup.addHeader(null);
-        assertEquals(1, headergroup.getAllHeaders().length);
+        Assert.assertEquals(1, headergroup.getAllHeaders().length);
         headergroup.removeHeader(header);
         headergroup.removeHeader(null);
-        assertEquals(0, headergroup.getAllHeaders().length);
+        Assert.assertEquals(0, headergroup.getAllHeaders().length);
     }
 
+    @Test
     public void testUpdateHeader() {
         HeaderGroup headergroup = new HeaderGroup();
         Header header1 = new BasicHeader("name1", "value1");
@@ -83,10 +83,11 @@ public class TestHeaderGroup extends Tes
         headergroup.updateHeader(new BasicHeader("name2", "newvalue"));
         headergroup.updateHeader(new BasicHeader("name4", "value4"));
         headergroup.updateHeader(null);
-        assertEquals(4, headergroup.getAllHeaders().length);
-        assertEquals("newvalue", headergroup.getFirstHeader("name2").getValue());
+        Assert.assertEquals(4, headergroup.getAllHeaders().length);
+        Assert.assertEquals("newvalue", headergroup.getFirstHeader("name2").getValue());
     }
 
+    @Test
     public void testSetHeaders() {
         HeaderGroup headergroup = new HeaderGroup();
         Header header1 = new BasicHeader("name1", "value1");
@@ -94,17 +95,18 @@ public class TestHeaderGroup extends Tes
         Header header3 = new BasicHeader("name3", "value3");
         headergroup.addHeader(header1);
         headergroup.setHeaders(new Header[] { header2, header3 });
-        assertEquals(2, headergroup.getAllHeaders().length);
-        assertEquals(0, headergroup.getHeaders("name1").length);
-        assertFalse(headergroup.containsHeader("name1"));
-        assertEquals(1, headergroup.getHeaders("name2").length);
-        assertTrue(headergroup.containsHeader("name2"));
-        assertEquals(1, headergroup.getHeaders("name3").length);
-        assertTrue(headergroup.containsHeader("name3"));
+        Assert.assertEquals(2, headergroup.getAllHeaders().length);
+        Assert.assertEquals(0, headergroup.getHeaders("name1").length);
+        Assert.assertFalse(headergroup.containsHeader("name1"));
+        Assert.assertEquals(1, headergroup.getHeaders("name2").length);
+        Assert.assertTrue(headergroup.containsHeader("name2"));
+        Assert.assertEquals(1, headergroup.getHeaders("name3").length);
+        Assert.assertTrue(headergroup.containsHeader("name3"));
         headergroup.setHeaders(null);
-        assertEquals(0, headergroup.getAllHeaders().length);
+        Assert.assertEquals(0, headergroup.getAllHeaders().length);
     }
 
+    @Test
     public void testFirstLastHeaders() {
         HeaderGroup headergroup = new HeaderGroup();
         Header header1 = new BasicHeader("name", "value1");
@@ -112,35 +114,38 @@ public class TestHeaderGroup extends Tes
         Header header3 = new BasicHeader("name", "value3");
         headergroup.setHeaders(new Header[] { header1, header2, header3 });
 
-        assertNull(headergroup.getFirstHeader("whatever"));
-        assertNull(headergroup.getLastHeader("whatever"));
+        Assert.assertNull(headergroup.getFirstHeader("whatever"));
+        Assert.assertNull(headergroup.getLastHeader("whatever"));
 
-        assertEquals("value1", headergroup.getFirstHeader("name").getValue());
-        assertEquals("value3", headergroup.getLastHeader("name").getValue());
+        Assert.assertEquals("value1", headergroup.getFirstHeader("name").getValue());
+        Assert.assertEquals("value3", headergroup.getLastHeader("name").getValue());
     }
 
+    @Test
     public void testCondensedHeader() {
         HeaderGroup headergroup = new HeaderGroup();
-        assertNull(headergroup.getCondensedHeader("name"));
+        Assert.assertNull(headergroup.getCondensedHeader("name"));
 
         Header header1 = new BasicHeader("name", "value1");
         Header header2 = new BasicHeader("name", "value2");
         Header header3 = new BasicHeader("name", "value3");
         headergroup.setHeaders(new Header[] { header1, header2, header3 });
 
-        assertEquals("value1, value2, value3", headergroup.getCondensedHeader("name").getValue());
+        Assert.assertEquals("value1, value2, value3", headergroup.getCondensedHeader("name").getValue());
 
         headergroup.setHeaders(new Header[] { header1 });
-        assertEquals(header1, headergroup.getCondensedHeader("name"));
+        Assert.assertEquals(header1, headergroup.getCondensedHeader("name"));
     }
 
+    @Test
     public void testIterator() {
         HeaderGroup headergroup = new HeaderGroup();
         Iterator<Header> i = headergroup.iterator();
-        assertNotNull(i);
-        assertFalse(i.hasNext());
+        Assert.assertNotNull(i);
+        Assert.assertFalse(i.hasNext());
     }
 
+    @Test
     public void testHeaderRemove() {
         HeaderGroup headergroup = new HeaderGroup();
         Header header1 = new BasicHeader("name", "value1");
@@ -148,20 +153,21 @@ public class TestHeaderGroup extends Tes
         Header header3 = new BasicHeader("name", "value3");
         headergroup.setHeaders(new Header[] { header1, header2, header3 });
         Iterator<Header> i = headergroup.iterator();
-        assertNotNull(i);
-        assertTrue(i.hasNext());
+        Assert.assertNotNull(i);
+        Assert.assertTrue(i.hasNext());
         i.next();
-        assertTrue(i.hasNext());
+        Assert.assertTrue(i.hasNext());
         i.next();
         i.remove();
-        assertEquals(2, headergroup.getAllHeaders().length);
-        assertTrue(i.hasNext());
+        Assert.assertEquals(2, headergroup.getAllHeaders().length);
+        Assert.assertTrue(i.hasNext());
         i.next();
         i.remove();
-        assertEquals(1, headergroup.getAllHeaders().length);
-        assertFalse(i.hasNext());
+        Assert.assertEquals(1, headergroup.getAllHeaders().length);
+        Assert.assertFalse(i.hasNext());
     }
 
+    @Test
     public void testCloning() throws Exception {
         HeaderGroup orig = new HeaderGroup();
         Header header1 = new BasicHeader("name", "value1");
@@ -171,15 +177,16 @@ public class TestHeaderGroup extends Tes
         HeaderGroup clone = (HeaderGroup) orig.clone();
         Header[] headers1 = orig.getAllHeaders();
         Header[] headers2 = clone.getAllHeaders();
-        assertNotNull(headers1);
-        assertNotNull(headers2);
-        assertEquals(headers1.length, headers2.length);
+        Assert.assertNotNull(headers1);
+        Assert.assertNotNull(headers2);
+        Assert.assertEquals(headers1.length, headers2.length);
         for (int i = 0; i < headers1.length; i++) {
-            assertEquals(headers1[i].getName(), headers2[i].getName());
-            assertEquals(headers1[i].getValue(), headers2[i].getValue());
+            Assert.assertEquals(headers1[i].getName(), headers2[i].getName());
+            Assert.assertEquals(headers1[i].getValue(), headers2[i].getValue());
         }
     }
 
+    @Test
     public void testSerialization() throws Exception {
         HeaderGroup orig = new HeaderGroup();
         Header header1 = new BasicHeader("name", "value1");
@@ -196,12 +203,12 @@ public class TestHeaderGroup extends Tes
         HeaderGroup clone = (HeaderGroup) instream.readObject();
         Header[] headers1 = orig.getAllHeaders();
         Header[] headers2 = clone.getAllHeaders();
-        assertNotNull(headers1);
-        assertNotNull(headers2);
-        assertEquals(headers1.length, headers2.length);
+        Assert.assertNotNull(headers1);
+        Assert.assertNotNull(headers2);
+        Assert.assertEquals(headers1.length, headers2.length);
         for (int i = 0; i < headers1.length; i++) {
-            assertEquals(headers1[i].getName(), headers2[i].getName());
-            assertEquals(headers1[i].getValue(), headers2[i].getValue());
+            Assert.assertEquals(headers1[i].getName(), headers2[i].getName());
+            Assert.assertEquals(headers1[i].getValue(), headers2[i].getValue());
         }
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java Mon May  9 11:26:57 2011
@@ -27,66 +27,68 @@
 
 package org.apache.http.message;
 
-import junit.framework.TestCase;
-
 import org.apache.http.NameValuePair;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link NameValuePair}.
  *
  */
-public class TestNameValuePair extends TestCase {
-
-    public TestNameValuePair(String testName) {
-        super(testName);
-    }
+public class TestNameValuePair {
 
+    @Test
     public void testConstructor() {
         NameValuePair param = new BasicNameValuePair("name", "value");
-        assertEquals("name", param.getName());
-        assertEquals("value", param.getValue());
+        Assert.assertEquals("name", param.getName());
+        Assert.assertEquals("value", param.getValue());
     }
 
+    @Test
     public void testInvalidName() {
         try {
             new BasicNameValuePair(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
     }
 
+    @Test
     public void testHashCode() {
         NameValuePair param1 = new BasicNameValuePair("name1", "value1");
         NameValuePair param2 = new BasicNameValuePair("name2", "value2");
         NameValuePair param3 = new BasicNameValuePair("name1", "value1");
-        assertTrue(param1.hashCode() != param2.hashCode());
-        assertTrue(param1.hashCode() == param3.hashCode());
+        Assert.assertTrue(param1.hashCode() != param2.hashCode());
+        Assert.assertTrue(param1.hashCode() == param3.hashCode());
     }
 
+    @Test
     public void testEquals() {
         NameValuePair param1 = new BasicNameValuePair("name1", "value1");
         NameValuePair param2 = new BasicNameValuePair("name2", "value2");
         NameValuePair param3 = new BasicNameValuePair("name1", "value1");
-        assertFalse(param1.equals(param2));
-        assertFalse(param1.equals(null));
-        assertFalse(param1.equals("name1 = value1"));
-        assertTrue(param1.equals(param1));
-        assertTrue(param2.equals(param2));
-        assertTrue(param1.equals(param3));
+        Assert.assertFalse(param1.equals(param2));
+        Assert.assertFalse(param1.equals(null));
+        Assert.assertFalse(param1.equals("name1 = value1"));
+        Assert.assertTrue(param1.equals(param1));
+        Assert.assertTrue(param2.equals(param2));
+        Assert.assertTrue(param1.equals(param3));
     }
 
+    @Test
     public void testToString() {
         NameValuePair param1 = new BasicNameValuePair("name1", "value1");
-        assertEquals("name1=value1", param1.toString());
+        Assert.assertEquals("name1=value1", param1.toString());
         NameValuePair param2 = new BasicNameValuePair("name1", null);
-        assertEquals("name1", param2.toString());
+        Assert.assertEquals("name1", param2.toString());
     }
 
+    @Test
     public void testCloning() throws Exception {
         BasicNameValuePair orig = new BasicNameValuePair("name1", "value1");
         BasicNameValuePair clone = (BasicNameValuePair) orig.clone();
-        assertEquals(orig, clone);
+        Assert.assertEquals(orig, clone);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java Mon May  9 11:26:57 2011
@@ -32,55 +32,50 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpVersion;
 import org.apache.http.RequestLine;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Simple tests for {@link RequestLine}.
- *
- *
  */
-public class TestRequestLine extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestRequestLine(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestRequestLine {
 
+    @Test
     public void testConstructor() {
         RequestLine requestline = new BasicRequestLine("GET", "/stuff", HttpVersion.HTTP_1_1);
-        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 testConstructorInvalidInput() {
         try {
             new BasicRequestLine(null, "/stuff", HttpVersion.HTTP_1_1);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException e) { /* expected */ }
         try {
             new BasicRequestLine("GET", null, HttpVersion.HTTP_1_1);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException e) { /* expected */ }
         try {
             new BasicRequestLine("GET", "/stuff", (HttpVersion)null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException e) { /* expected */ }
     }
 
+    @Test
     public void testCloning() throws Exception {
         BasicRequestLine orig = new BasicRequestLine("GET", "/stuff", HttpVersion.HTTP_1_1);
         BasicRequestLine clone = (BasicRequestLine) orig.clone();
-        assertEquals(orig.getMethod(), clone.getMethod());
-        assertEquals(orig.getUri(), clone.getUri());
-        assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
+        Assert.assertEquals(orig.getMethod(), clone.getMethod());
+        Assert.assertEquals(orig.getUri(), clone.getUri());
+        Assert.assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
     }
 
+    @Test
     public void testSerialization() throws Exception {
         BasicRequestLine orig = new BasicRequestLine("GET", "/stuff", HttpVersion.HTTP_1_1);
         ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
@@ -91,9 +86,9 @@ public class TestRequestLine extends Tes
         ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
         ObjectInputStream instream = new ObjectInputStream(inbuffer);
         BasicRequestLine clone = (BasicRequestLine) instream.readObject();
-        assertEquals(orig.getMethod(), clone.getMethod());
-        assertEquals(orig.getUri(), clone.getUri());
-        assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
+        Assert.assertEquals(orig.getMethod(), clone.getMethod());
+        Assert.assertEquals(orig.getUri(), clone.getUri());
+        Assert.assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java Mon May  9 11:26:57 2011
@@ -32,61 +32,56 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
 import org.apache.http.StatusLine;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Simple tests for {@link StatusLine}.
- *
- *
- * @version $Id$
  */
-public class TestStatusLine extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestStatusLine(String testName) {
-        super(testName);
-    }
-
-    // ----------------------------------------------------------- Test Methods
+public class TestStatusLine {
 
+    @Test
     public void testConstructor() {
         StatusLine statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
-        assertEquals(HttpVersion.HTTP_1_1, statusline.getProtocolVersion());
-        assertEquals(HttpStatus.SC_OK, statusline.getStatusCode());
-        assertEquals("OK", statusline.getReasonPhrase());
+        Assert.assertEquals(HttpVersion.HTTP_1_1, statusline.getProtocolVersion());
+        Assert.assertEquals(HttpStatus.SC_OK, statusline.getStatusCode());
+        Assert.assertEquals("OK", statusline.getReasonPhrase());
     }
 
+    @Test
     public void testConstructorInvalidInput() {
         try {
             new BasicStatusLine(null, HttpStatus.SC_OK, "OK");
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException e) { /* expected */ }
         try {
             new BasicStatusLine(HttpVersion.HTTP_1_1, -1, "OK");
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException e) { /* expected */ }
     }
 
+    @Test
     public void testToString() throws Exception {
         StatusLine statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
-        assertEquals("HTTP/1.1 200 OK", statusline.toString());
+        Assert.assertEquals("HTTP/1.1 200 OK", statusline.toString());
         statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null);
         // toString uses default formatting, hence the trailing space
-        assertEquals("HTTP/1.1 200 ", statusline.toString());
+        Assert.assertEquals("HTTP/1.1 200 ", statusline.toString());
     }
 
+    @Test
     public void testCloning() throws Exception {
         BasicStatusLine orig = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         BasicStatusLine clone = (BasicStatusLine) orig.clone();
-        assertEquals(orig.getReasonPhrase(), clone.getReasonPhrase());
-        assertEquals(orig.getStatusCode(), clone.getStatusCode());
-        assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
+        Assert.assertEquals(orig.getReasonPhrase(), clone.getReasonPhrase());
+        Assert.assertEquals(orig.getStatusCode(), clone.getStatusCode());
+        Assert.assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
     }
 
+    @Test
     public void testSerialization() throws Exception {
         BasicStatusLine orig = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
@@ -97,9 +92,9 @@ public class TestStatusLine extends Test
         ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
         ObjectInputStream instream = new ObjectInputStream(inbuffer);
         BasicStatusLine clone = (BasicStatusLine) instream.readObject();
-        assertEquals(orig.getReasonPhrase(), clone.getReasonPhrase());
-        assertEquals(orig.getStatusCode(), clone.getStatusCode());
-        assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
+        Assert.assertEquals(orig.getReasonPhrase(), clone.getReasonPhrase());
+        Assert.assertEquals(orig.getStatusCode(), clone.getStatusCode());
+        Assert.assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java Mon May  9 11:26:57 2011
@@ -30,45 +30,44 @@ package org.apache.http.params;
 import java.util.Iterator;
 import java.util.Set;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link BasicHttpParams}.
  *
  */
-public class TestBasicHttpParams extends TestCase {
-
-    public TestBasicHttpParams(String testName) {
-        super(testName);
-    }
+public class TestBasicHttpParams {
 
+    @Test
     public void testRemoveParam() {
         BasicHttpParams params = new BasicHttpParams();
         params.setParameter("param1", "paramValue1");
-        assertTrue("The parameter should be removed successfully",
+        Assert.assertTrue("The parameter should be removed successfully",
                 params.removeParameter("param1"));
-        assertFalse("The parameter should not be present",
+        Assert.assertFalse("The parameter should not be present",
                 params.removeParameter("param1"));
 
         //try a remove from an empty params
         params = new BasicHttpParams();
-        assertFalse("The parameter should not be present",
+        Assert.assertFalse("The parameter should not be present",
                 params.removeParameter("param1"));
     }
 
+    @Test
     public void testgetNames() {
         BasicHttpParams params = new BasicHttpParams();
         Set<String> nameSet = params.getNames();
-        assertTrue(nameSet.isEmpty());
+        Assert.assertTrue(nameSet.isEmpty());
         params.setBooleanParameter("true", true);
-        assertTrue(nameSet.isEmpty()); // Still empty, as it is a snapshot
+        Assert.assertTrue(nameSet.isEmpty()); // Still empty, as it is a snapshot
         nameSet = params.getNames();
-        assertFalse(nameSet.isEmpty());
-        assertEquals(1, nameSet.size());
+        Assert.assertFalse(nameSet.isEmpty());
+        Assert.assertEquals(1, nameSet.size());
         Iterator<String> iterator = nameSet.iterator(); // refetch, as iterator is a snapshot
-        assertTrue("Iterator has an entry",iterator.hasNext());
+        Assert.assertTrue("Iterator has an entry",iterator.hasNext());
         String entry = iterator.next();
-        // Note: Java 1.3 requires JUnit 3.8.1 which does not have assertTrue(Boolean)
-        assertTrue(((Boolean) params.getParameter(entry)).booleanValue());
+        // Note: Java 1.3 requires JUnit 3.8.1 which does not have Assert.assertTrue(Boolean)
+        Assert.assertTrue(((Boolean) params.getParameter(entry)).booleanValue());
     }
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java Mon May  9 11:26:57 2011
@@ -29,41 +29,40 @@ package org.apache.http.params;
 
 import java.util.Set;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link BasicHttpParams}.
  *
  */
-public class TestDefaultedHttpParams extends TestCase {
-
-    public TestDefaultedHttpParams(String testName) {
-        super(testName);
-    }
+public class TestDefaultedHttpParams {
 
+    @Test
     public void testAddRemoveParam() {
         DefaultedHttpParams deflt = new DefaultedHttpParams(new BasicHttpParams(), new BasicHttpParams());
-        assertFalse("The parameter should not be removed successfully", deflt.removeParameter("param1"));
+        Assert.assertFalse("The parameter should not be removed successfully", deflt.removeParameter("param1"));
         deflt.setParameter("param1", "paramValue1");
-        assertEquals(0, deflt.getDefaultNames().size());
-        assertEquals(1, deflt.getNames().size());
-        assertEquals(1, deflt.getLocalNames().size());
-        assertTrue("The parameter should be removed successfully", deflt.removeParameter("param1"));
-        assertFalse("The parameter should not be present", deflt.removeParameter("param1"));
-        assertEquals(0, deflt.getDefaultNames().size());
-        assertEquals(0, deflt.getNames().size());
-        assertEquals(0, deflt.getLocalNames().size());
+        Assert.assertEquals(0, deflt.getDefaultNames().size());
+        Assert.assertEquals(1, deflt.getNames().size());
+        Assert.assertEquals(1, deflt.getLocalNames().size());
+        Assert.assertTrue("The parameter should be removed successfully", deflt.removeParameter("param1"));
+        Assert.assertFalse("The parameter should not be present", deflt.removeParameter("param1"));
+        Assert.assertEquals(0, deflt.getDefaultNames().size());
+        Assert.assertEquals(0, deflt.getNames().size());
+        Assert.assertEquals(0, deflt.getLocalNames().size());
     }
 
+    @Test
     public void testEmptyParams() {
         DefaultedHttpParams deflt = new DefaultedHttpParams(new BasicHttpParams(), new BasicHttpParams());
-        assertNull("The parameter should not be present", deflt.getParameter("param1"));
+        Assert.assertNull("The parameter should not be present", deflt.getParameter("param1"));
         //try a remove from an empty params
-        assertFalse("The parameter should not be present", deflt.removeParameter("param1"));
+        Assert.assertFalse("The parameter should not be present", deflt.removeParameter("param1"));
 
-        assertEquals(0, deflt.getNames().size());
-        assertEquals(0, deflt.getLocalNames().size());
-        assertEquals(0, deflt.getDefaultNames().size());
+        Assert.assertEquals(0, deflt.getNames().size());
+        Assert.assertEquals(0, deflt.getLocalNames().size());
+        Assert.assertEquals(0, deflt.getDefaultNames().size());
     }
 
     private HttpParams addParams(String name){
@@ -73,26 +72,27 @@ public class TestDefaultedHttpParams ext
         return params;
     }
 
+    @Test
     public void testgetNames() {
         DefaultedHttpParams params = new DefaultedHttpParams(addParams("local"), addParams("default"));
 
         Set<String> nameSet = params.getNames();
-        assertEquals(3, nameSet.size());
+        Assert.assertEquals(3, nameSet.size());
         Set<String> localnameSet = params.getLocalNames();
-        assertEquals(2, localnameSet.size());
+        Assert.assertEquals(2, localnameSet.size());
         Set<String> defaultnameSet = params.getDefaultNames();
-        assertEquals(2, defaultnameSet.size());
+        Assert.assertEquals(2, defaultnameSet.size());
 
         params.setParameter("new", null);
-        assertEquals(3, nameSet.size()); // Name set not yet updated
-        assertEquals(2, localnameSet.size());
-        assertEquals(2, defaultnameSet.size());
+        Assert.assertEquals(3, nameSet.size()); // Name set not yet updated
+        Assert.assertEquals(2, localnameSet.size());
+        Assert.assertEquals(2, defaultnameSet.size());
 
         nameSet = params.getNames();
         localnameSet = params.getLocalNames();
         defaultnameSet = params.getDefaultNames();
-        assertEquals(4, nameSet.size());
-        assertEquals(3, localnameSet.size());
-        assertEquals(2, defaultnameSet.size());
+        Assert.assertEquals(4, nameSet.size());
+        Assert.assertEquals(3, localnameSet.size());
+        Assert.assertEquals(2, defaultnameSet.size());
     }
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java Mon May  9 11:26:57 2011
@@ -29,15 +29,13 @@ package org.apache.http.protocol;
 
 import java.io.IOException;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestInterceptor;
+import org.junit.Assert;
+import org.junit.Test;
 
-/**
- */
-public class TestBasicHttpProcessor extends TestCase {
+public class TestBasicHttpProcessor {
 
     static class TestHttpRequestInterceptorPlaceHolder implements HttpRequestInterceptor {
 
@@ -47,65 +45,63 @@ public class TestBasicHttpProcessor exte
         }
     }
 
-    // ------------------------------------------------------------ Constructor
-    public TestBasicHttpProcessor(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
+    @Test
     public void testAddFirstRequestInterceptorNull() {
         HttpRequestInterceptor itcp = null;
         BasicHttpProcessor instance = new BasicHttpProcessor();
 
         instance.addRequestInterceptor(itcp, 0);
         int itcpCount = instance.getRequestInterceptorCount();
-        assertEquals(0, itcpCount);
-        assertEquals(null, instance.getRequestInterceptor(0));
+        Assert.assertEquals(0, itcpCount);
+        Assert.assertEquals(null, instance.getRequestInterceptor(0));
     }
 
+    @Test
     public void testAddFirstRequestInterceptor() {
         HttpRequestInterceptor itcp1 = new TestHttpRequestInterceptorPlaceHolder();
         HttpRequestInterceptor itcp2 = new TestHttpRequestInterceptorPlaceHolder();
         BasicHttpProcessor instance = new BasicHttpProcessor();
 
-        assertEquals(0, instance.getRequestInterceptorCount());
+        Assert.assertEquals(0, instance.getRequestInterceptorCount());
         instance.addRequestInterceptor(itcp1);
-        assertEquals(1, instance.getRequestInterceptorCount());
-        assertSame(itcp1, instance.getRequestInterceptor(0));
+        Assert.assertEquals(1, instance.getRequestInterceptorCount());
+        Assert.assertSame(itcp1, instance.getRequestInterceptor(0));
 
         instance.addRequestInterceptor(itcp2, 0);
-        assertEquals(2, instance.getRequestInterceptorCount());
-        assertSame(itcp2, instance.getRequestInterceptor(0));
-        assertSame(itcp1, instance.getRequestInterceptor(1));
+        Assert.assertEquals(2, instance.getRequestInterceptorCount());
+        Assert.assertSame(itcp2, instance.getRequestInterceptor(0));
+        Assert.assertSame(itcp1, instance.getRequestInterceptor(1));
     }
 
+    @Test
     public void testAddTailRequestInterceptorNull() {
         HttpRequestInterceptor itcp = null;
         BasicHttpProcessor instance = new BasicHttpProcessor();
 
         instance.addRequestInterceptor(itcp, 0);
         int itcpCount = instance.getRequestInterceptorCount();
-        assertEquals(0, itcpCount);
-        assertEquals(null, instance.getRequestInterceptor(itcpCount - 1));
+        Assert.assertEquals(0, itcpCount);
+        Assert.assertEquals(null, instance.getRequestInterceptor(itcpCount - 1));
     }
 
+    @Test
     public void testAddTailRequestInterceptor() {
         HttpRequestInterceptor itcp1 = new TestHttpRequestInterceptorPlaceHolder();
         HttpRequestInterceptor itcp2 = new TestHttpRequestInterceptorPlaceHolder();
         BasicHttpProcessor instance = new BasicHttpProcessor();
 
         instance.addRequestInterceptor(itcp1);
-        assertEquals(1, instance.getRequestInterceptorCount());
-        assertSame(itcp1, instance.getRequestInterceptor(0));
+        Assert.assertEquals(1, instance.getRequestInterceptorCount());
+        Assert.assertSame(itcp1, instance.getRequestInterceptor(0));
 
         instance.addRequestInterceptor(itcp2, 1);
         int itcpCount = instance.getRequestInterceptorCount();
-        assertEquals(2, itcpCount);
-        assertSame(itcp1, instance.getRequestInterceptor(0));
-        assertSame(itcp2, instance.getRequestInterceptor(itcpCount - 1));
+        Assert.assertEquals(2, itcpCount);
+        Assert.assertSame(itcp1, instance.getRequestInterceptor(0));
+        Assert.assertSame(itcp2, instance.getRequestInterceptor(itcpCount - 1));
     }
 
+    @Test
     public void testClearByClass() {
         // remove a present class
         HttpRequestInterceptor itcp1 = new TestHttpRequestInterceptorPlaceHolder();
@@ -123,9 +119,9 @@ public class TestBasicHttpProcessor exte
         instance.addRequestInterceptor(itcp2);
         instance.addRequestInterceptor(itcp3);
         instance.removeRequestInterceptorByClass(itcp1.getClass());
-        assertEquals(1, instance.getRequestInterceptorCount());
+        Assert.assertEquals(1, instance.getRequestInterceptorCount());
         instance.removeRequestInterceptorByClass(itcp3.getClass());
-        assertEquals(0, instance.getRequestInterceptorCount());
+        Assert.assertEquals(0, instance.getRequestInterceptorCount());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpExecutionContext.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpExecutionContext.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpExecutionContext.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpExecutionContext.java Mon May  9 11:26:57 2011
@@ -27,19 +27,14 @@
 
 package org.apache.http.protocol;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
 // the name of this test is historic, the implementation classes of HttpContext
 // have been renamed to BasicHttpContext and SyncBasicHttpContext
-public class TestHttpExecutionContext extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestHttpExecutionContext(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestHttpExecutionContext {
 
+    @Test
     public void testContextOperations() {
         HttpContext parentContext = new SyncBasicHttpContext(null);
         HttpContext currentContext = new SyncBasicHttpContext(parentContext);
@@ -49,50 +44,52 @@ public class TestHttpExecutionContext ex
         currentContext.setAttribute("param3", "3");
         currentContext.setAttribute("param2", "4");
 
-        assertEquals("1", parentContext.getAttribute("param1"));
-        assertEquals("2", parentContext.getAttribute("param2"));
-        assertEquals(null, parentContext.getAttribute("param3"));
-
-        assertEquals("1", currentContext.getAttribute("param1"));
-        assertEquals("4", currentContext.getAttribute("param2"));
-        assertEquals("3", currentContext.getAttribute("param3"));
-        assertEquals(null, currentContext.getAttribute("param4"));
+        Assert.assertEquals("1", parentContext.getAttribute("param1"));
+        Assert.assertEquals("2", parentContext.getAttribute("param2"));
+        Assert.assertEquals(null, parentContext.getAttribute("param3"));
+
+        Assert.assertEquals("1", currentContext.getAttribute("param1"));
+        Assert.assertEquals("4", currentContext.getAttribute("param2"));
+        Assert.assertEquals("3", currentContext.getAttribute("param3"));
+        Assert.assertEquals(null, currentContext.getAttribute("param4"));
 
         currentContext.removeAttribute("param1");
         currentContext.removeAttribute("param2");
         currentContext.removeAttribute("param3");
         currentContext.removeAttribute("param4");
 
-        assertEquals("1", currentContext.getAttribute("param1"));
-        assertEquals("2", currentContext.getAttribute("param2"));
-        assertEquals(null, currentContext.getAttribute("param3"));
-        assertEquals(null, currentContext.getAttribute("param4"));
+        Assert.assertEquals("1", currentContext.getAttribute("param1"));
+        Assert.assertEquals("2", currentContext.getAttribute("param2"));
+        Assert.assertEquals(null, currentContext.getAttribute("param3"));
+        Assert.assertEquals(null, currentContext.getAttribute("param4"));
     }
 
+    @Test
     public void testEmptyContextOperations() {
         HttpContext currentContext = new SyncBasicHttpContext(null);
-        assertEquals(null, currentContext.getAttribute("param1"));
+        Assert.assertEquals(null, currentContext.getAttribute("param1"));
         currentContext.removeAttribute("param1");
-        assertEquals(null, currentContext.getAttribute("param1"));
+        Assert.assertEquals(null, currentContext.getAttribute("param1"));
     }
 
+    @Test
     public void testContextInvalidInput() throws Exception {
         HttpContext currentContext = new SyncBasicHttpContext(null);
         try {
             currentContext.setAttribute(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             currentContext.getAttribute(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             currentContext.removeAttribute(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java Mon May  9 11:26:57 2011
@@ -31,19 +31,15 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  */
-public class TestHttpRequestHandlerRegistry extends TestCase {
-
-    public TestHttpRequestHandlerRegistry(String testName) {
-        super(testName);
-    }
+public class TestHttpRequestHandlerRegistry {
 
     private static class DummyHttpRequestHandler implements HttpRequestHandler {
 
@@ -55,6 +51,7 @@ public class TestHttpRequestHandlerRegis
 
     }
 
+    @Test
     public void testRegisterUnregister() throws Exception {
         HttpRequestHandler h1 = new DummyHttpRequestHandler();
         HttpRequestHandler h2 = new DummyHttpRequestHandler();
@@ -68,18 +65,18 @@ public class TestHttpRequestHandlerRegis
         HttpRequestHandler h;
 
         h = registry.lookup("/h1");
-        assertNotNull(h);
-        assertTrue(h1 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
         h = registry.lookup("/h2");
-        assertNotNull(h);
-        assertTrue(h2 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h2 == h);
         h = registry.lookup("/h3");
-        assertNotNull(h);
-        assertTrue(h3 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h3 == h);
 
         registry.unregister("/h1");
         h = registry.lookup("/h1");
-        assertNull(h);
+        Assert.assertNull(h);
 
         Map<String, Object> map = new HashMap<String, Object>();
         map.put("/a1", h1);
@@ -88,15 +85,16 @@ public class TestHttpRequestHandlerRegis
         registry.setHandlers(map);
 
         h = registry.lookup("/h2");
-        assertNull(h);
+        Assert.assertNull(h);
         h = registry.lookup("/h3");
-        assertNull(h);
+        Assert.assertNull(h);
 
         h = registry.lookup("/a1");
-        assertNotNull(h);
-        assertTrue(h1 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
     }
 
+    @Test
     public void testWildCardMatching1() throws Exception {
         HttpRequestHandler h1 = new DummyHttpRequestHandler();
         HttpRequestHandler h2 = new DummyHttpRequestHandler();
@@ -112,22 +110,23 @@ public class TestHttpRequestHandlerRegis
         HttpRequestHandler h;
 
         h = registry.lookup("/one/request");
-        assertNotNull(h);
-        assertTrue(h1 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
 
         h = registry.lookup("/one/two/request");
-        assertNotNull(h);
-        assertTrue(h2 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h2 == h);
 
         h = registry.lookup("/one/two/three/request");
-        assertNotNull(h);
-        assertTrue(h3 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h3 == h);
 
         h = registry.lookup("default/request");
-        assertNotNull(h);
-        assertTrue(def == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
     }
 
+    @Test
     public void testWildCardMatching2() throws Exception {
         HttpRequestHandler h1 = new DummyHttpRequestHandler();
         HttpRequestHandler h2 = new DummyHttpRequestHandler();
@@ -141,18 +140,19 @@ public class TestHttpRequestHandlerRegis
         HttpRequestHandler h;
 
         h = registry.lookup("/that.view");
-        assertNotNull(h);
-        assertTrue(h1 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
 
         h = registry.lookup("/that.form");
-        assertNotNull(h);
-        assertTrue(h2 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h2 == h);
 
         h = registry.lookup("/whatever");
-        assertNotNull(h);
-        assertTrue(def == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
     }
 
+    @Test
     public void testWildCardMatchingWithQuery() throws Exception {
         HttpRequestHandler h1 = new DummyHttpRequestHandler();
         HttpRequestHandler h2 = new DummyHttpRequestHandler();
@@ -166,18 +166,19 @@ public class TestHttpRequestHandlerRegis
         HttpRequestHandler h;
 
         h = registry.lookup("/that.view?param=value");
-        assertNotNull(h);
-        assertTrue(h1 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
 
         h = registry.lookup("/that.form?whatever");
-        assertNotNull(h);
-        assertTrue(h2 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h2 == h);
 
         h = registry.lookup("/whatever");
-        assertNotNull(h);
-        assertTrue(def == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
     }
 
+    @Test
     public void testSuffixPatternOverPrefixPatternMatch() throws Exception {
         HttpRequestHandler h1 = new DummyHttpRequestHandler();
         HttpRequestHandler h2 = new DummyHttpRequestHandler();
@@ -189,22 +190,23 @@ public class TestHttpRequestHandlerRegis
         HttpRequestHandler h;
 
         h = registry.lookup("/match");
-        assertNotNull(h);
-        assertTrue(h1 == h);
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
     }
 
+    @Test
     public void testInvalidInput() throws Exception {
         HttpRequestHandlerRegistry registry = new HttpRequestHandlerRegistry();
         try {
             registry.register(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
 
         try {
             registry.register("", null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
@@ -213,14 +215,14 @@ public class TestHttpRequestHandlerRegis
 
         try {
             registry.setHandlers(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
 
         try {
             registry.lookup(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java Mon May  9 11:26:57 2011
@@ -38,9 +38,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
 
-import junit.framework.TestCase;
-
 import org.apache.http.Header;
+import org.apache.http.HttpConnectionMetrics;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
@@ -60,35 +59,37 @@ import org.apache.http.mockup.HttpServer
 import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.util.EncodingUtils;
 import org.apache.http.util.EntityUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-import org.apache.http.HttpConnectionMetrics;
-
-public class TestHttpServiceAndExecutor extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestHttpServiceAndExecutor(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestHttpServiceAndExecutor {
 
     private HttpServer server;
     private HttpClient client;
 
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void initServer() throws Exception {
         this.server = new HttpServer();
+    }
+
+    @Before
+    public void initClient() throws Exception {
         this.client = new HttpClient();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        this.server.shutdown();
+    @After
+    public void shutDownServer() throws Exception {
+        if (this.server != null) {
+            this.server.shutdown();
+        }
     }
 
     /**
      * This test case executes a series of simple GET requests
      */
+    @Test
     public void testSimpleBasicHttpRequests() throws Exception {
 
         int reqNo = 20;
@@ -141,9 +142,9 @@ public class TestHttpServiceAndExecutor 
                 byte[] received = EntityUtils.toByteArray(response.getEntity());
                 byte[] expected = testData.get(r);
 
-                assertEquals(expected.length, received.length);
+                Assert.assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
-                    assertEquals(expected[i], received[i]);
+                    Assert.assertEquals(expected[i], received[i]);
                 }
                 if (!this.client.keepAlive(response)) {
                     conn.close();
@@ -152,8 +153,8 @@ public class TestHttpServiceAndExecutor 
 
             //Verify the connection metrics
             HttpConnectionMetrics cm = conn.getMetrics();
-            assertEquals(reqNo, cm.getRequestCount());
-            assertEquals(reqNo, cm.getResponseCount());
+            Assert.assertEquals(reqNo, cm.getRequestCount());
+            Assert.assertEquals(reqNo, cm.getResponseCount());
 
         } finally {
             conn.close();
@@ -165,6 +166,7 @@ public class TestHttpServiceAndExecutor 
      * This test case executes a series of simple POST requests with content length
      * delimited content.
      */
+    @Test
     public void testSimpleHttpPostsWithContentLength() throws Exception {
 
         int reqNo = 20;
@@ -224,9 +226,9 @@ public class TestHttpServiceAndExecutor 
                 byte[] received = EntityUtils.toByteArray(response.getEntity());
                 byte[] expected = testData.get(r);
 
-                assertEquals(expected.length, received.length);
+                Assert.assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
-                    assertEquals(expected[i], received[i]);
+                    Assert.assertEquals(expected[i], received[i]);
                 }
                 if (!this.client.keepAlive(response)) {
                     conn.close();
@@ -234,8 +236,8 @@ public class TestHttpServiceAndExecutor 
             }
             //Verify the connection metrics
             HttpConnectionMetrics cm = conn.getMetrics();
-            assertEquals(reqNo, cm.getRequestCount());
-            assertEquals(reqNo, cm.getResponseCount());
+            Assert.assertEquals(reqNo, cm.getRequestCount());
+            Assert.assertEquals(reqNo, cm.getResponseCount());
 
         } finally {
             conn.close();
@@ -247,6 +249,7 @@ public class TestHttpServiceAndExecutor 
      * This test case executes a series of simple POST requests with chunk
      * coded content content.
      */
+    @Test
     public void testSimpleHttpPostsChunked() throws Exception {
 
         int reqNo = 20;
@@ -307,9 +310,9 @@ public class TestHttpServiceAndExecutor 
                 byte[] received = EntityUtils.toByteArray(response.getEntity());
                 byte[] expected = testData.get(r);
 
-                assertEquals(expected.length, received.length);
+                Assert.assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
-                    assertEquals(expected[i], received[i]);
+                    Assert.assertEquals(expected[i], received[i]);
                 }
                 if (!this.client.keepAlive(response)) {
                     conn.close();
@@ -317,8 +320,8 @@ public class TestHttpServiceAndExecutor 
             }
             //Verify the connection metrics
             HttpConnectionMetrics cm = conn.getMetrics();
-            assertEquals(reqNo, cm.getRequestCount());
-            assertEquals(reqNo, cm.getResponseCount());
+            Assert.assertEquals(reqNo, cm.getRequestCount());
+            Assert.assertEquals(reqNo, cm.getResponseCount());
         } finally {
             conn.close();
             this.server.shutdown();
@@ -328,6 +331,7 @@ public class TestHttpServiceAndExecutor 
     /**
      * This test case executes a series of simple HTTP/1.0 POST requests.
      */
+    @Test
     public void testSimpleHttpPostsHTTP10() throws Exception {
 
         int reqNo = 20;
@@ -388,13 +392,13 @@ public class TestHttpServiceAndExecutor 
                 post.setEntity(outgoing);
 
                 HttpResponse response = this.client.execute(post, host, conn);
-                assertEquals(HttpVersion.HTTP_1_0, response.getStatusLine().getProtocolVersion());
+                Assert.assertEquals(HttpVersion.HTTP_1_0, response.getStatusLine().getProtocolVersion());
                 byte[] received = EntityUtils.toByteArray(response.getEntity());
                 byte[] expected = testData.get(r);
 
-                assertEquals(expected.length, received.length);
+                Assert.assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
-                    assertEquals(expected[i], received[i]);
+                    Assert.assertEquals(expected[i], received[i]);
                 }
                 if (!this.client.keepAlive(response)) {
                     conn.close();
@@ -403,8 +407,8 @@ public class TestHttpServiceAndExecutor 
 
             //Verify the connection metrics
             HttpConnectionMetrics cm = conn.getMetrics();
-            assertEquals(reqNo, cm.getRequestCount());
-            assertEquals(reqNo, cm.getResponseCount());
+            Assert.assertEquals(reqNo, cm.getRequestCount());
+            Assert.assertEquals(reqNo, cm.getResponseCount());
         } finally {
             conn.close();
             this.server.shutdown();
@@ -415,6 +419,7 @@ public class TestHttpServiceAndExecutor 
      * This test case executes a series of simple POST requests using
      * the 'expect: continue' handshake.
      */
+    @Test
     public void testHttpPostsWithExpectContinue() throws Exception {
 
         int reqNo = 20;
@@ -478,9 +483,9 @@ public class TestHttpServiceAndExecutor 
                 byte[] received = EntityUtils.toByteArray(response.getEntity());
                 byte[] expected = testData.get(r);
 
-                assertEquals(expected.length, received.length);
+                Assert.assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
-                    assertEquals(expected[i], received[i]);
+                    Assert.assertEquals(expected[i], received[i]);
                 }
                 if (!this.client.keepAlive(response)) {
                     conn.close();
@@ -489,8 +494,8 @@ public class TestHttpServiceAndExecutor 
 
             //Verify the connection metrics
             HttpConnectionMetrics cm = conn.getMetrics();
-            assertEquals(reqNo, cm.getRequestCount());
-            assertEquals(reqNo, cm.getResponseCount());
+            Assert.assertEquals(reqNo, cm.getRequestCount());
+            Assert.assertEquals(reqNo, cm.getResponseCount());
         } finally {
             conn.close();
             this.server.shutdown();
@@ -502,6 +507,7 @@ public class TestHttpServiceAndExecutor 
      * This test case executes a series of simple POST requests that do not
      * meet the target server expectations.
      */
+    @Test
     public void testHttpPostsWithExpectationVerification() throws Exception {
 
         int reqNo = 3;
@@ -570,13 +576,13 @@ public class TestHttpServiceAndExecutor 
                 HttpResponse response = this.client.execute(post, host, conn);
 
                 HttpEntity entity = response.getEntity();
-                assertNotNull(entity);
+                Assert.assertNotNull(entity);
                 EntityUtils.consume(entity);
 
                 if (r < 2) {
-                    assertEquals(HttpStatus.SC_EXPECTATION_FAILED, response.getStatusLine().getStatusCode());
+                    Assert.assertEquals(HttpStatus.SC_EXPECTATION_FAILED, response.getStatusLine().getStatusCode());
                 } else {
-                    assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+                    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
                 }
 
                 if (!this.client.keepAlive(response)) {
@@ -585,8 +591,8 @@ public class TestHttpServiceAndExecutor 
             }
             //Verify the connection metrics
             HttpConnectionMetrics cm = conn.getMetrics();
-            assertEquals(reqNo, cm.getRequestCount());
-            assertEquals(reqNo, cm.getResponseCount());
+            Assert.assertEquals(reqNo, cm.getRequestCount());
+            Assert.assertEquals(reqNo, cm.getResponseCount());
         } finally {
             conn.close();
             this.server.shutdown();
@@ -646,6 +652,7 @@ public class TestHttpServiceAndExecutor 
 
     }
 
+    @Test
     public void testHttpContent() throws Exception {
 
         String[] patterns = {
@@ -728,22 +735,22 @@ public class TestHttpServiceAndExecutor 
 
                     HttpResponse response = this.client.execute(post, host, conn);
                     HttpEntity incoming = response.getEntity();
-                    assertNotNull(incoming);
+                    Assert.assertNotNull(incoming);
                     InputStream instream = incoming.getContent();
                     String charset = EntityUtils.getContentCharSet(incoming);
                     if (charset == null) {
                         charset = "US-ASCII";
                     }
-                    assertNotNull(instream);
+                    Assert.assertNotNull(instream);
                     BufferedReader reader = new BufferedReader(new InputStreamReader(instream, charset));
 
                     String line;
                     int count = 0;
                     while ((line = reader.readLine()) != null) {
-                        assertEquals(pattern, line);
+                        Assert.assertEquals(pattern, line);
                         count++;
                     }
-                    assertEquals(n, count);
+                    Assert.assertEquals(n, count);
                     if (!this.client.keepAlive(response)) {
                         conn.close();
                     }



Mime
View raw message