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

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

Author: olegk
Date: Mon May  9 11:26:57 2011
New Revision: 1100965

URL: http://svn.apache.org/viewvc?rev=1100965&view=rev
Log:
Updated test cases to take advantage of JUnit 4 features such as annotations

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/ExceptionEventTest.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpExceptions.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestSerializableEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestBasicRequest.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestEnglishReasonPhraseCatalog.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestSessionBuffers.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntityDeserializer.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestEntitySerializer.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestLaxContentLengthStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/entity/TestStrictContentLengthStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthOutputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityOutputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestMessageParser.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestAbstractMessage.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderElementIterator.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderIterator.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueFormatter.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicHeaderValueParser.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineFormatter.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicLineParser.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicMessages.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBasicTokenIterator.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeader.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderElement.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestNameValuePair.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestBasicHttpParams.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/params/TestDefaultedHttpParams.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestBasicHttpProcessor.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpExecutionContext.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestHandlerRegistry.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpServiceAndExecutor.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEncodingUtils.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestEntityUtils.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/util/TestLangUtils.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java Mon May  9 11:26:57 2011
@@ -27,31 +27,25 @@
 
 package org.apache.http;
 
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
 import org.apache.http.mockup.HttpSSLClient;
 import org.apache.http.mockup.HttpSSLServer;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.SyncBasicHttpParams;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Base class for all HttpCore NIO tests
  */
-public class HttpCoreNIOSSLTestBase extends TestCase {
-
-    public HttpCoreNIOSSLTestBase(String testName) {
-        super(testName);
-    }
+public class HttpCoreNIOSSLTestBase {
 
     protected HttpSSLServer server;
     protected HttpSSLClient client;
 
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void initServer() throws Exception {
         HttpParams serverParams = new SyncBasicHttpParams();
         serverParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 120000)
@@ -62,7 +56,10 @@ public class HttpCoreNIOSSLTestBase exte
 
         this.server = new HttpSSLServer(serverParams);
         this.server.setExceptionHandler(new SimpleIOReactorExceptionHandler());
+    }
 
+    @Before
+    public void initClient() throws Exception {
         HttpParams clientParams = new SyncBasicHttpParams();
         clientParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 120000)
@@ -76,17 +73,17 @@ public class HttpCoreNIOSSLTestBase exte
         this.client.setExceptionHandler(new SimpleIOReactorExceptionHandler());
     }
 
