hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1100965 [8/9] - in /httpcomponents/httpcore/trunk: httpcore-nio/src/test/java/org/apache/http/ httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/ httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/ httpcore-nio/src/test/j...
Date Mon, 09 May 2011 11:27:00 GMT
Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java Mon May  9 11:26:57 2011
@@ -27,8 +27,6 @@
 
 package org.apache.http.protocol;
 
-import junit.framework.TestCase;
-
 import org.apache.http.Header;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
@@ -42,25 +40,23 @@ import org.apache.http.message.BasicHttp
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.message.BasicHttpResponse;
 import org.apache.http.params.CoreProtocolPNames;
+import org.junit.Assert;
+import org.junit.Test;
 
-/**
- */
-public class TestStandardInterceptors extends TestCase {
-
-    public TestStandardInterceptors(String testName) {
-        super(testName);
-    }
+public class TestStandardInterceptors {
 
+    @Test
     public void testRequestConnControlGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
         RequestConnControl interceptor = new RequestConnControl();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        assertNotNull(header);
-        assertEquals(HTTP.CONN_KEEP_ALIVE, header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header.getValue());
     }
 
+    @Test
     public void testRequestConnControlCustom() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
@@ -69,21 +65,23 @@ public class TestStandardInterceptors ex
         RequestConnControl interceptor = new RequestConnControl();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        assertNotNull(header);
-        assertEquals(HTTP.CONN_CLOSE, header.getValue());
-        assertTrue(header == myheader);
+        Assert.assertNotNull(header);
+        Assert.assertEquals(HTTP.CONN_CLOSE, header.getValue());
+        Assert.assertTrue(header == myheader);
     }
 
+    @Test
     public void testRequestConnControlInvalidInput() throws Exception {
         RequestConnControl interceptor = new RequestConnControl();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testRequestContentProtocolException() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request1 = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -94,18 +92,19 @@ public class TestStandardInterceptors ex
         RequestContent interceptor = new RequestContent();
         try {
             interceptor.process(request1, context);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
         try {
             interceptor.process(request2, context);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
    }
 
+    @Test
     public void testRequestContentNullEntity() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -113,11 +112,12 @@ public class TestStandardInterceptors ex
         RequestContent interceptor = new RequestContent();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNotNull(header);
-        assertEquals("0", header.getValue());
-        assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
+        Assert.assertNotNull(header);
+        Assert.assertEquals("0", header.getValue());
+        Assert.assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
    }
 
+    @Test
     public void testRequestContentEntityContentLengthDelimitedHTTP11() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -128,11 +128,12 @@ public class TestStandardInterceptors ex
         RequestContent interceptor = new RequestContent();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNotNull(header);
-        assertEquals(s.length(), Integer.parseInt(header.getValue()));
-        assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
+        Assert.assertNotNull(header);
+        Assert.assertEquals(s.length(), Integer.parseInt(header.getValue()));
+        Assert.assertNull(request.getFirstHeader(HTTP.TRANSFER_ENCODING));
    }
 
+    @Test
     public void testRequestContentEntityChunkedHTTP11() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -144,11 +145,12 @@ public class TestStandardInterceptors ex
         RequestContent interceptor = new RequestContent();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.TRANSFER_ENCODING);
-        assertNotNull(header);
-        assertEquals("chunked", header.getValue());
-        assertNull(request.getFirstHeader(HTTP.CONTENT_LEN));
+        Assert.assertNotNull(header);
+        Assert.assertEquals("chunked", header.getValue());
+        Assert.assertNull(request.getFirstHeader(HTTP.CONTENT_LEN));
    }
 
+    @Test
     public void testRequestContentEntityUnknownLengthHTTP11() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -160,11 +162,12 @@ public class TestStandardInterceptors ex
         RequestContent interceptor = new RequestContent();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.TRANSFER_ENCODING);
-        assertNotNull(header);
-        assertEquals("chunked", header.getValue());
-        assertNull(request.getFirstHeader(HTTP.CONTENT_LEN));
+        Assert.assertNotNull(header);
+        Assert.assertEquals("chunked", header.getValue());
+        Assert.assertNull(request.getFirstHeader(HTTP.CONTENT_LEN));
     }
 
+    @Test
     public void testRequestContentEntityChunkedHTTP10() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
@@ -177,12 +180,13 @@ public class TestStandardInterceptors ex
         RequestContent interceptor = new RequestContent();
         try {
             interceptor.process(request, context);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testRequestContentTypeAndEncoding() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -194,13 +198,14 @@ public class TestStandardInterceptors ex
         RequestContent interceptor = new RequestContent();
         interceptor.process(request, context);
         Header h1 = request.getFirstHeader(HTTP.CONTENT_TYPE);
-        assertNotNull(h1);
-        assertEquals("whatever", h1.getValue());
+        Assert.assertNotNull(h1);
+        Assert.assertEquals("whatever", h1.getValue());
         Header h2 = request.getFirstHeader(HTTP.CONTENT_ENCODING);
-        assertNotNull(h2);
-        assertEquals("whatever", h2.getValue());
+        Assert.assertNotNull(h2);
+        Assert.assertEquals("whatever", h2.getValue());
     }
 
+    @Test
     public void testRequestContentNullTypeAndEncoding() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -209,10 +214,11 @@ public class TestStandardInterceptors ex
 
         RequestContent interceptor = new RequestContent();
         interceptor.process(request, context);
-        assertNull(request.getFirstHeader(HTTP.CONTENT_TYPE));
-        assertNull(request.getFirstHeader(HTTP.CONTENT_ENCODING));
+        Assert.assertNull(request.getFirstHeader(HTTP.CONTENT_TYPE));
+        Assert.assertNull(request.getFirstHeader(HTTP.CONTENT_ENCODING));
     }
 
+    @Test
     public void testRequestContentEntityUnknownLengthHTTP10() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
