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 2010/04/27 20:01:50 UTC

svn commit: r938585 [4/8] - in /httpcomponents/httpclient/trunk: ./ httpclient/src/test/java/org/apache/http/auth/ httpclient/src/test/java/org/apache/http/client/methods/ httpclient/src/test/java/org/apache/http/client/protocol/ httpclient/src/test/ja...

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java Tue Apr 27 18:01:48 2010
@@ -28,18 +28,13 @@ package org.apache.http.impl.client;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
-
-import junit.framework.*;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
- *
  * Simple tests for {@link BasicCredentialsProvider}.
- *
- *
- * @version $Id$
- *
  */
-public class TestBasicCredentialsProvider extends TestCase {
+public class TestBasicCredentialsProvider {
 
     public final static Credentials CREDS1 =
         new UsernamePasswordCredentials("user1", "pass1");
@@ -55,74 +50,58 @@ public class TestBasicCredentialsProvide
     public final static AuthScope DEFSCOPE =
         new AuthScope("host", AuthScope.ANY_PORT, "realm");
 
-
-    // ------------------------------------------------------------ Constructor
-    public TestBasicCredentialsProvider(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestBasicCredentialsProvider.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestBasicCredentialsProvider.class);
-    }
-
-
-    // ----------------------------------------------------------- Test Methods
-
+    @Test
     public void testBasicCredentialsProviderCredentials() {
         BasicCredentialsProvider state = new BasicCredentialsProvider();
         state.setCredentials(SCOPE1, CREDS1);
         state.setCredentials(SCOPE2, CREDS2);
-        assertEquals(CREDS1, state.getCredentials(SCOPE1));
-        assertEquals(CREDS2, state.getCredentials(SCOPE2));
+        Assert.assertEquals(CREDS1, state.getCredentials(SCOPE1));
+        Assert.assertEquals(CREDS2, state.getCredentials(SCOPE2));
     }
 
+    @Test
     public void testBasicCredentialsProviderNoCredentials() {
         BasicCredentialsProvider state = new BasicCredentialsProvider();
-        assertEquals(null, state.getCredentials(BOGUS));
+        Assert.assertEquals(null, state.getCredentials(BOGUS));
     }
 
+    @Test
     public void testBasicCredentialsProviderDefaultCredentials() {
         BasicCredentialsProvider state = new BasicCredentialsProvider();
         state.setCredentials(AuthScope.ANY, CREDS1);
         state.setCredentials(SCOPE2, CREDS2);
-        assertEquals(CREDS1, state.getCredentials(BOGUS));
+        Assert.assertEquals(CREDS1, state.getCredentials(BOGUS));
     }
 
-    // --------------------------------- Test Methods for Selecting Credentials
-
+    @Test
     public void testDefaultCredentials() throws Exception {
         BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials expected = new UsernamePasswordCredentials("name", "pass");
         state.setCredentials(AuthScope.ANY, expected);
         Credentials got = state.getCredentials(DEFSCOPE);
-        assertEquals(got, expected);
+        Assert.assertEquals(got, expected);
     }
 
+    @Test
     public void testRealmCredentials() throws Exception {
         BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials expected = new UsernamePasswordCredentials("name", "pass");
         state.setCredentials(DEFSCOPE, expected);
         Credentials got = state.getCredentials(DEFSCOPE);
-        assertEquals(expected, got);
+        Assert.assertEquals(expected, got);
     }
 
+    @Test
     public void testHostCredentials() throws Exception {
         BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials expected = new UsernamePasswordCredentials("name", "pass");
         state.setCredentials(
             new AuthScope("host", AuthScope.ANY_PORT, AuthScope.ANY_REALM), expected);
         Credentials got = state.getCredentials(DEFSCOPE);
-        assertEquals(expected, got);
+        Assert.assertEquals(expected, got);
     }
 
+    @Test
     public void testWrongHostCredentials() throws Exception {
         BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials expected = new UsernamePasswordCredentials("name", "pass");
@@ -130,9 +109,10 @@ public class TestBasicCredentialsProvide
             new AuthScope("host1", AuthScope.ANY_PORT, "realm"), expected);
         Credentials got = state.getCredentials(
             new AuthScope("host2", AuthScope.ANY_PORT, "realm"));
-        assertNotSame(expected, got);
+        Assert.assertNotSame(expected, got);
     }
 
+    @Test
     public void testWrongRealmCredentials() throws Exception {
         BasicCredentialsProvider state = new BasicCredentialsProvider();
         Credentials cred = new UsernamePasswordCredentials("name", "pass");
@@ -140,46 +120,46 @@ public class TestBasicCredentialsProvide
             new AuthScope("host", AuthScope.ANY_PORT, "realm1"), cred);
         Credentials got = state.getCredentials(
             new AuthScope("host", AuthScope.ANY_PORT, "realm2"));
-        assertNotSame(cred, got);
+        Assert.assertNotSame(cred, got);
     }
 
-    // ------------------------------- Test Methods for matching Credentials
-
+    @Test
     public void testScopeMatching() {
         AuthScope authscope1 = new AuthScope("somehost", 80, "somerealm", "somescheme");
         AuthScope authscope2 = new AuthScope("someotherhost", 80, "somerealm", "somescheme");
-        assertTrue(authscope1.match(authscope2) < 0);
+        Assert.assertTrue(authscope1.match(authscope2) < 0);
 
         int m1 = authscope1.match(
             new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, "somescheme"));
         int m2 = authscope1.match(
             new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "somerealm", AuthScope.ANY_SCHEME));
-        assertTrue(m2 > m1);
+        Assert.assertTrue(m2 > m1);
 
         m1 = authscope1.match(
             new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, "somescheme"));
         m2 = authscope1.match(
             new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "somerealm", AuthScope.ANY_SCHEME));
-        assertTrue(m2 > m1);
+        Assert.assertTrue(m2 > m1);
 
         m1 = authscope1.match(
             new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "somerealm", "somescheme"));
         m2 = authscope1.match(
             new AuthScope(AuthScope.ANY_HOST, 80, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME));
-        assertTrue(m2 > m1);
+        Assert.assertTrue(m2 > m1);
 
         m1 = authscope1.match(
             new AuthScope(AuthScope.ANY_HOST, 80, "somerealm", "somescheme"));
         m2 = authscope1.match(
             new AuthScope("somehost", AuthScope.ANY_PORT, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME));
-        assertTrue(m2 > m1);
+        Assert.assertTrue(m2 > m1);
 
         m1 = authscope1.match(AuthScope.ANY);
         m2 = authscope1.match(
             new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, "somescheme"));
-        assertTrue(m2 > m1);
+        Assert.assertTrue(m2 > m1);
     }
 
+    @Test
     public void testCredentialsMatching() {
         Credentials creds1 = new UsernamePasswordCredentials("name1", "pass1");
         Credentials creds2 = new UsernamePasswordCredentials("name2", "pass2");
@@ -197,16 +177,17 @@ public class TestBasicCredentialsProvide
         Credentials got = state.getCredentials(
             new AuthScope("someotherhost", 80, "someotherrealm", "basic"));
         Credentials expected = creds1;
-        assertEquals(expected, got);
+        Assert.assertEquals(expected, got);
 
         got = state.getCredentials(
             new AuthScope("someotherhost", 80, "somerealm", "basic"));
         expected = creds2;
-        assertEquals(expected, got);
+        Assert.assertEquals(expected, got);
 
         got = state.getCredentials(
             new AuthScope("somehost", 80, "someotherrealm", "basic"));
         expected = creds3;
-        assertEquals(expected, got);
+        Assert.assertEquals(expected, got);
     }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java Tue Apr 27 18:01:48 2010
