hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r938585 [7/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
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java Tue Apr 27 18:01:48 2010
@@ -32,10 +32,6 @@ import java.util.Calendar;
 import java.util.List;
 import java.util.TimeZone;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 import org.apache.http.Header;
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
@@ -43,24 +39,15 @@ import org.apache.http.cookie.CookieOrig
 import org.apache.http.cookie.CookieSpec;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.message.BasicHeader;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for Netscape cookie draft
  */
-public class TestCookieNetscapeDraft extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-
-    public TestCookieNetscapeDraft(String name) {
-        super(name);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestCookieNetscapeDraft.class);
-    }
+public class TestCookieNetscapeDraft {
 
+    @Test
     public void testParseAbsPath() throws Exception {
         Header header = new BasicHeader("Set-Cookie", "name1=value1;Path=/path/");
 
@@ -70,13 +57,14 @@ public class TestCookieNetscapeDraft ext
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertEquals("Found 1 cookies.",1,cookies.size());
-        assertEquals("Name","name1",cookies.get(0).getName());
-        assertEquals("Value","value1",cookies.get(0).getValue());
-        assertEquals("Domain","host",cookies.get(0).getDomain());
-        assertEquals("Path","/path/",cookies.get(0).getPath());
+        Assert.assertEquals("Found 1 cookies.",1,cookies.size());
+        Assert.assertEquals("Name","name1",cookies.get(0).getName());
+        Assert.assertEquals("Value","value1",cookies.get(0).getValue());
+        Assert.assertEquals("Domain","host",cookies.get(0).getDomain());
+        Assert.assertEquals("Path","/path/",cookies.get(0).getPath());
     }
 
+    @Test
     public void testParseAbsPath2() throws Exception {
         Header header = new BasicHeader("Set-Cookie", "name1=value1;Path=/");
 
@@ -86,13 +74,14 @@ public class TestCookieNetscapeDraft ext
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertEquals("Found 1 cookies.",1,cookies.size());
-        assertEquals("Name","name1",cookies.get(0).getName());
-        assertEquals("Value","value1",cookies.get(0).getValue());
-        assertEquals("Domain","host",cookies.get(0).getDomain());
-        assertEquals("Path","/",cookies.get(0).getPath());
+        Assert.assertEquals("Found 1 cookies.",1,cookies.size());
+        Assert.assertEquals("Name","name1",cookies.get(0).getName());
+        Assert.assertEquals("Value","value1",cookies.get(0).getValue());
+        Assert.assertEquals("Domain","host",cookies.get(0).getDomain());
+        Assert.assertEquals("Path","/",cookies.get(0).getPath());
     }
 
+    @Test
     public void testParseRelativePath() throws Exception {
         Header header = new BasicHeader("Set-Cookie", "name1=value1;Path=whatever");
 
@@ -102,13 +91,14 @@ public class TestCookieNetscapeDraft ext
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertEquals("Found 1 cookies.",1,cookies.size());
-        assertEquals("Name","name1",cookies.get(0).getName());
-        assertEquals("Value","value1",cookies.get(0).getValue());
-        assertEquals("Domain","host",cookies.get(0).getDomain());
-        assertEquals("Path","whatever",cookies.get(0).getPath());
+        Assert.assertEquals("Found 1 cookies.",1,cookies.size());
+        Assert.assertEquals("Name","name1",cookies.get(0).getName());
+        Assert.assertEquals("Value","value1",cookies.get(0).getValue());
+        Assert.assertEquals("Domain","host",cookies.get(0).getDomain());
+        Assert.assertEquals("Path","whatever",cookies.get(0).getPath());
     }
 
+    @Test
     public void testParseWithIllegalNetscapeDomain1() throws Exception {
         Header header = new BasicHeader("Set-Cookie","cookie-name=cookie-value; domain=.com");
 
@@ -119,12 +109,13 @@ public class TestCookieNetscapeDraft ext
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException e) {
             // expected
         }
     }
 
+    @Test
     public void testParseWithWrongNetscapeDomain2() throws Exception {
         Header header = new BasicHeader("Set-Cookie","cookie-name=cookie-value; domain=.y.z");
 
@@ -135,7 +126,7 @@ public class TestCookieNetscapeDraft ext
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException e) {
             // expected
         }
@@ -144,6 +135,7 @@ public class TestCookieNetscapeDraft ext
     /**
      * Tests Netscape specific cookie formatting.
      */
+    @Test
     public void testNetscapeCookieFormatting() throws Exception {
         Header header = new BasicHeader(
           "Set-Cookie", "name=value; path=/; domain=.mydomain.com");
@@ -152,13 +144,14 @@ public class TestCookieNetscapeDraft ext
         List<Cookie> cookies = cookiespec.parse(header, origin);
         cookiespec.validate(cookies.get(0), origin);
         List<Header> headers = cookiespec.formatCookies(cookies);
-        assertEquals(1, headers.size());
-        assertEquals("name=value", headers.get(0).getValue());
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("name=value", headers.get(0).getValue());
     }
 
     /**
      * Tests Netscape specific expire attribute parsing.
      */