@@ -225,31 +231,34 @@ public class TestStandardInterceptors ex
         RequestContent interceptor = new RequestContent();
         try {
             interceptor.process(request, context);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
    }
 
+    @Test
     public void testRequestContentInvalidInput() throws Exception {
         RequestContent interceptor = new RequestContent();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testRequestContentIgnoreNonenclosingRequests() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("POST", "/");
         RequestContent interceptor = new RequestContent();
         interceptor.process(request, context);
-        assertEquals(0, request.getAllHeaders().length);
+        Assert.assertEquals(0, request.getAllHeaders().length);
     }
 
-   public void testRequestExpectContinueGenerated() throws Exception {
+    @Test
+    public void testRequestExpectContinueGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
         String s = "whatever";
@@ -259,10 +268,11 @@ public class TestStandardInterceptors ex
         RequestExpectContinue interceptor = new RequestExpectContinue();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
-        assertNotNull(header);
-        assertEquals(HTTP.EXPECT_CONTINUE, header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals(HTTP.EXPECT_CONTINUE, header.getValue());
     }
 
+    @Test
     public void testRequestExpectContinueNotGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -273,9 +283,10 @@ public class TestStandardInterceptors ex
         RequestExpectContinue interceptor = new RequestExpectContinue();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testRequestExpectContinueHTTP10() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
@@ -287,9 +298,10 @@ public class TestStandardInterceptors ex
         RequestExpectContinue interceptor = new RequestExpectContinue();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testRequestExpectContinueZeroContent() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
@@ -300,27 +312,30 @@ public class TestStandardInterceptors ex
         RequestExpectContinue interceptor = new RequestExpectContinue();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testRequestExpectContinueInvalidInput() throws Exception {
         RequestExpectContinue interceptor = new RequestExpectContinue();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testRequestExpectContinueIgnoreNonenclosingRequests() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("POST", "/");
         RequestExpectContinue interceptor = new RequestExpectContinue();
         interceptor.process(request, context);
-        assertEquals(0, request.getAllHeaders().length);
+        Assert.assertEquals(0, request.getAllHeaders().length);
     }
 
+    @Test
     public void testRequestTargetHostGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpHost host = new HttpHost("somehost", 8080, "http");
@@ -329,10 +344,11 @@ public class TestStandardInterceptors ex
         RequestTargetHost interceptor = new RequestTargetHost();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.TARGET_HOST);
-        assertNotNull(header);
-        assertEquals("somehost:8080", header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals("somehost:8080", header.getValue());
     }
 
+    @Test
     public void testRequestTargetHostNotGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpHost host = new HttpHost("somehost", 8080, "http");
@@ -342,10 +358,11 @@ public class TestStandardInterceptors ex
         RequestTargetHost interceptor = new RequestTargetHost();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.TARGET_HOST);
-        assertNotNull(header);
-        assertEquals("whatever", header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals("whatever", header.getValue());
     }
 
+    @Test
     public void testRequestTargetHostMissingHostHTTP10() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest(
@@ -353,37 +370,40 @@ public class TestStandardInterceptors ex
         RequestTargetHost interceptor = new RequestTargetHost();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.TARGET_HOST);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testRequestTargetHostMissingHostHTTP11() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
         RequestTargetHost interceptor = new RequestTargetHost();
         try {
             interceptor.process(request, context);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testRequestTargetHostInvalidInput() throws Exception {
         RequestTargetHost interceptor = new RequestTargetHost();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             interceptor.process(new BasicHttpRequest("GET", "/"), null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testRequestTargetHostConnectHttp11() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpHost host = new HttpHost("somehost", 8080, "http");
@@ -392,10 +412,11 @@ public class TestStandardInterceptors ex
         RequestTargetHost interceptor = new RequestTargetHost();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.TARGET_HOST);
-        assertNotNull(header);
-        assertEquals("somehost:8080", header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals("somehost:8080", header.getValue());
     }
 
+    @Test
     public void testRequestTargetHostConnectHttp10() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpHost host = new HttpHost("somehost", 8080, "http");
@@ -404,9 +425,10 @@ public class TestStandardInterceptors ex
         RequestTargetHost interceptor = new RequestTargetHost();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.TARGET_HOST);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testRequestUserAgentGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
@@ -414,10 +436,11 @@ public class TestStandardInterceptors ex
         RequestUserAgent interceptor = new RequestUserAgent();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.USER_AGENT);
-        assertNotNull(header);
-        assertEquals("some agent", header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals("some agent", header.getValue());
     }
 
+    @Test
     public void testRequestUserAgentNotGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
@@ -426,38 +449,42 @@ public class TestStandardInterceptors ex
         RequestUserAgent interceptor = new RequestUserAgent();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.USER_AGENT);
-        assertNotNull(header);
-        assertEquals("whatever", header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals("whatever", header.getValue());
     }
 
+    @Test
     public void testRequestUserAgentMissingUserAgent() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
         RequestUserAgent interceptor = new RequestUserAgent();
         interceptor.process(request, context);
         Header header = request.getFirstHeader(HTTP.USER_AGENT);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testRequestUserAgentInvalidInput() throws Exception {
         RequestUserAgent interceptor = new RequestUserAgent();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testResponseConnControlNoEntity() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         ResponseConnControl interceptor = new ResponseConnControl();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testResponseConnControlEntityContentLength() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -466,9 +493,10 @@ public class TestStandardInterceptors ex
         ResponseConnControl interceptor = new ResponseConnControl();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testResponseConnControlEntityUnknownContentLength() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
@@ -480,10 +508,11 @@ public class TestStandardInterceptors ex
         ResponseConnControl interceptor = new ResponseConnControl();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        assertNotNull(header);
-        assertEquals(HTTP.CONN_CLOSE, header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals(HTTP.CONN_CLOSE, header.getValue());
     }
 
+    @Test
     public void testResponseConnControlEntityChunked() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -493,9 +522,10 @@ public class TestStandardInterceptors ex
         ResponseConnControl interceptor = new ResponseConnControl();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testResponseConnControlEntityUnknownContentLengthHTTP10() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
@@ -509,10 +539,11 @@ public class TestStandardInterceptors ex
         ResponseConnControl interceptor = new ResponseConnControl();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        assertNotNull(header);
-        assertEquals(HTTP.CONN_CLOSE, header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals(HTTP.CONN_CLOSE, header.getValue());
     }
 
+    @Test
     public void testResponseConnControlClientRequest() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
@@ -525,10 +556,11 @@ public class TestStandardInterceptors ex
         ResponseConnControl interceptor = new ResponseConnControl();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        assertNotNull(header);
-        assertEquals(HTTP.CONN_KEEP_ALIVE, header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header.getValue());
     }
 