-    @Override
-    protected void tearDown() {
-        try {
+    @After
+    public void shutDownClient() throws Exception {
+        if (this.client != null) {
             this.client.shutdown();
-        } catch (IOException ex) {
-            ex.printStackTrace(System.out);
         }
-        try {
+    }
+
+    @After
+    public void shutDownServer() throws Exception {
+        if (this.server != null) {
             this.server.shutdown();
-        } catch (IOException ex) {
-            ex.printStackTrace(System.out);
         }
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java Mon May  9 11:26:57 2011
@@ -27,32 +27,26 @@
 
 package org.apache.http;
 
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
 import org.apache.http.mockup.HttpClientNio;
 import org.apache.http.mockup.HttpServerNio;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.SyncBasicHttpParams;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Base class for all HttpCore NIO tests
  *
  */
-public class HttpCoreNIOTestBase extends TestCase {
-
-    public HttpCoreNIOTestBase(String testName) {
-        super(testName);
-    }
+public class HttpCoreNIOTestBase {
 
     protected HttpServerNio server;
     protected HttpClientNio client;
 
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void initServer() throws Exception {
         HttpParams serverParams = new SyncBasicHttpParams();
         serverParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000)
@@ -63,7 +57,10 @@ public class HttpCoreNIOTestBase extends
 
         this.server = new HttpServerNio(serverParams);
         this.server.setExceptionHandler(new SimpleIOReactorExceptionHandler());
+    }
 
+    @Before
+    public void initClient() throws Exception {
         HttpParams clientParams = new SyncBasicHttpParams();
         clientParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000)
@@ -77,17 +74,17 @@ public class HttpCoreNIOTestBase extends
         this.client.setExceptionHandler(new SimpleIOReactorExceptionHandler());
     }
 
-    @Override
-    protected void tearDown() {
-        try {
+    @After
+    public void shutDownClient() throws Exception {
+        if (this.client != null) {
             this.client.shutdown();
-        } catch (IOException ex) {
-            ex.printStackTrace(System.out);
         }
-        try {
+    }
+
+    @After
+    public void shutDownServer() throws Exception {
+        if (this.server != null) {
             this.server.shutdown();
-        } catch (IOException ex) {
-            ex.printStackTrace(System.out);
         }
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java Mon May  9 11:26:57 2011
@@ -31,8 +31,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.ReadableByteChannel;
 
-import junit.framework.TestCase;
-
 import org.apache.http.Header;
 import org.apache.http.MalformedChunkCodingException;
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
@@ -41,21 +39,13 @@ import org.apache.http.mockup.ReadableBy
 import org.apache.http.nio.reactor.SessionInputBuffer;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Simple tests for {@link ChunkDecoder}.
- *
- *
- * @version $Id$
  */
-public class TestChunkDecoder extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestChunkDecoder(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestChunkDecoder {
 
     private static String convert(final ByteBuffer src) {
         src.flip();
@@ -66,6 +56,7 @@ public class TestChunkDecoder extends Te
         return buffer.toString();
     }
 
+    @Test
     public void testBasicDecoding() throws Exception {
         String s = "5\r\n01234\r\n5\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n";
         ReadableByteChannel channel = new ReadableByteChannelMockup(
@@ -79,17 +70,18 @@ public class TestChunkDecoder extends Te
         ByteBuffer dst = ByteBuffer.allocate(1024);
 
         int bytesRead = decoder.read(dst);
-        assertEquals(16, bytesRead);
-        assertEquals("0123456789abcdef", convert(dst));
+        Assert.assertEquals(16, bytesRead);
+        Assert.assertEquals("0123456789abcdef", convert(dst));
         Header[] footers = decoder.getFooters();
-        assertEquals(0, footers.length);
+        Assert.assertEquals(0, footers.length);
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
     }
 
+    @Test
     public void testComplexDecoding() throws Exception {
         String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
                 "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\nFooter2: fghij\r\n\r\n";
@@ -111,22 +103,23 @@ public class TestChunkDecoder extends Te
             }
         }
 
-        assertEquals(26, bytesRead);
-        assertEquals("12345678901234561234512345", convert(dst));
+        Assert.assertEquals(26, bytesRead);
+        Assert.assertEquals("12345678901234561234512345", convert(dst));
 
         Header[] footers = decoder.getFooters();
-        assertEquals(2, footers.length);
-        assertEquals("Footer1", footers[0].getName());
-        assertEquals("abcde", footers[0].getValue());
-        assertEquals("Footer2", footers[1].getName());
-        assertEquals("fghij", footers[1].getValue());
+        Assert.assertEquals(2, footers.length);
+        Assert.assertEquals("Footer1", footers[0].getName());
+        Assert.assertEquals("abcde", footers[0].getValue());
+        Assert.assertEquals("Footer2", footers[1].getName());
+        Assert.assertEquals("fghij", footers[1].getValue());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
     }
 
+    @Test
     public void testDecodingWithSmallBuffer() throws Exception {
         String s1 = "5\r\n01234\r\n5\r\n5678";
         String s2 = "9\r\n6\r\nabcdef\r\n0\r\n\r\n";
@@ -152,16 +145,17 @@ public class TestChunkDecoder extends Te
             tmp.compact();
         }
 
-        assertEquals(16, bytesRead);
-        assertEquals("0123456789abcdef", convert(dst));
-        assertTrue(decoder.isCompleted());
+        Assert.assertEquals(16, bytesRead);
+        Assert.assertEquals("0123456789abcdef", convert(dst));
+        Assert.assertTrue(decoder.isCompleted());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
     }
 
+    @Test
     public void testIncompleteChunkDecoding() throws Exception {
         String[] chunks = {
                 "10;",
@@ -192,23 +186,24 @@ public class TestChunkDecoder extends Te
             }
         }
 
-        assertEquals(27, bytesRead);
-        assertEquals("123456789012345612345abcdef", convert(dst));
-        assertTrue(decoder.isCompleted());
+        Assert.assertEquals(27, bytesRead);
+        Assert.assertEquals("123456789012345612345abcdef", convert(dst));
+        Assert.assertTrue(decoder.isCompleted());
 
         Header[] footers = decoder.getFooters();
-        assertEquals(2, footers.length);
-        assertEquals("Footer1", footers[0].getName());
-        assertEquals("abcde", footers[0].getValue());
-        assertEquals("Footer2", footers[1].getName());
-        assertEquals("fghij", footers[1].getValue());
+        Assert.assertEquals(2, footers.length);
+        Assert.assertEquals("Footer1", footers[0].getName());
+        Assert.assertEquals("abcde", footers[0].getValue());
+        Assert.assertEquals("Footer2", footers[1].getName());
+        Assert.assertEquals("fghij", footers[1].getValue());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
     }
 
+    @Test
     public void testMalformedChunkSizeDecoding() throws Exception {
         String s = "5\r\n01234\r\n5zz\r\n56789\r\n6\r\nabcdef\r\n0\r\n\r\n";
         ReadableByteChannel channel = new ReadableByteChannelMockup(
@@ -223,12 +218,13 @@ public class TestChunkDecoder extends Te
 
         try {
             decoder.read(dst);
-            fail("MalformedChunkCodingException should have been thrown");
+            Assert.fail("MalformedChunkCodingException should have been thrown");
         } catch (MalformedChunkCodingException ex) {
             // expected
         }
     }
 
+    @Test
     public void testMalformedChunkEndingDecoding() throws Exception {
         String s = "5\r\n01234\r\n5\r\n56789\n\r6\r\nabcdef\r\n0\r\n\r\n";
         ReadableByteChannel channel = new ReadableByteChannelMockup(
@@ -243,12 +239,13 @@ public class TestChunkDecoder extends Te
 
         try {
             decoder.read(dst);
-            fail("MalformedChunkCodingException should have been thrown");
+            Assert.fail("MalformedChunkCodingException should have been thrown");
         } catch (MalformedChunkCodingException ex) {
             // expected
         }
     }
 
+    @Test
     public void testMalformedChunkTruncatedChunk() throws Exception {
         String s = "3\r\n12";
         ReadableByteChannel channel = new ReadableByteChannelMockup(
@@ -260,15 +257,16 @@ public class TestChunkDecoder extends Te
         ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
 
         ByteBuffer dst = ByteBuffer.allocate(1024);
-        assertEquals(2, decoder.read(dst));
+        Assert.assertEquals(2, decoder.read(dst));
         try {
             decoder.read(dst);
-            fail("MalformedChunkCodingException should have been thrown");
+            Assert.fail("MalformedChunkCodingException should have been thrown");
         } catch (MalformedChunkCodingException ex) {
             // expected
         }
     }
 
+    @Test
     public void testFoldedFooters() throws Exception {
         String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
                 "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1: abcde\r\n   \r\n  fghij\r\n\r\n";
@@ -283,15 +281,16 @@ public class TestChunkDecoder extends Te
         ByteBuffer dst = ByteBuffer.allocate(1024);
 
         int bytesRead = decoder.read(dst);
-        assertEquals(26, bytesRead);
-        assertEquals("12345678901234561234512345", convert(dst));
+        Assert.assertEquals(26, bytesRead);
+        Assert.assertEquals("12345678901234561234512345", convert(dst));
 
         Header[] footers = decoder.getFooters();
-        assertEquals(1, footers.length);
-        assertEquals("Footer1", footers[0].getName());
-        assertEquals("abcde  fghij", footers[0].getValue());
+        Assert.assertEquals(1, footers.length);
+        Assert.assertEquals("Footer1", footers[0].getName());
+        Assert.assertEquals("abcde  fghij", footers[0].getValue());
     }
 
+    @Test
     public void testMalformedFooters() throws Exception {
         String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
                 "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1 abcde\r\n\r\n";
@@ -307,12 +306,13 @@ public class TestChunkDecoder extends Te
 
         try {
             decoder.read(dst);
-            fail("MalformedChunkCodingException should have been thrown");
+            Assert.fail("MalformedChunkCodingException should have been thrown");
         } catch (IOException ex) {
             // expected
         }
     }
 
+    @Test
     public void testEndOfStreamConditionReadingLastChunk() throws Exception {
         String s = "10\r\n1234567890123456\r\n" +
                 "5\r\n12345\r\n5\r\n12345";
@@ -334,11 +334,12 @@ public class TestChunkDecoder extends Te
             }
         }
 
-        assertEquals(26, bytesRead);
-        assertEquals("12345678901234561234512345", convert(dst));
-        assertTrue(decoder.isCompleted());
+        Assert.assertEquals(26, bytesRead);
+        Assert.assertEquals("12345678901234561234512345", convert(dst));
+        Assert.assertTrue(decoder.isCompleted());
     }
 
+    @Test
     public void testReadingWitSmallBuffer() throws Exception {
         String s = "10\r\n1234567890123456\r\n" +
                 "40\r\n12345678901234561234567890123456" +
@@ -365,13 +366,14 @@ public class TestChunkDecoder extends Te
             }
         }
 
-        assertEquals(80, bytesRead);
-        assertEquals("12345678901234561234567890123456" +
+        Assert.assertEquals(80, bytesRead);
+        Assert.assertEquals("12345678901234561234567890123456" +
                 "12345678901234561234567890123456" +
                 "1234567890123456", convert(dst));
-        assertTrue(decoder.isCompleted());
+        Assert.assertTrue(decoder.isCompleted());
     }
 
+    @Test
     public void testEndOfStreamConditionReadingFooters() throws Exception {
         String s = "10\r\n1234567890123456\r\n" +
                 "5\r\n12345\r\n5\r\n12345\r\n0\r\n";
@@ -393,11 +395,12 @@ public class TestChunkDecoder extends Te
             }
         }
 
-        assertEquals(26, bytesRead);
-        assertEquals("12345678901234561234512345", convert(dst));
-        assertTrue(decoder.isCompleted());
+        Assert.assertEquals(26, bytesRead);
+        Assert.assertEquals("12345678901234561234512345", convert(dst));
+        Assert.assertTrue(decoder.isCompleted());
     }
 
+    @Test
     public void testInvalidConstructor() {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII");
@@ -406,24 +409,25 @@ public class TestChunkDecoder extends Te
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
         try {
             new ChunkDecoder(null, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new ChunkDecoder(channel, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new ChunkDecoder(channel, inbuf, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
     }
 
+    @Test
     public void testInvalidInput() throws Exception {
         String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
                 "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1 abcde\r\n\r\n";
@@ -437,7 +441,7 @@ public class TestChunkDecoder extends Te
 
         try {
             decoder.read(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java Mon May  9 11:26:57 2011
@@ -34,29 +34,19 @@ import java.nio.ByteBuffer;
 import java.nio.channels.Channels;
 import java.nio.channels.WritableByteChannel;
 
-import junit.framework.TestCase;
-
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionOutputBufferImpl;
 import org.apache.http.nio.reactor.SessionOutputBuffer;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.util.EncodingUtils;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Simple tests for {@link ChunkEncoder}.
- *
- *
- * @version $Id$
  */
-public class TestChunkEncoder extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestChunkEncoder(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestChunkEncoder {
 
     private static ByteBuffer wrap(final String s) {
         return ByteBuffer.wrap(EncodingUtils.getAsciiBytes(s));
@@ -66,6 +56,7 @@ public class TestChunkEncoder extends Te
         return Channels.newChannel(baos);
     }
 
+    @Test
     public void testBasicCoding() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -83,10 +74,11 @@ public class TestChunkEncoder extends Te
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("5\r\n12345\r\n3\r\n678\r\n2\r\n90\r\n0\r\n\r\n", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("5\r\n12345\r\n3\r\n678\r\n2\r\n90\r\n0\r\n\r\n", s);
     }
 
+    @Test
     public void testChunkNoExceed() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -101,10 +93,11 @@ public class TestChunkEncoder extends Te
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("4\r\n1234\r\n0\r\n\r\n", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("4\r\n1234\r\n0\r\n\r\n", s);
     }
 
+    @Test
     public void testHttpCore239() throws Exception {
         FixedByteChannel channel = new FixedByteChannel(16);
         HttpParams params = new BasicHttpParams();
@@ -118,30 +111,31 @@ public class TestChunkEncoder extends Te
         outbuf.write(wrap("0123456789ABCDEF"));
 
         ByteBuffer src = wrap("0123456789ABCDEF");
-        assertEquals(0, encoder.write(src));
-        assertEquals(0, encoder.write(src));
-        assertEquals(0, encoder.write(src));
+        Assert.assertEquals(0, encoder.write(src));
+        Assert.assertEquals(0, encoder.write(src));
+        Assert.assertEquals(0, encoder.write(src));
 
         // should not be able to copy any bytes, until we flush the channel and buffer
         channel.reset();
         outbuf.flush(channel);
         channel.reset();
 
-        assertEquals(4, encoder.write(src));
+        Assert.assertEquals(4, encoder.write(src));
         channel.flush();
-        assertEquals(4, encoder.write(src));
+        Assert.assertEquals(4, encoder.write(src));
         channel.flush();
-        assertEquals(4, encoder.write(src));
+        Assert.assertEquals(4, encoder.write(src));
         channel.flush();
-        assertEquals(4, encoder.write(src));
+        Assert.assertEquals(4, encoder.write(src));
         channel.flush();
-        assertEquals(0, encoder.write(src));
+        Assert.assertEquals(0, encoder.write(src));
 
         outbuf.flush(channel);
         String s = channel.toString("US-ASCII");
-        assertEquals("4\r\n0123\r\n4\r\n4567\r\n4\r\n89AB\r\n4\r\nCDEF\r\n", s);
+        Assert.assertEquals("4\r\n0123\r\n4\r\n4567\r\n4\r\n89AB\r\n4\r\nCDEF\r\n", s);
     }
 
+    @Test
     public void testChunkExceed() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -152,24 +146,25 @@ public class TestChunkEncoder extends Te
 
         ByteBuffer src = wrap("0123456789ABCDEF");
 
-        assertEquals(4, encoder.write(src));
-        assertTrue(src.hasRemaining());
-        assertEquals(12, src.remaining());
-
-        assertEquals(4, encoder.write(src));
-        assertTrue(src.hasRemaining());
-        assertEquals(8, src.remaining());
-
-        assertEquals(4, encoder.write(src));
-        assertEquals(4, encoder.write(src));
-        assertFalse(src.hasRemaining());
+        Assert.assertEquals(4, encoder.write(src));
+        Assert.assertTrue(src.hasRemaining());
+        Assert.assertEquals(12, src.remaining());
+
+        Assert.assertEquals(4, encoder.write(src));
+        Assert.assertTrue(src.hasRemaining());
+        Assert.assertEquals(8, src.remaining());
+
+        Assert.assertEquals(4, encoder.write(src));
+        Assert.assertEquals(4, encoder.write(src));
+        Assert.assertFalse(src.hasRemaining());
 
         outbuf.flush(channel);
         String s = baos.toString("US-ASCII");
-        assertEquals("4\r\n0123\r\n4\r\n4567\r\n4\r\n89AB\r\n4\r\nCDEF\r\n", s);
+        Assert.assertEquals("4\r\n0123\r\n4\r\n4567\r\n4\r\n89AB\r\n4\r\nCDEF\r\n", s);
 
     }
 
+    @Test
     public void testCodingEmptyBuffer() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -193,10 +188,11 @@ public class TestChunkEncoder extends Te
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("5\r\n12345\r\n3\r\n678\r\n2\r\n90\r\n0\r\n\r\n", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("5\r\n12345\r\n3\r\n678\r\n2\r\n90\r\n0\r\n\r\n", s);
     }
 
+    @Test
     public void testCodingCompleted() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -212,18 +208,19 @@ public class TestChunkEncoder extends Te
 
         try {
             encoder.write(wrap("more stuff"));
-            fail("IllegalStateException should have been thrown");
+            Assert.fail("IllegalStateException should have been thrown");
         } catch (IllegalStateException ex) {
             // ignore
         }
         try {
             encoder.complete();
-            fail("IllegalStateException should have been thrown");
+            Assert.fail("IllegalStateException should have been thrown");
         } catch (IllegalStateException ex) {
             // ignore
         }
     }
 
+    @Test
     public void testInvalidConstructor() {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -232,19 +229,19 @@ public class TestChunkEncoder extends Te
 
         try {
             new ChunkEncoder(null, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new ChunkEncoder(channel, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new ChunkEncoder(channel, outbuf, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java Mon May  9 11:26:57 2011
@@ -33,8 +33,6 @@ import java.io.UnsupportedEncodingExcept
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestFactory;
@@ -49,18 +47,13 @@ import org.apache.http.nio.reactor.Sessi
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.HttpParams;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Simple tests for {@link AbstractMessageParser}.
  */
-public class TestHttpMessageParser extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestHttpMessageParser(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestHttpMessageParser {
 
     private static ReadableByteChannel newChannel(final String s, final String charset)
             throws UnsupportedEncodingException {
@@ -72,6 +65,7 @@ public class TestHttpMessageParser exten
         return newChannel(s, "US-ASCII");
     }
 
+    @Test
     public void testSimpleParsing() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -79,11 +73,12 @@ public class TestHttpMessageParser exten
         NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
         requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.1\r\nSome header: stuff\r\n\r\n"));
         HttpRequest request = requestParser.parse();
-        assertNotNull(request);
-        assertEquals("/whatever", request.getRequestLine().getUri());
-        assertEquals(1, request.getAllHeaders().length);
+        Assert.assertNotNull(request);
+        Assert.assertEquals("/whatever", request.getRequestLine().getUri());
+        Assert.assertEquals(1, request.getAllHeaders().length);
     }
 
+    @Test
     public void testParsingChunkedMessages() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -92,19 +87,20 @@ public class TestHttpMessageParser exten
 
         requestParser.fillBuffer(newChannel("GET /whatev"));
         HttpRequest request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("er HTTP/1.1\r"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("\nSome header: stuff\r\n\r\n"));
         request = requestParser.parse();
 
-        assertNotNull(request);
-        assertEquals("/whatever", request.getRequestLine().getUri());
-        assertEquals(1, request.getAllHeaders().length);
+        Assert.assertNotNull(request);
+        Assert.assertEquals("/whatever", request.getRequestLine().getUri());
+        Assert.assertEquals(1, request.getAllHeaders().length);
 
     }
 
+    @Test
     public void testParsingFoldedHeaders() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -113,28 +109,29 @@ public class TestHttpMessageParser exten
 
         requestParser.fillBuffer(newChannel("GET /whatev"));
         HttpRequest request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("er HTTP/1.1\r"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("\nSome header: stuff\r\n"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("   more\r\n"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("\tstuff\r\n"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("\r\n"));
         request = requestParser.parse();
 
-        assertNotNull(request);
-        assertEquals("/whatever", request.getRequestLine().getUri());
-        assertEquals(1, request.getAllHeaders().length);
-        assertEquals("stuff more stuff", request.getFirstHeader("Some header").getValue());
+        Assert.assertNotNull(request);
+        Assert.assertEquals("/whatever", request.getRequestLine().getUri());
+        Assert.assertEquals(1, request.getAllHeaders().length);
+        Assert.assertEquals("stuff more stuff", request.getFirstHeader("Some header").getValue());
     }
 
+    @Test
     public void testParsingBadlyFoldedFirstHeader() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -143,25 +140,26 @@ public class TestHttpMessageParser exten
 
         requestParser.fillBuffer(newChannel("GET /whatev"));
         HttpRequest request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("er HTTP/1.1\r"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("\n  Some header: stuff\r\n"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("   more stuff\r\n"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("\r\n"));
         request = requestParser.parse();
 
-        assertNotNull(request);
-        assertEquals("/whatever", request.getRequestLine().getUri());
-        assertEquals(1, request.getAllHeaders().length);
-        assertEquals("stuff more stuff", request.getFirstHeader("Some header").getValue());
+        Assert.assertNotNull(request);
+        Assert.assertEquals("/whatever", request.getRequestLine().getUri());
+        Assert.assertEquals(1, request.getAllHeaders().length);
+        Assert.assertEquals("stuff more stuff", request.getFirstHeader("Some header").getValue());
     }
 
+    @Test
     public void testParsingEmptyFoldedHeader() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -170,28 +168,29 @@ public class TestHttpMessageParser exten
 
         requestParser.fillBuffer(newChannel("GET /whatev"));
         HttpRequest request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("er HTTP/1.1\r"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("\n  Some header: stuff\r\n"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("      \r\n"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("      more stuff\r\n"));
         request = requestParser.parse();
-        assertNull(request);
+        Assert.assertNull(request);
         requestParser.fillBuffer(newChannel("\r\n"));
         request = requestParser.parse();
 
-        assertNotNull(request);
-        assertEquals("/whatever", request.getRequestLine().getUri());
-        assertEquals(1, request.getAllHeaders().length);
-        assertEquals("stuff  more stuff", request.getFirstHeader("Some header").getValue());
+        Assert.assertNotNull(request);
+        Assert.assertEquals("/whatever", request.getRequestLine().getUri());
+        Assert.assertEquals(1, request.getAllHeaders().length);
+        Assert.assertEquals("stuff  more stuff", request.getFirstHeader("Some header").getValue());
     }
 
+    @Test
     public void testParsingIncompleteRequestLine() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -202,10 +201,11 @@ public class TestHttpMessageParser exten
         requestParser.fillBuffer(channel);
         requestParser.fillBuffer(channel);
         HttpRequest request = requestParser.parse();
-        assertNotNull(request);
-        assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getProtocolVersion());
+        Assert.assertNotNull(request);
+        Assert.assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getProtocolVersion());
     }
 
+    @Test
     public void testParsingIncompleteHeader() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -216,11 +216,12 @@ public class TestHttpMessageParser exten
         requestParser.fillBuffer(channel);
         requestParser.fillBuffer(channel);
         HttpRequest request = requestParser.parse();
-        assertNotNull(request);
-        assertEquals(1, request.getAllHeaders().length);
-        assertEquals("whatever", request.getFirstHeader("Header").getValue());
+        Assert.assertNotNull(request);
+        Assert.assertEquals(1, request.getAllHeaders().length);
+        Assert.assertEquals("whatever", request.getFirstHeader("Header").getValue());
     }
 
+    @Test
     public void testParsingInvalidRequestLine() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -231,12 +232,13 @@ public class TestHttpMessageParser exten
         requestParser.fillBuffer(channel);
         try {
             requestParser.parse();
-            fail("HttpException should have been thrown");
+            Assert.fail("HttpException should have been thrown");
         } catch (HttpException ex) {
             // expected
         }
     }
 
+    @Test
     public void testParsingInvalidStatusLine() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -247,12 +249,13 @@ public class TestHttpMessageParser exten
         responseParser.fillBuffer(channel);
         try {
             responseParser.parse();
-            fail("HttpException should have been thrown");
+            Assert.fail("HttpException should have been thrown");
         } catch (HttpException ex) {
             // expected
         }
     }
 
+    @Test
     public void testParsingInvalidHeader() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -263,12 +266,13 @@ public class TestHttpMessageParser exten
         responseParser.fillBuffer(channel);
         try {
             responseParser.parse();
-            fail("HttpException should have been thrown");
+            Assert.fail("HttpException should have been thrown");
         } catch (HttpException ex) {
             // expected
         }
     }
 
+    @Test
     public void testResetParser() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -278,49 +282,51 @@ public class TestHttpMessageParser exten
         ReadableByteChannel channel = newChannel("GET /whatever HTTP/1.0\r\nHeader: one\r\n\r\n");
         requestParser.fillBuffer(channel);
         HttpRequest request = requestParser.parse();
-        assertNotNull(request);
-        assertEquals(1, request.getAllHeaders().length);
-        assertEquals("one", request.getFirstHeader("Header").getValue());
+        Assert.assertNotNull(request);
+        Assert.assertEquals(1, request.getAllHeaders().length);
+        Assert.assertEquals("one", request.getFirstHeader("Header").getValue());
 
         requestParser.reset();
 
         channel = newChannel("GET /whatever HTTP/1.0\r\nHeader: two\r\n\r\n");
         requestParser.fillBuffer(channel);
         request = requestParser.parse();
-        assertNotNull(request);
-        assertEquals(1, request.getAllHeaders().length);
-        assertEquals("two", request.getFirstHeader("Header").getValue());
+        Assert.assertNotNull(request);
+        Assert.assertEquals(1, request.getAllHeaders().length);
+        Assert.assertEquals("two", request.getFirstHeader("Header").getValue());
     }
 
+    @Test
     public void testInvalidConstructor() {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
         try {
             new DefaultHttpRequestParser(null, null, null, params);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new DefaultHttpRequestParser(inbuf, null, null, params);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new DefaultHttpResponseParser(null, null, null, params);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new DefaultHttpResponseParser(inbuf, null, null, params);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
     }
 
+    @Test
     public void testLineLimitForStatus() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -337,11 +343,12 @@ public class TestHttpMessageParser exten
         try {
             requestParser.fillBuffer(newChannel("GET /loooooooooooooooong HTTP/1.0\r\nHeader: one\r\n\r\n"));
             requestParser.parse();
-            fail("IOException should have been thrown");
+            Assert.fail("IOException should have been thrown");
         } catch (IOException expected) {
         }
     }
 
+    @Test
     public void testLineLimitForHeader() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -361,11 +368,12 @@ public class TestHttpMessageParser exten
         try {
             requestParser.fillBuffer(newChannel("GET / HTTP/1.0\r\nHeader: 90123456\r\n\r\n"));
             requestParser.parse();
-            fail("IOException should have been thrown");
+            Assert.fail("IOException should have been thrown");
         } catch (IOException expected) {
         }
     }
 
+    @Test
     public void testLineLimitForFoldedHeader() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -377,11 +385,12 @@ public class TestHttpMessageParser exten
         try {
             requestParser.fillBuffer(newChannel("GET / HTTP/1.0\r\nHeader: 9012345\r\n 23456789012345\r\n 23456789012345\r\n 23456789012345\r\n\r\n"));
             requestParser.parse();
-            fail("IOException should have been thrown");
+            Assert.fail("IOException should have been thrown");
         } catch (IOException expected) {
         }
     }
 
+    @Test
     public void testMaxHeaderCount() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
@@ -396,11 +405,12 @@ public class TestHttpMessageParser exten
         try {
             requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.0\r\nHeader: one\r\nHeader: two\r\nHeader: three\r\n\r\n"));
             requestParser.parse();
-            fail("IOException should have been thrown");
+            Assert.fail("IOException should have been thrown");
         } catch (IOException expected) {
         }
     }
 
+    @Test
     public void testDetectLineLimitEarly() throws Exception {
         HttpParams params = new BasicHttpParams();
         SessionInputBuffer inbuf = new SessionInputBufferImpl(2, 128, params);
@@ -409,12 +419,12 @@ public class TestHttpMessageParser exten
         params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 2);
         NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
         ReadableByteChannel channel = newChannel("GET / HTTP/1.0\r\nHeader: one\r\n\r\n");
-        assertEquals(2, requestParser.fillBuffer(channel));
-        assertNull(requestParser.parse());
-        assertEquals(4, requestParser.fillBuffer(channel));
+        Assert.assertEquals(2, requestParser.fillBuffer(channel));
+        Assert.assertNull(requestParser.parse());
+        Assert.assertEquals(4, requestParser.fillBuffer(channel));
         try {
             requestParser.parse();
-            fail("IOException should have been thrown");
+            Assert.fail("IOException should have been thrown");
         } catch (IOException expected) {
         }
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java Mon May  9 11:26:57 2011
@@ -36,29 +36,19 @@ import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.channels.ReadableByteChannel;
 
-import junit.framework.TestCase;
-
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionInputBufferImpl;
 import org.apache.http.mockup.ReadableByteChannelMockup;
 import org.apache.http.nio.reactor.SessionInputBuffer;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Simple tests for {@link LengthDelimitedDecoder}.
- *
- *
- * @version $Id$
  */
-public class TestIdentityDecoder extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestIdentityDecoder(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestIdentityDecoder {
 
     private static String convert(final ByteBuffer src) {
         src.flip();
@@ -85,6 +75,7 @@ public class TestIdentityDecoder extends
         }
     }
 
+    @Test
     public void testBasicDecoding() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII");
@@ -97,31 +88,32 @@ public class TestIdentityDecoder extends
         ByteBuffer dst = ByteBuffer.allocate(1024);
 
         int bytesRead = decoder.read(dst);
-        assertEquals(6, bytesRead);
-        assertEquals("stuff;", convert(dst));
-        assertFalse(decoder.isCompleted());
-        assertEquals(6, metrics.getBytesTransferred());
+        Assert.assertEquals(6, bytesRead);
+        Assert.assertEquals("stuff;", convert(dst));
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(6, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(10, bytesRead);
-        assertEquals("more stuff", convert(dst));
-        assertFalse(decoder.isCompleted());
-        assertEquals(16, metrics.getBytesTransferred());
+        Assert.assertEquals(10, bytesRead);
+        Assert.assertEquals("more stuff", convert(dst));
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(16, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
-        assertEquals(16, metrics.getBytesTransferred());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
+        Assert.assertEquals(16, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
-        assertEquals(16, metrics.getBytesTransferred());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
+        Assert.assertEquals(16, metrics.getBytesTransferred());
     }
 
+    @Test
     public void testDecodingFromSessionBuffer() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII");
@@ -132,39 +124,40 @@ public class TestIdentityDecoder extends
 
         inbuf.fill(channel);
 
-        assertEquals(6, inbuf.length());
+        Assert.assertEquals(6, inbuf.length());
 
         IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics);
 
         ByteBuffer dst = ByteBuffer.allocate(1024);
 
         int bytesRead = decoder.read(dst);
-        assertEquals(6, bytesRead);
-        assertEquals("stuff;", convert(dst));
-        assertFalse(decoder.isCompleted());
-        assertEquals(0, metrics.getBytesTransferred()); // doesn't count if from session buffer
+        Assert.assertEquals(6, bytesRead);
+        Assert.assertEquals("stuff;", convert(dst));
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(0, metrics.getBytesTransferred()); // doesn't count if from session buffer
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(10, bytesRead);
-        assertEquals("more stuff", convert(dst));
-        assertFalse(decoder.isCompleted());
-        assertEquals(10, metrics.getBytesTransferred());
+        Assert.assertEquals(10, bytesRead);
+        Assert.assertEquals("more stuff", convert(dst));
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(10, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
-        assertEquals(10, metrics.getBytesTransferred());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
+        Assert.assertEquals(10, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
-        assertEquals(10, metrics.getBytesTransferred());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
+        Assert.assertEquals(10, metrics.getBytesTransferred());
 
     }
 
+    @Test
     public void testBasicDecodingFile() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
@@ -188,10 +181,10 @@ public class TestIdentityDecoder extends
             }
         }
 
-        assertEquals(testfile.length(), metrics.getBytesTransferred());
+        Assert.assertEquals(testfile.length(), metrics.getBytesTransferred());
         fchannel.close();
 
-        assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
+        Assert.assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
 
         deleteWithCheck(fileHandle);
     }
@@ -202,6 +195,7 @@ public class TestIdentityDecoder extends
         }
     }
 
+    @Test
     public void testDecodingFileWithBufferedSessionData() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
@@ -213,7 +207,7 @@ public class TestIdentityDecoder extends
                 channel, inbuf, metrics);
 
         int i = inbuf.fill(channel);
-        assertEquals(7, i);
+        Assert.assertEquals(7, i);
 
         File fileHandle = File.createTempFile("testFile", ".txt");
 
@@ -229,14 +223,15 @@ public class TestIdentityDecoder extends
         }
 
         // count everything except the initial 7 bytes that went to the session buffer
-        assertEquals(testfile.length() - 7, metrics.getBytesTransferred());
+        Assert.assertEquals(testfile.length() - 7, metrics.getBytesTransferred());
         fchannel.close();
 
-        assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
+        Assert.assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
 
         deleteWithCheck(fileHandle);
     }
 
+    @Test
     public void testDecodingFileWithOffsetAndBufferedSessionData() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");
@@ -248,7 +243,7 @@ public class TestIdentityDecoder extends
                 channel, inbuf, metrics);
 
         int i = inbuf.fill(channel);
-        assertEquals(7, i);
+        Assert.assertEquals(7, i);
 
         File fileHandle = File.createTempFile("testFile", ".txt");
 
@@ -271,14 +266,15 @@ public class TestIdentityDecoder extends
         }
 
         // count everything except the initial 7 bytes that went to the session buffer
-        assertEquals(testfile.length() - 7 - beginning.length, metrics.getBytesTransferred());
+        Assert.assertEquals(testfile.length() - 7 - beginning.length, metrics.getBytesTransferred());
         fchannel.close();
 
-        assertEquals("beginning; stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
+        Assert.assertEquals("beginning; stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
 
         deleteWithCheck(fileHandle);
     }
 
+    @Test
     public void testWriteBeyondFileSize() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"a"}, "US-ASCII");
@@ -293,17 +289,18 @@ public class TestIdentityDecoder extends
 
         RandomAccessFile testfile = new RandomAccessFile(fileHandle, "rw");
         FileChannel fchannel = testfile.getChannel();
-        assertEquals(0, testfile.length());
+        Assert.assertEquals(0, testfile.length());
 
         try {
             decoder.transfer(fchannel, 5, 10);
-            fail("expected IOException");
+            Assert.fail("expected IOException");
         } catch(IOException iox) {}
 
         testfile.close();
         deleteWithCheck(fileHandle);
     }
 
+    @Test
     public void testInvalidConstructor() {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII");
@@ -312,24 +309,25 @@ public class TestIdentityDecoder extends
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
         try {
             new IdentityDecoder(null, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new IdentityDecoder(channel, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new IdentityDecoder(channel, inbuf, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
     }
 
+    @Test
     public void testInvalidInput() throws Exception {
         String s = "stuff";
         ReadableByteChannel channel = new ReadableByteChannelMockup(
@@ -342,7 +340,7 @@ public class TestIdentityDecoder extends
 
         try {
             decoder.read(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java Mon May  9 11:26:57 2011
@@ -32,29 +32,19 @@ import java.nio.ByteBuffer;
 import java.nio.channels.Channels;
 import java.nio.channels.WritableByteChannel;
 
-import junit.framework.TestCase;
-
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionOutputBufferImpl;
 import org.apache.http.nio.reactor.SessionOutputBuffer;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.util.EncodingUtils;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Simple tests for {@link IdentityEncoder}.
- *
- *
- * @version $Id$
  */
-public class TestIdentityEncoder extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestIdentityEncoder(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestIdentityEncoder {
 
     private static ByteBuffer wrap(final String s) {
         return ByteBuffer.wrap(EncodingUtils.getAsciiBytes(s));
@@ -64,6 +54,7 @@ public class TestIdentityEncoder extends
         return Channels.newChannel(baos);
     }
 
+    @Test
     public void testBasicCoding() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -77,10 +68,11 @@ public class TestIdentityEncoder extends
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("stuff", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("stuff", s);
     }
 
+    @Test
     public void testCodingEmptyBuffer() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -100,10 +92,11 @@ public class TestIdentityEncoder extends
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("stuff", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("stuff", s);
     }
 
+    @Test
     public void testCodingCompleted() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -117,12 +110,13 @@ public class TestIdentityEncoder extends
 
         try {
             encoder.write(wrap("more stuff"));
-            fail("IllegalStateException should have been thrown");
+            Assert.fail("IllegalStateException should have been thrown");
         } catch (IllegalStateException ex) {
             // ignore
         }
     }
 
+    @Test
     public void testInvalidConstructor() {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -131,19 +125,19 @@ public class TestIdentityEncoder extends
 
         try {
             new IdentityEncoder(null, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new IdentityEncoder(channel, null, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new IdentityEncoder(channel, outbuf, null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }