You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2011/05/09 13:27:00 UTC

svn commit: r1100965 [4/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...

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestSerializableEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestSerializableEntity.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestSerializableEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestSerializableEntity.java Mon May  9 11:26:57 2011
@@ -33,9 +33,10 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestSerializableEntity extends TestCase {
+public class TestSerializableEntity {
 
     public static class SerializableObject implements Serializable {
 
@@ -48,10 +49,7 @@ public class TestSerializableEntity exte
         public SerializableObject() {}
     }
 
-    public TestSerializableEntity(String testName) {
-        super(testName);
-    }
-
+    @Test
     public void testBasicsBuff() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream(baos);
@@ -61,12 +59,13 @@ public class TestSerializableEntity exte
 
         SerializableEntity httpentity = new SerializableEntity(serializableObj, true);
 
-        assertEquals(baos.toByteArray().length, httpentity.getContentLength());
-        assertNotNull(httpentity.getContent());
-        assertTrue(httpentity.isRepeatable());
-        assertFalse(httpentity.isStreaming());
+        Assert.assertEquals(baos.toByteArray().length, httpentity.getContentLength());
+        Assert.assertNotNull(httpentity.getContent());
+        Assert.assertTrue(httpentity.isRepeatable());
+        Assert.assertFalse(httpentity.isStreaming());
     }
 
+    @Test
     public void testBasicsDirect() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream(baos);
@@ -76,21 +75,23 @@ public class TestSerializableEntity exte
 
         SerializableEntity httpentity = new SerializableEntity(serializableObj, false);
 
-        assertEquals(-1, httpentity.getContentLength());
-        assertNotNull(httpentity.getContent());
-        assertTrue(httpentity.isRepeatable());
-        assertFalse(httpentity.isStreaming());
+        Assert.assertEquals(-1, httpentity.getContentLength());
+        Assert.assertNotNull(httpentity.getContent());
+        Assert.assertTrue(httpentity.isRepeatable());
+        Assert.assertFalse(httpentity.isStreaming());
     }
 
+    @Test
     public void testIllegalConstructor() throws Exception {
         try {
             new SerializableEntity(null, false);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testWriteToBuff() throws Exception {
         Serializable serializableObj = new SerializableObject();
         SerializableEntity httpentity = new SerializableEntity(serializableObj, true);
@@ -98,21 +99,22 @@ public class TestSerializableEntity exte
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         httpentity.writeTo(out);
         byte[] bytes = out.toByteArray();
-        assertNotNull(bytes);
+        Assert.assertNotNull(bytes);
         ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(
                 bytes));
         SerializableObject serIn = (SerializableObject) oin.readObject();
-        assertEquals(4, serIn.intValue);
-        assertEquals("Hello", serIn.stringValue);
+        Assert.assertEquals(4, serIn.intValue);
+        Assert.assertEquals("Hello", serIn.stringValue);
 
         try {
             httpentity.writeTo(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testWriteToDirect() throws Exception {
         Serializable serializableObj = new SerializableObject();
         SerializableEntity httpentity = new SerializableEntity(serializableObj, false);
@@ -120,16 +122,16 @@ public class TestSerializableEntity exte
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         httpentity.writeTo(out);
         byte[] bytes = out.toByteArray();
-        assertNotNull(bytes);
+        Assert.assertNotNull(bytes);
         ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(
                 bytes));
         SerializableObject serIn = (SerializableObject) oin.readObject();
-        assertEquals(4, serIn.intValue);
-        assertEquals("Hello", serIn.stringValue);
+        Assert.assertEquals(4, serIn.intValue);
+        Assert.assertEquals("Hello", serIn.stringValue);
 
         try {
             httpentity.writeTo(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/entity/TestStringEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java Mon May  9 11:26:57 2011
@@ -29,53 +29,53 @@ package org.apache.http.entity;
 
 import java.io.ByteArrayOutputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.http.protocol.HTTP;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link StringEntity}.
  *
  */
-public class TestStringEntity extends TestCase {
-
-    public TestStringEntity(String testName) {
-        super(testName);
-    }
+public class TestStringEntity {
 
+    @Test
     public void testBasics() throws Exception {
         String s = "Message content";
         StringEntity httpentity = new StringEntity(s, HTTP.ISO_8859_1);
 
         byte[] bytes = s.getBytes(HTTP.ISO_8859_1);
-        assertEquals(bytes.length, httpentity.getContentLength());
-        assertNotNull(httpentity.getContent());
-        assertTrue(httpentity.isRepeatable());
-        assertFalse(httpentity.isStreaming());
+        Assert.assertEquals(bytes.length, httpentity.getContentLength());
+        Assert.assertNotNull(httpentity.getContent());
+        Assert.assertTrue(httpentity.isRepeatable());
+        Assert.assertFalse(httpentity.isStreaming());
     }
 
+    @Test
     public void testIllegalConstructor() throws Exception {
         try {
             new StringEntity(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testDefaultContent() throws Exception {
         String s = "Message content";
         StringEntity httpentity = new StringEntity(s, "text/csv", "ANSI_X3.4-1968");
-        assertEquals("text/csv; charset=ANSI_X3.4-1968",
+        Assert.assertEquals("text/csv; charset=ANSI_X3.4-1968",
                 httpentity.getContentType().getValue());
         httpentity = new StringEntity(s, HTTP.US_ASCII);
-        assertEquals("text/plain; charset=US-ASCII",
+        Assert.assertEquals("text/plain; charset=US-ASCII",
                 httpentity.getContentType().getValue());
         httpentity = new StringEntity(s);
-        assertEquals("text/plain; charset=ISO-8859-1",
+        Assert.assertEquals("text/plain; charset=ISO-8859-1",
                 httpentity.getContentType().getValue());
     }
 
+    @Test
     public void testWriteTo() throws Exception {
         String s = "Message content";
         byte[] bytes = s.getBytes(HTTP.ISO_8859_1);
@@ -84,24 +84,24 @@ public class TestStringEntity extends Te
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         httpentity.writeTo(out);
         byte[] bytes2 = out.toByteArray();
-        assertNotNull(bytes2);
-        assertEquals(bytes.length, bytes2.length);
+        Assert.assertNotNull(bytes2);
+        Assert.assertEquals(bytes.length, bytes2.length);
         for (int i = 0; i < bytes.length; i++) {
-            assertEquals(bytes[i], bytes2[i]);
+            Assert.assertEquals(bytes[i], bytes2[i]);
         }
 
         out = new ByteArrayOutputStream();
         httpentity.writeTo(out);
         bytes2 = out.toByteArray();
-        assertNotNull(bytes2);
-        assertEquals(bytes.length, bytes2.length);
+        Assert.assertNotNull(bytes2);
+        Assert.assertEquals(bytes.length, bytes2.length);
         for (int i = 0; i < bytes.length; i++) {
-            assertEquals(bytes[i], bytes2[i]);
+            Assert.assertEquals(bytes[i], bytes2[i]);
         }
 
         try {
             httpentity.writeTo(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/impl/TestBasicRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestBasicRequest.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestBasicRequest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestBasicRequest.java Mon May  9 11:26:57 2011
@@ -27,50 +27,49 @@
 
 package org.apache.http.impl;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpVersion;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.CoreProtocolPNames;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestBasicRequest extends TestCase {
-
-    public TestBasicRequest(String testName) {
-        super(testName);
-    }
+public class TestBasicRequest {
 
+    @Test
     public void testConstructor() throws Exception {
         new BasicHttpRequest("GET", "/stuff");
         new BasicHttpRequest("GET", "/stuff", HttpVersion.HTTP_1_1);
         try {
             new BasicHttpRequest(null, "/stuff");
-            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
         }
     }
 
+    @Test
     public void testRequestLine() throws Exception {
         HttpRequest request = new BasicHttpRequest("GET", "/stuff");
         request.getParams().setParameter(
                 CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_0);
-        assertEquals("GET", request.getRequestLine().getMethod());
-        assertEquals("/stuff", request.getRequestLine().getUri());
-        assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getProtocolVersion());
+        Assert.assertEquals("GET", request.getRequestLine().getMethod());
+        Assert.assertEquals("/stuff", request.getRequestLine().getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getProtocolVersion());
     }
 
+    @Test
     public void testRequestLine2() throws Exception {
         HttpRequest request = new BasicHttpRequest("GET", "/stuff", HttpVersion.HTTP_1_0);
-        assertEquals("GET", request.getRequestLine().getMethod());
-        assertEquals("/stuff", request.getRequestLine().getUri());
-        assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getProtocolVersion());
+        Assert.assertEquals("GET", request.getRequestLine().getMethod());
+        Assert.assertEquals("/stuff", request.getRequestLine().getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getProtocolVersion());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java Mon May  9 11:26:57 2011
@@ -27,8 +27,6 @@
 
 package org.apache.http.impl;
 
-import junit.framework.TestCase;
-
 import org.apache.http.ConnectionReuseStrategy;
 import org.apache.http.HttpConnection;
 import org.apache.http.HttpConnectionMetrics;
@@ -41,8 +39,12 @@ import org.apache.http.message.BasicStat
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-public class TestDefaultConnectionReuseStrategy extends TestCase {
+public class TestDefaultConnectionReuseStrategy {
 
     /** A mock connection that is open and not stale. */
     private HttpConnection mockConnection;
@@ -53,13 +55,7 @@ public class TestDefaultConnectionReuseS
     /** The reuse strategy to be tested. */
     private ConnectionReuseStrategy reuseStrategy;
 
-
-
-    public TestDefaultConnectionReuseStrategy(String testName) {
-        super(testName);
-    }
-
-    @Override
+    @Before
     public void setUp() {
         // open and not stale is required for most of the tests here
         mockConnection = new MockConnection(true, false);
@@ -68,57 +64,63 @@ public class TestDefaultConnectionReuseS
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, mockConnection);
     }
 
-    @Override
+    @After
     public void tearDown() {
         mockConnection = null;
     }
 
     // ------------------------------------------------------- TestCase Methods
 
+    @Test
     public void testIllegalResponseArg() throws Exception {
 
         HttpContext context = new BasicHttpContext(null);
 
         try {
             reuseStrategy.keepAlive(null, context);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testIllegalContextArg() throws Exception {
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_1, 200, "OK", false, -1);
         try {
             reuseStrategy.keepAlive(response, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testNoContentLengthResponseHttp1_0() throws Exception {
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_0, 200, "OK", false, -1);
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testNoContentLengthResponseHttp1_1() throws Exception {
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_1, 200, "OK", false, -1);
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testChunkedContent() throws Exception {
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
 
-        assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testClosedConnection() throws Exception {
 
         // based on testChunkedContent which is known to return true
@@ -128,10 +130,11 @@ public class TestDefaultConnectionReuseS
 
         HttpConnection mockonn = new MockConnection(false, false);
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, mockonn);
-        assertFalse("closed connection should not be kept alive",
+        Assert.assertFalse("closed connection should not be kept alive",
                     reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testStaleConnection() throws Exception {
 
         // based on testChunkedContent which is known to return true
@@ -141,101 +144,113 @@ public class TestDefaultConnectionReuseS
 
         HttpConnection mockonn = new MockConnection(true, true);
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, mockonn);
-        assertTrue("stale connection should not be detected",
+        Assert.assertTrue("stale connection should not be detected",
                     reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testIgnoreInvalidKeepAlive() throws Exception {
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_0, 200, "OK", false, -1);
         response.addHeader("Connection", "keep-alive");
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testExplicitClose() throws Exception {
         // Use HTTP 1.1
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
         response.addHeader("Connection", "close");
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testExplicitKeepAlive() throws Exception {
         // Use HTTP 1.0
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_0, 200, "OK", false, 10);
         response.addHeader("Connection", "keep-alive");
 
-        assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testHTTP10Default() throws Exception {
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_0, 200, "OK");
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testHTTP11Default() throws Exception {
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testFutureHTTP() throws Exception {
         HttpResponse response =
             createResponse(new HttpVersion(3, 45), 200, "OK");
 
-        assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testBrokenConnectionDirective1() throws Exception {
         // Use HTTP 1.0
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_0, 200, "OK");
         response.addHeader("Connection", "keep--alive");
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testBrokenConnectionDirective2() throws Exception {
         // Use HTTP 1.0
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_0, 200, "OK");
         response.addHeader("Connection", null);
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testConnectionTokens1() throws Exception {
         // Use HTTP 1.1
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
         response.addHeader("Connection", "yadda, cLOSe, dumdy");
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testConnectionTokens2() throws Exception {
         // Use HTTP 1.1
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
         response.addHeader("Connection", "yadda, kEEP-alive, dumdy");
 
-        assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testConnectionTokens3() throws Exception {
         // Use HTTP 1.1
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
         response.addHeader("Connection", "yadda, keep-alive, close, dumdy");
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testConnectionTokens4() throws Exception {
         // Use HTTP 1.1
         HttpResponse response =
@@ -244,9 +259,10 @@ public class TestDefaultConnectionReuseS
         response.addHeader("Proxy-Connection", "keep-alive");
 
         // Connection takes precedence over Proxy-Connection
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testConnectionTokens5() throws Exception {
         // Use HTTP 1.1
         HttpResponse response =
@@ -257,9 +273,10 @@ public class TestDefaultConnectionReuseS
         // Connection takes precedence over Proxy-Connection,
         // even if it doesn't contain a recognized token.
         // Default for HTTP/1.1 is to keep alive.
-        assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testConnectionTokens6() throws Exception {
         // Use HTTP 1.1
         HttpResponse response =
@@ -269,16 +286,17 @@ public class TestDefaultConnectionReuseS
 
         // Connection takes precedence over Proxy-Connection,
         // even if it is empty. Default for HTTP/1.1 is to keep alive.
-        assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
     }
 
+    @Test
     public void testConnectionTokensInvalid() throws Exception {
         // Use HTTP 1.1
         HttpResponse response =
             createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
         response.addHeader("Connection", "keep-alive=true");
 
-        assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
     }
 
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestEnglishReasonPhraseCatalog.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestEnglishReasonPhraseCatalog.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestEnglishReasonPhraseCatalog.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestEnglishReasonPhraseCatalog.java Mon May  9 11:26:57 2011
@@ -27,35 +27,27 @@
 
 package org.apache.http.impl;
 
-
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpStatus;
-
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  *
  * Unit tests for {@link EnglishReasonPhraseCatalog}
  *
  */
-public class TestEnglishReasonPhraseCatalog extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestEnglishReasonPhraseCatalog(String testName) {
-        super(testName);
-    }
-
-    // ----------------------------------------------------------- Test Methods
+public class TestEnglishReasonPhraseCatalog {
 
+    @Test
     public void testReasonPhrases() throws IllegalAccessException {
     Field[] publicFields = HttpStatus.class.getFields();
 
-    assertNotNull( publicFields );
+    Assert.assertNotNull( publicFields );
 
-    assertTrue( publicFields.length > 0 );
+    Assert.assertTrue( publicFields.length > 0 );
 
     for (int i = 0; i < publicFields.length; i++)
     {
@@ -71,31 +63,33 @@ public class TestEnglishReasonPhraseCata
             final int iValue = f.getInt(null);
             final String text = EnglishReasonPhraseCatalog.
                             INSTANCE.getReason(iValue, null);
-            assertNotNull("text is null for HttpStatus."+f.getName(), text);
-            assertTrue(text.length() > 0);
+            Assert.assertNotNull("text is null for HttpStatus."+f.getName(), text);
+            Assert.assertTrue(text.length() > 0);
         }
     }
     }
 
 
+    @Test
     public void testStatusInvalid() throws Exception {
         try {
             EnglishReasonPhraseCatalog.INSTANCE.getReason(-1, null);
-            fail("IllegalArgumentException must have been thrown (-1)");
+            Assert.fail("IllegalArgumentException must have been thrown (-1)");
         } catch (IllegalArgumentException expected) {
         }
         try {
             EnglishReasonPhraseCatalog.INSTANCE.getReason(99, null);
-            fail("IllegalArgumentException must have been thrown (99)");
+            Assert.fail("IllegalArgumentException must have been thrown (99)");
         } catch (IllegalArgumentException expected) {
         }
         try {
             EnglishReasonPhraseCatalog.INSTANCE.getReason(600, null);
-            fail("IllegalArgumentException must have been thrown (600)");
+            Assert.fail("IllegalArgumentException must have been thrown (600)");
         } catch (IllegalArgumentException expected) {
         }
     }
 
+    @Test
     public void testStatusAll() throws Exception {
         for (int i = 100; i < 600; i++) {
             EnglishReasonPhraseCatalog.INSTANCE.getReason(i, null);

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestSessionBuffers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestSessionBuffers.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestSessionBuffers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestSessionBuffers.java Mon May  9 11:26:57 2011
@@ -32,8 +32,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.http.io.HttpTransportMetrics;
 import org.apache.http.mockup.SessionInputBufferMockup;
 import org.apache.http.mockup.SessionOutputBufferMockup;
@@ -43,19 +41,18 @@ import org.apache.http.params.HttpParams
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestSessionBuffers extends TestCase {
-
-    public TestSessionBuffers(String testName) {
-        super(testName);
-    }
+public class TestSessionBuffers {
 
+    @Test
     public void testInit() throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         new SessionOutputBufferMockup(out);
         try {
             new SessionOutputBufferMockup(null, new BasicHttpParams());
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
@@ -63,42 +60,44 @@ public class TestSessionBuffers extends 
         new SessionInputBufferMockup(in, 10);
         try {
             new SessionInputBufferMockup(in, -10);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
         try {
             new SessionOutputBufferMockup(out, -10);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
         try {
             new SessionInputBufferMockup((InputStream)null, 1024);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
         }
     }
 
+    @Test
     public void testBasicBufferProperties() throws Exception {
         SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(new byte[] { 1, 2 , 3});
-        assertEquals(SessionInputBufferMockup.BUFFER_SIZE, inbuffer.capacity());
-        assertEquals(SessionInputBufferMockup.BUFFER_SIZE, inbuffer.available());
-        assertEquals(0, inbuffer.length());
+        Assert.assertEquals(SessionInputBufferMockup.BUFFER_SIZE, inbuffer.capacity());
+        Assert.assertEquals(SessionInputBufferMockup.BUFFER_SIZE, inbuffer.available());
+        Assert.assertEquals(0, inbuffer.length());
         inbuffer.read();
-        assertEquals(SessionInputBufferMockup.BUFFER_SIZE - 2, inbuffer.available());
-        assertEquals(2, inbuffer.length());
+        Assert.assertEquals(SessionInputBufferMockup.BUFFER_SIZE - 2, inbuffer.available());
+        Assert.assertEquals(2, inbuffer.length());
 
         SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup();
-        assertEquals(SessionOutputBufferMockup.BUFFER_SIZE, outbuffer.capacity());
-        assertEquals(SessionOutputBufferMockup.BUFFER_SIZE, outbuffer.available());
-        assertEquals(0, outbuffer.length());
+        Assert.assertEquals(SessionOutputBufferMockup.BUFFER_SIZE, outbuffer.capacity());
+        Assert.assertEquals(SessionOutputBufferMockup.BUFFER_SIZE, outbuffer.available());
+        Assert.assertEquals(0, outbuffer.length());
         outbuffer.write(new byte[] {1, 2, 3});
-        assertEquals(SessionOutputBufferMockup.BUFFER_SIZE - 3, outbuffer.available());
-        assertEquals(3, outbuffer.length());
+        Assert.assertEquals(SessionOutputBufferMockup.BUFFER_SIZE - 3, outbuffer.available());
+        Assert.assertEquals(3, outbuffer.length());
     }
 
+    @Test
     public void testBasicReadWriteLine() throws Exception {
 
         String[] teststrs = new String[5];
@@ -132,22 +131,23 @@ public class TestSessionBuffers extends 
         for (int i = 0; i < teststrs.length; i++) {
             expected += (teststrs[i].length() + 2/*CRLF*/);
         }
-        assertEquals(expected, bytesWritten);
+        Assert.assertEquals(expected, bytesWritten);
 
         SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(
                 outbuffer.getData());
 
         for (int i = 0; i < teststrs.length; i++) {
-            assertEquals(teststrs[i], inbuffer.readLine());
+            Assert.assertEquals(teststrs[i], inbuffer.readLine());
         }
 
-        assertNull(inbuffer.readLine());
-        assertNull(inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
         tmetrics = inbuffer.getMetrics();
         long bytesRead = tmetrics.getBytesTransferred();
-        assertEquals(expected, bytesRead);
+        Assert.assertEquals(expected, bytesRead);
     }
 
+    @Test
     public void testComplexReadWriteLine() throws Exception {
         SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup();
         outbuffer.write(new byte[] {'a', '\n'});
@@ -161,7 +161,7 @@ public class TestSessionBuffers extends 
         outbuffer.flush();
 
         long bytesWritten = outbuffer.getMetrics().getBytesTransferred();
-        assertEquals(8, bytesWritten);
+        Assert.assertEquals(8, bytesWritten);
 
         StringBuilder buffer = new StringBuilder();
         for (int i = 0; i < 14; i++) {
@@ -172,7 +172,7 @@ public class TestSessionBuffers extends 
         outbuffer.write(buffer.toString().getBytes("US-ASCII"));
         outbuffer.flush();
         bytesWritten = outbuffer.getMetrics().getBytesTransferred();
-        assertEquals(8 + 14 +2, bytesWritten);
+        Assert.assertEquals(8 + 14 +2, bytesWritten);
 
         buffer.setLength(0);
         for (int i = 0; i < 15; i++) {
@@ -183,7 +183,7 @@ public class TestSessionBuffers extends 
         outbuffer.write(buffer.toString().getBytes("US-ASCII"));
         outbuffer.flush();
         bytesWritten = outbuffer.getMetrics().getBytesTransferred();
-        assertEquals(8 + 14 + 2 + 15 + 2 , bytesWritten);
+        Assert.assertEquals(8 + 14 + 2 + 15 + 2 , bytesWritten);
 
         buffer.setLength(0);
         for (int i = 0; i < 16; i++) {
@@ -194,30 +194,31 @@ public class TestSessionBuffers extends 
         outbuffer.write(buffer.toString().getBytes("US-ASCII"));
         outbuffer.flush();
         bytesWritten = outbuffer.getMetrics().getBytesTransferred();
-        assertEquals(8 + 14 + 2 + 15 + 2 + 16 + 2, bytesWritten);
+        Assert.assertEquals(8 + 14 + 2 + 15 + 2 + 16 + 2, bytesWritten);
 
         outbuffer.write(new byte[] {'a'});
         outbuffer.flush();
         bytesWritten = outbuffer.getMetrics().getBytesTransferred();
-        assertEquals(8 + 14 + 2 + 15 + 2 + 16 + 2 + 1, bytesWritten);
+        Assert.assertEquals(8 + 14 + 2 + 15 + 2 + 16 + 2 + 1, bytesWritten);
 
         SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(
                 outbuffer.getData());
 
-        assertEquals("a", inbuffer.readLine());
-        assertEquals("", inbuffer.readLine());
-        assertEquals("\r", inbuffer.readLine());
-        assertEquals("", inbuffer.readLine());
-        assertEquals(s1, inbuffer.readLine());
-        assertEquals(s2, inbuffer.readLine());
-        assertEquals(s3, inbuffer.readLine());
-        assertEquals("a", inbuffer.readLine());
-        assertNull(inbuffer.readLine());
-        assertNull(inbuffer.readLine());
+        Assert.assertEquals("a", inbuffer.readLine());
+        Assert.assertEquals("", inbuffer.readLine());
+        Assert.assertEquals("\r", inbuffer.readLine());
+        Assert.assertEquals("", inbuffer.readLine());
+        Assert.assertEquals(s1, inbuffer.readLine());
+        Assert.assertEquals(s2, inbuffer.readLine());
+        Assert.assertEquals(s3, inbuffer.readLine());
+        Assert.assertEquals("a", inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
         long bytesRead = inbuffer.getMetrics().getBytesTransferred();
-        assertEquals(bytesWritten, bytesRead);
+        Assert.assertEquals(bytesWritten, bytesRead);
     }
 
+    @Test
     public void testBasicReadWriteLineLargeBuffer() throws Exception {
 
         String[] teststrs = new String[5];
@@ -250,20 +251,21 @@ public class TestSessionBuffers extends 
         for (int i = 0; i < teststrs.length; i++) {
             expected += (teststrs[i].length() + 2/*CRLF*/);
         }
-        assertEquals(expected, bytesWritten);
+        Assert.assertEquals(expected, bytesWritten);
 
         SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(
                 outbuffer.getData(), 1024);
 
         for (int i = 0; i < teststrs.length; i++) {
-            assertEquals(teststrs[i], inbuffer.readLine());
+            Assert.assertEquals(teststrs[i], inbuffer.readLine());
         }
-        assertNull(inbuffer.readLine());
-        assertNull(inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
         long bytesRead = inbuffer.getMetrics().getBytesTransferred();
-        assertEquals(expected, bytesRead);
+        Assert.assertEquals(expected, bytesRead);
     }
 
+    @Test
     public void testReadWriteBytes() throws Exception {
         // make the buffer larger than that of outbuffer
         byte[] out = new byte[40];
@@ -284,21 +286,21 @@ public class TestSessionBuffers extends 
         }
         outbuffer.flush();
         long bytesWritten = outbuffer.getMetrics().getBytesTransferred();
-        assertEquals(out.length, bytesWritten);
+        Assert.assertEquals(out.length, bytesWritten);
 
         byte[] tmp = outbuffer.getData();
-        assertEquals(out.length, tmp.length);
+        Assert.assertEquals(out.length, tmp.length);
         for (int i = 0; i < out.length; i++) {
-            assertEquals(out[i], tmp[i]);
+            Assert.assertEquals(out[i], tmp[i]);
         }
 
         SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(tmp);
 
         // these read operations will have no effect
-        assertEquals(0, inbuffer.read(null, 0, 10));
-        assertEquals(0, inbuffer.read(null));
+        Assert.assertEquals(0, inbuffer.read(null, 0, 10));
+        Assert.assertEquals(0, inbuffer.read(null));
         long bytesRead = inbuffer.getMetrics().getBytesTransferred();
-        assertEquals(0, bytesRead);
+        Assert.assertEquals(0, bytesRead);
 
         byte[] in = new byte[40];
         off = 0;
@@ -316,14 +318,15 @@ public class TestSessionBuffers extends 
             remaining -= l;
         }
         for (int i = 0; i < out.length; i++) {
-            assertEquals(out[i], in[i]);
+            Assert.assertEquals(out[i], in[i]);
         }
-        assertEquals(-1, inbuffer.read(tmp));
-        assertEquals(-1, inbuffer.read(tmp));
+        Assert.assertEquals(-1, inbuffer.read(tmp));
+        Assert.assertEquals(-1, inbuffer.read(tmp));
         bytesRead = inbuffer.getMetrics().getBytesTransferred();
-        assertEquals(out.length, bytesRead);
+        Assert.assertEquals(out.length, bytesRead);
     }
 
+    @Test
     public void testReadWriteByte() throws Exception {
         // make the buffer larger than that of outbuffer
         byte[] out = new byte[40];
@@ -336,12 +339,12 @@ public class TestSessionBuffers extends 
         }
         outbuffer.flush();
         long bytesWritten = outbuffer.getMetrics().getBytesTransferred();
-        assertEquals(out.length, bytesWritten);
+        Assert.assertEquals(out.length, bytesWritten);
 
         byte[] tmp = outbuffer.getData();
-        assertEquals(out.length, tmp.length);
+        Assert.assertEquals(out.length, tmp.length);
         for (int i = 0; i < out.length; i++) {
-            assertEquals(out[i], tmp[i]);
+            Assert.assertEquals(out[i], tmp[i]);
         }
 
         SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(tmp);
@@ -350,14 +353,15 @@ public class TestSessionBuffers extends 
             in[i] = (byte)inbuffer.read();
         }
         for (int i = 0; i < out.length; i++) {
-            assertEquals(out[i], in[i]);
+            Assert.assertEquals(out[i], in[i]);
         }
-        assertEquals(-1, inbuffer.read());
-        assertEquals(-1, inbuffer.read());
+        Assert.assertEquals(-1, inbuffer.read());
+        Assert.assertEquals(-1, inbuffer.read());
         long bytesRead = inbuffer.getMetrics().getBytesTransferred();
-        assertEquals(out.length, bytesRead);
+        Assert.assertEquals(out.length, bytesRead);
     }
 
+    @Test
     public void testLineLimit() throws Exception {
         HttpParams params = new BasicHttpParams();
         String s = "a very looooooooooooooooooooooooooooooooooooooong line\r\n     ";
@@ -365,20 +369,20 @@ public class TestSessionBuffers extends 
         // no limit
         params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 0);
         SessionInputBufferMockup inbuffer1 = new SessionInputBufferMockup(tmp, 5, params);
-        assertNotNull(inbuffer1.readLine());
+        Assert.assertNotNull(inbuffer1.readLine());
         long bytesRead = inbuffer1.getMetrics().getBytesTransferred();
-        assertEquals(60, bytesRead);
+        Assert.assertEquals(60, bytesRead);
 
         // 15 char limit
         params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 15);
         SessionInputBufferMockup inbuffer2 = new SessionInputBufferMockup(tmp, 5, params);
         try {
             inbuffer2.readLine();
-            fail("IOException should have been thrown");
+            Assert.fail("IOException should have been thrown");
         } catch (IOException ex) {
             // expected
             bytesRead = inbuffer2.getMetrics().getBytesTransferred();
-            assertEquals(20, bytesRead);
+            Assert.assertEquals(20, bytesRead);
         }
     }
 
@@ -401,6 +405,7 @@ public class TestSessionBuffers extends 
         return buffer.toString();
     }
 
+    @Test
     public void testMultibyteCodedReadWriteLine() throws Exception {
         String s1 = constructString(SWISS_GERMAN_HELLO);
         String s2 = constructString(RUSSIAN_HELLO);
@@ -428,22 +433,23 @@ public class TestSessionBuffers extends 
         long expected = ((s1.toString().getBytes("UTF-8").length + 2)+
                 (s2.toString().getBytes("UTF-8").length + 2) +
                 (s3.toString().getBytes("UTF-8").length + 2)) * 10;
-        assertEquals(expected, bytesWritten);
+        Assert.assertEquals(expected, bytesWritten);
 
         SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(
                 outbuffer.getData(), params);
 
         for (int i = 0; i < 10; i++) {
-            assertEquals(s1, inbuffer.readLine());
-            assertEquals(s2, inbuffer.readLine());
-            assertEquals(s3, inbuffer.readLine());
+            Assert.assertEquals(s1, inbuffer.readLine());
+            Assert.assertEquals(s2, inbuffer.readLine());
+            Assert.assertEquals(s3, inbuffer.readLine());
         }
-        assertNull(inbuffer.readLine());
-        assertNull(inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
         long bytesRead = inbuffer.getMetrics().getBytesTransferred();
-        assertEquals(expected, bytesRead);
+        Assert.assertEquals(expected, bytesRead);
     }
 
+    @Test
     public void testNonAsciiReadWriteLine() throws Exception {
         String s1 = constructString(SWISS_GERMAN_HELLO);
 
@@ -461,7 +467,7 @@ public class TestSessionBuffers extends 
         outbuffer.flush();
         long bytesWritten = outbuffer.getMetrics().getBytesTransferred();
         long expected = ((s1.toString().getBytes(HTTP.ISO_8859_1).length + 2)) * 10;
-        assertEquals(expected, bytesWritten);
+        Assert.assertEquals(expected, bytesWritten);
 
         SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(
                 outbuffer.getData(),
@@ -471,24 +477,25 @@ public class TestSessionBuffers extends 
         for (int i = 0; i < 10; i++) {
             CharArrayBuffer buf = new CharArrayBuffer(64);
             int len = inbuffer.readLine(buf);
-            assertEquals(len, SWISS_GERMAN_HELLO.length);
-            assertEquals(s1, buf.toString());
+            Assert.assertEquals(len, SWISS_GERMAN_HELLO.length);
+            Assert.assertEquals(s1, buf.toString());
         }
-        assertNull(inbuffer.readLine());
-        assertNull(inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
+        Assert.assertNull(inbuffer.readLine());
         long bytesRead = inbuffer.getMetrics().getBytesTransferred();
-        assertEquals(expected, bytesRead);
+        Assert.assertEquals(expected, bytesRead);
     }
 
+    @Test
     public void testInvalidCharArrayBuffer() throws Exception {
         SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(new byte[] {});
         try {
             inbuffer.readLine(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
             long bytesRead = inbuffer.getMetrics().getBytesTransferred();
-            assertEquals(0, bytesRead);
+            Assert.assertEquals(0, bytesRead);
         }
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntityDeserializer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntityDeserializer.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntityDeserializer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntityDeserializer.java Mon May  9 11:26:57 2011
@@ -29,8 +29,6 @@ package org.apache.http.impl.entity;
 
 import java.io.InputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpMessage;
 import org.apache.http.ProtocolException;
@@ -41,30 +39,30 @@ import org.apache.http.io.SessionInputBu
 import org.apache.http.mockup.HttpMessageMockup;
 import org.apache.http.mockup.SessionInputBufferMockup;
 import org.apache.http.params.CoreProtocolPNames;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestEntityDeserializer extends TestCase {
-
-    public TestEntityDeserializer(String testName) {
-        super(testName);
-    }
+public class TestEntityDeserializer {
 
+    @Test
     public void testIllegalGenerateArg() throws Exception {
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         try {
             entitygen.deserialize(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             entitygen.deserialize(new SessionInputBufferMockup(new byte[] {}) , null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithTransferEncoding() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup("0\r\n", "US-ASCII");
         HttpMessage message = new HttpMessageMockup();
@@ -77,20 +75,21 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(-1, entity.getContentLength());
-        assertTrue(entity.isChunked());
-        assertTrue(entity.getContent() instanceof ChunkedInputStream);
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(-1, entity.getContentLength());
+        Assert.assertTrue(entity.isChunked());
+        Assert.assertTrue(entity.getContent() instanceof ChunkedInputStream);
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(-1, entity.getContentLength());
-        assertTrue(entity.isChunked());
-        assertTrue(entity.getContent() instanceof ChunkedInputStream);
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(-1, entity.getContentLength());
+        Assert.assertTrue(entity.isChunked());
+        Assert.assertTrue(entity.getContent() instanceof ChunkedInputStream);
     }
 
+    @Test
     public void testEntityWithIdentityTransferEncoding() throws Exception {
         SessionInputBuffer datareceiver =
             new SessionInputBufferMockup(new byte[] {});
@@ -104,11 +103,12 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(-1, entity.getContentLength());
-        assertFalse(entity.isChunked());
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(-1, entity.getContentLength());
+        Assert.assertFalse(entity.isChunked());
     }
 
+    @Test
     public void testEntityWithUnsupportedTransferEncoding() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup("0\r\n", "US-ASCII");
         HttpMessage message = new HttpMessageMockup();
@@ -121,21 +121,22 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(-1, entity.getContentLength());
-        assertTrue(entity.isChunked());
-        assertTrue(entity.getContent() instanceof ChunkedInputStream);
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(-1, entity.getContentLength());
+        Assert.assertTrue(entity.isChunked());
+        Assert.assertTrue(entity.getContent() instanceof ChunkedInputStream);
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             entitygen.deserialize(datareceiver, message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testChunkedTransferEncodingMustBeLast() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup("0\r\n", "US-ASCII");
         HttpMessage message = new HttpMessageMockup();
@@ -148,21 +149,22 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(-1, entity.getContentLength());
-        assertFalse(entity.isChunked());
-        assertFalse(entity.getContent() instanceof ChunkedInputStream);
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(-1, entity.getContentLength());
+        Assert.assertFalse(entity.isChunked());
+        Assert.assertFalse(entity.getContent() instanceof ChunkedInputStream);
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             entitygen.deserialize(datareceiver, message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithContentLength() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {});
         HttpMessage message = new HttpMessageMockup();
@@ -174,12 +176,13 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(0, entity.getContentLength());
-        assertFalse(entity.isChunked());
-        assertTrue(entity.getContent() instanceof ContentLengthInputStream);
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(0, entity.getContentLength());
+        Assert.assertFalse(entity.isChunked());
+        Assert.assertTrue(entity.getContent() instanceof ContentLengthInputStream);
     }
 
+    @Test
     public void testEntityWithMultipleContentLength() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
         HttpMessage message = new HttpMessageMockup();
@@ -193,23 +196,24 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(1, entity.getContentLength());
-        assertFalse(entity.isChunked());
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(1, entity.getContentLength());
+        Assert.assertFalse(entity.isChunked());
         InputStream instream = entity.getContent();
-        assertNotNull(instream);
-        assertTrue(instream instanceof ContentLengthInputStream);
+        Assert.assertNotNull(instream);
+        Assert.assertTrue(instream instanceof ContentLengthInputStream);
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             entitygen.deserialize(datareceiver, message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithMultipleContentLengthSomeWrong() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
         HttpMessage message = new HttpMessageMockup();
@@ -223,23 +227,24 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(1, entity.getContentLength());
-        assertFalse(entity.isChunked());
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(1, entity.getContentLength());
+        Assert.assertFalse(entity.isChunked());
         InputStream instream = entity.getContent();
-        assertNotNull(instream);
-        assertTrue(instream instanceof ContentLengthInputStream);
+        Assert.assertNotNull(instream);
+        Assert.assertTrue(instream instanceof ContentLengthInputStream);
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             entitygen.deserialize(datareceiver, message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithMultipleContentLengthAllWrong() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
         HttpMessage message = new HttpMessageMockup();
@@ -252,24 +257,25 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(-1, entity.getContentLength());
-        assertFalse(entity.isChunked());
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(-1, entity.getContentLength());
+        Assert.assertFalse(entity.isChunked());
         InputStream instream = entity.getContent();
-        assertNotNull(instream);
-        assertFalse(instream instanceof ContentLengthInputStream);
-        assertTrue(instream instanceof IdentityInputStream);
+        Assert.assertNotNull(instream);
+        Assert.assertFalse(instream instanceof ContentLengthInputStream);
+        Assert.assertTrue(instream instanceof IdentityInputStream);
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             entitygen.deserialize(datareceiver, message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithInvalidContentLength() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
         HttpMessage message = new HttpMessageMockup();
@@ -281,24 +287,25 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(-1, entity.getContentLength());
-        assertFalse(entity.isChunked());
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(-1, entity.getContentLength());
+        Assert.assertFalse(entity.isChunked());
         InputStream instream = entity.getContent();
-        assertNotNull(instream);
-        assertFalse(instream instanceof ContentLengthInputStream);
-        assertTrue(instream instanceof IdentityInputStream);
+        Assert.assertNotNull(instream);
+        Assert.assertFalse(instream instanceof ContentLengthInputStream);
+        Assert.assertTrue(instream instanceof IdentityInputStream);
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             entitygen.deserialize(datareceiver, message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityNeitherContentLengthNorTransferEncoding() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
         HttpMessage message = new HttpMessageMockup();
@@ -308,16 +315,17 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertEquals(-1, entity.getContentLength());
-        assertFalse(entity.isChunked());
+        Assert.assertNotNull(entity);
+        Assert.assertEquals(-1, entity.getContentLength());
+        Assert.assertFalse(entity.isChunked());
         InputStream instream = entity.getContent();
-        assertNotNull(instream);
-        assertFalse(instream instanceof ContentLengthInputStream);
-        assertFalse(instream instanceof ChunkedInputStream);
-        assertTrue(instream instanceof IdentityInputStream);
+        Assert.assertNotNull(instream);
+        Assert.assertFalse(instream instanceof ContentLengthInputStream);
+        Assert.assertFalse(instream instanceof ChunkedInputStream);
+        Assert.assertTrue(instream instanceof IdentityInputStream);
     }
 
+    @Test
     public void testEntityContentType() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
         HttpMessage message = new HttpMessageMockup();
@@ -326,11 +334,12 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertNotNull(entity.getContentType());
-        assertEquals("stuff", entity.getContentType().getValue());
+        Assert.assertNotNull(entity);
+        Assert.assertNotNull(entity.getContentType());
+        Assert.assertEquals("stuff", entity.getContentType().getValue());
     }
 
+    @Test
     public void testEntityContentEncoding() throws Exception {
         SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
         HttpMessage message = new HttpMessageMockup();
@@ -339,9 +348,9 @@ public class TestEntityDeserializer exte
         EntityDeserializer entitygen = new EntityDeserializer(
                 new LaxContentLengthStrategy());
         HttpEntity entity = entitygen.deserialize(datareceiver, message);
-        assertNotNull(entity);
-        assertNotNull(entity.getContentEncoding());
-        assertEquals("what not", entity.getContentEncoding().getValue());
+        Assert.assertNotNull(entity);
+        Assert.assertNotNull(entity.getContentEncoding());
+        Assert.assertEquals("what not", entity.getContentEncoding().getValue());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntitySerializer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntitySerializer.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntitySerializer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntitySerializer.java Mon May  9 11:26:57 2011
@@ -29,8 +29,6 @@ package org.apache.http.impl.entity;
 
 import java.io.OutputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpMessage;
 import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolException;
@@ -42,36 +40,36 @@ import org.apache.http.io.SessionOutputB
 import org.apache.http.mockup.HttpMessageMockup;
 import org.apache.http.mockup.SessionOutputBufferMockup;
 import org.apache.http.params.CoreProtocolPNames;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestEntitySerializer extends TestCase {
-
-    public TestEntitySerializer(String testName) {
-        super(testName);
-    }
+public class TestEntitySerializer {
 
+    @Test
     public void testIllegalGenerateArg() throws Exception {
         EntitySerializer entitywriter = new EntitySerializer(
                 new StrictContentLengthStrategy());
         try {
             entitywriter.serialize(null, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             entitywriter.serialize(new SessionOutputBufferMockup() , null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             entitywriter.serialize(new SessionOutputBufferMockup() , new HttpMessageMockup(), null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithChunkTransferEncoding() throws Exception {
         SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
         HttpMessage message = new HttpMessageMockup();
@@ -80,10 +78,11 @@ public class TestEntitySerializer extend
         EntitySerializer entitywriter = new EntitySerializer(
                 new StrictContentLengthStrategy());
         OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
-        assertNotNull(outstream);
-        assertTrue(outstream instanceof ChunkedOutputStream);
+        Assert.assertNotNull(outstream);
+        Assert.assertTrue(outstream instanceof ChunkedOutputStream);
     }
 
+    @Test
     public void testEntityWithIdentityTransferEncoding() throws Exception {
         SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
         HttpMessage message = new HttpMessageMockup();
@@ -92,10 +91,11 @@ public class TestEntitySerializer extend
         EntitySerializer entitywriter = new EntitySerializer(
                 new StrictContentLengthStrategy());
         OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
-        assertNotNull(outstream);
-        assertTrue(outstream instanceof IdentityOutputStream);
+        Assert.assertNotNull(outstream);
+        Assert.assertTrue(outstream instanceof IdentityOutputStream);
     }
 
+    @Test
     public void testEntityWithInvalidTransferEncoding() throws Exception {
         SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
         HttpMessage message = new HttpMessageMockup();
@@ -105,12 +105,13 @@ public class TestEntitySerializer extend
                 new StrictContentLengthStrategy());
         try {
             entitywriter.doSerialize(datatransmitter, message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithInvalidChunkEncodingAndHTTP10() throws Exception {
         SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
         HttpMessage message = new HttpMessageMockup();
@@ -122,12 +123,13 @@ public class TestEntitySerializer extend
                 new StrictContentLengthStrategy());
         try {
             entitywriter.doSerialize(datatransmitter, message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithContentLength() throws Exception {
         SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
         HttpMessage message = new HttpMessageMockup();
@@ -135,10 +137,11 @@ public class TestEntitySerializer extend
         EntitySerializer entitywriter = new EntitySerializer(
                 new StrictContentLengthStrategy());
         OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
-        assertNotNull(outstream);
-        assertTrue(outstream instanceof ContentLengthOutputStream);
+        Assert.assertNotNull(outstream);
+        Assert.assertTrue(outstream instanceof ContentLengthOutputStream);
     }
 
+    @Test
     public void testEntityWithInvalidContentLength() throws Exception {
         SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
         HttpMessage message = new HttpMessageMockup();
@@ -148,22 +151,24 @@ public class TestEntitySerializer extend
                 new StrictContentLengthStrategy());
         try {
             entitywriter.doSerialize(datatransmitter, message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityNoContentDelimiter() throws Exception {
         SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
         HttpMessage message = new HttpMessageMockup();
         EntitySerializer entitywriter = new EntitySerializer(
                 new StrictContentLengthStrategy());
         OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
-        assertNotNull(outstream);
-        assertTrue(outstream instanceof IdentityOutputStream);
+        Assert.assertNotNull(outstream);
+        Assert.assertTrue(outstream instanceof IdentityOutputStream);
     }
 
+    @Test
     public void testEntitySerialization() throws Exception {
         byte[] content = new byte[] {1, 2, 3, 4, 5};
         ByteArrayEntity entity = new ByteArrayEntity(content);
@@ -177,8 +182,8 @@ public class TestEntitySerializer extend
         entitywriter.serialize(datatransmitter, message, entity);
 
         byte[] data = datatransmitter.getData();
-        assertNotNull(data);
-        assertEquals(content.length, data.length);
+        Assert.assertNotNull(data);
+        Assert.assertEquals(content.length, data.length);
     }
 }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestLaxContentLengthStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestLaxContentLengthStrategy.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestLaxContentLengthStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestLaxContentLengthStrategy.java Mon May  9 11:26:57 2011
@@ -27,20 +27,17 @@
 
 package org.apache.http.impl.entity;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpMessage;
 import org.apache.http.ProtocolException;
 import org.apache.http.entity.ContentLengthStrategy;
 import org.apache.http.mockup.HttpMessageMockup;
 import org.apache.http.params.CoreProtocolPNames;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestLaxContentLengthStrategy extends TestCase {
-
-    public TestLaxContentLengthStrategy(String testName) {
-        super(testName);
-    }
+public class TestLaxContentLengthStrategy {
 
+    @Test
     public void testEntityWithTransferEncoding() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -50,13 +47,14 @@ public class TestLaxContentLengthStrateg
         message.addHeader("Content-Type", "unknown");
         message.addHeader("Transfer-Encoding", "identity, chunked");
         message.addHeader("Content-Length", "plain wrong");
-        assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
-        assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
     }
 
+    @Test
     public void testEntityWithIdentityTransferEncoding() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -66,9 +64,10 @@ public class TestLaxContentLengthStrateg
         message.addHeader("Content-Type", "unknown");
         message.addHeader("Transfer-Encoding", "identity");
         message.addHeader("Content-Length", "plain wrong");
-        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
     }
 
+    @Test
     public void testEntityWithUnsupportedTransferEncoding() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -78,18 +77,19 @@ public class TestLaxContentLengthStrateg
         message.addHeader("Content-Type", "unknown");
         message.addHeader("Transfer-Encoding", "whatever; param=value, chunked");
         message.addHeader("Content-Length", "plain wrong");
-        assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             lenStrategy.determineLength(message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testChunkedTransferEncodingMustBeLast() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -99,18 +99,19 @@ public class TestLaxContentLengthStrateg
         message.addHeader("Content-Type", "unknown");
         message.addHeader("Transfer-Encoding", "chunked, identity");
         message.addHeader("Content-Length", "plain wrong");
-        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             lenStrategy.determineLength(message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithContentLength() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -119,9 +120,10 @@ public class TestLaxContentLengthStrateg
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
         message.addHeader("Content-Type", "unknown");
         message.addHeader("Content-Length", "0");
-        assertEquals(0, lenStrategy.determineLength(message));
+        Assert.assertEquals(0, lenStrategy.determineLength(message));
     }
 
+    @Test
     public void testEntityWithMultipleContentLength() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -132,18 +134,19 @@ public class TestLaxContentLengthStrateg
         message.addHeader("Content-Length", "0");
         message.addHeader("Content-Length", "0");
         message.addHeader("Content-Length", "1");
-        assertEquals(1, lenStrategy.determineLength(message));
+        Assert.assertEquals(1, lenStrategy.determineLength(message));
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             lenStrategy.determineLength(message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithMultipleContentLengthSomeWrong() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -154,18 +157,19 @@ public class TestLaxContentLengthStrateg
         message.addHeader("Content-Length", "1");
         message.addHeader("Content-Length", "yyy");
         message.addHeader("Content-Length", "xxx");
-        assertEquals(1, lenStrategy.determineLength(message));
+        Assert.assertEquals(1, lenStrategy.determineLength(message));
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             lenStrategy.determineLength(message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithMultipleContentLengthAllWrong() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -175,18 +179,19 @@ public class TestLaxContentLengthStrateg
         message.addHeader("Content-Type", "unknown");
         message.addHeader("Content-Length", "yyy");
         message.addHeader("Content-Length", "xxx");
-        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             lenStrategy.determineLength(message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithInvalidContentLength() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -195,24 +200,25 @@ public class TestLaxContentLengthStrateg
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
         message.addHeader("Content-Type", "unknown");
         message.addHeader("Content-Length", "xxx");
-        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
 
         // strict mode
         message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
         try {
             lenStrategy.determineLength(message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityNeitherContentLengthNorTransferEncoding() throws Exception {
         ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
 
         // lenient mode
-        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java Mon May  9 11:26:57 2011
@@ -27,37 +27,36 @@
 
 package org.apache.http.impl.entity;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpMessage;
 import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolException;
 import org.apache.http.entity.ContentLengthStrategy;
 import org.apache.http.mockup.HttpMessageMockup;
 import org.apache.http.params.CoreProtocolPNames;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestStrictContentLengthStrategy extends TestCase {
-
-    public TestStrictContentLengthStrategy(String testName) {
-        super(testName);
-    }
+public class TestStrictContentLengthStrategy {
 
+    @Test
     public void testEntityWithChunkTransferEncoding() throws Exception {
         ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
         message.addHeader("Transfer-Encoding", "Chunked");
 
-        assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
     }
 
+    @Test
     public void testEntityWithIdentityTransferEncoding() throws Exception {
         ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
         message.addHeader("Transfer-Encoding", "Identity");
 
-        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
     }
 
+    @Test
     public void testEntityWithInvalidTransferEncoding() throws Exception {
         ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -65,12 +64,13 @@ public class TestStrictContentLengthStra
 
         try {
             lenStrategy.determineLength(message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithInvalidChunkEncodingAndHTTP10() throws Exception {
         ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -80,19 +80,21 @@ public class TestStrictContentLengthStra
 
         try {
             lenStrategy.determineLength(message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityWithContentLength() throws Exception {
         ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
         message.addHeader("Content-Length", "100");
-        assertEquals(100, lenStrategy.determineLength(message));
+        Assert.assertEquals(100, lenStrategy.determineLength(message));
     }
 
+    @Test
     public void testEntityWithInvalidContentLength() throws Exception {
         ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
@@ -100,16 +102,17 @@ public class TestStrictContentLengthStra
 
         try {
             lenStrategy.determineLength(message);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEntityNoContentDelimiter() throws Exception {
         ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
         HttpMessage message = new HttpMessageMockup();
-        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
+        Assert.assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
     }
 
 }