+    @Test
     public void testResponseConnControlClientRequest2() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
@@ -540,9 +572,10 @@ public class TestStandardInterceptors ex
         ResponseConnControl interceptor = new ResponseConnControl();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testResponseConnControlStatusCode() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
@@ -565,39 +598,42 @@ public class TestStandardInterceptors ex
                     HttpVersion.HTTP_1_1, statusCodes[i], "Unreasonable");
             interceptor.process(response, context);
             Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
-            assertNotNull(header);
-            assertEquals(HTTP.CONN_CLOSE, header.getValue());
+            Assert.assertNotNull(header);
+            Assert.assertEquals(HTTP.CONN_CLOSE, header.getValue());
         }
 
     }
 
+    @Test
     public void testResponseConnControlHostInvalidInput() throws Exception {
         ResponseConnControl interceptor = new ResponseConnControl();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
             interceptor.process(response, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testResponseContentNoEntity() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNotNull(header);
-        assertEquals("0", header.getValue());
+        Assert.assertNotNull(header);
+        Assert.assertEquals("0", header.getValue());
     }
 
+    @Test
     public void testResponseContentStatusNoContent() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -605,9 +641,10 @@ public class TestStandardInterceptors ex
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testResponseContentStatusResetContent() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -615,9 +652,10 @@ public class TestStandardInterceptors ex
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testResponseContentStatusNotModified() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -625,9 +663,10 @@ public class TestStandardInterceptors ex
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header header = response.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNull(header);
+        Assert.assertNull(header);
     }
 
+    @Test
     public void testResponseContentEntityChunked() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -637,12 +676,13 @@ public class TestStandardInterceptors ex
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
-        assertNotNull(h1);
-        assertEquals(HTTP.CHUNK_CODING, h1.getValue());
+        Assert.assertNotNull(h1);
+        Assert.assertEquals(HTTP.CHUNK_CODING, h1.getValue());
         Header h2 = response.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNull(h2);
+        Assert.assertNull(h2);
     }
 
+    @Test
     public void testResponseContentEntityContentLenghtDelimited() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -652,12 +692,13 @@ public class TestStandardInterceptors ex
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNotNull(h1);
-        assertEquals("10", h1.getValue());
+        Assert.assertNotNull(h1);
+        Assert.assertEquals("10", h1.getValue());
         Header h2 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
-        assertNull(h2);
+        Assert.assertNull(h2);
     }
 
+    @Test
     public void testResponseContentEntityUnknownContentLength() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -666,11 +707,12 @@ public class TestStandardInterceptors ex
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
-        assertNull(h1);
+        Assert.assertNull(h1);
         Header h2 = response.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNull(h2);
+        Assert.assertNull(h2);
     }
 
+    @Test
     public void testResponseContentEntityChunkedHTTP10() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
@@ -680,11 +722,12 @@ public class TestStandardInterceptors ex
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
-        assertNull(h1);
+        Assert.assertNull(h1);
         Header h2 = response.getFirstHeader(HTTP.CONTENT_LEN);
-        assertNull(h2);
+        Assert.assertNull(h2);
     }
 
+    @Test
     public void testResponseContentEntityNoContentTypeAndEncoding() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -693,11 +736,12 @@ public class TestStandardInterceptors ex
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.CONTENT_TYPE);
-        assertNull(h1);
+        Assert.assertNull(h1);
         Header h2 = response.getFirstHeader(HTTP.CONTENT_ENCODING);
-        assertNull(h2);
+        Assert.assertNull(h2);
     }
 
+    @Test
     public void testResponseContentEntityContentTypeAndEncoding() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -708,23 +752,25 @@ public class TestStandardInterceptors ex
         ResponseContent interceptor = new ResponseContent();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.CONTENT_TYPE);
-        assertNotNull(h1);
-        assertEquals("whatever", h1.getValue());
+        Assert.assertNotNull(h1);
+        Assert.assertEquals("whatever", h1.getValue());
         Header h2 = response.getFirstHeader(HTTP.CONTENT_ENCODING);
-        assertNotNull(h2);
-        assertEquals("whatever", h2.getValue());
+        Assert.assertNotNull(h2);
+        Assert.assertEquals("whatever", h2.getValue());
     }
 
+    @Test
     public void testResponseContentInvalidInput() throws Exception {
         ResponseContent interceptor = new ResponseContent();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testResponseContentInvalidResponseState() throws Exception {
         ResponseContent interceptor = new ResponseContent();
         HttpContext context = new BasicHttpContext(null);
@@ -732,7 +778,7 @@ public class TestStandardInterceptors ex
             HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
             response.addHeader(new BasicHeader(HTTP.CONTENT_LEN, "10"));
             interceptor.process(response, context);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
@@ -740,24 +786,26 @@ public class TestStandardInterceptors ex
             HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
             response.addHeader(new BasicHeader(HTTP.TRANSFER_ENCODING, "stuff"));
             interceptor.process(response, context);
-            fail("ProtocolException should have been thrown");
+            Assert.fail("ProtocolException should have been thrown");
         } catch (ProtocolException ex) {
             // expected
         }
     }
 
