hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r938585 [1/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...
Date Tue, 27 Apr 2010 18:01:50 GMT
Author: olegk
Date: Tue Apr 27 18:01:48 2010
New Revision: 938585

URL: http://svn.apache.org/viewvc?rev=938585&view=rev
Log:
Migrated test cases to JUnit 4.x

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestRfc3492Idn.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestExceptions.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestScheme.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/params/TestRouteParams.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/scheme/TestScheme.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookieOrigin.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePathComparator.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/cookie/TestCookiePolicy.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestClientAuthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestCookieIdentityComparator.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRedirectLocation.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestRetryHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultResponseParser.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestLocalServer.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestProxySelRoutePlanner.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestWaitingThread.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestAbstractCookieSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieBestMatchSpec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2965Spec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestDateUtils.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeCookieAttribHandlers.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestNetscapeDraftHeaderParser.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestPublicSuffixListParser.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC2109CookieAttribHandlers.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/BasicServerTestBase.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/localserver/ServerTestBase.java
    httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
    httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
    httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartFormHttpEntity.java
    httpcomponents/httpclient/trunk/pom.xml

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java Tue Apr 27 18:01:48 2010
@@ -32,96 +32,81 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestCredentials extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestCredentials(final String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestCredentials.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestCredentials.class);
-    }
+public class TestCredentials {
 
+    @Test
     public void testUsernamePasswordCredentialsBasics() {
         UsernamePasswordCredentials creds1 = new UsernamePasswordCredentials(
                 "name", "pwd");
-        assertEquals("name", creds1.getUserName());
-        assertEquals(new BasicUserPrincipal("name"),
+        Assert.assertEquals("name", creds1.getUserName());
+        Assert.assertEquals(new BasicUserPrincipal("name"),
                 creds1.getUserPrincipal());
-        assertEquals("pwd", creds1.getPassword());
-        assertEquals("[principal: name]", creds1.toString());
+        Assert.assertEquals("pwd", creds1.getPassword());
+        Assert.assertEquals("[principal: name]", creds1.toString());
         UsernamePasswordCredentials creds2 = new UsernamePasswordCredentials(
                 "name:pwd");
-        assertEquals("name", creds2.getUserName());
-        assertEquals(new BasicUserPrincipal("name"),
+        Assert.assertEquals("name", creds2.getUserName());
+        Assert.assertEquals(new BasicUserPrincipal("name"),
                 creds2.getUserPrincipal());
-        assertEquals("pwd", creds2.getPassword());
-        assertEquals("[principal: name]", creds2.toString());
+        Assert.assertEquals("pwd", creds2.getPassword());
+        Assert.assertEquals("[principal: name]", creds2.toString());
         UsernamePasswordCredentials creds3 = new UsernamePasswordCredentials(
             "name");
-        assertEquals("name", creds3.getUserName());
-        assertEquals(new BasicUserPrincipal("name"),
+        Assert.assertEquals("name", creds3.getUserName());
+        Assert.assertEquals(new BasicUserPrincipal("name"),
                 creds3.getUserPrincipal());
-        assertEquals(null, creds3.getPassword());
-        assertEquals("[principal: name]", creds3.toString());
+        Assert.assertEquals(null, creds3.getPassword());
+        Assert.assertEquals("[principal: name]", creds3.toString());
     }
 
+    @Test
     public void testNTCredentialsBasics() {
         NTCredentials creds1 = new NTCredentials(
                 "name", "pwd", "localhost", "domain");
-        assertEquals("name", creds1.getUserName());
-        assertEquals(new NTUserPrincipal("DOMAIN", "name"),
+        Assert.assertEquals("name", creds1.getUserName());
+        Assert.assertEquals(new NTUserPrincipal("DOMAIN", "name"),
                 creds1.getUserPrincipal());
-        assertEquals("pwd", creds1.getPassword());
-        assertEquals("[principal: DOMAIN/name][workstation: LOCALHOST]",
+        Assert.assertEquals("pwd", creds1.getPassword());
+        Assert.assertEquals("[principal: DOMAIN/name][workstation: LOCALHOST]",
                 creds1.toString());
         NTCredentials creds2 = new NTCredentials(
                 "name", null, null, null);
-        assertEquals("name", creds2.getUserName());
-        assertEquals(new NTUserPrincipal(null, "name"),
+        Assert.assertEquals("name", creds2.getUserName());
+        Assert.assertEquals(new NTUserPrincipal(null, "name"),
                 creds2.getUserPrincipal());
-        assertEquals(null, creds2.getPassword());
-        assertEquals("[principal: name][workstation: null]",
+        Assert.assertEquals(null, creds2.getPassword());
+        Assert.assertEquals("[principal: name][workstation: null]",
                 creds2.toString());
         NTCredentials creds3 = new NTCredentials(
                 "domain/name:pwd");
-        assertEquals("name", creds3.getUserName());
-        assertEquals(new NTUserPrincipal("DOMAIN", "name"),
+        Assert.assertEquals("name", creds3.getUserName());
+        Assert.assertEquals(new NTUserPrincipal("DOMAIN", "name"),
                 creds3.getUserPrincipal());
-        assertEquals("pwd", creds3.getPassword());
-        assertEquals("[principal: DOMAIN/name][workstation: null]",
+        Assert.assertEquals("pwd", creds3.getPassword());
+        Assert.assertEquals("[principal: DOMAIN/name][workstation: null]",
                 creds3.toString());
         NTCredentials creds4 = new NTCredentials(
             "domain/name");
-        assertEquals("name", creds4.getUserName());
-        assertEquals(new NTUserPrincipal("DOMAIN", "name"),
+        Assert.assertEquals("name", creds4.getUserName());
+        Assert.assertEquals(new NTUserPrincipal("DOMAIN", "name"),
                 creds4.getUserPrincipal());
-        assertEquals(null, creds4.getPassword());
-        assertEquals("[principal: DOMAIN/name][workstation: null]",
+        Assert.assertEquals(null, creds4.getPassword());
+        Assert.assertEquals("[principal: DOMAIN/name][workstation: null]",
                 creds4.toString());
         NTCredentials creds5 = new NTCredentials(
             "name");
-        assertEquals("name", creds5.getUserName());
-        assertEquals(new NTUserPrincipal(null, "name"),
+        Assert.assertEquals("name", creds5.getUserName());
+        Assert.assertEquals(new NTUserPrincipal(null, "name"),
                 creds5.getUserPrincipal());
-        assertEquals(null, creds5.getPassword());
-        assertEquals("[principal: name][workstation: null]",
+        Assert.assertEquals(null, creds5.getPassword());
+        Assert.assertEquals("[principal: name][workstation: null]",
                 creds5.toString());
     }
 
+    @Test
     public void testUsernamePasswordCredentialsHashCode() {
         UsernamePasswordCredentials creds1 = new UsernamePasswordCredentials(
                 "name", "pwd");
@@ -130,11 +115,12 @@ public class TestCredentials extends Tes
         UsernamePasswordCredentials creds3 = new UsernamePasswordCredentials(
                 "name", "otherpwd");
 
-        assertTrue(creds1.hashCode() == creds1.hashCode());
-        assertTrue(creds1.hashCode() != creds2.hashCode());
-        assertTrue(creds1.hashCode() == creds3.hashCode());
+        Assert.assertTrue(creds1.hashCode() == creds1.hashCode());
+        Assert.assertTrue(creds1.hashCode() != creds2.hashCode());
+        Assert.assertTrue(creds1.hashCode() == creds3.hashCode());
     }
 
+    @Test
     public void testUsernamePasswordCredentialsEquals() {
         UsernamePasswordCredentials creds1 = new UsernamePasswordCredentials(
                 "name", "pwd");
@@ -143,11 +129,12 @@ public class TestCredentials extends Tes
         UsernamePasswordCredentials creds3 = new UsernamePasswordCredentials(
                 "name", "otherpwd");
 
-        assertTrue(creds1.equals(creds1));
-        assertFalse(creds1.equals(creds2));
-        assertTrue(creds1.equals(creds3));
+        Assert.assertTrue(creds1.equals(creds1));
+        Assert.assertFalse(creds1.equals(creds2));
+        Assert.assertTrue(creds1.equals(creds3));
     }
 
+    @Test
     public void testNTCredentialsHashCode() {
         NTCredentials creds1 = new NTCredentials(
                 "name", "pwd", "somehost", "domain");
@@ -168,17 +155,18 @@ public class TestCredentials extends Tes
         NTCredentials creds9 = new NTCredentials(
                 "name", "pwd", "somehost", null);
 
-        assertTrue(creds1.hashCode() == creds1.hashCode());
-        assertTrue(creds1.hashCode() != creds2.hashCode());
-        assertTrue(creds1.hashCode() == creds3.hashCode());
-        assertFalse(creds1.hashCode() == creds4.hashCode());
-        assertFalse(creds1.hashCode() == creds5.hashCode());
-        assertFalse(creds1.hashCode() == creds6.hashCode());
-        assertFalse(creds1.hashCode() == creds7.hashCode());
-        assertTrue(creds8.hashCode() == creds5.hashCode());
-        assertTrue(creds9.hashCode() == creds7.hashCode());
+        Assert.assertTrue(creds1.hashCode() == creds1.hashCode());
+        Assert.assertTrue(creds1.hashCode() != creds2.hashCode());
+        Assert.assertTrue(creds1.hashCode() == creds3.hashCode());
+        Assert.assertFalse(creds1.hashCode() == creds4.hashCode());
+        Assert.assertFalse(creds1.hashCode() == creds5.hashCode());
+        Assert.assertFalse(creds1.hashCode() == creds6.hashCode());
+        Assert.assertFalse(creds1.hashCode() == creds7.hashCode());
+        Assert.assertTrue(creds8.hashCode() == creds5.hashCode());
+        Assert.assertTrue(creds9.hashCode() == creds7.hashCode());
     }
 
+    @Test
     public void testNTCredentialsEquals() {
         NTCredentials creds1 = new NTCredentials(
                 "name", "pwd", "somehost", "domain");
@@ -199,18 +187,19 @@ public class TestCredentials extends Tes
         NTCredentials creds9 = new NTCredentials(
                 "name", "pwd", "somehost", null);
 
-        assertTrue(creds1.equals(creds1));
-        assertFalse(creds1.equals(creds2));
-        assertTrue(creds1.equals(creds3));
-        assertFalse(creds1.equals(creds4));
-        assertFalse(creds1.equals(creds5));
-        assertFalse(creds1.equals(creds6));
-        assertFalse(creds1.equals(creds7));
-        assertTrue(creds8.equals(creds5));
-        assertTrue(creds9.equals(creds7));
+        Assert.assertTrue(creds1.equals(creds1));
+        Assert.assertFalse(creds1.equals(creds2));
+        Assert.assertTrue(creds1.equals(creds3));
+        Assert.assertFalse(creds1.equals(creds4));
+        Assert.assertFalse(creds1.equals(creds5));
+        Assert.assertFalse(creds1.equals(creds6));
+        Assert.assertFalse(creds1.equals(creds7));
+        Assert.assertTrue(creds8.equals(creds5));
+        Assert.assertTrue(creds9.equals(creds7));
 
     }
 
+    @Test
     public void testUsernamePasswordCredentialsSerialization() throws Exception {
         UsernamePasswordCredentials orig = new UsernamePasswordCredentials("name", "pwd");
         ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
@@ -221,9 +210,10 @@ public class TestCredentials extends Tes
         ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
         ObjectInputStream instream = new ObjectInputStream(inbuffer);
         UsernamePasswordCredentials clone = (UsernamePasswordCredentials) instream.readObject();
-        assertEquals(orig, clone);
+        Assert.assertEquals(orig, clone);
     }
 
+    @Test
     public void testNTCredentialsSerialization() throws Exception {
         NTCredentials orig = new NTCredentials("name", "pwd", "somehost", "domain");
         ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
@@ -234,7 +224,7 @@ public class TestCredentials extends Tes
         ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
         ObjectInputStream instream = new ObjectInputStream(inbuffer);
         NTCredentials clone = (NTCredentials) instream.readObject();
-        assertEquals(orig, clone);
+        Assert.assertEquals(orig, clone);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java Tue Apr 27 18:01:48 2010
@@ -29,33 +29,15 @@ package org.apache.http.client.methods;
 
 import java.util.Set;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 import org.apache.http.ProtocolVersion;
 import org.apache.http.message.BasicHttpResponse;
 import org.apache.http.message.BasicStatusLine;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestHttpOptions extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestHttpOptions(final String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestHttpOptions.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestHttpOptions.class);
-    }
+public class TestHttpOptions {
 
+    @Test
     public void testMultipleAllows() {
         ProtocolVersion proto = new ProtocolVersion("HTTP", 1, 1);
         BasicStatusLine line = new BasicStatusLine(proto, 200, "test reason");
@@ -66,8 +48,8 @@ public class TestHttpOptions extends Tes
         HttpOptions opt = new HttpOptions();
         Set<String> methodsName = opt.getAllowedMethods(resp);
 
-        assertTrue(methodsName.contains("POST"));
-        assertTrue(methodsName.contains("GET"));
+        Assert.assertTrue(methodsName.contains("POST"));
+        Assert.assertTrue(methodsName.contains("GET"));
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java Tue Apr 27 18:01:48 2010
@@ -35,44 +35,28 @@ import org.apache.http.entity.InputStrea
 import org.apache.http.entity.StringEntity;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.util.LangUtils;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class TestHttpRequestBase extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestHttpRequestBase(final String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestHttpRequestBase.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestHttpRequestBase.class);
-    }
+public class TestHttpRequestBase {
 
+    @Test
     public void testBasicProperties() throws Exception {
         HttpGet httpget = new HttpGet("http://host/path");
         httpget.getParams().setParameter(
                 HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_0);
-        assertEquals("GET", httpget.getRequestLine().getMethod());
-        assertEquals("http://host/path", httpget.getRequestLine().getUri());
-        assertEquals(HttpVersion.HTTP_1_0, httpget.getRequestLine().getProtocolVersion());
+        Assert.assertEquals("GET", httpget.getRequestLine().getMethod());
+        Assert.assertEquals("http://host/path", httpget.getRequestLine().getUri());
+        Assert.assertEquals(HttpVersion.HTTP_1_0, httpget.getRequestLine().getProtocolVersion());
     }
 
+    @Test
     public void testEmptyURI() throws Exception {
         HttpGet httpget = new HttpGet("");
-        assertEquals("/", httpget.getRequestLine().getUri());
+        Assert.assertEquals("/", httpget.getRequestLine().getUri());
     }
 
+    @Test
     public void testCloneBasicRequests() throws Exception {
         HttpGet httpget = new HttpGet("http://host/path");
         httpget.addHeader("h1", "this header");
@@ -82,20 +66,21 @@ public class TestHttpRequestBase extends
         httpget.getParams().setParameter("p2", "whatever");
         HttpGet clone = (HttpGet) httpget.clone();
 
-        assertEquals(httpget.getMethod(), clone.getMethod());
-        assertEquals(httpget.getURI(), clone.getURI());
+        Assert.assertEquals(httpget.getMethod(), clone.getMethod());
+        Assert.assertEquals(httpget.getURI(), clone.getURI());
 
         Header[] headers1 = httpget.getAllHeaders();
         Header[] headers2 = clone.getAllHeaders();
 
-        assertTrue(LangUtils.equals(headers1, headers2));
-        assertTrue(httpget.getParams() != clone.getParams());
+        Assert.assertTrue(LangUtils.equals(headers1, headers2));
+        Assert.assertTrue(httpget.getParams() != clone.getParams());
 
-        assertEquals(Integer.valueOf(1), clone.getParams().getParameter("p1"));
-        assertEquals("whatever", clone.getParams().getParameter("p2"));
-        assertEquals(null, clone.getParams().getParameter("p3"));
+        Assert.assertEquals(Integer.valueOf(1), clone.getParams().getParameter("p1"));
+        Assert.assertEquals("whatever", clone.getParams().getParameter("p2"));
+        Assert.assertEquals(null, clone.getParams().getParameter("p3"));
     }
 
+    @Test
     public void testCloneEntityEnclosingRequests() throws Exception {
         HttpPost httppost = new HttpPost("http://host/path");
         httppost.addHeader("h1", "this header");
@@ -105,35 +90,35 @@ public class TestHttpRequestBase extends
         httppost.getParams().setParameter("p2", "whatever");
         HttpPost clone = (HttpPost) httppost.clone();
 
-        assertEquals(httppost.getMethod(), clone.getMethod());
-        assertEquals(httppost.getURI(), clone.getURI());
+        Assert.assertEquals(httppost.getMethod(), clone.getMethod());
+        Assert.assertEquals(httppost.getURI(), clone.getURI());
 
         Header[] headers1 = httppost.getAllHeaders();
         Header[] headers2 = clone.getAllHeaders();
 
-        assertTrue(LangUtils.equals(headers1, headers2));
-        assertTrue(httppost.getParams() != clone.getParams());
+        Assert.assertTrue(LangUtils.equals(headers1, headers2));
+        Assert.assertTrue(httppost.getParams() != clone.getParams());
 
-        assertEquals(Integer.valueOf(1), clone.getParams().getParameter("p1"));
-        assertEquals("whatever", clone.getParams().getParameter("p2"));
-        assertEquals(null, clone.getParams().getParameter("p3"));
+        Assert.assertEquals(Integer.valueOf(1), clone.getParams().getParameter("p1"));
+        Assert.assertEquals("whatever", clone.getParams().getParameter("p2"));
+        Assert.assertEquals(null, clone.getParams().getParameter("p3"));
 
-        assertNull(clone.getEntity());
+        Assert.assertNull(clone.getEntity());
 
         StringEntity e1 = new StringEntity("stuff");
         httppost.setEntity(e1);
         clone = (HttpPost) httppost.clone();
-        assertTrue(clone.getEntity() instanceof StringEntity);
-        assertFalse(clone.getEntity().equals(e1));
+        Assert.assertTrue(clone.getEntity() instanceof StringEntity);
+        Assert.assertFalse(clone.getEntity().equals(e1));
+    }
 
+    @Test(expected=CloneNotSupportedException.class)
+    public void testCloneStreamingEntityEnclosingRequests() throws Exception {
         ByteArrayInputStream instream = new ByteArrayInputStream(new byte[] {});
         InputStreamEntity e2 = new InputStreamEntity(instream, -1);
+        HttpPost httppost = new HttpPost("http://host/path");
         httppost.setEntity(e2);
-
-        try {
-            httppost.clone();
-            fail("CloneNotSupportedException should have been thrown");
-        } catch (CloneNotSupportedException expected) {
-        }
+        httppost.clone();
     }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java Tue Apr 27 18:01:48 2010
@@ -28,9 +28,6 @@ package org.apache.http.client.protocol;
 import java.io.IOException;
 import java.util.List;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
@@ -55,32 +52,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;
 
 /**
  * Cookie2 support tests.
- *
  */
 public class TestCookie2Support extends BasicServerTestBase {
 
-    // ------------------------------------------------------------ Constructor
-    public TestCookie2Support(final String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestCookie2Support.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestCookie2Support.class);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         localServer = new LocalTestServer(null, null);
         localServer.registerDefaultHandlers();
         localServer.start();
@@ -101,6 +83,7 @@ public class TestCookie2Support extends 
 
     }
 
+    @Test
     public void testCookieVersionSupportHeader1() throws Exception {
         this.localServer.register("*", new CookieVer0Service());
 
@@ -120,8 +103,8 @@ public class TestCookie2Support extends 
         }
 
         List<Cookie> cookies = cookieStore.getCookies();
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
 
         HttpResponse response2 = client.execute(getServerHttp(), httpget, context);
         HttpEntity e2 = response2.getEntity();
@@ -132,8 +115,8 @@ public class TestCookie2Support extends 
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
 
         Header cookiesupport = reqWrapper.getFirstHeader("Cookie2");
-        assertNotNull(cookiesupport);
-        assertEquals("$Version=1", cookiesupport.getValue());
+        Assert.assertNotNull(cookiesupport);
+        Assert.assertEquals("$Version=1", cookiesupport.getValue());
     }
 
     private static class CookieVer1Service implements HttpRequestHandler {
@@ -152,6 +135,7 @@ public class TestCookie2Support extends 
 
     }
 
+    @Test
     public void testCookieVersionSupportHeader2() throws Exception {
         this.localServer.register("*", new CookieVer1Service());
 
@@ -171,8 +155,8 @@ public class TestCookie2Support extends 
         }
 
         List<Cookie> cookies = cookieStore.getCookies();
-        assertNotNull(cookies);
-        assertEquals(2, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(2, cookies.size());
 
         HttpResponse response2 = client.execute(getServerHttp(), httpget, context);
         HttpEntity e2 = response2.getEntity();
@@ -183,8 +167,8 @@ public class TestCookie2Support extends 
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
 
         Header cookiesupport = reqWrapper.getFirstHeader(SM.COOKIE2);
-        assertNotNull(cookiesupport);
-        assertEquals("$Version=1", cookiesupport.getValue());
+        Assert.assertNotNull(cookiesupport);
+        Assert.assertEquals("$Version=1", cookiesupport.getValue());
     }
 
     private static class CookieVer2Service implements HttpRequestHandler {
@@ -202,6 +186,7 @@ public class TestCookie2Support extends 
 
     }
 
+    @Test
     public void testCookieVersionSupportHeader3() throws Exception {
         this.localServer.register("*", new CookieVer2Service());
 
@@ -221,8 +206,8 @@ public class TestCookie2Support extends 
         }
 
         List<Cookie> cookies = cookieStore.getCookies();
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
 
         HttpResponse response2 = client.execute(getServerHttp(), httpget, context);
         HttpEntity e2 = response2.getEntity();
@@ -233,8 +218,8 @@ public class TestCookie2Support extends 
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
 
         Header cookiesupport = reqWrapper.getFirstHeader("Cookie2");
-        assertNotNull(cookiesupport);
-        assertEquals("$Version=1", cookiesupport.getValue());
+        Assert.assertNotNull(cookiesupport);
+        Assert.assertEquals("$Version=1", cookiesupport.getValue());
     }
 
     private static class SetCookieVersionMixService implements HttpRequestHandler {
@@ -253,6 +238,7 @@ public class TestCookie2Support extends 
 
     }
 
+    @Test
     public void testSetCookieVersionMix() throws Exception {
         this.localServer.register("*", new SetCookieVersionMixService());
 
@@ -272,10 +258,10 @@ public class TestCookie2Support extends 
         }
 
         List<Cookie> cookies = cookieStore.getCookies();
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
-        assertEquals("right", cookies.get(0).getValue());
-        assertTrue(cookies.get(0) instanceof SetCookie2);
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
+        Assert.assertEquals("right", cookies.get(0).getValue());
+        Assert.assertTrue(cookies.get(0) instanceof SetCookie2);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRedirects.java Tue Apr 27 18:01:48 2010
@@ -60,35 +60,17 @@ import org.apache.http.protocol.Executio
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Redirection test cases.
- *
  */
 public class TestRedirects extends BasicServerTestBase {
 
-    // ------------------------------------------------------------ Constructor
-    public TestRedirects(final String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------------------- Main
-    public static void main(String args[]) {
-        String[] testCaseName = { TestRedirects.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestRedirects.class);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         localServer = new LocalTestServer(null, null);
         localServer.registerDefaultHandlers();
         localServer.start();
@@ -235,6 +217,7 @@ public class TestRedirects extends Basic
         }
     }
 
+    @Test
     public void testBasicRedirect300() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -256,10 +239,11 @@ public class TestRedirects extends Basic
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_MULTIPLE_CHOICES, response.getStatusLine().getStatusCode());
-        assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(HttpStatus.SC_MULTIPLE_CHOICES, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
     }
 
+    @Test
     public void testBasicRedirect301() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -283,12 +267,13 @@ public class TestRedirects extends Basic
         HttpHost targetHost = (HttpHost) context.getAttribute(
                 ExecutionContext.HTTP_TARGET_HOST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
-        assertEquals(host, targetHost.getHostName());
-        assertEquals(port, targetHost.getPort());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(host, targetHost.getHostName());
+        Assert.assertEquals(port, targetHost.getPort());
     }
 
+    @Test
     public void testBasicRedirect302() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -312,12 +297,13 @@ public class TestRedirects extends Basic
         HttpHost targetHost = (HttpHost) context.getAttribute(
                 ExecutionContext.HTTP_TARGET_HOST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
-        assertEquals(host, targetHost.getHostName());
-        assertEquals(port, targetHost.getPort());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(host, targetHost.getHostName());
+        Assert.assertEquals(port, targetHost.getPort());
     }
 
+    @Test
     public void testBasicRedirect303() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -341,12 +327,13 @@ public class TestRedirects extends Basic
         HttpHost targetHost = (HttpHost) context.getAttribute(
                 ExecutionContext.HTTP_TARGET_HOST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
-        assertEquals(host, targetHost.getHostName());
-        assertEquals(port, targetHost.getPort());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(host, targetHost.getHostName());
+        Assert.assertEquals(port, targetHost.getPort());
     }
 
+    @Test
     public void testBasicRedirect304() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -368,10 +355,11 @@ public class TestRedirects extends Basic
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_NOT_MODIFIED, response.getStatusLine().getStatusCode());
-        assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(HttpStatus.SC_NOT_MODIFIED, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
     }
 
+    @Test
     public void testBasicRedirect305() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -393,10 +381,11 @@ public class TestRedirects extends Basic
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_USE_PROXY, response.getStatusLine().getStatusCode());
-        assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(HttpStatus.SC_USE_PROXY, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
     }
 
+    @Test
     public void testBasicRedirect307() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -420,12 +409,13 @@ public class TestRedirects extends Basic
         HttpHost targetHost = (HttpHost) context.getAttribute(
                 ExecutionContext.HTTP_TARGET_HOST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
-        assertEquals(host, targetHost.getHostName());
-        assertEquals(port, targetHost.getPort());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(host, targetHost.getHostName());
+        Assert.assertEquals(port, targetHost.getPort());
     }
 
+    @Test(expected=ClientProtocolException.class)
     public void testMaxRedirectCheck() throws Exception {
         this.localServer.register("*", new CircularRedirectService());
 
@@ -434,15 +424,15 @@ public class TestRedirects extends Basic
         client.getParams().setIntParameter(ClientPNames.MAX_REDIRECTS, 5);
 
         HttpGet httpget = new HttpGet("/circular-oldlocation/");
-
         try {
             client.execute(getServerHttp(), httpget);
-            fail("ClientProtocolException exception should have been thrown");
         } catch (ClientProtocolException e) {
-            assertTrue(e.getCause() instanceof RedirectException);
+            Assert.assertTrue(e.getCause() instanceof RedirectException);
+            throw e;
         }
     }
 
+    @Test(expected=ClientProtocolException.class)
     public void testCircularRedirect() throws Exception {
         this.localServer.register("*", new CircularRedirectService());
 
@@ -453,12 +443,13 @@ public class TestRedirects extends Basic
 
         try {
             client.execute(getServerHttp(), httpget);
-            fail("ClientProtocolException exception should have been thrown");
         } catch (ClientProtocolException e) {
-            assertTrue(e.getCause() instanceof CircularRedirectException);
+            Assert.assertTrue(e.getCause() instanceof CircularRedirectException);
+            throw e;
         }
     }
 
+    @Test
     public void testPostNoRedirect() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -480,11 +471,12 @@ public class TestRedirects extends Basic
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, response.getStatusLine().getStatusCode());
-        assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
-        assertEquals("POST", reqWrapper.getRequestLine().getMethod());
+        Assert.assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals("POST", reqWrapper.getRequestLine().getMethod());
     }
 
+    @Test
     public void testPostRedirectSeeOther() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -507,11 +499,12 @@ public class TestRedirects extends Basic
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
-        assertEquals("GET", reqWrapper.getRequestLine().getMethod());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals("GET", reqWrapper.getRequestLine().getMethod());
     }
 
+    @Test
     public void testRelativeRedirect() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -536,12 +529,13 @@ public class TestRedirects extends Basic
         HttpHost targetHost = (HttpHost) context.getAttribute(
                 ExecutionContext.HTTP_TARGET_HOST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals("/relativelocation/", reqWrapper.getRequestLine().getUri());
-        assertEquals(host, targetHost.getHostName());
-        assertEquals(port, targetHost.getPort());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/relativelocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(host, targetHost.getHostName());
+        Assert.assertEquals(port, targetHost.getPort());
     }
 
+    @Test
     public void testRelativeRedirect2() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -566,12 +560,13 @@ public class TestRedirects extends Basic
         HttpHost targetHost = (HttpHost) context.getAttribute(
                 ExecutionContext.HTTP_TARGET_HOST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals("/test/relativelocation", reqWrapper.getRequestLine().getUri());
-        assertEquals(host, targetHost.getHostName());
-        assertEquals(port, targetHost.getPort());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/test/relativelocation", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(host, targetHost.getHostName());
+        Assert.assertEquals(port, targetHost.getPort());
     }
 
+    @Test(expected=ClientProtocolException.class)
     public void testRejectRelativeRedirect() throws Exception {
         this.localServer.register("*", new RelativeRedirectService());
 
@@ -583,13 +578,13 @@ public class TestRedirects extends Basic
 
         try {
             client.execute(getServerHttp(), httpget);
-            fail("ClientProtocolException exception should have been thrown");
         } catch (ClientProtocolException e) {
-            assertTrue(e.getCause() instanceof ProtocolException);
-            // expected
+            Assert.assertTrue(e.getCause() instanceof ProtocolException);
+            throw e;
         }
     }
 
+    @Test(expected=IllegalStateException.class)
     public void testRejectBogusRedirectLocation() throws Exception {
         this.localServer.register("*", new BogusRedirectService("xxx://bogus"));
 
@@ -597,14 +592,10 @@ public class TestRedirects extends Basic
 
         HttpGet httpget = new HttpGet("/oldlocation/");
 
-        try {
-            client.execute(getServerHttp(), httpget);
-            fail("IllegalStateException should have been thrown");
-        } catch (IllegalStateException e) {
-            // expected
-        }
+        client.execute(getServerHttp(), httpget);
     }
 
+    @Test(expected=ClientProtocolException.class)
     public void testRejectInvalidRedirectLocation() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -618,13 +609,13 @@ public class TestRedirects extends Basic
 
         try {
             client.execute(getServerHttp(), httpget);
-            fail("ClientProtocolException should have been thrown");
         } catch (ClientProtocolException e) {
-            assertTrue(e.getCause() instanceof ProtocolException);
-            // expected
+            Assert.assertTrue(e.getCause() instanceof ProtocolException);
+            throw e;
         }
     }
 
+    @Test
     public void testRedirectWithCookie() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -657,13 +648,14 @@ public class TestRedirects extends Basic
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
 
         Header[] headers = reqWrapper.getHeaders(SM.COOKIE);
-        assertEquals("There can only be one (cookie)", 1, headers.length);
+        Assert.assertEquals("There can only be one (cookie)", 1, headers.length);
     }
 
+    @Test
     public void testDefaultHeadersRedirect() throws Exception {
         InetSocketAddress address = this.localServer.getServiceAddress();
         int port = address.getPort();
@@ -692,11 +684,11 @@ public class TestRedirects extends Basic
         HttpRequest reqWrapper = (HttpRequest) context.getAttribute(
                 ExecutionContext.HTTP_REQUEST);
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
 
         Header header = reqWrapper.getFirstHeader(HTTP.USER_AGENT);
-        assertEquals("my-test-client", header.getValue());
+        Assert.assertEquals("my-test-client", header.getValue());
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestUriEscapes.java Tue Apr 27 18:01:48 2010
@@ -29,9 +29,6 @@ package org.apache.http.client.protocol;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
@@ -45,24 +42,14 @@ import org.apache.http.localserver.Basic
 import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 public class TestUriEscapes extends BasicServerTestBase {
 
-    public TestUriEscapes(final String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestUriEscapes.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestUriEscapes.class);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         localServer = new LocalTestServer(null, null);
         localServer.registerDefaultHandlers();
         localServer.start();
@@ -110,55 +97,68 @@ public class TestUriEscapes extends Basi
             response.getEntity().consumeContent();
         }
 
-        assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
-        assertEquals(uri, listener.getRequestedUri());
+        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
+        Assert.assertEquals(uri, listener.getRequestedUri());
     }
 
+    @Test
     public void testEscapedAmpersandInQueryAbsolute() throws Exception {
         doTest("/path/a=b&c=%26d", false);
     }
 
+    @Test
     public void testEscapedAmpersandInQueryRelative() throws Exception {
         doTest("/path/a=b&c=%26d", true);
     }
 
+    @Test
     public void testPlusInPathAbsolute() throws Exception {
         doTest("/path+go", false);
     }
 
+    @Test
     public void testPlusInPathRelative() throws Exception {
         doTest("/path+go", true);
     }
 
+    @Test
     public void testEscapedSpaceInPathAbsolute() throws Exception {
         doTest("/path%20go?a=b&c=d", false);
     }
 
+    @Test
     public void testEscapedSpaceInPathRelative() throws Exception {
         doTest("/path%20go?a=b&c=d", true);
     }
 
+    @Test
     public void testEscapedAmpersandInPathAbsolute() throws Exception {
         doTest("/this%26that?a=b&c=d", false);
     }
 
+    @Test
     public void testEscapedAmpersandInPathRelative() throws Exception {
         doTest("/this%26that?a=b&c=d", true);
     }
 
+    @Test
     public void testEscapedSpaceInQueryAbsolute() throws Exception {
         doTest("/path?a=b&c=d%20e", false);
     }
 
+    @Test
     public void testEscapedSpaceInQueryRelative() throws Exception {
         doTest("/path?a=b&c=d%20e", true);
     }
 
+    @Test
     public void testPlusInQueryAbsolute() throws Exception {
         doTest("/path?a=b&c=d+e", false);
     }
 
+    @Test
     public void testPlusInQueryRelative() throws Exception {
         doTest("/path?a=b&c=d+e", true);
     }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestRfc3492Idn.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestRfc3492Idn.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestRfc3492Idn.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestRfc3492Idn.java Tue Apr 27 18:01:48 2010
@@ -27,65 +27,54 @@
 package org.apache.http.client.utils;
 
 import org.apache.http.client.utils.Rfc3492Idn;
+import org.junit.Assert;
+import org.junit.Test;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class TestRfc3492Idn extends TestCase {
-    public TestRfc3492Idn(String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestRfc3492Idn.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestRfc3492Idn.class);
-    }
+public class TestRfc3492Idn {
 
     /**
      * Some of the sample strings from RFC 3492
      */
+    @Test
     public void testDecode() throws Exception {
         Rfc3492Idn idn = new Rfc3492Idn();
         // (A) Arabic
-        assertEquals("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" +
+        Assert.assertEquals("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" +
                      "\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F",
                      idn.decode("egbpdaj6bu4bxfgehfvwxn"));
 
         // (B) Chinese (simplified)
-        assertEquals("\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587",
+        Assert.assertEquals("\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587",
                      idn.decode("ihqwcrb4cv8a8dqg056pqjye"));
 
         // (I) Russian (Cyrillic)
-        assertEquals("\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E"+
+        Assert.assertEquals("\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E"+
                      "\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440"+
                      "\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A"+
                      "\u0438",
                      idn.decode("b1abfaaepdrnnbgefbaDotcwatmq2g4l"));
 
         // (P) Maji<de>Koi<suru>5<byou><mae>
-        assertEquals("\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059" +
+        Assert.assertEquals("\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059" +
                      "\u308B\u0035\u79D2\u524D",
                      idn.decode("MajiKoi5-783gue6qz075azm5e"));
 
     }
 
+    @Test
     public void testToUnicode() throws Exception {
         Rfc3492Idn idn = new Rfc3492Idn();
         // (A) Arabic
-        assertEquals("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" +
+        Assert.assertEquals("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" +
                      "\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F",
                      idn.toUnicode("xn--egbpdaj6bu4bxfgehfvwxn"));
 
         // some real-world domains
-        assertEquals("www.z\u00fcrich.ch",
+        Assert.assertEquals("www.z\u00fcrich.ch",
                      idn.toUnicode("www.xn--zrich-kva.ch"));
 
-        assertEquals("www.g\u00e4ggelig\u00e4\u00e4l.ch",
+        Assert.assertEquals("www.g\u00e4ggelig\u00e4\u00e4l.ch",
                      idn.toUnicode("www.xn--gggeligl-0zaga.ch"));
     }
+
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java Tue Apr 27 18:01:48 2010
@@ -28,256 +28,290 @@ package org.apache.http.client.utils;
 import java.net.URI;
 
 import org.apache.http.HttpHost;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * This TestCase contains test methods for URI resolving according to RFC 3986.
  * The examples are listed in section "5.4 Reference Resolution Examples"
  */
-public class TestURIUtils extends TestCase {
+public class TestURIUtils {
 
     private URI baseURI = URI.create("http://a/b/c/d;p?q");
 
-    public TestURIUtils(final String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestURIUtils.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestURIUtils.class);
-    }
-
+    @Test
     public void testRewite00() throws Exception {
         URI uri = URI.create("http://thishost/stuff");
         HttpHost target = new HttpHost("thathost", -1);
         Assert.assertEquals("http://thathost/stuff", URIUtils.rewriteURI(uri, target).toString());
     }
 
+    @Test
     public void testRewite01() throws Exception {
         URI uri = URI.create("http://thishost/stuff");
         Assert.assertEquals("/stuff", URIUtils.rewriteURI(uri, null).toString());
     }
 
+    @Test
     public void testRewite02() throws Exception {
         URI uri = URI.create("http://thishost//");
         Assert.assertEquals("/", URIUtils.rewriteURI(uri, null).toString());
     }
 
+    @Test
     public void testRewite03() throws Exception {
         URI uri = URI.create("http://thishost//stuff///morestuff");
         Assert.assertEquals("/stuff/morestuff", URIUtils.rewriteURI(uri, null).toString());
     }
 
+    @Test
     public void testRewite04() throws Exception {
         URI uri = URI.create("http://thishost/stuff#crap");
         HttpHost target = new HttpHost("thathost", -1);
         Assert.assertEquals("http://thathost/stuff", URIUtils.rewriteURI(uri, target, true).toString());
     }
 
+    @Test
     public void testRewite05() throws Exception {
         URI uri = URI.create("http://thishost/stuff#crap");
         HttpHost target = new HttpHost("thathost", -1);
         Assert.assertEquals("http://thathost/stuff#crap", URIUtils.rewriteURI(uri, target, false).toString());
     }
 
+    @Test
     public void testResolve00() {
         Assert.assertEquals("g:h", URIUtils.resolve(this.baseURI, "g:h").toString());
     }
 
+    @Test
     public void testResolve01() {
         Assert.assertEquals("http://a/b/c/g", URIUtils.resolve(this.baseURI, "g").toString());
     }
 
+    @Test
     public void testResolve02() {
         Assert.assertEquals("http://a/b/c/g", URIUtils.resolve(this.baseURI, "./g").toString());
     }
 
+    @Test
     public void testResolve03() {
         Assert.assertEquals("http://a/b/c/g/", URIUtils.resolve(this.baseURI, "g/").toString());
     }
 
+    @Test
     public void testResolve04() {
         Assert.assertEquals("http://a/g", URIUtils.resolve(this.baseURI, "/g").toString());
     }
 
+    @Test
     public void testResolve05() {
         Assert.assertEquals("http://g", URIUtils.resolve(this.baseURI, "//g").toString());
     }
 
+    @Test
     public void testResolve06() {
         Assert.assertEquals("http://a/b/c/d;p?y", URIUtils.resolve(this.baseURI, "?y").toString());
     }
 
+    @Test
     public void testResolve06_() {
         Assert.assertEquals("http://a/b/c/d;p?y#f", URIUtils.resolve(this.baseURI, "?y#f")
                 .toString());
     }
 
+    @Test
     public void testResolve07() {
         Assert.assertEquals("http://a/b/c/g?y", URIUtils.resolve(this.baseURI, "g?y").toString());
     }
 
+    @Test
     public void testResolve08() {
-        Assert
-                .assertEquals("http://a/b/c/d;p?q#s", URIUtils.resolve(this.baseURI, "#s")
-                        .toString());
+        Assert.assertEquals("http://a/b/c/d;p?q#s", URIUtils.resolve(this.baseURI, "#s")
+                .toString());
     }
 
+    @Test
     public void testResolve09() {
         Assert.assertEquals("http://a/b/c/g#s", URIUtils.resolve(this.baseURI, "g#s").toString());
     }
 
+    @Test
     public void testResolve10() {
         Assert.assertEquals("http://a/b/c/g?y#s", URIUtils.resolve(this.baseURI, "g?y#s")
                 .toString());
     }
 
+    @Test
     public void testResolve11() {
         Assert.assertEquals("http://a/b/c/;x", URIUtils.resolve(this.baseURI, ";x").toString());
     }
 
+    @Test
     public void testResolve12() {
         Assert.assertEquals("http://a/b/c/g;x", URIUtils.resolve(this.baseURI, "g;x").toString());
     }
 
+    @Test
     public void testResolve13() {
         Assert.assertEquals("http://a/b/c/g;x?y#s", URIUtils.resolve(this.baseURI, "g;x?y#s")
                 .toString());
     }
 
+    @Test
     public void testResolve14() {
         Assert.assertEquals("http://a/b/c/d;p?q", URIUtils.resolve(this.baseURI, "").toString());
     }
 
+    @Test
     public void testResolve15() {
         Assert.assertEquals("http://a/b/c/", URIUtils.resolve(this.baseURI, ".").toString());
     }
 
+    @Test
     public void testResolve16() {
         Assert.assertEquals("http://a/b/c/", URIUtils.resolve(this.baseURI, "./").toString());
     }
 
+    @Test
     public void testResolve17() {
         Assert.assertEquals("http://a/b/", URIUtils.resolve(this.baseURI, "..").toString());
     }
 
+    @Test
     public void testResolve18() {
         Assert.assertEquals("http://a/b/", URIUtils.resolve(this.baseURI, "../").toString());
     }
 
+    @Test
     public void testResolve19() {
         Assert.assertEquals("http://a/b/g", URIUtils.resolve(this.baseURI, "../g").toString());
     }
 
+    @Test
     public void testResolve20() {
         Assert.assertEquals("http://a/", URIUtils.resolve(this.baseURI, "../..").toString());
     }
 
+    @Test
     public void testResolve21() {
         Assert.assertEquals("http://a/", URIUtils.resolve(this.baseURI, "../../").toString());
     }
 
+    @Test
     public void testResolve22() {
         Assert.assertEquals("http://a/g", URIUtils.resolve(this.baseURI, "../../g").toString());
     }
 
+    @Test
     public void testResolveAbnormal23() {
         Assert.assertEquals("http://a/g", URIUtils.resolve(this.baseURI, "../../../g").toString());
     }
 
+    @Test
     public void testResolveAbnormal24() {
         Assert.assertEquals("http://a/g", URIUtils.resolve(this.baseURI, "../../../../g")
                 .toString());
     }
 
+    @Test
     public void testResolve25() {
         Assert.assertEquals("http://a/g", URIUtils.resolve(this.baseURI, "/./g").toString());
     }
 
+    @Test
     public void testResolve26() {
         Assert.assertEquals("http://a/g", URIUtils.resolve(this.baseURI, "/../g").toString());
     }
 
+    @Test
     public void testResolve27() {
         Assert.assertEquals("http://a/b/c/g.", URIUtils.resolve(this.baseURI, "g.").toString());
     }
 
+    @Test
     public void testResolve28() {
         Assert.assertEquals("http://a/b/c/.g", URIUtils.resolve(this.baseURI, ".g").toString());
     }
 
+    @Test
     public void testResolve29() {
         Assert.assertEquals("http://a/b/c/g..", URIUtils.resolve(this.baseURI, "g..").toString());
     }
 
+    @Test
     public void testResolve30() {
         Assert.assertEquals("http://a/b/c/..g", URIUtils.resolve(this.baseURI, "..g").toString());
     }
 
+    @Test
     public void testResolve31() {
         Assert.assertEquals("http://a/b/g", URIUtils.resolve(this.baseURI, "./../g").toString());
     }
 
+    @Test
     public void testResolve32() {
         Assert.assertEquals("http://a/b/c/g/", URIUtils.resolve(this.baseURI, "./g/.").toString());
     }
 
+    @Test
     public void testResolve33() {
         Assert.assertEquals("http://a/b/c/g/h", URIUtils.resolve(this.baseURI, "g/./h").toString());
     }
 
+    @Test
     public void testResolve34() {
         Assert.assertEquals("http://a/b/c/h", URIUtils.resolve(this.baseURI, "g/../h").toString());
     }
 
+    @Test
     public void testResolve35() {
         Assert.assertEquals("http://a/b/c/g;x=1/y", URIUtils.resolve(this.baseURI, "g;x=1/./y")
                 .toString());
     }
 
+    @Test
     public void testResolve36() {
         Assert.assertEquals("http://a/b/c/y", URIUtils.resolve(this.baseURI, "g;x=1/../y")
                 .toString());
     }
 
+    @Test
     public void testResolve37() {
         Assert.assertEquals("http://a/b/c/g?y/./x", URIUtils.resolve(this.baseURI, "g?y/./x")
                 .toString());
     }
 
+    @Test
     public void testResolve38() {
         Assert.assertEquals("http://a/b/c/g?y/../x", URIUtils.resolve(this.baseURI, "g?y/../x")
                 .toString());
     }
 
+    @Test
     public void testResolve39() {
         Assert.assertEquals("http://a/b/c/g#s/./x", URIUtils.resolve(this.baseURI, "g#s/./x")
                 .toString());
     }
 
+    @Test
     public void testResolve40() {
         Assert.assertEquals("http://a/b/c/g#s/../x", URIUtils.resolve(this.baseURI, "g#s/../x")
                 .toString());
     }
 
+    @Test
     public void testResolve41() {
         Assert.assertEquals("http:g", URIUtils.resolve(this.baseURI, "http:g").toString());
     }
 
     // examples from section 5.2.4
+    @Test
     public void testResolve42() {
         Assert.assertEquals("http://s/a/g", URIUtils.resolve(this.baseURI,
                 "http://s/a/b/c/./../../g").toString());
     }
 
+    @Test
     public void testResolve43() {
         Assert.assertEquals("http://s/mid/6", URIUtils.resolve(this.baseURI,
                 "http://s/mid/content=5/../6").toString());

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java Tue Apr 27 18:01:48 2010
@@ -31,86 +31,73 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 import org.apache.http.NameValuePair;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.protocol.HTTP;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class TestURLEncodedUtils extends TestCase {
-
-    public TestURLEncodedUtils(final String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestURLEncodedUtils.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestURLEncodedUtils.class);
-    }
+public class TestURLEncodedUtils {
 
+    @Test
     public void testParseURI () throws Exception {
         List <NameValuePair> result;
 
         result = parse("", null);
-        assertTrue(result.isEmpty());
+        Assert.assertTrue(result.isEmpty());
 
         result = parse("Name1=Value1", null);
-        assertEquals(1, result.size());
+        Assert.assertEquals(1, result.size());
         assertNameValuePair(result.get(0), "Name1", "Value1");
 
         result = parse("Name2=", null);
-        assertEquals(1, result.size());
+        Assert.assertEquals(1, result.size());
         assertNameValuePair(result.get(0), "Name2", null);
 
         result = parse("Name3", null);
-        assertEquals(1, result.size());
+        Assert.assertEquals(1, result.size());
         assertNameValuePair(result.get(0), "Name3", null);
 
         result = parse("Name4=Value+4%21", null);
-        assertEquals(1, result.size());
+        Assert.assertEquals(1, result.size());
         assertNameValuePair(result.get(0), "Name4", "Value 4!");
 
         result = parse("Name4=Value%2B4%21", null);
-        assertEquals(1, result.size());
+        Assert.assertEquals(1, result.size());
         assertNameValuePair(result.get(0), "Name4", "Value+4!");
 
         result = parse("Name4=Value+4%21+%214", null);
-        assertEquals(1, result.size());
+        Assert.assertEquals(1, result.size());
         assertNameValuePair(result.get(0), "Name4", "Value 4! !4");
 
         result = parse("Name5=aaa&Name6=bbb", null);
-        assertEquals(2, result.size());
+        Assert.assertEquals(2, result.size());
         assertNameValuePair(result.get(0), "Name5", "aaa");
         assertNameValuePair(result.get(1), "Name6", "bbb");
 
         result = parse("Name7=aaa&Name7=b%2Cb&Name7=ccc", null);
-        assertEquals(3, result.size());
+        Assert.assertEquals(3, result.size());
         assertNameValuePair(result.get(0), "Name7", "aaa");
         assertNameValuePair(result.get(1), "Name7", "b,b");
         assertNameValuePair(result.get(2), "Name7", "ccc");
 
         result = parse("Name8=xx%2C++yy++%2Czz", null);
-        assertEquals(1, result.size());
+        Assert.assertEquals(1, result.size());
         assertNameValuePair(result.get(0), "Name8", "xx,  yy  ,zz");
     }
 
+    @Test
     public void testParseEntity () throws Exception {
         final StringEntity entity = new StringEntity("Name1=Value1", null);
 
         entity.setContentType(URLEncodedUtils.CONTENT_TYPE);
         final List <NameValuePair> result = URLEncodedUtils.parse(entity);
-        assertEquals(1, result.size());
+        Assert.assertEquals(1, result.size());
         assertNameValuePair(result.get(0), "Name1", "Value1");
 
         entity.setContentType("text/test");
-        assertTrue(URLEncodedUtils.parse(entity).isEmpty());
+        Assert.assertTrue(URLEncodedUtils.parse(entity).isEmpty());
     }
 
     static final int SWISS_GERMAN_HELLO [] = {
@@ -132,6 +119,7 @@ public class TestURLEncodedUtils extends
         return buffer.toString();
     }
 
+    @Test
     public void testParseUTF8Entity () throws Exception {
         String ru_hello = constructString(RUSSIAN_HELLO);
         String ch_hello = constructString(SWISS_GERMAN_HELLO);
@@ -141,68 +129,70 @@ public class TestURLEncodedUtils extends
 
         String s = URLEncodedUtils.format(parameters, HTTP.UTF_8);
 
-        assertEquals("russian=%D0%92%D1%81%D0%B5%D0%BC_%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82" +
+        Assert.assertEquals("russian=%D0%92%D1%81%D0%B5%D0%BC_%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82" +
                 "&swiss=Gr%C3%BCezi_z%C3%A4m%C3%A4", s);
 
         StringEntity entity = new StringEntity(s, HTTP.UTF_8);
         entity.setContentType(URLEncodedUtils.CONTENT_TYPE + HTTP.CHARSET_PARAM + HTTP.UTF_8);
         List <NameValuePair> result = URLEncodedUtils.parse(entity);
-        assertEquals(2, result.size());
+        Assert.assertEquals(2, result.size());
         assertNameValuePair(result.get(0), "russian", ru_hello);
         assertNameValuePair(result.get(1), "swiss", ch_hello);
     }
 
+    @Test
     public void testIsEncoded () throws Exception {
         final StringEntity entity = new StringEntity("...", null);
 
         entity.setContentType(URLEncodedUtils.CONTENT_TYPE);
-        assertTrue(URLEncodedUtils.isEncoded(entity));
+        Assert.assertTrue(URLEncodedUtils.isEncoded(entity));
 
         entity.setContentType(URLEncodedUtils.CONTENT_TYPE + "; charset=US-ASCII");
-        assertTrue(URLEncodedUtils.isEncoded(entity));
+        Assert.assertTrue(URLEncodedUtils.isEncoded(entity));
 
         entity.setContentType("text/test");
-        assertFalse(URLEncodedUtils.isEncoded(entity));
+        Assert.assertFalse(URLEncodedUtils.isEncoded(entity));
     }
 
+    @Test
     public void testFormat () throws Exception {
         final List <NameValuePair> params = new ArrayList <NameValuePair>();
-        assertEquals(0, URLEncodedUtils.format(params, null).length());
+        Assert.assertEquals(0, URLEncodedUtils.format(params, null).length());
 
         params.clear();
         params.add(new BasicNameValuePair("Name1", "Value1"));
-        assertEquals("Name1=Value1", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name1=Value1", URLEncodedUtils.format(params, null));
 
         params.clear();
         params.add(new BasicNameValuePair("Name2", null));
-        assertEquals("Name2=", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name2=", URLEncodedUtils.format(params, null));
 
         params.clear();
         params.add(new BasicNameValuePair("Name4", "Value 4!"));
-        assertEquals("Name4=Value+4%21", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name4=Value+4%21", URLEncodedUtils.format(params, null));
 
         params.clear();
         params.add(new BasicNameValuePair("Name4", "Value+4!"));
-        assertEquals("Name4=Value%2B4%21", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name4=Value%2B4%21", URLEncodedUtils.format(params, null));
 
         params.clear();
         params.add(new BasicNameValuePair("Name4", "Value 4! !4"));
-        assertEquals("Name4=Value+4%21+%214", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name4=Value+4%21+%214", URLEncodedUtils.format(params, null));
 
         params.clear();
         params.add(new BasicNameValuePair("Name5", "aaa"));
         params.add(new BasicNameValuePair("Name6", "bbb"));
-        assertEquals("Name5=aaa&Name6=bbb", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name5=aaa&Name6=bbb", URLEncodedUtils.format(params, null));
 
         params.clear();
         params.add(new BasicNameValuePair("Name7", "aaa"));
         params.add(new BasicNameValuePair("Name7", "b,b"));
         params.add(new BasicNameValuePair("Name7", "ccc"));
-        assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", URLEncodedUtils.format(params, null));
 
         params.clear();
         params.add(new BasicNameValuePair("Name8", "xx,  yy  ,zz"));
-        assertEquals("Name8=xx%2C++yy++%2Czz", URLEncodedUtils.format(params, null));
+        Assert.assertEquals("Name8=xx%2C++yy++%2Czz", URLEncodedUtils.format(params, null));
     }
 
     private List <NameValuePair> parse (final String params, final String encoding) {
@@ -213,7 +203,8 @@ public class TestURLEncodedUtils extends
             final NameValuePair parameter,
             final String expectedName,
             final String expectedValue) {
-        assertEquals(parameter.getName(), expectedName);
-        assertEquals(parameter.getValue(), expectedValue);
+        Assert.assertEquals(parameter.getName(), expectedName);
+        Assert.assertEquals(parameter.getValue(), expectedValue);
     }
+
 }
\ No newline at end of file

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java Tue Apr 27 18:01:48 2010
@@ -32,9 +32,6 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
@@ -53,35 +50,25 @@ import org.apache.http.protocol.Executio
 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;
 
 public class TestConnectionAutoRelease extends ServerTestBase {
 
-    public TestConnectionAutoRelease(String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestConnectionAutoRelease.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestConnectionAutoRelease.class);
-    }
-
-    public ThreadSafeClientConnManager createTSCCM(SchemeRegistry schreg) {
+    private ThreadSafeClientConnManager createTSCCM(SchemeRegistry schreg) {
         if (schreg == null)
             schreg = supportedSchemes;
         return new ThreadSafeClientConnManager(schreg);
     }
 
+    @Test
     public void testReleaseOnEntityConsumeContent() throws Exception {
         ThreadSafeClientConnManager mgr = createTSCCM(null);
         mgr.setDefaultMaxPerRoute(1);
         mgr.setMaxTotalConnections(1);
 
         // Zero connections in the pool
-        assertEquals(0, mgr.getConnectionsInPool());
+        Assert.assertEquals(0, mgr.getConnectionsInPool());
 
         DefaultHttpClient client = new DefaultHttpClient(mgr);
 
@@ -94,16 +81,16 @@ public class TestConnectionAutoRelease e
         ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
         try {
             connreq.getConnection(250, TimeUnit.MILLISECONDS);
-            fail("ConnectionPoolTimeoutException should have been thrown");
+            Assert.fail("ConnectionPoolTimeoutException should have been thrown");
         } catch (ConnectionPoolTimeoutException expected) {
         }
 
         HttpEntity e = response.getEntity();
-        assertNotNull(e);
+        Assert.assertNotNull(e);
         e.consumeContent();
 
         // Expect one connection in the pool
-        assertEquals(1, mgr.getConnectionsInPool());
+        Assert.assertEquals(1, mgr.getConnectionsInPool());
 
         // Make sure one connection is available
         connreq = mgr.requestConnection(new HttpRoute(target), null);
@@ -114,13 +101,14 @@ public class TestConnectionAutoRelease e
         mgr.shutdown();
     }
 
+    @Test
     public void testReleaseOnEntityWriteTo() throws Exception {
         ThreadSafeClientConnManager mgr = createTSCCM(null);
         mgr.setDefaultMaxPerRoute(1);
         mgr.setMaxTotalConnections(1);
 
         // Zero connections in the pool
-        assertEquals(0, mgr.getConnectionsInPool());
+        Assert.assertEquals(0, mgr.getConnectionsInPool());
 
         DefaultHttpClient client = new DefaultHttpClient(mgr);
 
@@ -133,17 +121,17 @@ public class TestConnectionAutoRelease e
         ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
         try {
             connreq.getConnection(250, TimeUnit.MILLISECONDS);
-            fail("ConnectionPoolTimeoutException should have been thrown");
+            Assert.fail("ConnectionPoolTimeoutException should have been thrown");
         } catch (ConnectionPoolTimeoutException expected) {
         }
 
         HttpEntity e = response.getEntity();
-        assertNotNull(e);
+        Assert.assertNotNull(e);
         ByteArrayOutputStream outsteam = new ByteArrayOutputStream();
         e.writeTo(outsteam);
 
         // Expect one connection in the pool
-        assertEquals(1, mgr.getConnectionsInPool());
+        Assert.assertEquals(1, mgr.getConnectionsInPool());
 
         // Make sure one connection is available
         connreq = mgr.requestConnection(new HttpRoute(target), null);
@@ -154,13 +142,14 @@ public class TestConnectionAutoRelease e
         mgr.shutdown();
     }
 
+    @Test
     public void testReleaseOnAbort() throws Exception {
         ThreadSafeClientConnManager mgr = createTSCCM(null);
         mgr.setDefaultMaxPerRoute(1);
         mgr.setMaxTotalConnections(1);
 
         // Zero connections in the pool
-        assertEquals(0, mgr.getConnectionsInPool());
+        Assert.assertEquals(0, mgr.getConnectionsInPool());
 
         DefaultHttpClient client = new DefaultHttpClient(mgr);
 
@@ -173,16 +162,16 @@ public class TestConnectionAutoRelease e
         ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
         try {
             connreq.getConnection(250, TimeUnit.MILLISECONDS);
-            fail("ConnectionPoolTimeoutException should have been thrown");
+            Assert.fail("ConnectionPoolTimeoutException should have been thrown");
         } catch (ConnectionPoolTimeoutException expected) {
         }
 
         HttpEntity e = response.getEntity();
-        assertNotNull(e);
+        Assert.assertNotNull(e);
         httpget.abort();
 
         // Expect zero connections in the pool
-        assertEquals(0, mgr.getConnectionsInPool());
+        Assert.assertEquals(0, mgr.getConnectionsInPool());
 
         // Make sure one connection is available
         connreq = mgr.requestConnection(new HttpRoute(target), null);
@@ -193,6 +182,7 @@ public class TestConnectionAutoRelease e
         mgr.shutdown();
     }
 
+    @Test
     public void testReleaseOnIOException() throws Exception {
 
         localServer.register("/dropdead", new HttpRequestHandler() {
@@ -232,7 +222,7 @@ public class TestConnectionAutoRelease e
         mgr.setMaxTotalConnections(1);
 
         // Zero connections in the pool
-        assertEquals(0, mgr.getConnectionsInPool());
+        Assert.assertEquals(0, mgr.getConnectionsInPool());
 
         DefaultHttpClient client = new DefaultHttpClient(mgr);
 
@@ -245,22 +235,22 @@ public class TestConnectionAutoRelease e
         ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
         try {
             connreq.getConnection(250, TimeUnit.MILLISECONDS);
-            fail("ConnectionPoolTimeoutException should have been thrown");
+            Assert.fail("ConnectionPoolTimeoutException should have been thrown");
         } catch (ConnectionPoolTimeoutException expected) {
         }
 
         HttpEntity e = response.getEntity();
-        assertNotNull(e);
+        Assert.assertNotNull(e);
         // Read the content
         try {
             EntityUtils.toByteArray(e);
-            fail("MalformedChunkCodingException should have been thrown");
+            Assert.fail("MalformedChunkCodingException should have been thrown");
         } catch (MalformedChunkCodingException expected) {
 
         }
 
         // Expect zero connections in the pool
-        assertEquals(0, mgr.getConnectionsInPool());
+        Assert.assertEquals(0, mgr.getConnectionsInPool());
 
         // Make sure one connection is available
         connreq = mgr.requestConnection(new HttpRoute(target), null);



Mime
View raw message