@@ -28,9 +28,6 @@ package org.apache.http.impl.client;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
@@ -59,27 +56,17 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Unit tests for automatic client authentication.
  */
 public class TestClientAuthentication extends BasicServerTestBase {
 
-    public TestClientAuthentication(final String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestClientAuthentication.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestClientAuthentication.class);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         BasicHttpProcessor httpproc = new BasicHttpProcessor();
         httpproc.addInterceptor(new ResponseDate());
         httpproc.addInterceptor(new ResponseServer());
@@ -136,6 +123,7 @@ public class TestClientAuthentication ex
 
     }
 
+    @Test
     public void testBasicAuthenticationNoCreds() throws Exception {
         localServer.register("*", new AuthHandler());
         localServer.start();
@@ -149,14 +137,15 @@ public class TestClientAuthentication ex
 
         HttpResponse response = httpclient.execute(getServerHttp(), httpget);
         HttpEntity entity = response.getEntity();
-        assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
-        assertNotNull(entity);
+        Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
+        Assert.assertNotNull(entity);
         entity.consumeContent();
         AuthScope authscope = credsProvider.getAuthScope();
-        assertNotNull(authscope);
-        assertEquals("test realm", authscope.getRealm());
+        Assert.assertNotNull(authscope);
+        Assert.assertEquals("test realm", authscope.getRealm());
     }
 
+    @Test
     public void testBasicAuthenticationFailure() throws Exception {
         localServer.register("*", new AuthHandler());
         localServer.start();
@@ -171,14 +160,15 @@ public class TestClientAuthentication ex
 
         HttpResponse response = httpclient.execute(getServerHttp(), httpget);
         HttpEntity entity = response.getEntity();
-        assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
-        assertNotNull(entity);
+        Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
+        Assert.assertNotNull(entity);
         entity.consumeContent();
         AuthScope authscope = credsProvider.getAuthScope();
-        assertNotNull(authscope);
-        assertEquals("test realm", authscope.getRealm());
+        Assert.assertNotNull(authscope);
+        Assert.assertEquals("test realm", authscope.getRealm());
     }
 
+    @Test
     public void testBasicAuthenticationSuccess() throws Exception {
         localServer.register("*", new AuthHandler());
         localServer.start();
@@ -193,14 +183,15 @@ public class TestClientAuthentication ex
 
         HttpResponse response = httpclient.execute(getServerHttp(), httpget);
         HttpEntity entity = response.getEntity();
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertNotNull(entity);
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertNotNull(entity);
         entity.consumeContent();
         AuthScope authscope = credsProvider.getAuthScope();
-        assertNotNull(authscope);
-        assertEquals("test realm", authscope.getRealm());
+        Assert.assertNotNull(authscope);
+        Assert.assertEquals("test realm", authscope.getRealm());
     }
 
+    @Test
     public void testBasicAuthenticationSuccessOnRepeatablePost() throws Exception {
         localServer.register("*", new AuthHandler());
         localServer.start();
@@ -216,14 +207,15 @@ public class TestClientAuthentication ex
 
         HttpResponse response = httpclient.execute(getServerHttp(), httppost);
         HttpEntity entity = response.getEntity();
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertNotNull(entity);
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertNotNull(entity);
         entity.consumeContent();
         AuthScope authscope = credsProvider.getAuthScope();
-        assertNotNull(authscope);
-        assertEquals("test realm", authscope.getRealm());
+        Assert.assertNotNull(authscope);
+        Assert.assertEquals("test realm", authscope.getRealm());
     }
 
+    @Test(expected=ClientProtocolException.class)
     public void testBasicAuthenticationFailureOnNonRepeatablePost() throws Exception {
         localServer.register("*", new AuthHandler());
         localServer.start();
@@ -241,11 +233,12 @@ public class TestClientAuthentication ex
 
         try {
             httpclient.execute(getServerHttp(), httppost);
-            fail("ClientProtocolException should have been thrown");
+            Assert.fail("ClientProtocolException should have been thrown");
         } catch (ClientProtocolException ex) {
             Throwable cause = ex.getCause();
-            assertNotNull(cause);
-            assertTrue(cause instanceof NonRepeatableRequestException);
+            Assert.assertNotNull(cause);
+            Assert.assertTrue(cause instanceof NonRepeatableRequestException);
+            throw ex;
         }
     }
 
@@ -279,6 +272,7 @@ public class TestClientAuthentication ex
 
     }
 