+    @Test
     public void testNetscapeCookieExpireAttribute() throws Exception {
         CookieSpec cookiespec = new NetscapeDraftSpec();
         Header header = new BasicHeader("Set-Cookie",
@@ -166,19 +159,20 @@ public class TestCookieNetscapeDraft ext
         CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
         List<Cookie> cookies = cookiespec.parse(header, origin);
         cookiespec.validate(cookies.get(0), origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         Cookie cookie = cookies.get(0);
         Calendar c = Calendar.getInstance();
         c.setTimeZone(TimeZone.getTimeZone("GMT"));
         c.setTime(cookie.getExpiryDate());
         int year = c.get(Calendar.YEAR);
-        assertEquals(2070, year);
+        Assert.assertEquals(2070, year);
     }
 
     /**
      * Expire attribute with two digit year.
      */
+    @Test
     public void testNetscapeCookieExpireAttributeTwoDigitYear() throws Exception {
         CookieSpec cookiespec = new NetscapeDraftSpec();
         Header header = new BasicHeader("Set-Cookie",
@@ -186,19 +180,20 @@ public class TestCookieNetscapeDraft ext
         CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
         List<Cookie> cookies = cookiespec.parse(header, origin);
         cookiespec.validate(cookies.get(0), origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         Cookie cookie = cookies.get(0);
         Calendar c = Calendar.getInstance();
         c.setTimeZone(TimeZone.getTimeZone("GMT"));
         c.setTime(cookie.getExpiryDate());
         int year = c.get(Calendar.YEAR);
-        assertEquals(2070, year);
+        Assert.assertEquals(2070, year);
     }
 
     /**
      * Invalid expire attribute.
      */
+    @Test
     public void testNetscapeCookieInvalidExpireAttribute() throws Exception {
         CookieSpec cookiespec = new NetscapeDraftSpec();
         CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
@@ -207,7 +202,7 @@ public class TestCookieNetscapeDraft ext
         try {
             List<Cookie> cookies = cookiespec.parse(header, origin);
             cookiespec.validate(cookies.get(0), origin);
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException e) {
             // expected
         }
@@ -216,6 +211,7 @@ public class TestCookieNetscapeDraft ext
     /**
      * Tests Netscape specific expire attribute without a time zone.
      */
+    @Test
     public void testNetscapeCookieExpireAttributeNoTimeZone() throws Exception {
         CookieSpec cookiespec = new NetscapeDraftSpec();
         Header header = new BasicHeader("Set-Cookie",
@@ -223,7 +219,7 @@ public class TestCookieNetscapeDraft ext
         CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
         try {
             cookiespec.parse(header, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException ex) {
             // expected
         }
@@ -232,17 +228,19 @@ public class TestCookieNetscapeDraft ext
     /**
      * Tests if cookie values with embedded comma are handled correctly.
      */
+    @Test
     public void testCookieWithComma() throws Exception {
         Header header = new BasicHeader("Set-Cookie", "a=b,c");
 
         CookieSpec cookiespec = new NetscapeDraftSpec();
         CookieOrigin origin = new CookieOrigin("localhost", 80, "/", false);
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertEquals("number of cookies", 1, cookies.size());
-        assertEquals("a", cookies.get(0).getName());
-        assertEquals("b,c", cookies.get(0).getValue());
+        Assert.assertEquals("number of cookies", 1, cookies.size());
+        Assert.assertEquals("a", cookies.get(0).getName());
+        Assert.assertEquals("b,c", cookies.get(0).getValue());
     }
 
+    @Test
     public void testFormatCookies() throws Exception {
         BasicClientCookie c1 = new BasicClientCookie("name1", "value1");
         c1.setDomain(".whatever.com");
@@ -259,35 +257,36 @@ public class TestCookieNetscapeDraft ext
         cookies.add(c2);
         cookies.add(c3);
         List<Header> headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("name1=value1; name2=value2; name3", headers.get(0).getValue());
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("name1=value1; name2=value2; name3", headers.get(0).getValue());
     }
 
+    @Test
     public void testInvalidInput() throws Exception {
         CookieSpec cookiespec = new NetscapeDraftSpec();
         try {
             cookiespec.parse(null, null);
-            fail("IllegalArgumentException must have been thrown");
+            Assert.fail("IllegalArgumentException must have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             cookiespec.parse(new BasicHeader("Set-Cookie", "name=value"), null);
-            fail("IllegalArgumentException must have been thrown");
+            Assert.fail("IllegalArgumentException must have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             cookiespec.formatCookies(null);
-            fail("IllegalArgumentException must have been thrown");
+            Assert.fail("IllegalArgumentException must have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             List<Cookie> cookies = new ArrayList<Cookie>();
             cookiespec.formatCookies(cookies);
-            fail("IllegalArgumentException must have been thrown");
+            Assert.fail("IllegalArgumentException must have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java Tue Apr 27 18:01:48 2010
@@ -30,10 +30,6 @@ package org.apache.http.impl.cookie;
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 import org.apache.http.Header;
 import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
@@ -41,34 +37,22 @@ import org.apache.http.cookie.CookieOrig
 import org.apache.http.cookie.CookieSpec;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.message.BasicHeader;
-
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for RFC2109 cookie spec
- *
- *
  */
-public class TestCookieRFC2109Spec extends TestCase {
-
-
-    // ------------------------------------------------------------ Constructor
-
-    public TestCookieRFC2109Spec(String name) {
-        super(name);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestCookieRFC2109Spec.class);
-    }
+public class TestCookieRFC2109Spec {
 
+    @Test
     public void testConstructor() throws Exception {
         new RFC2109Spec();
         new RFC2109Spec(null, false);
         new RFC2109Spec(new String[] { DateUtils.PATTERN_RFC1036 }, false);
     }
 
+    @Test
     public void testParseVersion() throws Exception {
         Header header = new BasicHeader("Set-Cookie","cookie-name=cookie-value; version=1");
 
@@ -78,15 +62,16 @@ public class TestCookieRFC2109Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertEquals("Found 1 cookie.",1,cookies.size());
-        assertEquals("Name","cookie-name",cookies.get(0).getName());
-        assertEquals("Value","cookie-value",cookies.get(0).getValue());
-        assertEquals("Version",1,cookies.get(0).getVersion());
+        Assert.assertEquals("Found 1 cookie.",1,cookies.size());
+        Assert.assertEquals("Name","cookie-name",cookies.get(0).getName());
+        Assert.assertEquals("Value","cookie-value",cookies.get(0).getValue());
+        Assert.assertEquals("Version",1,cookies.get(0).getVersion());
     }
 
     /**
      * Test domain equals host
      */
+    @Test
     public void testCookiesomainEqualsHost() throws Exception {
         Header header = new BasicHeader("Set-Cookie",
             "cookie-name=cookie-value; domain=www.b.com; version=1");
@@ -97,14 +82,15 @@ public class TestCookieRFC2109Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
-        assertEquals("www.b.com", cookies.get(0).getDomain());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
+        Assert.assertEquals("www.b.com", cookies.get(0).getDomain());
     }
 
     /**
      * Domain does not start with a dot
      */
+    @Test
     public void testParseWithIllegalDomain1() throws Exception {
         Header header = new BasicHeader("Set-Cookie",
             "cookie-name=cookie-value; domain=a.b.com; version=1");
@@ -116,7 +102,7 @@ public class TestCookieRFC2109Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException e) {
             // expected
         }
@@ -125,6 +111,7 @@ public class TestCookieRFC2109Spec exten
     /**
      * Domain must have alt least one embedded dot
      */
+    @Test
     public void testParseWithIllegalDomain2() throws Exception {
         Header header = new BasicHeader("Set-Cookie",
             "cookie-name=cookie-value; domain=.com; version=1");
@@ -136,7 +123,7 @@ public class TestCookieRFC2109Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException e) {
             // expected
         }
@@ -145,6 +132,7 @@ public class TestCookieRFC2109Spec exten
     /**
      * Host minus domain may not contain any dots
      */
+    @Test
     public void testParseWithIllegalDomain4() throws Exception {
         Header header = new BasicHeader("Set-Cookie",
             "cookie-name=cookie-value; domain=.c.com; version=1");
@@ -156,7 +144,7 @@ public class TestCookieRFC2109Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException e) {
             // expected
         }
@@ -167,6 +155,7 @@ public class TestCookieRFC2109Spec exten
      * rejected in the strict mode, but gets accepted in the
      * browser compatibility mode.
      */
+    @Test
     public void testSecondDomainLevelCookie() throws Exception {
         BasicClientCookie cookie = new BasicClientCookie("name", null);
         cookie.setDomain(".sourceforge.net");
@@ -178,12 +167,13 @@ public class TestCookieRFC2109Spec exten
         CookieOrigin origin = new CookieOrigin("sourceforge.net", 80, "/", false);
         try {
             cookiespec.validate(cookie, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException e) {
             // Expected
         }
     }
 
+    @Test
     public void testSecondDomainLevelCookieMatch() throws Exception {
         BasicClientCookie cookie = new BasicClientCookie("name", null);
         cookie.setDomain(".sourceforge.net");
@@ -193,9 +183,10 @@ public class TestCookieRFC2109Spec exten
 
         CookieSpec cookiespec = new RFC2109Spec();
         CookieOrigin origin = new CookieOrigin("sourceforge.net", 80, "/", false);
-        assertFalse(cookiespec.match(cookie, origin));
+        Assert.assertFalse(cookiespec.match(cookie, origin));
     }
 
+    @Test
     public void testParseWithWrongPath() throws Exception {
         Header header = new BasicHeader("Set-Cookie",
             "cookie-name=cookie-value; domain=127.0.0.1; path=/not/just/root");
@@ -207,7 +198,7 @@ public class TestCookieRFC2109Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException e) {
             // expected
         }
@@ -216,6 +207,7 @@ public class TestCookieRFC2109Spec exten
     /**
      * Tests if cookie constructor rejects cookie name containing blanks.
      */
+    @Test
     public void testCookieNameWithBlanks() throws Exception {
         Header setcookie = new BasicHeader("Set-Cookie", "invalid name=");
         CookieSpec cookiespec = new RFC2109Spec();
@@ -225,7 +217,7 @@ public class TestCookieRFC2109Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException e) {
             // expected
         }
@@ -234,6 +226,7 @@ public class TestCookieRFC2109Spec exten
     /**
      * Tests if cookie constructor rejects cookie name starting with $.
      */
+    @Test
     public void testCookieNameStartingWithDollarSign() throws Exception {
         Header setcookie = new BasicHeader("Set-Cookie", "$invalid_name=");
         CookieSpec cookiespec = new RFC2109Spec();
@@ -243,7 +236,7 @@ public class TestCookieRFC2109Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException e) {
             // expected
         }
@@ -253,6 +246,7 @@ public class TestCookieRFC2109Spec exten
      * Tests if default cookie validator rejects cookies originating from a host without domain
      * where domain attribute does not match the host of origin
      */
+    @Test
     public void testInvalidDomainWithSimpleHostName() throws Exception {
         CookieSpec cookiespec = new RFC2109Spec();
         Header header = new BasicHeader("Set-Cookie",
@@ -261,7 +255,7 @@ public class TestCookieRFC2109Spec exten
         List<Cookie> cookies = cookiespec.parse(header, origin1);
         try {
             cookiespec.validate(cookies.get(0), origin1);
-            fail("MalformedCookieException must have thrown");
+            Assert.fail("MalformedCookieException must have thrown");
         }
         catch(MalformedCookieException expected) {
         }
@@ -271,7 +265,7 @@ public class TestCookieRFC2109Spec exten
         cookies = cookiespec.parse(header, origin2);
         try {
             cookiespec.validate(cookies.get(0), origin2);
-            fail("MalformedCookieException must have thrown");
+            Assert.fail("MalformedCookieException must have thrown");
         }
         catch(MalformedCookieException expected) {
         }
@@ -280,22 +274,24 @@ public class TestCookieRFC2109Spec exten
     /**
      * Tests if cookie values with embedded comma are handled correctly.
      */
+    @Test
     public void testCookieWithComma() throws Exception {
         Header header = new BasicHeader("Set-Cookie", "a=b,c");
 
         CookieSpec cookiespec = new RFC2109Spec();
         CookieOrigin origin = new CookieOrigin("localhost", 80, "/", false);
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertEquals("number of cookies", 2, cookies.size());
-        assertEquals("a", cookies.get(0).getName());
-        assertEquals("b", cookies.get(0).getValue());
-        assertEquals("c", cookies.get(1).getName());
-        assertEquals(null, cookies.get(1).getValue());
+        Assert.assertEquals("number of cookies", 2, cookies.size());
+        Assert.assertEquals("a", cookies.get(0).getName());
+        Assert.assertEquals("b", cookies.get(0).getValue());
+        Assert.assertEquals("c", cookies.get(1).getName());
+        Assert.assertEquals(null, cookies.get(1).getValue());
     }
 
     /**
      * Tests RFC 2109 compiant cookie formatting.
      */
+    @Test
     public void testRFC2109CookieFormatting() throws Exception {
         CookieSpec cookiespec = new RFC2109Spec(null, false);
         Header header = new BasicHeader("Set-Cookie",
@@ -304,9 +300,9 @@ public class TestCookieRFC2109Spec exten
         List<Cookie> cookies  = cookiespec.parse(header, origin);
         cookiespec.validate(cookies.get(0), origin);
         List<Header> headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=1; name=\"value\"; $Path=\"/\"; $Domain=\".mydomain.com\"",
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=1; name=\"value\"; $Path=\"/\"; $Domain=\".mydomain.com\"",
                 headers.get(0).getValue());
 
         header = new BasicHeader( "Set-Cookie",
@@ -314,12 +310,13 @@ public class TestCookieRFC2109Spec exten
         cookies = cookiespec.parse(header, origin);
         cookiespec.validate(cookies.get(0), origin);
         headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=0; name=value; $Path=/; $Domain=.mydomain.com",
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=0; name=value; $Path=/; $Domain=.mydomain.com",
                 headers.get(0).getValue());
     }
 
+    @Test
     public void testRFC2109CookiesFormatting() throws Exception {
         CookieSpec cookiespec = new RFC2109Spec(null, true);
         Header header = new BasicHeader("Set-Cookie",
@@ -330,12 +327,12 @@ public class TestCookieRFC2109Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(2, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(2, cookies.size());
         List<Header> headers  = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals(
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals(
             "$Version=0; name1=value1; $Path=/; $Domain=.mydomain.com; " +
             "name2=value2; $Path=/; $Domain=.mydomain.com",
             headers.get(0).getValue());
@@ -347,10 +344,10 @@ public class TestCookieRFC2109Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(2, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(2, cookies.size());
         headers = cookiespec.formatCookies(cookies);
-        assertEquals(
+        Assert.assertEquals(
             "$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".mydomain.com\"; " +
             "name2=\"value2\"; $Path=\"/\"; $Domain=\".mydomain.com\"",
             headers.get(0).getValue());
@@ -359,6 +356,7 @@ public class TestCookieRFC2109Spec exten
     /**
      * Tests if null cookie values are handled correctly.
      */
+    @Test
     public void testNullCookieValueFormatting() {
         BasicClientCookie cookie = new BasicClientCookie("name", null);
         cookie.setDomain(".whatever.com");
@@ -370,21 +368,22 @@ public class TestCookieRFC2109Spec exten
         List<Cookie> cookies = new ArrayList<Cookie>();
         cookies.add(cookie);
         List<Header> headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=0; name=; $Path=/; $Domain=.whatever.com",
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=0; name=; $Path=/; $Domain=.whatever.com",
                 headers.get(0).getValue());
 
         cookie.setVersion(1);
         cookies = new ArrayList<Cookie>();
         cookies.add(cookie);
         headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=1; name=; $Path=\"/\"; $Domain=\".whatever.com\"",
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=1; name=; $Path=\"/\"; $Domain=\".whatever.com\"",
                 headers.get(0).getValue());
     }
 
+    @Test
     public void testCookieNullDomainNullPathFormatting() {
         BasicClientCookie cookie = new BasicClientCookie("name", null);
         cookie.setPath("/");
@@ -394,20 +393,21 @@ public class TestCookieRFC2109Spec exten
         List<Cookie> cookies = new ArrayList<Cookie>();
         cookies.add(cookie);
         List<Header> headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=0; name=; $Path=/", headers.get(0).getValue());
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=0; name=; $Path=/", headers.get(0).getValue());
 
         cookie.setAttribute(ClientCookie.DOMAIN_ATTR, null);
         cookie.setAttribute(ClientCookie.PATH_ATTR, null);
         cookies = new ArrayList<Cookie>();
         cookies.add(cookie);
         headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=0; name=", headers.get(0).getValue());
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=0; name=", headers.get(0).getValue());
     }
 
+    @Test
     public void testCookieOrderingByPath() {
         BasicClientCookie c1 = new BasicClientCookie("name1", "value1");
         c1.setPath("/a/b/c");
@@ -429,44 +429,45 @@ public class TestCookieRFC2109Spec exten
         cookies.add(c1);
         cookies.add(c3);
         List<Header> headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=0; name1=value1; $Path=/a/b/c; " +
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=0; name1=value1; $Path=/a/b/c; " +
                 "name2=value2; $Path=/a/b; " +
                 "name3=value3; $Path=/a; " +
                 "name4=value4; $Path=/", headers.get(0).getValue());
     }
 
+    @Test
     public void testInvalidInput() throws Exception {
         CookieSpec cookiespec = new RFC2109Spec();
         try {
             cookiespec.parse(null, null);
-            fail("IllegalArgumentException must have been thrown");
+            Assert.fail("IllegalArgumentException must have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             cookiespec.parse(new BasicHeader("Set-Cookie", "name=value"), null);
-            fail("IllegalArgumentException must have been thrown");
+            Assert.fail("IllegalArgumentException must have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             cookiespec.validate(null, null);
-            fail("IllegalArgumentException must have been thrown");
+            Assert.fail("IllegalArgumentException must have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             cookiespec.formatCookies(null);
-            fail("IllegalArgumentException must have been thrown");
+            Assert.fail("IllegalArgumentException must have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             List<Cookie> cookies = new ArrayList<Cookie>();
             cookiespec.formatCookies(cookies);
-            fail("IllegalArgumentException must have been thrown");
+            Assert.fail("IllegalArgumentException must have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2965Spec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2965Spec.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2965Spec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2965Spec.java Tue Apr 27 18:01:48 2010
@@ -26,10 +26,6 @@
 
 package org.apache.http.impl.cookie;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -41,117 +37,111 @@ import org.apache.http.cookie.CookieOrig
 import org.apache.http.cookie.CookieSpec;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.message.BasicHeader;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Test cases for RFC2965 cookie spec
- *
  */
-public class TestCookieRFC2965Spec extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-
-    public TestCookieRFC2965Spec(String name) {
-        super(name);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
-    public static Test suite() {
-        return new TestSuite(TestCookieRFC2965Spec.class);
-    }
-
-    // ------------------------------------------------------- Test Cookie Parsing
+public class TestCookieRFC2965Spec {
 
     /**
      * Test parsing cookie <tt>"Path"</tt> attribute.
      */
+    @Test
     public void testParsePath() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Path=/;Version=1;Path=");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert .assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         // only the first occurrence of path attribute is considered, others ignored
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals("/", cookie.getPath());
-        assertTrue(cookie.containsAttribute(ClientCookie.PATH_ATTR));
+        Assert.assertEquals("/", cookie.getPath());
+        Assert.assertTrue(cookie.containsAttribute(ClientCookie.PATH_ATTR));
     }
 
+    @Test
     public void testParsePathDefault() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/path/", false);
         // Path is OPTIONAL, defaults to the request path
         Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals("/path", cookie.getPath());
-        assertFalse(cookie.containsAttribute(ClientCookie.PATH_ATTR));
+        Assert.assertEquals("/path", cookie.getPath());
+        Assert.assertFalse(cookie.containsAttribute(ClientCookie.PATH_ATTR));
     }
 
+    @Test
     public void testParseNullPath() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Path=;Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals("/", cookie.getPath());
-        assertTrue(cookie.containsAttribute(ClientCookie.PATH_ATTR));
+        Assert.assertEquals("/", cookie.getPath());
+        Assert.assertTrue(cookie.containsAttribute(ClientCookie.PATH_ATTR));
     }
 
+    @Test
     public void testParseBlankPath() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Path=\"   \";Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals("/", cookie.getPath());
-        assertTrue(cookie.containsAttribute(ClientCookie.PATH_ATTR));
+        Assert.assertEquals("/", cookie.getPath());
+        Assert.assertTrue(cookie.containsAttribute(ClientCookie.PATH_ATTR));
     }
 
     /**
      * Test parsing cookie <tt>"Domain"</tt> attribute.
      */
+    @Test
     public void testParseDomain() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Domain=.domain.com;Version=1;Domain=");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         // only the first occurrence of domain attribute is considered, others ignored
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals(".domain.com", cookie.getDomain());
-        assertTrue(cookie.containsAttribute(ClientCookie.DOMAIN_ATTR));
+        Assert.assertEquals(".domain.com", cookie.getDomain());
+        Assert.assertTrue(cookie.containsAttribute(ClientCookie.DOMAIN_ATTR));
 
         // should put a leading dot if there is no dot in front of domain
         header = new BasicHeader("Set-Cookie2", "name=value;Domain=domain.com;Version=1");
         cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         cookie = (ClientCookie) cookies.get(0);
-        assertEquals(".domain.com", cookie.getDomain());
+        Assert.assertEquals(".domain.com", cookie.getDomain());
     }
 
+    @Test
     public void testParseDomainDefaultValue() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         // Domain is OPTIONAL, defaults to the request host
         Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals("www.domain.com", cookie.getDomain());
-        assertFalse(cookie.containsAttribute(ClientCookie.DOMAIN_ATTR));
+        Assert.assertEquals("www.domain.com", cookie.getDomain());
+        Assert.assertFalse(cookie.containsAttribute(ClientCookie.DOMAIN_ATTR));
     }
 
+    @Test
     public void testParseNullDomain() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
@@ -159,19 +149,20 @@ public class TestCookieRFC2965Spec exten
         Header header = new BasicHeader("Set-Cookie2", "name=value;Domain=;Version=1");
         try {
             cookiespec.parse(header, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException ex) {
             // expected
         }
     }
 
+    @Test
     public void testParseBlankDomain() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Domain=\"   \";Version=1");
         try {
             cookiespec.parse(header, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException ex) {
             // expected
         }
@@ -180,87 +171,93 @@ public class TestCookieRFC2965Spec exten
     /**
      * Test parsing cookie <tt>"Port"</tt> attribute.
      */
+    @Test
     public void testParsePort() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Port=\"80,800,8000\";Version=1;Port=nonsense");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         // only the first occurrence of port attribute is considered, others ignored
         ClientCookie cookie = (ClientCookie) cookies.get(0);
         int[] ports = cookie.getPorts();
-        assertNotNull(ports);
-        assertEquals(3, ports.length);
-        assertEquals(80, ports[0]);
-        assertEquals(800, ports[1]);
-        assertEquals(8000, ports[2]);
-        assertTrue(cookie.containsAttribute(ClientCookie.PORT_ATTR));
+        Assert.assertNotNull(ports);
+        Assert.assertEquals(3, ports.length);
+        Assert.assertEquals(80, ports[0]);
+        Assert.assertEquals(800, ports[1]);
+        Assert.assertEquals(8000, ports[2]);
+        Assert.assertTrue(cookie.containsAttribute(ClientCookie.PORT_ATTR));
     }
 
+    @Test
     public void testParsePortDefault() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         // Port is OPTIONAL, cookie can be accepted from any port
         Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertFalse(cookie.containsAttribute(ClientCookie.PORT_ATTR));
+        Assert.assertFalse(cookie.containsAttribute(ClientCookie.PORT_ATTR));
     }
 
+    @Test
     public void testParseNullPort() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         // null port defaults to request port
         Header header = new BasicHeader("Set-Cookie2", "name=value;Port=;Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
         int[] ports = cookie.getPorts();
-        assertNotNull(ports);
-        assertEquals(1, ports.length);
-        assertEquals(80, ports[0]);
-        assertEquals("", cookie.getAttribute(ClientCookie.PORT_ATTR));
+        Assert.assertNotNull(ports);
+        Assert.assertEquals(1, ports.length);
+        Assert.assertEquals(80, ports[0]);
+        Assert.assertEquals("", cookie.getAttribute(ClientCookie.PORT_ATTR));
     }
 
+    @Test
     public void testParseBlankPort() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         // blank port defaults to request port
         Header header = new BasicHeader("Set-Cookie2", "name=value;Port=\"  \";Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
         int[] ports = cookie.getPorts();
-        assertNotNull(ports);
-        assertEquals(1, ports.length);
-        assertEquals(80, ports[0]);
-        assertEquals("  ", cookie.getAttribute(ClientCookie.PORT_ATTR));
+        Assert.assertNotNull(ports);
+        Assert.assertEquals(1, ports.length);
+        Assert.assertEquals(80, ports[0]);
+        Assert.assertEquals("  ", cookie.getAttribute(ClientCookie.PORT_ATTR));
     }
 
+    @Test
     public void testParseInvalidPort() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Port=nonsense;Version=1");
         try {
             cookiespec.parse(header, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException ex) {
             // expected
         }
     }
 
+    @Test
     public void testParseNegativePort() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Port=\"80,-800,8000\";Version=1");
         try {
             cookiespec.parse(header, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException ex) {
             // expected
         }
@@ -269,33 +266,36 @@ public class TestCookieRFC2965Spec exten
     /**
      * test parsing cookie name/value.
      */
+    @Test
     public void testParseNameValue() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1;");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals("name", cookie.getName());
-        assertEquals("value", cookie.getValue());
+        Assert.assertEquals("name", cookie.getName());
+        Assert.assertEquals("value", cookie.getValue());
     }
 
     /**
      * test parsing cookie <tt>"Version"</tt> attribute.
      */
+    @Test
     public void testParseVersion() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1;");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals(1, cookie.getVersion());
-        assertTrue(cookie.containsAttribute(ClientCookie.VERSION_ATTR));
+        Assert.assertEquals(1, cookie.getVersion());
+        Assert.assertTrue(cookie.containsAttribute(ClientCookie.VERSION_ATTR));
     }
 
+    @Test
     public void testParseNullVersion() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
@@ -303,19 +303,20 @@ public class TestCookieRFC2965Spec exten
         Header header = new BasicHeader("Set-Cookie2", "name=value;Version=;");
         try {
             cookiespec.parse(header, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException ex) {
             // expected
         }
     }
 
+    @Test
     public void testParseNegativeVersion() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Version=-1;");
         try {
             cookiespec.parse(header, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException ex) {
             // expected
         }
@@ -323,49 +324,53 @@ public class TestCookieRFC2965Spec exten
     /**
      * test parsing cookie <tt>"Max-age"</tt> attribute.
      */
+    @Test
     public void testParseMaxage() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Max-age=3600;Version=1;Max-age=nonsense");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         // only the first occurence of max-age attribute is considered, others ignored
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertFalse(cookie.isExpired(new Date()));
+        Assert.assertFalse(cookie.isExpired(new Date()));
     }
 
+    @Test
     public void testParseMaxageDefault() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         // Max-age is OPTIONAL, defaults to session cookie
         Header header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertFalse(cookie.isPersistent());
+        Assert.assertFalse(cookie.isPersistent());
     }
 
+    @Test
     public void testParseNullMaxage() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Max-age=;Version=1");
         try {
             cookiespec.parse(header, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException ex) {
             // expected
         }
     }
 
+    @Test
     public void testParseNegativeMaxage() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Max-age=-3600;Version=1;");
         try {
             cookiespec.parse(header, origin);
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException ex) {
             // expected
         }
@@ -374,80 +379,84 @@ public class TestCookieRFC2965Spec exten
     /**
      * test parsing <tt>"Secure"</tt> attribute.
      */
+    @Test
     public void testParseSecure() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Secure;Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertTrue(cookie.isSecure());
+        Assert.assertTrue(cookie.isSecure());
     }
 
     /**
      * test parsing <tt>"Discard"</tt> attribute.
      */
+    @Test
     public void testParseDiscard() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Discard;Max-age=36000;Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
         // discard overrides max-age
-        assertFalse(cookie.isPersistent());
+        Assert.assertFalse(cookie.isPersistent());
 
         // Discard is OPTIONAL, default behavior is dictated by max-age
         header = new BasicHeader("Set-Cookie2", "name=value;Max-age=36000;Version=1");
         cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         cookie = (ClientCookie) cookies.get(0);
-        assertTrue(cookie.isPersistent());
+        Assert.assertTrue(cookie.isPersistent());
     }
 
     /**
      * test parsing <tt>"Comment"</tt>, <tt>"CommentURL"</tt> and
      * <tt>"Secure"</tt> attributes.
      */
+    @Test
     public void testParseOtherAttributes() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "name=value;Comment=\"good cookie\";" +
                 "CommentURL=\"www.domain.com/goodcookie/\";Secure;Version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals("good cookie", cookie.getComment());
-        assertEquals("www.domain.com/goodcookie/", cookie.getCommentURL());
-        assertTrue(cookie.isSecure());
+        Assert.assertEquals("good cookie", cookie.getComment());
+        Assert.assertEquals("www.domain.com/goodcookie/", cookie.getCommentURL());
+        Assert.assertTrue(cookie.isSecure());
 
         // Comment, CommentURL, Secure are OPTIONAL
         header = new BasicHeader("Set-Cookie2", "name=value;Version=1");
         cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         cookie = (ClientCookie) cookies.get(0);
-        assertFalse(cookie.isSecure());
+        Assert.assertFalse(cookie.isSecure());
     }
 
     /**
      * Test parsing header with 2 cookies (separated by comma)
      */
+    @Test
     public void testCookiesWithComma() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
         Header header = new BasicHeader("Set-Cookie2", "a=b,c");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(2, cookies.size());
-        assertEquals("a", cookies.get(0).getName());
-        assertEquals("b", cookies.get(0).getValue());
-        assertEquals("c", cookies.get(1).getName());
-        assertEquals(null, cookies.get(1).getValue());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(2, cookies.size());
+        Assert.assertEquals("a", cookies.get(0).getName());
+        Assert.assertEquals("b", cookies.get(0).getValue());
+        Assert.assertEquals("c", cookies.get(1).getName());
+        Assert.assertEquals(null, cookies.get(1).getValue());
     }
 
     // ------------------------------------------------------- Test Cookie Validation
@@ -456,6 +465,7 @@ public class TestCookieRFC2965Spec exten
      * Test <tt>Domain</tt> validation when domain is not specified
      * in <tt>Set-Cookie2</tt> header.
      */
+    @Test
     public void testValidateNoDomain() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
@@ -464,17 +474,18 @@ public class TestCookieRFC2965Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
         // cookie domain must string match request host
-        assertEquals("www.domain.com", cookie.getDomain());
+        Assert.assertEquals("www.domain.com", cookie.getDomain());
     }
 
     /**
      * Test <tt>Domain</tt> validation. Cookie domain attribute must have a
      * leading dot.
      */
+    @Test
     public void testValidateDomainLeadingDot() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
@@ -483,15 +494,16 @@ public class TestCookieRFC2965Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals(".domain.com", cookie.getDomain());
+        Assert.assertEquals(".domain.com", cookie.getDomain());
     }
 
     /**
      * Test <tt>Domain</tt> validation. Domain must have at least one embedded dot.
      */
+    @Test
     public void testValidateDomainEmbeddedDot() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("b.com", 80, "/", false);
@@ -501,7 +513,7 @@ public class TestCookieRFC2965Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException expected) {}
 
         origin = new CookieOrigin("www.domain.com", 80, "/", false);
@@ -510,8 +522,8 @@ public class TestCookieRFC2965Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
     }
 
     /**
@@ -519,6 +531,7 @@ public class TestCookieRFC2965Spec exten
      * (without any dots) are valid only when cookie domain is specified
      * as ".local".
      */
+    @Test
     public void testValidateDomainLocal() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("simplehost", 80, "/", false);
@@ -528,23 +541,24 @@ public class TestCookieRFC2965Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals(".local", cookie.getDomain());
+        Assert.assertEquals(".local", cookie.getDomain());
 
         // when domain is NOT specified as .local, simple host names are invalid
         header = new BasicHeader("Set-Cookie2", "name=value; domain=domain.com; version=1");
         try {
-            // since domain is not .local, this must fail
+            // since domain is not .local, this must Assert.fail
             cookies = cookiespec.parse(header, origin);
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException expected) {}
     }
 
+    @Test
     public void testValidateDomainLocalhost() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("localhost", 80, "/", false);
@@ -553,16 +567,17 @@ public class TestCookieRFC2965Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals("localhost.local", cookie.getDomain());
+        Assert.assertEquals("localhost.local", cookie.getDomain());
     }
 
     /**
      * Test <tt>Domain</tt> validation. Effective host name
      * must domain-match domain attribute.
      */
+    @Test
     public void testValidateDomainEffectiveHost() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
 
@@ -574,7 +589,7 @@ public class TestCookieRFC2965Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException expected) {}
 
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);
@@ -584,14 +599,15 @@ public class TestCookieRFC2965Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
     }
 
     /**
      * Test local <tt>Domain</tt> validation.
      * Effective host name minus domain must not contain any dots.
      */
+    @Test
     public void testValidateDomainIllegal() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("a.b.domain.com", 80, "/", false);
@@ -601,7 +617,7 @@ public class TestCookieRFC2965Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException expected) {}
     }
 
@@ -609,6 +625,7 @@ public class TestCookieRFC2965Spec exten
      * Test cookie <tt>Path</tt> validation. Cookie path attribute must path-match
      * request path.
      */
+    @Test
     public void testValidatePath() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         Header header = new BasicHeader("Set-Cookie2", "name=value;path=/path;version=1");
@@ -618,7 +635,7 @@ public class TestCookieRFC2965Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException expected) {}
 
         // path-matching is case-sensitive
@@ -629,7 +646,7 @@ public class TestCookieRFC2965Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException expected) {}
 
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/path/path1", false);
@@ -638,14 +655,15 @@ public class TestCookieRFC2965Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
-        assertEquals("/path", cookies.get(0).getPath());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
+        Assert.assertEquals("/path", cookies.get(0).getPath());
     }
 
     /**
      * Test cookie name validation.
      */