+    @Test
     public void testResponseDateGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         ResponseDate interceptor = new ResponseDate();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.DATE_HEADER);
-        assertNotNull(h1);
+        Assert.assertNotNull(h1);
         interceptor.process(response, context);
         Header h2 = response.getFirstHeader(HTTP.DATE_HEADER);
-        assertNotNull(h2);
+        Assert.assertNotNull(h2);
     }
 
+    @Test
     public void testResponseDateNotGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -765,19 +813,21 @@ public class TestStandardInterceptors ex
         ResponseDate interceptor = new ResponseDate();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.DATE_HEADER);
-        assertNull(h1);
+        Assert.assertNull(h1);
     }
 
+    @Test
     public void testResponseDateInvalidInput() throws Exception {
         ResponseDate interceptor = new ResponseDate();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testRequestDateGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request =
@@ -787,12 +837,13 @@ public class TestStandardInterceptors ex
         RequestDate interceptor = new RequestDate();
         interceptor.process(request, context);
         Header h1 = request.getFirstHeader(HTTP.DATE_HEADER);
-        assertNotNull(h1);
+        Assert.assertNotNull(h1);
         interceptor.process(request, context);
         Header h2 = request.getFirstHeader(HTTP.DATE_HEADER);
-        assertNotNull(h2);
+        Assert.assertNotNull(h2);
     }
 
+    @Test
     public void testRequestDateNotGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
@@ -800,19 +851,21 @@ public class TestStandardInterceptors ex
         RequestDate interceptor = new RequestDate();
         interceptor.process(request, context);
         Header h1 = request.getFirstHeader(HTTP.DATE_HEADER);
-        assertNull(h1);
+        Assert.assertNull(h1);
     }
 
+    @Test
     public void testRequestDateInvalidInput() throws Exception {
         RequestDate interceptor = new RequestDate();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testResponseServerGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -820,10 +873,11 @@ public class TestStandardInterceptors ex
         ResponseServer interceptor = new ResponseServer();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.SERVER_HEADER);
-        assertNotNull(h1);
-        assertEquals("some server", h1.getValue());
+        Assert.assertNotNull(h1);
+        Assert.assertEquals("some server", h1.getValue());
     }
 
+    @Test
     public void testResponseServerNotGenerated() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -832,24 +886,26 @@ public class TestStandardInterceptors ex
         ResponseServer interceptor = new ResponseServer();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.SERVER_HEADER);
-        assertNotNull(h1);
-        assertEquals("whatever", h1.getValue());
+        Assert.assertNotNull(h1);
+        Assert.assertEquals("whatever", h1.getValue());
     }
 
+    @Test
     public void testResponseServerMissing() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         ResponseServer interceptor = new ResponseServer();
         interceptor.process(response, context);
         Header h1 = response.getFirstHeader(HTTP.SERVER_HEADER);
-        assertNull(h1);
+        Assert.assertNull(h1);
     }
 
+    @Test
     public void testResponseServerInvalidInput() throws Exception {
         ResponseServer interceptor = new ResponseServer();
         try {
             interceptor.process(null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java Mon May  9 11:26:57 2011
@@ -32,81 +32,82 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link ByteArrayBuffer}.
  *
  */
-public class TestByteArrayBuffer extends TestCase {
-
-    public TestByteArrayBuffer(String testName) {
-        super(testName);
-    }
+public class TestByteArrayBuffer {
 
+    @Test
     public void testConstructor() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(16);
-        assertEquals(16, buffer.capacity());
-        assertEquals(0, buffer.length());
-        assertNotNull(buffer.buffer());
-        assertEquals(16, buffer.buffer().length);
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(0, buffer.length());
+        Assert.assertNotNull(buffer.buffer());
+        Assert.assertEquals(16, buffer.buffer().length);
         try {
             new ByteArrayBuffer(-1);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testSimpleAppend() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(16);
-        assertEquals(16, buffer.capacity());
-        assertEquals(0, buffer.length());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(0, buffer.length());
         byte[] b1 = buffer.toByteArray();
-        assertNotNull(b1);
-        assertEquals(0, b1.length);
-        assertTrue(buffer.isEmpty());
-        assertFalse(buffer.isFull());
+        Assert.assertNotNull(b1);
+        Assert.assertEquals(0, b1.length);
+        Assert.assertTrue(buffer.isEmpty());
+        Assert.assertFalse(buffer.isFull());
 
         byte[] tmp = new byte[] { 1, 2, 3, 4};
         buffer.append(tmp, 0, tmp.length);
-        assertEquals(16, buffer.capacity());
-        assertEquals(4, buffer.length());
-        assertFalse(buffer.isEmpty());
-        assertFalse(buffer.isFull());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(4, buffer.length());
+        Assert.assertFalse(buffer.isEmpty());
+        Assert.assertFalse(buffer.isFull());
 
         byte[] b2 = buffer.toByteArray();
-        assertNotNull(b2);
-        assertEquals(4, b2.length);
+        Assert.assertNotNull(b2);
+        Assert.assertEquals(4, b2.length);
         for (int i = 0; i < tmp.length; i++) {
-            assertEquals(tmp[i], b2[i]);
-            assertEquals(tmp[i], buffer.byteAt(i));
+            Assert.assertEquals(tmp[i], b2[i]);
+            Assert.assertEquals(tmp[i], buffer.byteAt(i));
         }
         buffer.clear();
-        assertEquals(16, buffer.capacity());
-        assertEquals(0, buffer.length());
-        assertTrue(buffer.isEmpty());
-        assertFalse(buffer.isFull());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(0, buffer.length());
+        Assert.assertTrue(buffer.isEmpty());
+        Assert.assertFalse(buffer.isFull());
     }
 
+    @Test
     public void testExpandAppend() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
-        assertEquals(4, buffer.capacity());
+        Assert.assertEquals(4, buffer.capacity());
 
         byte[] tmp = new byte[] { 1, 2, 3, 4};
         buffer.append(tmp, 0, 2);
         buffer.append(tmp, 0, 4);
         buffer.append(tmp, 0, 0);
 
-        assertEquals(8, buffer.capacity());
-        assertEquals(6, buffer.length());
+        Assert.assertEquals(8, buffer.capacity());
+        Assert.assertEquals(6, buffer.length());
 
         buffer.append(tmp, 0, 4);
 
-        assertEquals(16, buffer.capacity());
-        assertEquals(10, buffer.length());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(10, buffer.length());
     }
 
+    @Test
     public void testInvalidAppend() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
         buffer.append((byte[])null, 0, 0);
@@ -114,82 +115,87 @@ public class TestByteArrayBuffer extends
         byte[] tmp = new byte[] { 1, 2, 3, 4};
         try {
             buffer.append(tmp, -1, 0);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, -1);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, 8);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 10, Integer.MAX_VALUE);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 2, 4);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
     }
 