+    @Test
     public void testBasicAuthenticationCredentialsCaching() throws Exception {
         localServer.register("*", new AuthHandler());
         localServer.start();
@@ -299,17 +293,17 @@ public class TestClientAuthentication ex
 
         HttpResponse response1 = httpclient.execute(getServerHttp(), httpget, context);
         HttpEntity entity1 = response1.getEntity();
-        assertEquals(HttpStatus.SC_OK, response1.getStatusLine().getStatusCode());
-        assertNotNull(entity1);
+        Assert.assertEquals(HttpStatus.SC_OK, response1.getStatusLine().getStatusCode());
+        Assert.assertNotNull(entity1);
         entity1.consumeContent();
 
         HttpResponse response2 = httpclient.execute(getServerHttp(), httpget, context);
         HttpEntity entity2 = response1.getEntity();
-        assertEquals(HttpStatus.SC_OK, response2.getStatusLine().getStatusCode());
-        assertNotNull(entity2);
+        Assert.assertEquals(HttpStatus.SC_OK, response2.getStatusLine().getStatusCode());
+        Assert.assertNotNull(entity2);
         entity1.consumeContent();
 
-        assertEquals(1, authHandler.getCount());
+        Assert.assertEquals(1, authHandler.getCount());
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java Tue Apr 27 18:01:48 2010
@@ -44,9 +44,7 @@ import org.apache.http.HeaderElement;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.HttpStatus;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.entity.DeflateDecompressingEntity;
@@ -62,6 +60,8 @@ import org.apache.http.localserver.Serve
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.http.util.EntityUtils;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test case for how Content Codings are processed. By default, we want to do the right thing and
@@ -70,10 +70,6 @@ import org.apache.http.util.EntityUtils;
  */
 public class TestContentCodings extends ServerTestBase {
 
-    public TestContentCodings(String testName) {
-        super(testName);
-    }
-
     /**
      * Test for when we don't get an entity back; e.g. for a 204 or 304 response; nothing blows
      * up with the new behaviour.
@@ -81,6 +77,7 @@ public class TestContentCodings extends 
      * @throws Exception
      *             if there was a problem
      */
+    @Test
     public void testResponseWithNoContent() throws Exception {
         this.localServer.register("*", new HttpRequestHandler() {
 
@@ -99,8 +96,8 @@ public class TestContentCodings extends 
 
         HttpGet request = new HttpGet("/some-resource");
         HttpResponse response = client.execute(getServerHttp(), request);
-        assertEquals(HttpStatus.SC_NO_CONTENT, response.getStatusLine().getStatusCode());
-        assertNull(response.getEntity());
+        Assert.assertEquals(HttpStatus.SC_NO_CONTENT, response.getStatusLine().getStatusCode());
+        Assert.assertNull(response.getEntity());
 
         client.getConnectionManager().shutdown();
     }
@@ -112,6 +109,7 @@ public class TestContentCodings extends 
      * @throws Exception
      * @see DeflateDecompressingEntity
      */
+    @Test
     public void testDeflateSupportForServerReturningRfc1950Stream() throws Exception {
         final String entityText = "Hello, this is some plain text coming back.";
 
@@ -121,7 +119,7 @@ public class TestContentCodings extends 
 
         HttpGet request = new HttpGet("/some-resource");
         HttpResponse response = client.execute(getServerHttp(), request);
-        assertEquals("The entity text is correctly transported", entityText,
+        Assert.assertEquals("The entity text is correctly transported", entityText,
                 EntityUtils.toString(response.getEntity()));
 
         client.getConnectionManager().shutdown();
@@ -134,6 +132,7 @@ public class TestContentCodings extends 
      * @throws Exception
      * @see DeflateDecompressingEntity
      */
+    @Test
     public void testDeflateSupportForServerReturningRfc1951Stream() throws Exception {
         final String entityText = "Hello, this is some plain text coming back.";
 
@@ -142,7 +141,7 @@ public class TestContentCodings extends 
         DefaultHttpClient client = createHttpClient();
         HttpGet request = new HttpGet("/some-resource");
         HttpResponse response = client.execute(getServerHttp(), request);
-        assertEquals("The entity text is correctly transported", entityText,
+        Assert.assertEquals("The entity text is correctly transported", entityText,
                 EntityUtils.toString(response.getEntity()));
 
         client.getConnectionManager().shutdown();
@@ -153,6 +152,7 @@ public class TestContentCodings extends 
      *
      * @throws Exception
      */
+    @Test
     public void testGzipSupport() throws Exception {
         final String entityText = "Hello, this is some plain text coming back.";
 
@@ -161,7 +161,7 @@ public class TestContentCodings extends 
         DefaultHttpClient client = createHttpClient();
         HttpGet request = new HttpGet("/some-resource");
         HttpResponse response = client.execute(getServerHttp(), request);
-        assertEquals("The entity text is correctly transported", entityText,
+        Assert.assertEquals("The entity text is correctly transported", entityText,
                 EntityUtils.toString(response.getEntity()));
 
         client.getConnectionManager().shutdown();
@@ -173,6 +173,7 @@ public class TestContentCodings extends 
      * @throws Exception
      *             if there was a problem
      */
+    @Test
     public void testThreadSafetyOfContentCodings() throws Exception {
         final String entityText = "Hello, this is some plain text coming back.";
 
@@ -216,78 +217,19 @@ public class TestContentCodings extends 
 
         for (WorkerTask workerTask : workers) {
             if (workerTask.isFailed()) {
-                fail("A worker failed");
+                Assert.fail("A worker failed");
             }
-            assertEquals(entityText, workerTask.getText());
+            Assert.assertEquals(entityText, workerTask.getText());
         }
     }
 
     /**
-     * This test is no longer relevant, since the functionality has been added via a new subclass of
-     * {@link DefaultHttpClient} rather than changing the existing class.
-     *
-     * @throws Exception
-     */
-    public void removedTestExistingProtocolInterceptorsAreNotAffected() throws Exception {
-        final String entityText = "Hello, this is some plain text coming back.";
-
-        this.localServer.register("*", createGzipEncodingRequestHandler(entityText));
-
-        DefaultHttpClient client = createHttpClient();
-        HttpGet request = new HttpGet("/some-resource");
-
-        client.addRequestInterceptor(new HttpRequestInterceptor() {
-
-            /**
-             * {@inheritDoc}
-             */
-            public void process(
-                    HttpRequest request, HttpContext context) throws HttpException, IOException {
-                request.addHeader("Accept-Encoding", "gzip");
-            }
-        });
-
-        /* Get around Java The Language's lack of mutable closures */
-        final boolean clientSawGzip[] = new boolean[1];
-
-        client.addResponseInterceptor(new HttpResponseInterceptor() {
-
-            /**
-             * {@inheritDoc}
-             */
-            public void process(
-                    HttpResponse response, HttpContext context) throws HttpException, IOException {
-                HttpEntity entity = response.getEntity();
-                if (entity != null) {
-                    Header ce = entity.getContentEncoding();
-
-                    if (ce != null) {
-                        HeaderElement[] codecs = ce.getElements();
-                        for (int i = 0, n = codecs.length; i < n; ++i) {
-                            if ("gzip".equalsIgnoreCase(codecs[i].getName())) {
-                                clientSawGzip[0] = true;
-                                return;
-                            }
-                        }
-                    }
-                }
-            }
-        });
-
-        client.execute(getServerHttp(), request);
-
-        assertTrue("Client which added the new custom protocol interceptor to handle gzip responses " +
-                "was unaffected.",
-                clientSawGzip[0]);
-
-        client.getConnectionManager().shutdown();
-    }
-    /**
      * Checks that we can turn off the new Content-Coding support. The default is that it's on, but that is a change
      * to existing behaviour and might not be desirable in some situations.
      *
      * @throws Exception
      */
+    @Test
     public void testCanBeDisabledAtRequestTime() throws Exception {
         final String entityText = "Hello, this is some plain text coming back.";
 
@@ -316,8 +258,8 @@ public class TestContentCodings extends 
 
         HttpResponse response = client.execute(getServerHttp(), request);
 
-        assertFalse("The Accept-Encoding header was not there", sawAcceptEncodingHeader[0]);
-        assertEquals("The entity isn't treated as gzip or zip content", entityText,
+        Assert.assertFalse("The Accept-Encoding header was not there", sawAcceptEncodingHeader[0]);
+        Assert.assertEquals("The entity isn't treated as gzip or zip content", entityText,
                 EntityUtils.toString(response.getEntity()));
 
         client.getConnectionManager().shutdown();
@@ -329,6 +271,7 @@ public class TestContentCodings extends 
      *
      * @throws Exception
      */
+    @Test
     public void testHttpEntityWriteToForGzip() throws Exception {
         final String entityText = "Hello, this is some plain text coming back.";
 
@@ -341,7 +284,7 @@ public class TestContentCodings extends 
 
         response.getEntity().writeTo(out);
 
-        assertEquals(entityText, out.toString("utf-8"));
+        Assert.assertEquals(entityText, out.toString("utf-8"));
 
         client.getConnectionManager().shutdown();
     }
@@ -352,6 +295,7 @@ public class TestContentCodings extends 
      *
      * @throws Exception
      */
+    @Test
     public void testHttpEntityWriteToForDeflate() throws Exception {
         final String entityText = "Hello, this is some plain text coming back.";
 
@@ -364,7 +308,7 @@ public class TestContentCodings extends 
 
         response.getEntity().writeTo(out);
 
-        assertEquals(entityText, out.toString("utf-8"));
+        Assert.assertEquals(entityText, out.toString("utf-8"));
 
         client.getConnectionManager().shutdown();
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestCookieIdentityComparator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestCookieIdentityComparator.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestCookieIdentityComparator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestCookieIdentityComparator.java Tue Apr 27 18:01:48 2010
@@ -27,92 +27,75 @@ package org.apache.http.impl.client;
 
 import org.apache.http.cookie.CookieIdentityComparator;
 import org.apache.http.impl.cookie.BasicClientCookie;
-
-import junit.framework.*;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Simple tests for {@link CookieIdentityComparator}.
- *
- * @version $Id:$
  */
-public class TestCookieIdentityComparator extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestCookieIdentityComparator(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestCookieIdentityComparator.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestCookieIdentityComparator.class);
-    }
-
-
-    // ----------------------------------------------------------- Test Methods
+public class TestCookieIdentityComparator {
 
+    @Test
     public void testCookieIdentityComparasionByName() {
         CookieIdentityComparator comparator = new CookieIdentityComparator();
         BasicClientCookie c1 = new BasicClientCookie("name", "value1");
         BasicClientCookie c2 = new BasicClientCookie("name", "value2");
-        assertTrue(comparator.compare(c1, c2) == 0);
+        Assert.assertTrue(comparator.compare(c1, c2) == 0);
 
         BasicClientCookie c3 = new BasicClientCookie("name1", "value");
         BasicClientCookie c4 = new BasicClientCookie("name2", "value");
-        assertFalse(comparator.compare(c3, c4) == 0);
+        Assert.assertFalse(comparator.compare(c3, c4) == 0);
     }
 
+    @Test
     public void testCookieIdentityComparasionByNameAndDomain() {
         CookieIdentityComparator comparator = new CookieIdentityComparator();
         BasicClientCookie c1 = new BasicClientCookie("name", "value1");
         c1.setDomain("www.domain.com");
         BasicClientCookie c2 = new BasicClientCookie("name", "value2");
         c2.setDomain("www.domain.com");
-        assertTrue(comparator.compare(c1, c2) == 0);
+        Assert.assertTrue(comparator.compare(c1, c2) == 0);
 
         BasicClientCookie c3 = new BasicClientCookie("name", "value1");
         c3.setDomain("www.domain.com");
         BasicClientCookie c4 = new BasicClientCookie("name", "value2");
         c4.setDomain("domain.com");
-        assertFalse(comparator.compare(c3, c4) == 0);
+        Assert.assertFalse(comparator.compare(c3, c4) == 0);
     }
 
+    @Test
     public void testCookieIdentityComparasionByNameAndNullDomain() {
         CookieIdentityComparator comparator = new CookieIdentityComparator();
         BasicClientCookie c1 = new BasicClientCookie("name", "value1");
         c1.setDomain(null);
         BasicClientCookie c2 = new BasicClientCookie("name", "value2");
         c2.setDomain(null);
-        assertTrue(comparator.compare(c1, c2) == 0);
+        Assert.assertTrue(comparator.compare(c1, c2) == 0);
 
         BasicClientCookie c3 = new BasicClientCookie("name", "value1");
         c3.setDomain("www.domain.com");
         BasicClientCookie c4 = new BasicClientCookie("name", "value2");
         c4.setDomain(null);
-        assertFalse(comparator.compare(c3, c4) == 0);
+        Assert.assertFalse(comparator.compare(c3, c4) == 0);
     }
 
+    @Test
     public void testCookieIdentityComparasionByNameAndLocalHost() {
         CookieIdentityComparator comparator = new CookieIdentityComparator();
         BasicClientCookie c1 = new BasicClientCookie("name", "value1");
         c1.setDomain("localhost");
         BasicClientCookie c2 = new BasicClientCookie("name", "value2");
         c2.setDomain("localhost");
-        assertTrue(comparator.compare(c1, c2) == 0);
+        Assert.assertTrue(comparator.compare(c1, c2) == 0);
 
         BasicClientCookie c3 = new BasicClientCookie("name", "value1");
         c3.setDomain("localhost.local");
         BasicClientCookie c4 = new BasicClientCookie("name", "value2");
         c4.setDomain("localhost");
-        assertTrue(comparator.compare(c3, c4) == 0);
+        Assert.assertTrue(comparator.compare(c3, c4) == 0);
     }
 
+    @Test
     public void testCookieIdentityComparasionByNameDomainAndPath() {
         CookieIdentityComparator comparator = new CookieIdentityComparator();
         BasicClientCookie c1 = new BasicClientCookie("name", "value1");
@@ -121,7 +104,7 @@ public class TestCookieIdentityComparato
         BasicClientCookie c2 = new BasicClientCookie("name", "value2");
         c2.setDomain("www.domain.com");
         c2.setPath("/whatever");
-        assertTrue(comparator.compare(c1, c2) == 0);
+        Assert.assertTrue(comparator.compare(c1, c2) == 0);
 
         BasicClientCookie c3 = new BasicClientCookie("name", "value1");
         c3.setDomain("www.domain.com");
@@ -129,9 +112,10 @@ public class TestCookieIdentityComparato
         BasicClientCookie c4 = new BasicClientCookie("name", "value2");
         c4.setDomain("domain.com");
         c4.setPath("/whatever-not");
-        assertFalse(comparator.compare(c3, c4) == 0);
+        Assert.assertFalse(comparator.compare(c3, c4) == 0);
     }
 
+    @Test
     public void testCookieIdentityComparasionByNameDomainAndNullPath() {
         CookieIdentityComparator comparator = new CookieIdentityComparator();
         BasicClientCookie c1 = new BasicClientCookie("name", "value1");
@@ -140,7 +124,7 @@ public class TestCookieIdentityComparato
         BasicClientCookie c2 = new BasicClientCookie("name", "value2");
         c2.setDomain("www.domain.com");
         c2.setPath(null);
-        assertTrue(comparator.compare(c1, c2) == 0);
+        Assert.assertTrue(comparator.compare(c1, c2) == 0);
 
         BasicClientCookie c3 = new BasicClientCookie("name", "value1");
         c3.setDomain("www.domain.com");
@@ -148,7 +132,7 @@ public class TestCookieIdentityComparato
         BasicClientCookie c4 = new BasicClientCookie("name", "value2");
         c4.setDomain("domain.com");
         c4.setPath(null);
-        assertFalse(comparator.compare(c3, c4) == 0);
+        Assert.assertFalse(comparator.compare(c3, c4) == 0);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java Tue Apr 27 18:01:48 2010
@@ -32,9 +32,6 @@ import java.util.concurrent.CountDownLat
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.http.Header;
 import org.apache.http.HttpClientConnection;
 import org.apache.http.HttpEntity;
@@ -77,27 +74,17 @@ import org.apache.http.protocol.Executio
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestExecutor;
 import org.apache.http.protocol.HttpRequestHandler;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link DefaultRequestDirector}
  */
 public class TestDefaultClientRequestDirector extends BasicServerTestBase {
 
-    public TestDefaultClientRequestDirector(final String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestDefaultClientRequestDirector.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestDefaultClientRequestDirector.class);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         localServer = new LocalTestServer(null, null);
         localServer.registerDefaultHandlers();
         localServer.start();
@@ -108,6 +95,7 @@ public class TestDefaultClientRequestDir
      * {@link DefaultRequestDirector} is allocating a connection, that the
      * connection is properly aborted.
      */
+    @Test
     public void testAbortInAllocate() throws Exception {
         CountDownLatch connLatch = new CountDownLatch(1);
         CountDownLatch awaitLatch = new CountDownLatch(1);
@@ -130,14 +118,14 @@ public class TestDefaultClientRequestDir
             }
         }).start();
 
-        assertTrue("should have tried to get a connection", connLatch.await(1, TimeUnit.SECONDS));
+        Assert.assertTrue("should have tried to get a connection", connLatch.await(1, TimeUnit.SECONDS));
 
         httpget.abort();
 
-        assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
-        assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
+        Assert.assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
+        Assert.assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
                 throwableRef.get() instanceof IOException);
-        assertTrue("cause should be InterruptedException, was: " + throwableRef.get().getCause(),
+        Assert.assertTrue("cause should be InterruptedException, was: " + throwableRef.get().getCause(),
                 throwableRef.get().getCause() instanceof InterruptedException);
     }
 
@@ -145,6 +133,7 @@ public class TestDefaultClientRequestDir
      * Tests that an abort called after the connection has been retrieved
      * but before a release trigger is set does still abort the request.
      */
+    @Test
     public void testAbortAfterAllocateBeforeRequest() throws Exception {
         this.localServer.register("*", new BasicService());
 
@@ -177,8 +166,8 @@ public class TestDefaultClientRequestDir
 
         releaseLatch.countDown();
 
-        assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
-        assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
+        Assert.assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
+        Assert.assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
                 throwableRef.get() instanceof IOException);
     }
 
@@ -186,6 +175,7 @@ public class TestDefaultClientRequestDir
      * Tests that an abort called completely before execute
      * still aborts the request.
      */
+    @Test
     public void testAbortBeforeExecute() throws Exception {
         this.localServer.register("*", new BasicService());
 
@@ -221,8 +211,8 @@ public class TestDefaultClientRequestDir
         httpget.abort();
         startLatch.countDown();
 
-        assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
-        assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
+        Assert.assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
+        Assert.assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
                 throwableRef.get() instanceof IOException);
     }
 
@@ -231,6 +221,7 @@ public class TestDefaultClientRequestDir
      * still aborts in the correct place (while trying to get the new
      * host's route, not while doing the subsequent request).
      */
+    @Test
     public void testAbortAfterRedirectedRoute() throws Exception {
         final int port = this.localServer.getServiceAddress().getPort();
         this.localServer.register("*", new BasicRedirectService(port));
@@ -260,14 +251,14 @@ public class TestDefaultClientRequestDir
             }
         }).start();
 
-        assertTrue("should have tried to get a connection", connLatch.await(1, TimeUnit.SECONDS));
+        Assert.assertTrue("should have tried to get a connection", connLatch.await(1, TimeUnit.SECONDS));
 
         httpget.abort();
 
-        assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
-        assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
+        Assert.assertTrue("should have finished get request", getLatch.await(1, TimeUnit.SECONDS));
+        Assert.assertTrue("should be instanceof IOException, was: " + throwableRef.get(),
                 throwableRef.get() instanceof IOException);
-        assertTrue("cause should be InterruptedException, was: " + throwableRef.get().getCause(),
+        Assert.assertTrue("cause should be InterruptedException, was: " + throwableRef.get().getCause(),
                 throwableRef.get().getCause() instanceof InterruptedException);
     }
 
@@ -276,6 +267,7 @@ public class TestDefaultClientRequestDir
      * Tests that if a socket fails to connect, the allocated connection is
      * properly released back to the connection manager.
      */
+    @Test
     public void testSocketConnectFailureReleasesConnection() throws Exception {
         final ConnMan2 conMan = new ConnMan2();
         final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
@@ -284,13 +276,14 @@ public class TestDefaultClientRequestDir
 
         try {
             client.execute(httpget, context);
-            fail("expected IOException");
+            Assert.fail("expected IOException");
         } catch(IOException expected) {}
 
-        assertNotNull(conMan.allocatedConnection);
-        assertSame(conMan.allocatedConnection, conMan.releasedConnection);
+        Assert.assertNotNull(conMan.allocatedConnection);
+        Assert.assertSame(conMan.allocatedConnection, conMan.releasedConnection);
     }
 
+    @Test
     public void testRequestFailureReleasesConnection() throws Exception {
         this.localServer.register("*", new ThrowingService());
 
@@ -303,11 +296,11 @@ public class TestDefaultClientRequestDir
 
         try {
             client.execute(getServerHttp(), httpget);
-            fail("expected IOException");
+            Assert.fail("expected IOException");
         } catch (IOException expected) {}
 
-        assertNotNull(conMan.allocatedConnection);
-        assertSame(conMan.allocatedConnection, conMan.releasedConnection);
+        Assert.assertNotNull(conMan.allocatedConnection);
+        Assert.assertSame(conMan.allocatedConnection, conMan.releasedConnection);
     }
 
     private static class ThrowingService implements HttpRequestHandler {
@@ -600,6 +593,7 @@ public class TestDefaultClientRequestDir
         }
     }
 
+    @Test
     public void testDefaultHostAtClientLevel() throws Exception {
         int port = this.localServer.getServiceAddress().getPort();
         this.localServer.register("*", new SimpleService());
@@ -617,9 +611,10 @@ public class TestDefaultClientRequestDir
         if (e != null) {
             e.consumeContent();
         }
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
     }
 
+    @Test
     public void testDefaultHostAtRequestLevel() throws Exception {
         int port = this.localServer.getServiceAddress().getPort();
         this.localServer.register("*", new SimpleService());
@@ -639,7 +634,7 @@ public class TestDefaultClientRequestDir
         if (e != null) {
             e.consumeContent();
         }
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
     }
 
     private static class FaultyHttpRequestExecutor extends HttpRequestExecutor {
@@ -687,7 +682,7 @@ public class TestDefaultClientRequestDir
 
     }
 
-
+    @Test
     public void testAutoGeneratedHeaders() throws Exception {
         int port = this.localServer.getServiceAddress().getPort();
         this.localServer.register("*", new SimpleService());
@@ -729,14 +724,15 @@ public class TestDefaultClientRequestDir
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
 
-        assertTrue(reqWrapper instanceof RequestWrapper);
+        Assert.assertTrue(reqWrapper instanceof RequestWrapper);
         Header[] myheaders = reqWrapper.getHeaders("my-header");
-        assertNotNull(myheaders);
-        assertEquals(1, myheaders.length);
+        Assert.assertNotNull(myheaders);
+        Assert.assertEquals(1, myheaders.length);
     }
 
+    @Test(expected=ClientProtocolException.class)
     public void testNonRepeatableEntity() throws Exception {
         int port = this.localServer.getServiceAddress().getPort();
         this.localServer.register("*", new SimpleService());
@@ -755,12 +751,12 @@ public class TestDefaultClientRequestDir
 
         try {
             client.execute(getServerHttp(), httppost, context);
-            fail("ClientProtocolException should have been thrown");
         } catch (ClientProtocolException ex) {
-            assertTrue(ex.getCause() instanceof NonRepeatableRequestException);
+            Assert.assertTrue(ex.getCause() instanceof NonRepeatableRequestException);
             NonRepeatableRequestException nonRepeat = (NonRepeatableRequestException)ex.getCause();
-            assertTrue(nonRepeat.getCause() instanceof IOException);
-            assertEquals(failureMsg, nonRepeat.getCause().getMessage());
+            Assert.assertTrue(nonRepeat.getCause() instanceof IOException);
+            Assert.assertEquals(failureMsg, nonRepeat.getCause().getMessage());
+            throw ex;
         }
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java Tue Apr 27 18:01:48 2010
@@ -26,10 +26,6 @@
 
 package org.apache.http.impl.client;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
@@ -38,50 +34,32 @@ import org.apache.http.message.BasicHttp
 import org.apache.http.message.BasicStatusLine;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.HttpContext;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  *  Simple tests for {@link DefaultConnectionKeepAliveStrategy}.
- *
  */
-public class TestDefaultConnKeepAliveStrategy extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestDefaultConnKeepAliveStrategy(final String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestDefaultConnKeepAliveStrategy.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestDefaultConnKeepAliveStrategy.class);
-    }
+public class TestDefaultConnKeepAliveStrategy {
 
+    @Test(expected=IllegalArgumentException.class)
     public void testIllegalResponseArg() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
-        try {
-            keepAliveStrat.getKeepAliveDuration(null, context);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }
+        keepAliveStrat.getKeepAliveDuration(null, context);
     }
 
+    @Test
     public void testNoKeepAliveHeader() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(
                 new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"));
         ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
         long d = keepAliveStrat.getKeepAliveDuration(response, context);
-        assertEquals(-1, d);
+        Assert.assertEquals(-1, d);
     }
 
+    @Test
     public void testEmptyKeepAliveHeader() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(
@@ -89,9 +67,10 @@ public class TestDefaultConnKeepAliveStr
         response.addHeader("Keep-Alive", "timeout, max=20");
         ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
         long d = keepAliveStrat.getKeepAliveDuration(response, context);
-        assertEquals(-1, d);
+        Assert.assertEquals(-1, d);
     }
 
+    @Test
     public void testInvalidKeepAliveHeader() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(
@@ -99,9 +78,10 @@ public class TestDefaultConnKeepAliveStr
         response.addHeader("Keep-Alive", "timeout=whatever, max=20");
         ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
         long d = keepAliveStrat.getKeepAliveDuration(response, context);
-        assertEquals(-1, d);
+        Assert.assertEquals(-1, d);
     }
 
+    @Test
     public void testKeepAliveHeader() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(
@@ -109,7 +89,7 @@ public class TestDefaultConnKeepAliveStr
         response.addHeader("Keep-Alive", "timeout=300, max=20");
         ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
         long d = keepAliveStrat.getKeepAliveDuration(response, context);
-        assertEquals(300000, d);
+        Assert.assertEquals(300000, d);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRedirectLocation.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRedirectLocation.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRedirectLocation.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRedirectLocation.java Tue Apr 27 18:01:48 2010
@@ -29,33 +29,15 @@ package org.apache.http.impl.client;
 import java.net.URI;
 import java.util.List;
 
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  *  Simple tests for {@link RedirectLocations}.
  */
-public class TestRedirectLocation extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestRedirectLocation(final String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestRedirectLocation.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestRedirectLocation.class);
-    }
+public class TestRedirectLocation {
 
+    @Test
     public void testBasics() throws Exception {
         RedirectLocations locations = new RedirectLocations();
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java Tue Apr 27 18:01:48 2010
@@ -28,8 +28,6 @@ package org.apache.http.impl.client;
 import java.io.IOException;
 import java.net.UnknownHostException;
 
-import junit.framework.TestCase;
-
 import org.apache.http.client.HttpRequestRetryHandler;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpRequestBase;
@@ -41,9 +39,12 @@ import org.apache.http.impl.conn.SingleC
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.protocol.HttpContext;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestRequestRetryHandler extends TestCase {
+public class TestRequestRetryHandler {
 
+    @Test(expected=UnknownHostException.class)
     public void testUseRetryHandlerInConnectionTimeOutWithThreadSafeClientConnManager()
             throws Exception {
 
@@ -54,6 +55,7 @@ public class TestRequestRetryHandler ext
         assertOnRetry(connManager);
     }
 
+    @Test(expected=UnknownHostException.class)
     public void testUseRetryHandlerInConnectionTimeOutWithSingleClientConnManager()
             throws Exception {
 
@@ -77,7 +79,8 @@ public class TestRequestRetryHandler ext
         try {
             client.execute(request);
         } catch (UnknownHostException ex) {
-            assertEquals(2, testRetryHandler.retryNumber);
+            Assert.assertEquals(2, testRetryHandler.retryNumber);
+            throw ex;
         }
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java Tue Apr 27 18:01:48 2010
@@ -28,9 +28,6 @@ package org.apache.http.impl.client;
 
 import java.io.IOException;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
@@ -44,32 +41,17 @@ import org.apache.http.protocol.BasicHtt
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  *  Simple tests for {@link RequestWrapper}.
- *
  */
 public class TestRequestWrapper extends BasicServerTestBase {
 
-    // ------------------------------------------------------------ Constructor
-    public TestRequestWrapper(final String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestRequestWrapper.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestRequestWrapper.class);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         localServer = new LocalTestServer(null, null);
         localServer.registerDefaultHandlers();
         localServer.start();
@@ -91,6 +73,7 @@ public class TestRequestWrapper extends 
         }
     }
 
+    @Test
     public void testRequestURIRewriting() throws Exception {
         int port = this.localServer.getServiceAddress().getPort();
         this.localServer.register("*", new SimpleService());
@@ -110,12 +93,13 @@ public class TestRequestWrapper extends 
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
 
-        assertTrue(reqWrapper instanceof RequestWrapper);
-        assertEquals("/path", reqWrapper.getRequestLine().getUri());
+        Assert.assertTrue(reqWrapper instanceof RequestWrapper);
+        Assert.assertEquals("/path", reqWrapper.getRequestLine().getUri());
     }
 
+    @Test
     public void testRequestURIRewritingEmptyPath() throws Exception {
         int port = this.localServer.getServiceAddress().getPort();
         this.localServer.register("*", new SimpleService());
@@ -135,10 +119,10 @@ public class TestRequestWrapper extends 
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
 
-        assertTrue(reqWrapper instanceof RequestWrapper);
-        assertEquals("/", reqWrapper.getRequestLine().getUri());
+        Assert.assertTrue(reqWrapper instanceof RequestWrapper);
+        Assert.assertEquals("/", reqWrapper.getRequestLine().getUri());
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java Tue Apr 27 18:01:48 2010
@@ -27,9 +27,6 @@ package org.apache.http.impl.client;
 
 import java.io.IOException;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
@@ -50,25 +47,14 @@ import org.apache.http.protocol.BasicHtt
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link DefaultRequestDirector}
  */
 public class TestStatefulConnManagement extends ServerTestBase {
 
-    public TestStatefulConnManagement(final String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestStatefulConnManagement.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestStatefulConnManagement.class);
-    }
-
     private static class SimpleService implements HttpRequestHandler {
 
         public SimpleService() {
@@ -85,6 +71,7 @@ public class TestStatefulConnManagement 
         }
     }
 
+    @Test
     public void testStatefulConnections() throws Exception {
 
         int workerCount = 5;
@@ -135,7 +122,7 @@ public class TestStatefulConnManagement 
             if (ex != null) {
                 throw ex;
             }
-            assertEquals(requestCount, workers[i].getCount());
+            Assert.assertEquals(requestCount, workers[i].getCount());
         }
 
         for (int i = 0; i < contexts.length; i++) {
@@ -144,8 +131,8 @@ public class TestStatefulConnManagement 
 
             for (int r = 0; r < requestCount; r++) {
                 Integer state = (Integer) context.getAttribute("r" + r);
-                assertNotNull(state);
-                assertEquals(id, state);
+                Assert.assertNotNull(state);
+                Assert.assertEquals(id, state);
             }
         }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java Tue Apr 27 18:01:48 2010
@@ -40,29 +40,15 @@ import org.apache.http.message.BasicLine
 import org.apache.http.mockup.SessionInputBufferMockup;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for <code>DefaultResponseParser</code>.
  */
-public class TestDefaultResponseParser extends TestCase {
-
-    public TestDefaultResponseParser(String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestDefaultResponseParser.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestDefaultResponseParser.class);
-    }
+public class TestDefaultResponseParser {
 
+    @Test
     public void testResponseParsingWithSomeGarbage() throws Exception {
         String s =
             "garbage\r\n" +
@@ -82,17 +68,18 @@ public class TestDefaultResponseParser e
                 params);
 
         HttpResponse response = (HttpResponse) parser.parse();
-        assertNotNull(response);
-        assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
-        assertEquals(200, response.getStatusLine().getStatusCode());
+        Assert.assertNotNull(response);
+        Assert.assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
+        Assert.assertEquals(200, response.getStatusLine().getStatusCode());
 
         Header[] headers = response.getAllHeaders();
-        assertNotNull(headers);
-        assertEquals(2, headers.length);
-        assertEquals("header1", headers[0].getName());
-        assertEquals("header2", headers[1].getName());
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(2, headers.length);
+        Assert.assertEquals("header1", headers[0].getName());
+        Assert.assertEquals("header2", headers[1].getName());
     }
 
+    @Test(expected=ProtocolException.class)
     public void testResponseParsingWithTooMuchGarbage() throws Exception {
         String s =
             "garbage\r\n" +
@@ -111,14 +98,10 @@ public class TestDefaultResponseParser e
                 BasicLineParser.DEFAULT,
                 new DefaultHttpResponseFactory(),
                 params);
-
-        try {
-            parser.parse();
-            fail("ProtocolException should have been thrown");
-        } catch (ProtocolException ex) {
-        }
+        parser.parse();
     }
 
+    @Test(expected=NoHttpResponseException.class)
     public void testResponseParsingNoResponse() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuffer = new SessionInputBufferMockup("", "US-ASCII", params);
@@ -127,14 +110,10 @@ public class TestDefaultResponseParser e
                 BasicLineParser.DEFAULT,
                 new DefaultHttpResponseFactory(),
                 params);
-
-        try {
-            parser.parse();
-            fail("NoHttpResponseException should have been thrown");
-        } catch (NoHttpResponseException ex) {
-        }
+        parser.parse();
     }
 
+    @Test(expected=ProtocolException.class)
     public void testResponseParsingOnlyGarbage() throws Exception {
         String s =
             "garbage\r\n" +
@@ -148,12 +127,7 @@ public class TestDefaultResponseParser e
                 BasicLineParser.DEFAULT,
                 new DefaultHttpResponseFactory(),
                 params);
-
-        try {
-            parser.parse();
-            fail("ProtocolException should have been thrown");
-        } catch (ProtocolException ex) {
-        }
+        parser.parse();
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java Tue Apr 27 18:01:48 2010
@@ -27,9 +27,6 @@
 
 package org.apache.http.impl.conn;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.http.HttpClientConnection;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
@@ -42,7 +39,8 @@ import org.apache.http.localserver.Serve
 import org.apache.http.params.DefaultedHttpParams;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.util.EntityUtils;
-
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * This is more a test for the {@link LocalTestServer LocalTestServer}
@@ -50,21 +48,7 @@ import org.apache.http.util.EntityUtils;
  */
 public class TestLocalServer extends ServerTestBase {
 
-
-    public TestLocalServer(String testName) {
-        super(testName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestLocalServer.class);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestLocalServer.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-
+    @Test
     public void testEcho() throws Exception {
 
         final String  message = "Hello, world!";
@@ -95,16 +79,16 @@ public class TestLocalServer extends Ser
         httpExecutor.postProcess
             (response, httpProcessor, httpContext);
 
-        assertEquals("wrong status in response", HttpStatus.SC_OK,
+        Assert.assertEquals("wrong status in response", HttpStatus.SC_OK,
                      response.getStatusLine().getStatusCode());
 
         String received = EntityUtils.toString(response.getEntity());
         conn.close();
 
-        assertEquals("wrong echo", message, received);
+        Assert.assertEquals("wrong echo", message, received);
     }
 
-
+    @Test
     public void testRandom() throws Exception {
 
         final HttpHost target = getServerHttp();
@@ -140,13 +124,13 @@ public class TestLocalServer extends Ser
             httpExecutor.postProcess
                 (response, httpProcessor, httpContext);
 
-            assertEquals("(" + sizes[i] + ") wrong status in response",
+            Assert.assertEquals("(" + sizes[i] + ") wrong status in response",
                          HttpStatus.SC_OK,
                          response.getStatusLine().getStatusCode());
 
             byte[] data = EntityUtils.toByteArray(response.getEntity());
             if (sizes[i] >= 0)
-                assertEquals("(" + sizes[i] + ") wrong length of response",
+                Assert.assertEquals("(" + sizes[i] + ") wrong length of response",
                              sizes[i], data.length);
             conn.close();
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestProxySelRoutePlanner.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestProxySelRoutePlanner.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestProxySelRoutePlanner.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestProxySelRoutePlanner.java Tue Apr 27 18:01:48 2010
@@ -33,10 +33,6 @@ import java.net.InetSocketAddress;
 import java.util.List;
 import java.util.ArrayList;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpVersion;
@@ -49,25 +45,13 @@ import org.apache.http.conn.scheme.Schem
 import org.apache.http.conn.scheme.SchemeRegistry;
 
 import org.apache.http.mockup.ProxySelectorMockup;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for <code>ProxySelectorRoutePlanner</code>.
  */
-public class TestProxySelRoutePlanner extends TestCase {
-
-    public TestProxySelRoutePlanner(String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestProxySelRoutePlanner.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestProxySelRoutePlanner.class);
-    }
-
+public class TestProxySelRoutePlanner {
 
     /**
      * Instantiates a default scheme registry.
@@ -82,7 +66,7 @@ public class TestProxySelRoutePlanner ex
         return schreg;
     }
 
-
+    @Test
     public void testDirect() throws Exception {
 
         HttpRoutePlanner hrp =
@@ -96,11 +80,11 @@ public class TestProxySelRoutePlanner ex
 
         HttpRoute route = hrp.determineRoute(target, request, null);
 
-        assertEquals("wrong target", target, route.getTargetHost());
-        assertEquals("not direct", 1, route.getHopCount());
+        Assert.assertEquals("wrong target", target, route.getTargetHost());
+        Assert.assertEquals("not direct", 1, route.getHopCount());
     }
 
-
+    @Test
     public void testProxy() throws Exception {
 
         InetAddress ia = InetAddress.getByAddress(new byte[] {
@@ -124,10 +108,10 @@ public class TestProxySelRoutePlanner ex
 
         HttpRoute route = hrp.determineRoute(target, request, null);
 
-        assertEquals("wrong target", target, route.getTargetHost());
-        assertEquals("not via proxy", 2, route.getHopCount());
-        assertEquals("wrong proxy", isa1.getPort(),
+        Assert.assertEquals("wrong target", target, route.getTargetHost());
+        Assert.assertEquals("not via proxy", 2, route.getHopCount());
+        Assert.assertEquals("wrong proxy", isa1.getPort(),
                      route.getProxyHost().getPort());
     }
 
-} // class TestProxySelRoutePlanner
+}

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java Tue Apr 27 18:01:48 2010
@@ -29,9 +29,6 @@ package org.apache.http.impl.conn;
 
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
@@ -44,22 +41,11 @@ import org.apache.http.localserver.Serve
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.util.EntityUtils;
+import org.junit.Assert;
+import org.junit.Test;
 
 public class TestSCMWithServer extends ServerTestBase {
 
-    public TestSCMWithServer(String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestSCMWithServer.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestSCMWithServer.class);
-    }
-
     /**
      * Helper to instantiate a <code>SingleClientConnManager</code>.
      *
@@ -78,6 +64,7 @@ public class TestSCMWithServer extends S
      * Tests that SCM can still connect to the same host after
      * a connection was aborted.
      */
+    @Test
     public void testOpenAfterAbort() throws Exception {
         SingleClientConnManager mgr = createSCCM(null);
 
@@ -85,11 +72,11 @@ public class TestSCMWithServer extends S
         final HttpRoute route = new HttpRoute(target, null, false);
 
         ManagedClientConnection conn = mgr.getConnection(route, null);
-        assertTrue(conn instanceof AbstractClientConnAdapter);
+        Assert.assertTrue(conn instanceof AbstractClientConnAdapter);
         ((AbstractClientConnAdapter) conn).abortConnection();
 
         conn = mgr.getConnection(route, null);
-        assertFalse("connection should have been closed", conn.isOpen());
+        Assert.assertFalse("connection should have been closed", conn.isOpen());
         conn.open(route, httpContext, defaultParams);
 
         mgr.releaseConnection(conn, -1, null);
@@ -99,6 +86,7 @@ public class TestSCMWithServer extends S
     /**
      * Tests releasing with time limits.
      */
+    @Test
     public void testReleaseConnectionWithTimeLimits() throws Exception {
 
         SingleClientConnManager mgr = createSCCM(null);
@@ -119,11 +107,11 @@ public class TestSCMWithServer extends S
                 request, conn, target,
                 httpExecutor, httpProcessor, defaultParams, httpContext);
 
-        assertEquals("wrong status in first response",
+        Assert.assertEquals("wrong status in first response",
                      HttpStatus.SC_OK,
                      response.getStatusLine().getStatusCode());
         byte[] data = EntityUtils.toByteArray(response.getEntity());
-        assertEquals("wrong length of first response entity",
+        Assert.assertEquals("wrong length of first response entity",
                      rsplen, data.length);
         // ignore data, but it must be read
 
@@ -131,7 +119,7 @@ public class TestSCMWithServer extends S
         // expect the next connection obtained to be closed
         mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
         conn = mgr.getConnection(route, null);
-        assertFalse("connection should have been closed", conn.isOpen());
+        Assert.assertFalse("connection should have been closed", conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
         conn.open(route, httpContext, defaultParams);
@@ -139,11 +127,11 @@ public class TestSCMWithServer extends S
         response = httpExecutor.execute(request, conn, httpContext);
         httpExecutor.postProcess(response, httpProcessor, httpContext);
 
-        assertEquals("wrong status in second response",
+        Assert.assertEquals("wrong status in second response",
                      HttpStatus.SC_OK,
                      response.getStatusLine().getStatusCode());
         data = EntityUtils.toByteArray(response.getEntity());
-        assertEquals("wrong length of second response entity",
+        Assert.assertEquals("wrong length of second response entity",
                      rsplen, data.length);
         // ignore data, but it must be read
 
@@ -152,18 +140,18 @@ public class TestSCMWithServer extends S
         conn.markReusable();
         mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
         conn =  mgr.getConnection(route, null);
-        assertTrue("connection should have been open", conn.isOpen());
+        Assert.assertTrue("connection should have been open", conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
         httpContext.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         response = httpExecutor.execute(request, conn, httpContext);
         httpExecutor.postProcess(response, httpProcessor, httpContext);
 
-        assertEquals("wrong status in third response",
+        Assert.assertEquals("wrong status in third response",
                      HttpStatus.SC_OK,
                      response.getStatusLine().getStatusCode());
         data = EntityUtils.toByteArray(response.getEntity());
-        assertEquals("wrong length of third response entity",
+        Assert.assertEquals("wrong length of third response entity",
                      rsplen, data.length);
         // ignore data, but it must be read
 
@@ -171,7 +159,7 @@ public class TestSCMWithServer extends S
         mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
         Thread.sleep(150);
         conn =  mgr.getConnection(route, null);
-        assertTrue("connection should have been closed", !conn.isOpen());
+        Assert.assertTrue("connection should have been closed", !conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
         conn.open(route, httpContext, defaultParams);
@@ -179,18 +167,18 @@ public class TestSCMWithServer extends S
         response = httpExecutor.execute(request, conn, httpContext);
         httpExecutor.postProcess(response, httpProcessor, httpContext);
 
-        assertEquals("wrong status in third response",
+        Assert.assertEquals("wrong status in third response",
                      HttpStatus.SC_OK,
                      response.getStatusLine().getStatusCode());
         data = EntityUtils.toByteArray(response.getEntity());
-        assertEquals("wrong length of fourth response entity",
+        Assert.assertEquals("wrong length of fourth response entity",
                      rsplen, data.length);
         // ignore data, but it must be read
 
         mgr.shutdown();
     }
 
-
+    @Test
     public void testCloseExpiredConnections() throws Exception {
 
         SingleClientConnManager mgr = createSCCM(null);
@@ -205,17 +193,18 @@ public class TestSCMWithServer extends S
         mgr.closeExpiredConnections();
 
         conn = mgr.getConnection(route, null);
-        assertTrue(conn.isOpen());
+        Assert.assertTrue(conn.isOpen());
         mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
 
         Thread.sleep(150);
         mgr.closeExpiredConnections();
         conn = mgr.getConnection(route, null);
-        assertFalse(conn.isOpen());
+        Assert.assertFalse(conn.isOpen());
 
         mgr.shutdown();
     }
 
+    @Test(expected=IllegalStateException.class)
     public void testAlreadyLeased() throws Exception {
 
         SingleClientConnManager mgr = createSCCM(null);
@@ -227,12 +216,7 @@ public class TestSCMWithServer extends S
         mgr.releaseConnection(conn, 100, TimeUnit.MILLISECONDS);
 
         mgr.getConnection(route, null);
-        try {
-            mgr.getConnection(route, null);
-            fail("IllegalStateException should have been thrown");
-        } catch (IllegalStateException ex) {
-            mgr.shutdown();
-        }
+        mgr.getConnection(route, null);
     }
 
 }