+    @Test
     public void testValidateCookieName() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("127.0.0.1", 80, "/", false);
@@ -656,7 +674,7 @@ public class TestCookieRFC2965Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException expected) {}
 
         // cookie name must not start with '$'.
@@ -666,23 +684,24 @@ public class TestCookieRFC2965Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException exception should have been thrown");
+            Assert.fail("MalformedCookieException exception should have been thrown");
         } catch (MalformedCookieException expected) {}
 
         // valid name
         header = new BasicHeader("Set-Cookie2", "name=value; version=1");
         List<Cookie> cookies = cookiespec.parse(header, origin);
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
-        assertEquals("name", cookie.getName());
-        assertEquals("value", cookie.getValue());
+        Assert.assertEquals("name", cookie.getName());
+        Assert.assertEquals("value", cookie.getValue());
     }
 
     /**
      * Test cookie <tt>Port</tt> validation. Request port must be in the
      * port attribute list.
      */
+    @Test
     public void testValidatePort() throws Exception {
         Header header = new BasicHeader("Set-Cookie2", "name=value; Port=\"80,800\"; version=1");
         CookieSpec cookiespec = new RFC2965Spec();
@@ -692,7 +711,7 @@ public class TestCookieRFC2965Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException e) {}
 
         // valid port list
@@ -701,19 +720,20 @@ public class TestCookieRFC2965Spec exten
         for (int i = 0; i < cookies.size(); i++) {
             cookiespec.validate(cookies.get(i), origin);
         }
-        assertNotNull(cookies);
-        assertEquals(1, cookies.size());
+        Assert.assertNotNull(cookies);
+        Assert.assertEquals(1, cookies.size());
         ClientCookie cookie = (ClientCookie) cookies.get(0);
         int[] ports = cookie.getPorts();
-        assertNotNull(ports);
-        assertEquals(2, ports.length);
-        assertEquals(80, ports[0]);
-        assertEquals(800, ports[1]);
+        Assert.assertNotNull(ports);
+        Assert.assertEquals(2, ports.length);
+        Assert.assertEquals(80, ports[0]);
+        Assert.assertEquals(800, ports[1]);
     }
 
     /**
      * Test cookie <tt>Version</tt> validation.
      */
+    @Test
     public void testValidateVersion() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         // version attribute is REQUIRED
@@ -724,7 +744,7 @@ public class TestCookieRFC2965Spec exten
             for (int i = 0; i < cookies.size(); i++) {
                 cookiespec.validate(cookies.get(i), origin);
             }
-            fail("MalformedCookieException should have been thrown");
+            Assert.fail("MalformedCookieException should have been thrown");
         } catch (MalformedCookieException e) {}
     }
 