+    @Test
     public void testAppendOneByte() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
-        assertEquals(4, buffer.capacity());
+        Assert.assertEquals(4, buffer.capacity());
 
         byte[] tmp = new byte[] { 1, 127, -1, -128, 1, -2};
         for (int i = 0; i < tmp.length; i++) {
             buffer.append(tmp[i]);
         }
-        assertEquals(8, buffer.capacity());
-        assertEquals(6, buffer.length());
+        Assert.assertEquals(8, buffer.capacity());
+        Assert.assertEquals(6, buffer.length());
 
         for (int i = 0; i < tmp.length; i++) {
-            assertEquals(tmp[i], buffer.byteAt(i));
+            Assert.assertEquals(tmp[i], buffer.byteAt(i));
         }
     }
 
+    @Test
     public void testSetLength() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
         buffer.setLength(2);
-        assertEquals(2, buffer.length());
+        Assert.assertEquals(2, buffer.length());
     }
 
+    @Test
     public void testSetInvalidLength() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
         try {
             buffer.setLength(-2);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.setLength(200);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEnsureCapacity() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
         buffer.ensureCapacity(2);
-        assertEquals(4, buffer.capacity());
+        Assert.assertEquals(4, buffer.capacity());
         buffer.ensureCapacity(8);
-        assertEquals(8, buffer.capacity());
+        Assert.assertEquals(8, buffer.capacity());
     }
 
+    @Test
     public void testIndexOf() throws Exception {
         final byte COLON = (byte) ':';
         final byte COMMA = (byte) ',';
@@ -200,14 +206,15 @@ public class TestByteArrayBuffer extends
         ByteArrayBuffer buffer = new ByteArrayBuffer(16);
         buffer.append(bytes, 0, bytes.length);
 
-        assertEquals(index1, buffer.indexOf(COLON));
-        assertEquals(-1, buffer.indexOf(COMMA));
-        assertEquals(index1, buffer.indexOf(COLON, -1, 11));
-        assertEquals(index1, buffer.indexOf(COLON, 0, 1000));
-        assertEquals(-1, buffer.indexOf(COLON, 2, 1));
-        assertEquals(index2, buffer.indexOf(COLON, index1 + 1, buffer.length()));
+        Assert.assertEquals(index1, buffer.indexOf(COLON));
+        Assert.assertEquals(-1, buffer.indexOf(COMMA));
+        Assert.assertEquals(index1, buffer.indexOf(COLON, -1, 11));
+        Assert.assertEquals(index1, buffer.indexOf(COLON, 0, 1000));
+        Assert.assertEquals(-1, buffer.indexOf(COLON, 2, 1));
+        Assert.assertEquals(index2, buffer.indexOf(COLON, index1 + 1, buffer.length()));
     }
 
+    @Test
     public void testAppendCharArrayAsAscii() throws Exception {
         String s1 = "stuff";
         String s2 = " and more stuff";
@@ -218,27 +225,31 @@ public class TestByteArrayBuffer extends
         buffer.append(b1, 0, b1.length);
         buffer.append(b2, 0, b2.length);
 
-        assertEquals(s1 + s2, new String(buffer.toByteArray(), "US-ASCII"));
+        Assert.assertEquals(s1 + s2, new String(buffer.toByteArray(), "US-ASCII"));
     }
 
+    @Test
     public void testAppendNullCharArray() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(8);
         buffer.append((char[])null, 0, 0);
-        assertEquals(0, buffer.length());
+        Assert.assertEquals(0, buffer.length());
     }
 
+    @Test
     public void testAppendEmptyCharArray() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(8);
         buffer.append(new char[] {}, 0, 0);
-        assertEquals(0, buffer.length());
+        Assert.assertEquals(0, buffer.length());
     }
 
+    @Test
     public void testAppendNullCharArrayBuffer() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(8);
         buffer.append((CharArrayBuffer)null, 0, 0);
-        assertEquals(0, buffer.length());
+        Assert.assertEquals(0, buffer.length());
     }
 
+    @Test
     public void testInvalidAppendCharArrayAsAscii() throws Exception {
         ByteArrayBuffer buffer = new ByteArrayBuffer(4);
         buffer.append((char[])null, 0, 0);
@@ -246,36 +257,37 @@ public class TestByteArrayBuffer extends
         char[] tmp = new char[] { '1', '2', '3', '4'};
         try {
             buffer.append(tmp, -1, 0);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, -1);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, 8);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 10, Integer.MAX_VALUE);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 2, 4);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
     }
 