@@ -734,6 +754,7 @@ public class TestCookieRFC2965Spec exten
      * test cookie <tt>Path</tt> matching. Cookie path attribute must path-match
      * path of the request URI.
      */
+    @Test
     public void testMatchPath() throws Exception {
         BasicClientCookie2 cookie = new BasicClientCookie2("name", "value");
         cookie.setDomain(".domain.com");
@@ -741,14 +762,15 @@ public class TestCookieRFC2965Spec exten
         cookie.setPorts(new int[] {80});
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin1 = new CookieOrigin("www.domain.com", 80, "/", false);
-        assertFalse(cookiespec.match(cookie, origin1));
+        Assert.assertFalse(cookiespec.match(cookie, origin1));
         CookieOrigin origin2 = new CookieOrigin("www.domain.com", 80, "/path/path1", false);
-        assertTrue(cookiespec.match(cookie, origin2));
+        Assert.assertTrue(cookiespec.match(cookie, origin2));
     }
 
     /**
      * test cookie <tt>Domain</tt> matching.
      */
+    @Test
     public void testMatchDomain() throws Exception {
         BasicClientCookie2 cookie = new BasicClientCookie2("name", "value");
         cookie.setDomain(".domain.com");
@@ -757,18 +779,19 @@ public class TestCookieRFC2965Spec exten
         CookieSpec cookiespec = new RFC2965Spec();
         // effective host name minus domain must not contain any dots
         CookieOrigin origin1 = new CookieOrigin("a.b.domain.com" /* request host */, 80, "/", false);
-        assertFalse(cookiespec.match(cookie, origin1));
+        Assert.assertFalse(cookiespec.match(cookie, origin1));
         // The effective host name MUST domain-match the Domain
         // attribute of the cookie.
         CookieOrigin origin2 = new CookieOrigin("www.domain.org" /* request host */, 80, "/", false);
-        assertFalse(cookiespec.match(cookie, origin2));
+        Assert.assertFalse(cookiespec.match(cookie, origin2));
         CookieOrigin origin3 = new CookieOrigin("www.domain.com" /* request host */, 80, "/", false);
-        assertTrue(cookiespec.match(cookie, origin3));
+        Assert.assertTrue(cookiespec.match(cookie, origin3));
     }
 
     /**
      * test cookie local <tt>Domain</tt> matching.
      */
+    @Test
     public void testMatchDomainLocal() throws Exception {
         BasicClientCookie2 cookie = new BasicClientCookie2("name", "value");
         cookie.setDomain(".local");
@@ -776,14 +799,15 @@ public class TestCookieRFC2965Spec exten
         cookie.setPorts(new int[] {80});
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin1 = new CookieOrigin("host" /* request host */, 80, "/", false);
-        assertTrue(cookiespec.match(cookie, origin1));
+        Assert.assertTrue(cookiespec.match(cookie, origin1));
         CookieOrigin origin2 = new CookieOrigin("host.com" /* request host */, 80, "/", false);
-        assertFalse(cookiespec.match(cookie, origin2));
+        Assert.assertFalse(cookiespec.match(cookie, origin2));
     }
 
     /**
      * test cookie <tt>Port</tt> matching.
      */
+    @Test
     public void testMatchPort() throws Exception {
         // cookie can be sent to any port if port attribute not specified
         BasicClientCookie2 cookie = new BasicClientCookie2("name", "value");
@@ -793,9 +817,9 @@ public class TestCookieRFC2965Spec exten
 
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin1 = new CookieOrigin("www.domain.com", 8080 /* request port */, "/", false);
-        assertTrue(cookiespec.match(cookie, origin1));
+        Assert.assertTrue(cookiespec.match(cookie, origin1));
         CookieOrigin origin2 = new CookieOrigin("www.domain.com", 323 /* request port */, "/", false);
-        assertTrue(cookiespec.match(cookie, origin2));
+        Assert.assertTrue(cookiespec.match(cookie, origin2));
 
         // otherwise, request port must be in cookie's port list
         cookie = new BasicClientCookie2("name", "value");
@@ -804,14 +828,15 @@ public class TestCookieRFC2965Spec exten
         cookie.setPorts(new int[] {80, 8080});
         cookie.setAttribute(ClientCookie.PORT_ATTR, "80, 8080");
         CookieOrigin origin3 = new CookieOrigin("www.domain.com", 434 /* request port */, "/", false);
-        assertFalse(cookiespec.match(cookie, origin3));
+        Assert.assertFalse(cookiespec.match(cookie, origin3));
         CookieOrigin origin4 = new CookieOrigin("www.domain.com", 8080 /* request port */, "/", false);
-        assertTrue(cookiespec.match(cookie, origin4));
+        Assert.assertTrue(cookiespec.match(cookie, origin4));
     }
 
     /**
      * test cookie expiration.
      */