+    @Test
     public void testSerialization() throws Exception {
         ByteArrayBuffer orig = new ByteArrayBuffer(32);
         orig.append(1);
@@ -289,14 +301,14 @@ public class TestByteArrayBuffer extends
         ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
         ObjectInputStream instream = new ObjectInputStream(inbuffer);
         ByteArrayBuffer clone = (ByteArrayBuffer) instream.readObject();
-        assertEquals(orig.capacity(), clone.capacity());
-        assertEquals(orig.length(), clone.length());
+        Assert.assertEquals(orig.capacity(), clone.capacity());
+        Assert.assertEquals(orig.length(), clone.length());
         byte[] data = clone.toByteArray();
-        assertNotNull(data);
-        assertEquals(3, data.length);
-        assertEquals(1, data[0]);
-        assertEquals(2, data[1]);
-        assertEquals(3, data[2]);
+        Assert.assertNotNull(data);
+        Assert.assertEquals(3, data.length);
+        Assert.assertEquals(1, data[0]);
+        Assert.assertEquals(2, data[1]);
+        Assert.assertEquals(3, data[2]);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java Mon May  9 11:26:57 2011
@@ -32,114 +32,119 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link CharArrayBuffer}.
  *
  */
-public class TestCharArrayBuffer extends TestCase {
-
-    public TestCharArrayBuffer(String testName) {
-        super(testName);
-    }
+public class TestCharArrayBuffer {
 
+    @Test
     public void testConstructor() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(16);
-        assertEquals(16, buffer.capacity());
-        assertEquals(0, buffer.length());
-        assertNotNull(buffer.buffer());
-        assertEquals(16, buffer.buffer().length);
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(0, buffer.length());
+        Assert.assertNotNull(buffer.buffer());
+        Assert.assertEquals(16, buffer.buffer().length);
         try {
             new CharArrayBuffer(-1);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testSimpleAppend() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(16);
-        assertEquals(16, buffer.capacity());
-        assertEquals(0, buffer.length());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(0, buffer.length());
         char[] b1 = buffer.toCharArray();
-        assertNotNull(b1);
-        assertEquals(0, b1.length);
-        assertTrue(buffer.isEmpty());
-        assertFalse(buffer.isFull());
+        Assert.assertNotNull(b1);
+        Assert.assertEquals(0, b1.length);
+        Assert.assertTrue(buffer.isEmpty());
+        Assert.assertFalse(buffer.isFull());
 
         char[] tmp = new char[] { '1', '2', '3', '4'};
         buffer.append(tmp, 0, tmp.length);
-        assertEquals(16, buffer.capacity());
-        assertEquals(4, buffer.length());
-        assertFalse(buffer.isEmpty());
-        assertFalse(buffer.isFull());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(4, buffer.length());
+        Assert.assertFalse(buffer.isEmpty());
+        Assert.assertFalse(buffer.isFull());
 
         char[] b2 = buffer.toCharArray();
-        assertNotNull(b2);
-        assertEquals(4, b2.length);
+        Assert.assertNotNull(b2);
+        Assert.assertEquals(4, b2.length);
         for (int i = 0; i < tmp.length; i++) {
-            assertEquals(tmp[i], b2[i]);
-            assertEquals(tmp[i], buffer.charAt(i));
+            Assert.assertEquals(tmp[i], b2[i]);
+            Assert.assertEquals(tmp[i], buffer.charAt(i));
         }
-        assertEquals("1234", buffer.toString());
+        Assert.assertEquals("1234", buffer.toString());
 
         buffer.clear();
-        assertEquals(16, buffer.capacity());
-        assertEquals(0, buffer.length());
-        assertTrue(buffer.isEmpty());
-        assertFalse(buffer.isFull());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(0, buffer.length());
+        Assert.assertTrue(buffer.isEmpty());
+        Assert.assertFalse(buffer.isFull());
     }
 
+    @Test
     public void testExpandAppend() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(4);
-        assertEquals(4, buffer.capacity());
+        Assert.assertEquals(4, buffer.capacity());
 
         char[] tmp = new char[] { '1', '2', '3', '4'};
         buffer.append(tmp, 0, 2);
         buffer.append(tmp, 0, 4);
         buffer.append(tmp, 0, 0);
 
-        assertEquals(8, buffer.capacity());
-        assertEquals(6, buffer.length());
+        Assert.assertEquals(8, buffer.capacity());
+        Assert.assertEquals(6, buffer.length());
 
         buffer.append(tmp, 0, 4);
 
-        assertEquals(16, buffer.capacity());
-        assertEquals(10, buffer.length());
+        Assert.assertEquals(16, buffer.capacity());
+        Assert.assertEquals(10, buffer.length());
 
-        assertEquals("1212341234", buffer.toString());
+        Assert.assertEquals("1212341234", buffer.toString());
     }
 
+    @Test
     public void testAppendString() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(8);
         buffer.append("stuff");
         buffer.append(" and more stuff");
-        assertEquals("stuff and more stuff", buffer.toString());
+        Assert.assertEquals("stuff and more stuff", buffer.toString());
     }
 
+    @Test
     public void testAppendNullString() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(8);
         buffer.append((String)null);
-        assertEquals("null", buffer.toString());
+        Assert.assertEquals("null", buffer.toString());
     }
 
+    @Test
     public void testAppendCharArrayBuffer() throws Exception {
         CharArrayBuffer buffer1 = new CharArrayBuffer(8);
         buffer1.append(" and more stuff");
         CharArrayBuffer buffer2 = new CharArrayBuffer(8);
         buffer2.append("stuff");
         buffer2.append(buffer1);
-        assertEquals("stuff and more stuff", buffer2.toString());
+        Assert.assertEquals("stuff and more stuff", buffer2.toString());
     }
 
+    @Test
     public void testAppendNullCharArrayBuffer() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(8);
         buffer.append((CharArrayBuffer)null);
         buffer.append((CharArrayBuffer)null, 0, 0);
-        assertEquals("", buffer.toString());
+        Assert.assertEquals("", buffer.toString());
     }
 
+    @Test
     public void testAppendSingleChar() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(4);
         buffer.append('1');
@@ -148,9 +153,10 @@ public class TestCharArrayBuffer extends
         buffer.append('4');
         buffer.append('5');
         buffer.append('6');
-        assertEquals("123456", buffer.toString());
+        Assert.assertEquals("123456", buffer.toString());
     }
 
+    @Test
     public void testInvalidCharArrayAppend() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(4);
         buffer.append((char[])null, 0, 0);
@@ -158,128 +164,135 @@ public class TestCharArrayBuffer extends
         char[] tmp = new char[] { '1', '2', '3', '4'};
         try {
             buffer.append(tmp, -1, 0);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, -1);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, 8);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 10, Integer.MAX_VALUE);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 2, 4);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
     }
 
+    @Test
     public void testSetLength() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(4);
         buffer.setLength(2);
-        assertEquals(2, buffer.length());
+        Assert.assertEquals(2, buffer.length());
     }
 
+    @Test
     public void testSetInvalidLength() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(4);
         try {
             buffer.setLength(-2);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.setLength(200);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEnsureCapacity() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(4);
         buffer.ensureCapacity(2);
-        assertEquals(4, buffer.capacity());
+        Assert.assertEquals(4, buffer.capacity());
         buffer.ensureCapacity(8);
-        assertEquals(8, buffer.capacity());
+        Assert.assertEquals(8, buffer.capacity());
     }
 
+    @Test
     public void testIndexOf() {
         CharArrayBuffer buffer = new CharArrayBuffer(16);
         buffer.append("name: value");
-        assertEquals(4, buffer.indexOf(':'));
-        assertEquals(-1, buffer.indexOf(','));
-        assertEquals(4, buffer.indexOf(':', -1, 11));
-        assertEquals(4, buffer.indexOf(':', 0, 1000));
-        assertEquals(-1, buffer.indexOf(':', 2, 1));
+        Assert.assertEquals(4, buffer.indexOf(':'));
+        Assert.assertEquals(-1, buffer.indexOf(','));
+        Assert.assertEquals(4, buffer.indexOf(':', -1, 11));
+        Assert.assertEquals(4, buffer.indexOf(':', 0, 1000));
+        Assert.assertEquals(-1, buffer.indexOf(':', 2, 1));
     }
 
+    @Test
     public void testSubstring() {
         CharArrayBuffer buffer = new CharArrayBuffer(16);
         buffer.append(" name:  value    ");
-        assertEquals(5, buffer.indexOf(':'));
-        assertEquals(" name", buffer.substring(0, 5));
-        assertEquals("  value    ", buffer.substring(6, buffer.length()));
-        assertEquals("name", buffer.substringTrimmed(0, 5));
-        assertEquals("value", buffer.substringTrimmed(6, buffer.length()));
-        assertEquals("", buffer.substringTrimmed(13, buffer.length()));
+        Assert.assertEquals(5, buffer.indexOf(':'));
+        Assert.assertEquals(" name", buffer.substring(0, 5));
+        Assert.assertEquals("  value    ", buffer.substring(6, buffer.length()));
+        Assert.assertEquals("name", buffer.substringTrimmed(0, 5));
+        Assert.assertEquals("value", buffer.substringTrimmed(6, buffer.length()));
+        Assert.assertEquals("", buffer.substringTrimmed(13, buffer.length()));
     }
 
+    @Test
     public void testSubstringIndexOfOutBound() {
         CharArrayBuffer buffer = new CharArrayBuffer(16);
         buffer.append("stuff");
         try {
             buffer.substring(-2, 10);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.substringTrimmed(-2, 10);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.substring(12, 10);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.substringTrimmed(12, 10);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.substring(2, 1);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.substringTrimmed(2, 1);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
     }
 
+    @Test
     public void testAppendAsciiByteArray() throws Exception {
         String s1 = "stuff";
         String s2 = " and more stuff";
@@ -290,36 +303,40 @@ public class TestCharArrayBuffer extends
         buffer.append(b1, 0, b1.length);
         buffer.append(b2, 0, b2.length);
 
-        assertEquals("stuff and more stuff", buffer.toString());
+        Assert.assertEquals("stuff and more stuff", buffer.toString());
     }
 
+    @Test
     public void testAppendISOByteArray() throws Exception {
         byte[] b = new byte[] {0x00, 0x20, 0x7F, -0x80, -0x01};
 
         CharArrayBuffer buffer = new CharArrayBuffer(8);
         buffer.append(b, 0, b.length);
         char[] ch = buffer.toCharArray();
-        assertNotNull(ch);
-        assertEquals(5, ch.length);
-        assertEquals(0x00, ch[0]);
-        assertEquals(0x20, ch[1]);
-        assertEquals(0x7F, ch[2]);
-        assertEquals(0x80, ch[3]);
-        assertEquals(0xFF, ch[4]);
+        Assert.assertNotNull(ch);
+        Assert.assertEquals(5, ch.length);
+        Assert.assertEquals(0x00, ch[0]);
+        Assert.assertEquals(0x20, ch[1]);
+        Assert.assertEquals(0x7F, ch[2]);
+        Assert.assertEquals(0x80, ch[3]);
+        Assert.assertEquals(0xFF, ch[4]);
     }
 
+    @Test
     public void testAppendNullByteArray() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(8);
         buffer.append((byte[])null, 0, 0);
-        assertEquals("", buffer.toString());
+        Assert.assertEquals("", buffer.toString());
     }
 
+    @Test
     public void testAppendNullByteArrayBuffer() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(8);
         buffer.append((ByteArrayBuffer)null, 0, 0);
-        assertEquals("", buffer.toString());
+        Assert.assertEquals("", buffer.toString());
     }
 
+    @Test
     public void testInvalidAppendAsciiByteArray() throws Exception {
         CharArrayBuffer buffer = new CharArrayBuffer(4);
         buffer.append((byte[])null, 0, 0);
@@ -327,36 +344,37 @@ public class TestCharArrayBuffer extends
         byte[] tmp = new byte[] { '1', '2', '3', '4'};
         try {
             buffer.append(tmp, -1, 0);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, -1);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 0, 8);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 10, Integer.MAX_VALUE);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
             buffer.append(tmp, 2, 4);