+    @Test
     public void testCookieExpiration() throws Exception {
         Date now = new Date();
 
@@ -822,7 +847,7 @@ public class TestCookieRFC2965Spec exten
         cookie.setPorts(null);
         cookie.setExpiryDate(beforeOneHour);
 
-        assertTrue(cookie.isExpired(now));
+        Assert.assertTrue(cookie.isExpired(now));
 
         Date afterOneHour = new Date(now.getTime() + 3600 * 1000L);
         cookie = new BasicClientCookie2("name", "value");
@@ -831,17 +856,18 @@ public class TestCookieRFC2965Spec exten
         cookie.setPorts(null);
         cookie.setExpiryDate(afterOneHour);
 
-        assertFalse(cookie.isExpired(now));
+        Assert.assertFalse(cookie.isExpired(now));
 
         // discard attributes overrides cookie age, makes it a session cookie.
         cookie.setDiscard(true);
-        assertFalse(cookie.isPersistent());
-        assertTrue(cookie.isExpired(now));
+        Assert.assertFalse(cookie.isPersistent());
+        Assert.assertTrue(cookie.isExpired(now));
     }
 
     /**
      * test cookie <tt>Secure</tt> attribute.
      */
+    @Test
     public void testCookieSecure() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         // secure cookie can only be sent over a secure connection
@@ -850,9 +876,9 @@ public class TestCookieRFC2965Spec exten
         cookie.setPath("/");
         cookie.setSecure(true);
         CookieOrigin origin1 = new CookieOrigin("www.domain.com", 80, "/", false);
-        assertFalse(cookiespec.match(cookie, origin1));
+        Assert.assertFalse(cookiespec.match(cookie, origin1));
         CookieOrigin origin2 = new CookieOrigin("www.domain.com", 80, "/", true);
-        assertTrue(cookiespec.match(cookie, origin2));
+        Assert.assertTrue(cookiespec.match(cookie, origin2));
     }
 
     // ------------------------------------------------------- Test Cookie Formatting
@@ -860,6 +886,7 @@ public class TestCookieRFC2965Spec exten
     /**
      * Tests RFC 2965 compliant cookie formatting.
      */
+    @Test
     public void testRFC2965CookieFormatting() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec(null, true);
         BasicClientCookie2 cookie1 = new BasicClientCookie2("name1", "value");
@@ -875,9 +902,9 @@ public class TestCookieRFC2965Spec exten
         List<Cookie> cookies = new ArrayList<Cookie>();
         cookies.add(cookie1);
         List<Header> headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=1; name1=\"value\"; $Path=\"/\"; $Domain=\".domain.com\"; $Port=\"80,8080\"",
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=1; name1=\"value\"; $Path=\"/\"; $Domain=\".domain.com\"; $Port=\"80,8080\"",
                 headers.get(0).getValue());
 
 