-            fail("IndexOutOfBoundsException should have been thrown");
+            Assert.fail("IndexOutOfBoundsException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
     }
 
+    @Test
     public void testSerialization() throws Exception {
         CharArrayBuffer orig = new CharArrayBuffer(32);
         orig.append('a');
@@ -370,14 +388,14 @@ public class TestCharArrayBuffer extends
         ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
         ObjectInputStream instream = new ObjectInputStream(inbuffer);
         CharArrayBuffer clone = (CharArrayBuffer) instream.readObject();
-        assertEquals(orig.capacity(), clone.capacity());
-        assertEquals(orig.length(), clone.length());
+        Assert.assertEquals(orig.capacity(), clone.capacity());
+        Assert.assertEquals(orig.length(), clone.length());
         char[] data = clone.toCharArray();
-        assertNotNull(data);
-        assertEquals(3, data.length);
-        assertEquals('a', data[0]);
-        assertEquals('b', data[1]);
-        assertEquals('c', data[2]);
+        Assert.assertNotNull(data);
+        Assert.assertEquals(3, data.length);
+        Assert.assertEquals('a', data[0]);
+        Assert.assertEquals('b', data[1]);
+        Assert.assertEquals('c', data[2]);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEncodingUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEncodingUtils.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEncodingUtils.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEncodingUtils.java Mon May  9 11:26:57 2011
@@ -27,17 +27,14 @@
 
 package org.apache.http.util;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit tests for {@link TestEncodingUtils}.
  *
  */
-public class TestEncodingUtils extends TestCase {
-
-    public TestEncodingUtils(String testName) {
-        super(testName);
-    }
+public class TestEncodingUtils {
 
     private static String constructString(int [] unicodeChars) {
         StringBuilder buffer = new StringBuilder();
@@ -53,6 +50,7 @@ public class TestEncodingUtils extends T
             0x47, 0x72, 0xFC, 0x65, 0x7A, 0x69, 0x5F, 0x7A, 0xE4, 0x6D, 0xE4
         };
 
+    @Test
     public void testBytesToString() throws Exception {
         String s = constructString(SWISS_GERMAN_HELLO);
         byte[] utf = s.getBytes("UTF-8");
@@ -61,35 +59,36 @@ public class TestEncodingUtils extends T
         String s1 = EncodingUtils.getString(utf, "UTF-8");
         String s2 = EncodingUtils.getString(latin1, "ISO-8859-1");
 
-        assertEquals(s, s1);
-        assertEquals(s, s2);
+        Assert.assertEquals(s, s1);
+        Assert.assertEquals(s, s2);
 
         try {
             EncodingUtils.getString(null, 0, 0, "UTF-8");
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             EncodingUtils.getString(null, "UTF-8");
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             EncodingUtils.getString(new byte[] {}, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             EncodingUtils.getString(new byte[] {}, "");
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testStringToBytesToString() throws Exception {
         String s = constructString(SWISS_GERMAN_HELLO);
         byte[] utf = s.getBytes("UTF-8");
@@ -98,83 +97,86 @@ public class TestEncodingUtils extends T
         byte[] data1 = EncodingUtils.getBytes(s, "UTF-8");
         byte[] data2 = EncodingUtils.getBytes(s, "ISO-8859-1");
 
-        assertNotNull(data1);
-        assertEquals(utf.length, data1.length);
+        Assert.assertNotNull(data1);
+        Assert.assertEquals(utf.length, data1.length);
         for (int i = 0; i < utf.length; i++) {
-            assertEquals(utf[i], data1[i]);
+            Assert.assertEquals(utf[i], data1[i]);
         }
-        assertNotNull(data2);
-        assertEquals(latin1.length, data2.length);
+        Assert.assertNotNull(data2);
+        Assert.assertEquals(latin1.length, data2.length);
         for (int i = 0; i < latin1.length; i++) {
-            assertEquals(latin1[i], data2[i]);
+            Assert.assertEquals(latin1[i], data2[i]);
         }
 
         try {
             EncodingUtils.getBytes(null, "UTF-8");
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             EncodingUtils.getBytes("what not", null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             EncodingUtils.getBytes("what not", "");
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testAsciiBytesToString() throws Exception {
         String s = "ascii only, I mean it!";
-        assertEquals(s, EncodingUtils.getAsciiString(s.getBytes("US-ASCII")));
+        Assert.assertEquals(s, EncodingUtils.getAsciiString(s.getBytes("US-ASCII")));
         try {
             EncodingUtils.getAsciiString(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             EncodingUtils.getAsciiString(null, 0, 0);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testAsciiStringToBytes() throws Exception {
         String s = "ascii only, I mean it!";
         byte[] ascii = s.getBytes("US-ASCII");
         byte[] data = EncodingUtils.getAsciiBytes(s);
 
-        assertNotNull(data);
-        assertEquals(ascii.length, data.length);
+        Assert.assertNotNull(data);
+        Assert.assertEquals(ascii.length, data.length);
         for (int i = 0; i < ascii.length; i++) {
-            assertEquals(ascii[i], data[i]);
+            Assert.assertEquals(ascii[i], data[i]);
         }
         try {
             EncodingUtils.getAsciiBytes(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testUnsupportedEncoding() {
         String s = constructString(SWISS_GERMAN_HELLO);
         byte[] b1 = s.getBytes();
         byte[] b2 = EncodingUtils.getBytes(s, "ThisJustAintRight");
-        assertEquals(b1.length, b2.length);
+        Assert.assertEquals(b1.length, b2.length);
         for (int i = 0; i < b1.length; i++) {
-            assertEquals(b1[i], b2[i]);
+            Assert.assertEquals(b1[i], b2[i]);
         }
         String s1 = new String(b1);
         String s2 = EncodingUtils.getString(b1, "ThisJustAintRight");
-        assertEquals(s1, s2);
+        Assert.assertEquals(s1, s2);
     }
 
 }



Mime
View raw message