@@ -893,9 +920,9 @@ public class TestCookieRFC2965Spec exten
         cookies = new ArrayList<Cookie>();
         cookies.add(cookie2);
         headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=2; name2=\"value\"; $Path=\"/a/\"; $Domain=\".domain.com\"",
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=2; name2=\"value\"; $Path=\"/a/\"; $Domain=\".domain.com\"",
                 headers.get(0).getValue());
 
         BasicClientCookie2 cookie3 = new BasicClientCookie2("name3", "value");
@@ -910,9 +937,9 @@ public class TestCookieRFC2965Spec exten
         cookies = new ArrayList<Cookie>();
         cookies.add(cookie3);
         headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=1; name3=\"value\"; $Path=\"/a/b/\"; $Port=\"\"",
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=1; name3=\"value\"; $Path=\"/a/b/\"; $Port=\"\"",
                 headers.get(0).getValue());
 
         cookies = new ArrayList<Cookie>();
@@ -920,9 +947,9 @@ public class TestCookieRFC2965Spec exten
         cookies.add(cookie2);
         cookies.add(cookie1);
         headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
-        assertEquals("$Version=1; " +
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
+        Assert.assertEquals("$Version=1; " +
                 "name3=\"value\"; $Path=\"/a/b/\"; $Port=\"\"; " +
                 "name2=\"value\"; $Path=\"/a/\"; $Domain=\".domain.com\"; " +
                 "name1=\"value\"; $Path=\"/\"; $Domain=\".domain.com\"; $Port=\"80,8080\"",
@@ -932,6 +959,7 @@ public class TestCookieRFC2965Spec exten
     /**
      * Tests RFC 2965 compliant cookies formatting.
      */
+    @Test
     public void testRFC2965CookiesFormatting() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec(null, true);
         BasicClientCookie2 cookie1 = new BasicClientCookie2("name1", "value1");
@@ -957,10 +985,10 @@ public class TestCookieRFC2965Spec exten
         cookies.add(cookie1);
         cookies.add(cookie2);
         List<Header> headers = cookiespec.formatCookies(cookies);
-        assertNotNull(headers);
-        assertEquals(1, headers.size());
+        Assert.assertNotNull(headers);
+        Assert.assertEquals(1, headers.size());
 
-        assertEquals("$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".domain.com\"; $Port=\"80,8080\"; " +
+        Assert.assertEquals("$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".domain.com\"; $Port=\"80,8080\"; " +
             "name2=\"\"; $Path=\"/\"; $Domain=\".domain.com\"",
             headers.get(0).getValue());
     }
@@ -970,6 +998,7 @@ public class TestCookieRFC2965Spec exten
     /**
      * Test rejection of <tt>Set-Cookie</tt> header.
      */
+    @Test
     public void testRejectSetCookie() throws Exception {
         CookieSpec cookiespec = new RFC2965Spec();
         CookieOrigin origin = new CookieOrigin("www.domain.com", 80, "/", false);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestDateUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestDateUtils.java?rev=938585&r1=938584&r2=938585&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestDateUtils.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/cookie/TestDateUtils.java Tue Apr 27 18:01:48 2010
@@ -30,29 +30,15 @@ package org.apache.http.impl.cookie;
 import java.util.Calendar;
 import java.util.Date;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link DateUtils}.
- *
  */
-public class TestDateUtils extends TestCase {
-
-    public TestDateUtils(String testName) {
-        super(testName);
-    }
-
-    public static void main(String args[]) {
-        String[] testCaseName = { TestDateUtils.class.getName() };
-        junit.textui.TestRunner.main(testCaseName);
-    }
-
-    public static Test suite() {
-        return new TestSuite(TestDateUtils.class);
-    }
+public class TestDateUtils {
 
+    @Test
     public void testBasicDateParse() throws Exception {
         Calendar calendar = Calendar.getInstance();
         calendar.setTimeZone(DateUtils.GMT);
@@ -64,40 +50,42 @@ public class TestDateUtils extends TestC
                 DateUtils.PATTERN_RFC1123
                 };
         Date date2 = DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", formats, null);
-        assertEquals(date1, date2);
+        Assert.assertEquals(date1, date2);
         date2 = DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", formats);
-        assertEquals(date1, date2);
+        Assert.assertEquals(date1, date2);
         date2 = DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT");
-        assertEquals(date1, date2);
+        Assert.assertEquals(date1, date2);
     }
 
+    @Test
     public void testInvalidInput() throws Exception {
         try {
             DateUtils.parseDate(null, null, null);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", new String[] {}, null);
-            fail("DateParseException should habe been thrown");
+            Assert.fail("DateParseException should habe been thrown");
         } catch (DateParseException ex) {
             // expected
         }
         try {
             DateUtils.formatDate(null);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             DateUtils.formatDate(new Date(), null);
-            fail("IllegalArgumentException should habe been thrown");
+            Assert.fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testTwoDigitYearDateParse() throws Exception {
         Calendar calendar = Calendar.getInstance();
         calendar.setTimeZone(DateUtils.GMT);
@@ -109,7 +97,7 @@ public class TestDateUtils extends TestC
                 DateUtils.PATTERN_RFC1036
                 };
         Date date2 = DateUtils.parseDate("Friday, 14-Oct-05 00:00:00 GMT", formats, null);
-        assertEquals(date1, date2);
+        Assert.assertEquals(date1, date2);
 
         calendar.set(1900, Calendar.JANUARY, 0, 0, 0, 0);
         calendar.set(Calendar.MILLISECOND, 0);
@@ -120,9 +108,10 @@ public class TestDateUtils extends TestC
         date1 = calendar.getTime();
 
         date2 = DateUtils.parseDate("Friday, 14-Oct-05 00:00:00 GMT", formats, startDate);
-        assertEquals(date1, date2);
+        Assert.assertEquals(date1, date2);
     }
 
+    @Test
     public void testParseQuotedDate() throws Exception {
         Calendar calendar = Calendar.getInstance();
         calendar.setTimeZone(DateUtils.GMT);
@@ -134,9 +123,10 @@ public class TestDateUtils extends TestC
                 DateUtils.PATTERN_RFC1123
                 };
         Date date2 = DateUtils.parseDate("'Fri, 14 Oct 2005 00:00:00 GMT'", formats);
-        assertEquals(date1, date2);
+        Assert.assertEquals(date1, date2);
     }
 
+    @Test
     public void testBasicDateFormat() throws Exception {
         Calendar calendar = Calendar.getInstance();
         calendar.setTimeZone(DateUtils.GMT);
@@ -144,10 +134,11 @@ public class TestDateUtils extends TestC
         calendar.set(Calendar.MILLISECOND, 0);
         Date date = calendar.getTime();
 
-        assertEquals("Fri, 14 Oct 2005 00:00:00 GMT", DateUtils.formatDate(date));
-        assertEquals("Fri, 14 Oct 2005 00:00:00 GMT", DateUtils.formatDate(date, DateUtils.PATTERN_RFC1123));
+        Assert.assertEquals("Fri, 14 Oct 2005 00:00:00 GMT", DateUtils.formatDate(date));
+        Assert.assertEquals("Fri, 14 Oct 2005 00:00:00 GMT", DateUtils.formatDate(date, DateUtils.PATTERN_RFC1123));
     }
 
+    @Test
     public void testConstructor() {
         new DateParseException();
         new DateParseException("Oppsie");



Mime
View raw message