hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1100965 [2/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-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.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 TestLengthDelimitedDecoder extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestLengthDelimitedDecoder(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestLengthDelimitedDecoder {
 
     private static String convert(final ByteBuffer src) {
         src.flip();
@@ -85,6 +75,7 @@ public class TestLengthDelimitedDecoder 
         }
     }
 
+    @Test
     public void testBasicDecoding() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII");
@@ -98,25 +89,26 @@ public class TestLengthDelimitedDecoder 
         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));
-        assertTrue(decoder.isCompleted());
-        assertEquals(16, metrics.getBytesTransferred());
+        Assert.assertEquals(10, bytesRead);
+        Assert.assertEquals("more stuff", convert(dst));
+        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 testCodingBeyondContentLimit() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {
@@ -132,25 +124,26 @@ public class TestLengthDelimitedDecoder 
         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));
-        assertTrue(decoder.isCompleted());
-        assertEquals(16, metrics.getBytesTransferred());
+        Assert.assertEquals(10, bytesRead);
+        Assert.assertEquals("more stuff", convert(dst));
+        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 testBasicDecodingSmallBuffer() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII");
@@ -164,46 +157,47 @@ public class TestLengthDelimitedDecoder 
         ByteBuffer dst = ByteBuffer.allocate(4);
 
         int bytesRead = decoder.read(dst);
-        assertEquals(4, bytesRead);
-        assertEquals("stuf", convert(dst));
-        assertFalse(decoder.isCompleted());
-        assertEquals(4, metrics.getBytesTransferred());
+        Assert.assertEquals(4, bytesRead);
+        Assert.assertEquals("stuf", convert(dst));
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(4, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(2, bytesRead);
-        assertEquals("f;", convert(dst));
-        assertFalse(decoder.isCompleted());
-        assertEquals(6, metrics.getBytesTransferred());
+        Assert.assertEquals(2, bytesRead);
+        Assert.assertEquals("f;", convert(dst));
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(6, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(4, bytesRead);
-        assertEquals("more", convert(dst));
-        assertFalse(decoder.isCompleted());
-        assertEquals(10, metrics.getBytesTransferred());
+        Assert.assertEquals(4, bytesRead);
+        Assert.assertEquals("more", convert(dst));
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(10, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(4, bytesRead);
-        assertEquals(" stu", convert(dst));
-        assertFalse(decoder.isCompleted());
-        assertEquals(14, metrics.getBytesTransferred());
+        Assert.assertEquals(4, bytesRead);
+        Assert.assertEquals(" stu", convert(dst));
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(14, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(2, bytesRead);
-        assertEquals("ff", convert(dst));
-        assertTrue(decoder.isCompleted());
-        assertEquals(16, metrics.getBytesTransferred());
+        Assert.assertEquals(2, bytesRead);
+        Assert.assertEquals("ff", convert(dst));
+        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 testDecodingFromSessionBuffer1() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII");
@@ -214,7 +208,7 @@ public class TestLengthDelimitedDecoder 
 
         inbuf.fill(channel);
 
-        assertEquals(6, inbuf.length());
+        Assert.assertEquals(6, inbuf.length());
 
         LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
                 channel, inbuf, metrics, 16);
@@ -222,25 +216,26 @@ public class TestLengthDelimitedDecoder 
         ByteBuffer dst = ByteBuffer.allocate(1024);
 
         int bytesRead = decoder.read(dst);
-        assertEquals(6, bytesRead);
-        assertEquals("stuff;", convert(dst));
-        assertFalse(decoder.isCompleted());
-        assertEquals(0, metrics.getBytesTransferred());
+        Assert.assertEquals(6, bytesRead);
+        Assert.assertEquals("stuff;", convert(dst));
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(0, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(10, bytesRead);
-        assertEquals("more stuff", convert(dst));
-        assertTrue(decoder.isCompleted());
-        assertEquals(10, metrics.getBytesTransferred());
+        Assert.assertEquals(10, bytesRead);
+        Assert.assertEquals("more stuff", convert(dst));
+        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 testDecodingFromSessionBuffer2() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {
@@ -254,7 +249,7 @@ public class TestLengthDelimitedDecoder 
         inbuf.fill(channel);
         inbuf.fill(channel);
 
-        assertEquals(38, inbuf.length());
+        Assert.assertEquals(38, inbuf.length());
 
         LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
                 channel, inbuf, metrics, 16);
@@ -262,18 +257,19 @@ public class TestLengthDelimitedDecoder 
         ByteBuffer dst = ByteBuffer.allocate(1024);
 
         int bytesRead = decoder.read(dst);
-        assertEquals(16, bytesRead);
-        assertEquals("stuff;more stuff", convert(dst));
-        assertTrue(decoder.isCompleted());
-        assertEquals(0, metrics.getBytesTransferred());
+        Assert.assertEquals(16, bytesRead);
+        Assert.assertEquals("stuff;more stuff", convert(dst));
+        Assert.assertTrue(decoder.isCompleted());
+        Assert.assertEquals(0, metrics.getBytesTransferred());
 
         dst.clear();
         bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
-        assertEquals(0, metrics.getBytesTransferred());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
+        Assert.assertEquals(0, metrics.getBytesTransferred());
     }
 
+    @Test
     public void testBasicDecodingFile() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII");
@@ -296,10 +292,10 @@ public class TestLengthDelimitedDecoder 
                 pos += bytesRead;
             }
         }
-        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);
     }
@@ -310,6 +306,7 @@ public class TestLengthDelimitedDecoder 
         }
     }
 
+    @Test
     public void testDecodingFileWithBufferedSessionData() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff; ", "more stuff; ", "a lot more stuff!!!"}, "US-ASCII");
@@ -321,7 +318,7 @@ public class TestLengthDelimitedDecoder 
                 channel, inbuf, metrics, 36);
 
         int i = inbuf.fill(channel);
-        assertEquals(7, i);
+        Assert.assertEquals(7, i);
 
         File fileHandle = File.createTempFile("testFile", ".txt");
 
@@ -336,14 +333,15 @@ public class TestLengthDelimitedDecoder 
             }
         }
 
-        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");
@@ -355,7 +353,7 @@ public class TestLengthDelimitedDecoder 
                 channel, inbuf, metrics, 36);
 
         int i = inbuf.fill(channel);
-        assertEquals(7, i);
+        Assert.assertEquals(7, i);
 
         File fileHandle = File.createTempFile("testFile", ".txt");
 
@@ -378,14 +376,15 @@ public class TestLengthDelimitedDecoder 
         }
 
         // 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");
@@ -400,17 +399,18 @@ public class TestLengthDelimitedDecoder 
 
         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 testCodingBeyondContentLimitFile() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {
@@ -428,24 +428,25 @@ public class TestLengthDelimitedDecoder 
         FileChannel fchannel = testfile.getChannel();
 
         long bytesRead = decoder.transfer(fchannel, 0, 6);
-        assertEquals(6, bytesRead);
-        assertFalse(decoder.isCompleted());
-        assertEquals(6, metrics.getBytesTransferred());
+        Assert.assertEquals(6, bytesRead);
+        Assert.assertFalse(decoder.isCompleted());
+        Assert.assertEquals(6, metrics.getBytesTransferred());
 
         bytesRead = decoder.transfer(fchannel,0 , 10);
-        assertEquals(10, bytesRead);
-        assertTrue(decoder.isCompleted());
-        assertEquals(16, metrics.getBytesTransferred());
+        Assert.assertEquals(10, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
+        Assert.assertEquals(16, metrics.getBytesTransferred());
 
         bytesRead = decoder.transfer(fchannel, 0, 1);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
-        assertEquals(16, metrics.getBytesTransferred());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
+        Assert.assertEquals(16, metrics.getBytesTransferred());
 
         testfile.close();
         deleteWithCheck(fileHandle);
     }
 
+    @Test
     public void testInvalidConstructor() {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII");
@@ -455,30 +456,31 @@ public class TestLengthDelimitedDecoder 
         HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
         try {
             new LengthDelimitedDecoder(null, null, null, 10);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new LengthDelimitedDecoder(channel, null, null, 10);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new LengthDelimitedDecoder(channel, inbuf, null, 10);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new LengthDelimitedDecoder(channel, inbuf, metrics, -10);
-            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(
@@ -492,12 +494,13 @@ public class TestLengthDelimitedDecoder 
 
         try {
             decoder.read(null);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
     }
 
+    @Test
     public void testZeroLengthDecoding() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff"}, "US-ASCII");
@@ -511,9 +514,9 @@ public class TestLengthDelimitedDecoder 
         ByteBuffer dst = ByteBuffer.allocate(1024);
 
         int bytesRead = decoder.read(dst);
-        assertEquals(-1, bytesRead);
-        assertTrue(decoder.isCompleted());
-        assertEquals(0, metrics.getBytesTransferred());
+        Assert.assertEquals(-1, bytesRead);
+        Assert.assertTrue(decoder.isCompleted());
+        Assert.assertEquals(0, metrics.getBytesTransferred());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java Mon May  9 11:26:57 2011
@@ -37,29 +37,19 @@ import java.nio.channels.Channels;
 import java.nio.channels.FileChannel;
 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 LengthDelimitedEncoder}.
- *
- *
- * @version $Id$
  */
-public class TestLengthDelimitedEncoder extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestLengthDelimitedEncoder(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestLengthDelimitedEncoder {
 
     private static ByteBuffer wrap(final String s) {
         return ByteBuffer.wrap(EncodingUtils.getAsciiBytes(s));
@@ -69,6 +59,7 @@ public class TestLengthDelimitedEncoder 
         return Channels.newChannel(baos);
     }
 
+    @Test
     public void testBasicCoding() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -83,10 +74,11 @@ public class TestLengthDelimitedEncoder 
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("stuff;more stuff", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("stuff;more stuff", s);
     }
 
+    @Test
     public void testCodingBeyondContentLimit() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -101,10 +93,11 @@ public class TestLengthDelimitedEncoder 
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("stuff;more stuff", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("stuff;more stuff", s);
     }
 
+    @Test
     public void testCodingEmptyBuffer() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -125,10 +118,11 @@ public class TestLengthDelimitedEncoder 
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("stuff;more stuff", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("stuff;more stuff", s);
     }
 
+    @Test
     public void testCodingCompleted() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -142,13 +136,14 @@ public class TestLengthDelimitedEncoder 
 
         try {
             encoder.write(wrap("more stuff"));
-            fail("IllegalStateException should have been thrown");
+            Assert.fail("IllegalStateException should have been thrown");
         } catch (IllegalStateException ex) {
             // ignore
         }
     }
 
     /* ----------------- FileChannel Part testing --------------------------- */
+    @Test
     public void testCodingBeyondContentLimitFromFile() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -175,8 +170,8 @@ public class TestLengthDelimitedEncoder 
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("stuff;more stuff", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("stuff;more stuff", s);
 
         fchannel.close();
 
@@ -189,6 +184,7 @@ public class TestLengthDelimitedEncoder 
         }
     }
 
+    @Test
     public void testCodingEmptyFile() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -216,13 +212,14 @@ public class TestLengthDelimitedEncoder 
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("stuff;more stuff", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("stuff;more stuff", s);
 
         fchannel.close();
         deleteWithCheck(tmpFile);
     }
 
+    @Test
     public void testCodingCompletedFromFile() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -246,7 +243,7 @@ public class TestLengthDelimitedEncoder 
         FileChannel fchannel = new FileInputStream(tmpFile).getChannel();
         try {
             encoder.transfer(fchannel, 0, 10);
-            fail("IllegalStateException should have been thrown");
+            Assert.fail("IllegalStateException should have been thrown");
         } catch (IllegalStateException ex) {
             // ignore
         } finally {
@@ -255,6 +252,7 @@ public class TestLengthDelimitedEncoder 
         }
     }
 
+    @Test
     public void testCodingFromFileSmaller() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -281,13 +279,14 @@ public class TestLengthDelimitedEncoder 
 
         String s = baos.toString("US-ASCII");
 
-        assertTrue(encoder.isCompleted());
-        assertEquals("stuff;more stuff", s);
+        Assert.assertTrue(encoder.isCompleted());
+        Assert.assertEquals("stuff;more stuff", s);
 
         fchannel.close();
         deleteWithCheck(tmpFile);
     }
 
+    @Test
     public void testInvalidConstructor() {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         WritableByteChannel channel = newChannel(baos);
@@ -297,25 +296,25 @@ public class TestLengthDelimitedEncoder 
 
         try {
             new LengthDelimitedEncoder(null, null, null, 10);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new LengthDelimitedEncoder(channel, null, null, 10);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new LengthDelimitedEncoder(channel, outbuf, null, 10);
-            fail("IllegalArgumentException should have been thrown");
+            Assert.fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
         try {
             new LengthDelimitedEncoder(channel, outbuf, metrics, -10);
-            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/reactor/ExceptionEventTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/ExceptionEventTest.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/ExceptionEventTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/ExceptionEventTest.java Mon May  9 11:26:57 2011
@@ -29,28 +29,32 @@ package org.apache.http.impl.nio.reactor
 
 import java.util.Date;
 
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class ExceptionEventTest extends TestCase {
+public class ExceptionEventTest {
 
+    @Test
     public void testGetCause() {
         NullPointerException npe = new NullPointerException("npe");
         ExceptionEvent ee = new ExceptionEvent(npe);
-        assertSame(npe, ee.getCause());
+        Assert.assertSame(npe, ee.getCause());
         ee = new ExceptionEvent(npe, new Date());
-        assertSame(npe, ee.getCause());
+        Assert.assertSame(npe, ee.getCause());
     }
 
+    @Test
     public void testGetTimestamp() {
         NullPointerException npe = new NullPointerException("npe");
         ExceptionEvent ee = new ExceptionEvent(npe);
-        assertNotNull(ee.getTimestamp());
+        Assert.assertNotNull(ee.getTimestamp());
         ee = new ExceptionEvent(npe, new Date(1234567890L));
-        assertEquals(new Date(1234567890L), ee.getTimestamp());
+        Assert.assertEquals(new Date(1234567890L), ee.getTimestamp());
     }
 
+    @Test
     public void testToString() {
-        assertNotNull(new ExceptionEvent(new NullPointerException()));
+        Assert.assertNotNull(new ExceptionEvent(new NullPointerException()));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestBaseIOReactorSSL.java Mon May  9 11:26:57 2011
@@ -39,16 +39,14 @@ import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.mockup.SimpleHttpRequestHandlerResolver;
 import org.apache.http.mockup.HttpSSLServer;
+import org.apache.http.mockup.SimpleHttpRequestHandlerResolver;
 import org.apache.http.nio.NHttpServiceHandler;
 import org.apache.http.nio.protocol.BufferingHttpServiceHandler;
 import org.apache.http.nio.protocol.EventListener;
@@ -66,13 +64,17 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-public class TestBaseIOReactorSSL extends TestCase {
+public class TestBaseIOReactorSSL {
 
     private HttpSSLServer server;
 
-    @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void initServer() throws Exception {
         HttpParams serverParams = new SyncBasicHttpParams();
         serverParams
             .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
@@ -84,9 +86,11 @@ public class TestBaseIOReactorSSL extend
         this.server = new HttpSSLServer(serverParams);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
-        this.server.shutdown();
+    @After
+    public void shutDownServer() throws Exception {
+        if (this.server != null) {
+            this.server.shutdown();
+        }
     }
 
     private NHttpServiceHandler createHttpServiceHandler(
@@ -122,6 +126,7 @@ public class TestBaseIOReactorSSL extend
         }
     }
 
+    @Test
     public void testBufferedInput() throws Exception {
         final int[] result = new int[1];
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
@@ -168,7 +173,7 @@ public class TestBaseIOReactorSSL extend
         synchronized (result) {
             result.wait(500);
         }
-        assertEquals(1, result[0]);
+        Assert.assertEquals(1, result[0]);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactors.java Mon May  9 11:26:57 2011
@@ -70,19 +70,15 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Tests for basic I/O functionality.
  */
 public class TestDefaultIOReactors extends HttpCoreNIOTestBase {
 
-    // ------------------------------------------------------------ Constructor
-    public TestDefaultIOReactors(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
+    @Test
     public void testGracefulShutdown() throws Exception {
 
         // Open some connection and make sure
@@ -206,7 +202,7 @@ public class TestDefaultIOReactors exten
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -222,21 +218,22 @@ public class TestDefaultIOReactors exten
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         requestConns.await();
-        assertEquals(0, requestConns.getCount());
+        Assert.assertEquals(0, requestConns.getCount());
 
         this.client.shutdown();
         this.server.shutdown();
 
-        assertEquals(openClientConns.get(), closedClientConns.get());
-        assertEquals(openServerConns.get(), closedServerConns.get());
+        Assert.assertEquals(openClientConns.get(), closedClientConns.get());
+        Assert.assertEquals(openServerConns.get(), closedServerConns.get());
     }
 
+    @Test
     public void testRuntimeException() throws Exception {
 
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
@@ -322,22 +319,23 @@ public class TestDefaultIOReactors exten
         this.server.join(20000);
 
         Exception ex = this.server.getException();
-        assertNotNull(ex);
-        assertTrue(ex instanceof IOReactorException);
-        assertNotNull(ex.getCause());
-        assertTrue(ex.getCause() instanceof OoopsieRuntimeException);
+        Assert.assertNotNull(ex);
+        Assert.assertTrue(ex instanceof IOReactorException);
+        Assert.assertNotNull(ex.getCause());
+        Assert.assertTrue(ex.getCause() instanceof OoopsieRuntimeException);
 
         List<ExceptionEvent> auditlog = this.server.getAuditLog();
-        assertNotNull(auditlog);
-        assertEquals(1, auditlog.size());
+        Assert.assertNotNull(auditlog);
+        Assert.assertEquals(1, auditlog.size());
 
         // I/O reactor shut down itself
-        assertEquals(IOReactorStatus.SHUT_DOWN, this.server.getStatus());
+        Assert.assertEquals(IOReactorStatus.SHUT_DOWN, this.server.getStatus());
 
         this.client.shutdown();
         this.server.shutdown();
     }
 
+    @Test
     public void testUnhandledRuntimeException() throws Exception {
 
         final CountDownLatch requestConns = new CountDownLatch(1);
@@ -434,27 +432,28 @@ public class TestDefaultIOReactors exten
                 null);
 
         requestConns.await();
-        assertEquals(0, requestConns.getCount());
+        Assert.assertEquals(0, requestConns.getCount());
 
         this.server.join(20000);
 
         Exception ex = this.server.getException();
-        assertNotNull(ex);
-        assertTrue(ex instanceof IOReactorException);
-        assertNotNull(ex.getCause());
-        assertTrue(ex.getCause() instanceof OoopsieRuntimeException);
+        Assert.assertNotNull(ex);
+        Assert.assertTrue(ex instanceof IOReactorException);
+        Assert.assertNotNull(ex.getCause());
+        Assert.assertTrue(ex.getCause() instanceof OoopsieRuntimeException);
 
         List<ExceptionEvent> auditlog = this.server.getAuditLog();
-        assertNotNull(auditlog);
-        assertEquals(1, auditlog.size());
+        Assert.assertNotNull(auditlog);
+        Assert.assertEquals(1, auditlog.size());
 
         // I/O reactor shut down itself
-        assertEquals(IOReactorStatus.SHUT_DOWN, this.server.getStatus());
+        Assert.assertEquals(IOReactorStatus.SHUT_DOWN, this.server.getStatus());
 
         this.client.shutdown();
         this.server.shutdown();
     }
 
+    @Test
     public void testHandledRuntimeException() throws Exception {
 
         final CountDownLatch requestConns = new CountDownLatch(1);
@@ -552,12 +551,12 @@ public class TestDefaultIOReactors exten
                 null);
 
         requestConns.await();
-        assertEquals(0, requestConns.getCount());
+        Assert.assertEquals(0, requestConns.getCount());
 
         this.server.join(1000);
 
-        assertEquals(IOReactorStatus.ACTIVE, this.server.getStatus());
-        assertNull(this.server.getException());
+        Assert.assertEquals(IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertNull(this.server.getException());
 
         this.client.shutdown();
         this.server.shutdown();

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java Mon May  9 11:26:57 2011
@@ -66,6 +66,8 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Basic functionality tests for SSL I/O reactors.
@@ -73,13 +75,7 @@ import org.apache.http.protocol.Response
  */
 public class TestDefaultIOReactorsSSL extends HttpCoreNIOSSLTestBase {
 
-    // ------------------------------------------------------------ Constructor
-    public TestDefaultIOReactorsSSL(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
+    @Test
     public void testGracefulShutdown() throws Exception {
 
         // Open some connection and make sure
@@ -203,7 +199,7 @@ public class TestDefaultIOReactorsSSL ex
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -219,19 +215,19 @@ public class TestDefaultIOReactorsSSL ex
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         requestConns.await();
-        assertEquals(0, requestConns.getCount());
+        Assert.assertEquals(0, requestConns.getCount());
 
         this.client.shutdown();
         this.server.shutdown();
 
-        assertEquals(openClientConns.get(), closedClientConns.get());
-        assertEquals(openServerConns.get(), closedServerConns.get());
+        Assert.assertEquals(openClientConns.get(), closedClientConns.get());
+        Assert.assertEquals(openServerConns.get(), closedServerConns.get());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java Mon May  9 11:26:57 2011
@@ -34,8 +34,6 @@ import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.TestCase;
-
 import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.impl.DefaultHttpResponseFactory;
@@ -54,19 +52,15 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Basic tests for {@link DefaultListeningIOReactor}.
  */
-public class TestDefaultListeningIOReactor extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestDefaultListeningIOReactor(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestDefaultListeningIOReactor {
 
+    @Test
     public void testEndpointUpAndDown() throws Exception {
 
         HttpParams params = new SyncBasicHttpParams();
@@ -104,8 +98,8 @@ public class TestDefaultListeningIOReact
         t.start();
 
         Set<ListenerEndpoint> endpoints = ioreactor.getEndpoints();
-        assertNotNull(endpoints);
-        assertEquals(0, endpoints.size());
+        Assert.assertNotNull(endpoints);
+        Assert.assertEquals(0, endpoints.size());
 
         ListenerEndpoint port9998 = ioreactor.listen(new InetSocketAddress(9998));
         port9998.waitFor();
@@ -114,25 +108,26 @@ public class TestDefaultListeningIOReact
         port9999.waitFor();
 
         endpoints = ioreactor.getEndpoints();
-        assertNotNull(endpoints);
-        assertEquals(2, endpoints.size());
+        Assert.assertNotNull(endpoints);
+        Assert.assertEquals(2, endpoints.size());
 
         port9998.close();
 
         endpoints = ioreactor.getEndpoints();
-        assertNotNull(endpoints);
-        assertEquals(1, endpoints.size());
+        Assert.assertNotNull(endpoints);
+        Assert.assertEquals(1, endpoints.size());
 
         ListenerEndpoint endpoint = endpoints.iterator().next();
 
-        assertEquals(9999, ((InetSocketAddress) endpoint.getAddress()).getPort());
+        Assert.assertEquals(9999, ((InetSocketAddress) endpoint.getAddress()).getPort());
 
         ioreactor.shutdown(1000);
         t.join(1000);
 
-        assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
+        Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
     }
 
+    @Test
     public void testEndpointAlreadyBoundFatal() throws Exception {
 
         HttpParams params = new SyncBasicHttpParams();
@@ -163,7 +158,7 @@ public class TestDefaultListeningIOReact
             public void run() {
                 try {
                     ioreactor.execute(eventDispatch);
-                    fail("IOException should have been thrown");
+                    Assert.fail("IOException should have been thrown");
                 } catch (IOException ex) {
                     latch.countDown();
                 }
@@ -178,22 +173,23 @@ public class TestDefaultListeningIOReact
 
         ListenerEndpoint endpoint2 = ioreactor.listen(new InetSocketAddress(9999));
         endpoint2.waitFor();
-        assertNotNull(endpoint2.getException());
+        Assert.assertNotNull(endpoint2.getException());
 
         // I/O reactor is now expected to be shutting down
         latch.await(2000, TimeUnit.MILLISECONDS);
-        assertTrue(ioreactor.getStatus().compareTo(IOReactorStatus.SHUTTING_DOWN) >= 0);
+        Assert.assertTrue(ioreactor.getStatus().compareTo(IOReactorStatus.SHUTTING_DOWN) >= 0);
 
         Set<ListenerEndpoint> endpoints = ioreactor.getEndpoints();
-        assertNotNull(endpoints);
-        assertEquals(0, endpoints.size());
+        Assert.assertNotNull(endpoints);
+        Assert.assertEquals(0, endpoints.size());
 
         ioreactor.shutdown(1000);
         t.join(1000);
 
-        assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
+        Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
     }
 
+    @Test
     public void testEndpointAlreadyBoundNonFatal() throws Exception {
 
         HttpParams params = new SyncBasicHttpParams();
@@ -247,17 +243,17 @@ public class TestDefaultListeningIOReact
 
         ListenerEndpoint endpoint2 = ioreactor.listen(new InetSocketAddress(9999));
         endpoint2.waitFor();
-        assertNotNull(endpoint2.getException());
+        Assert.assertNotNull(endpoint2.getException());
 
         // Sleep a little to make sure the I/O reactor is not shutting down
         Thread.sleep(500);
 
-        assertEquals(IOReactorStatus.ACTIVE, ioreactor.getStatus());
+        Assert.assertEquals(IOReactorStatus.ACTIVE, ioreactor.getStatus());
 
         ioreactor.shutdown(1000);
         t.join(1000);
 
-        assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
+        Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java Mon May  9 11:26:57 2011
@@ -36,29 +36,19 @@ import java.nio.channels.ReadableByteCha
 import java.nio.channels.WritableByteChannel;
 import java.nio.charset.CharacterCodingException;
 
-import junit.framework.TestCase;
-
 import org.apache.http.nio.reactor.SessionInputBuffer;
 import org.apache.http.nio.reactor.SessionOutputBuffer;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.util.CharArrayBuffer;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Simple tests for {@link SessionInputBuffer} and {@link SessionOutputBuffer}.
- *
- *
- * @version $Id$
  */
-public class TestSessionInOutBuffers extends TestCase {
-
-    // ------------------------------------------------------------ Constructor
-    public TestSessionInOutBuffers(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
+public class TestSessionInOutBuffers {
 
     private static WritableByteChannel newChannel(final ByteArrayOutputStream outstream) {
         return Channels.newChannel(outstream);
@@ -78,6 +68,7 @@ public class TestSessionInOutBuffers ext
         return newChannel(s, "US-ASCII");
     }
 
+    @Test
     public void testReadLineChunks() throws Exception {
 
         HttpParams params = new BasicHttpParams();
@@ -90,33 +81,34 @@ public class TestSessionInOutBuffers ext
         CharArrayBuffer line = new CharArrayBuffer(64);
 
         line.clear();
-        assertTrue(inbuf.readLine(line, false));
-        assertEquals("One", line.toString());
+        Assert.assertTrue(inbuf.readLine(line, false));
+        Assert.assertEquals("One", line.toString());
 
         line.clear();
-        assertTrue(inbuf.readLine(line, false));
-        assertEquals("Two", line.toString());
+        Assert.assertTrue(inbuf.readLine(line, false));
+        Assert.assertEquals("Two", line.toString());
 
         line.clear();
-        assertFalse(inbuf.readLine(line, false));
+        Assert.assertFalse(inbuf.readLine(line, false));
 
         channel = newChannel("\r\nFour");
         inbuf.fill(channel);
 
         line.clear();
-        assertTrue(inbuf.readLine(line, false));
-        assertEquals("Three", line.toString());
+        Assert.assertTrue(inbuf.readLine(line, false));
+        Assert.assertEquals("Three", line.toString());
 
         inbuf.fill(channel);
 
         line.clear();
-        assertTrue(inbuf.readLine(line, true));
-        assertEquals("Four", line.toString());
+        Assert.assertTrue(inbuf.readLine(line, true));
+        Assert.assertEquals("Four", line.toString());
 
         line.clear();
-        assertFalse(inbuf.readLine(line, true));
+        Assert.assertFalse(inbuf.readLine(line, true));
     }
 
+    @Test
     public void testWriteLineChunks() throws Exception {
 
         HttpParams params = new BasicHttpParams();
@@ -130,48 +122,49 @@ public class TestSessionInOutBuffers ext
         CharArrayBuffer line = new CharArrayBuffer(64);
 
         line.clear();
-        assertTrue(inbuf.readLine(line, false));
-        assertEquals("One", line.toString());
+        Assert.assertTrue(inbuf.readLine(line, false));
+        Assert.assertEquals("One", line.toString());
 
         outbuf.writeLine(line);
 
         line.clear();
-        assertTrue(inbuf.readLine(line, false));
-        assertEquals("Two", line.toString());
+        Assert.assertTrue(inbuf.readLine(line, false));
+        Assert.assertEquals("Two", line.toString());
 
         outbuf.writeLine(line);
 
         line.clear();
-        assertFalse(inbuf.readLine(line, false));
+        Assert.assertFalse(inbuf.readLine(line, false));
 
         inChannel = newChannel("\r\nFour");
         inbuf.fill(inChannel);
 
         line.clear();
-        assertTrue(inbuf.readLine(line, false));
-        assertEquals("Three", line.toString());
+        Assert.assertTrue(inbuf.readLine(line, false));
+        Assert.assertEquals("Three", line.toString());
 
         outbuf.writeLine(line);
 
         inbuf.fill(inChannel);
 
         line.clear();
-        assertTrue(inbuf.readLine(line, true));
-        assertEquals("Four", line.toString());
+        Assert.assertTrue(inbuf.readLine(line, true));
+        Assert.assertEquals("Four", line.toString());
 
         outbuf.writeLine(line);
 
         line.clear();
-        assertFalse(inbuf.readLine(line, true));
+        Assert.assertFalse(inbuf.readLine(line, true));
 
         ByteArrayOutputStream outstream = new ByteArrayOutputStream();
         WritableByteChannel outChannel = newChannel(outstream);
         outbuf.flush(outChannel);
 
         String s = new String(outstream.toByteArray(), "US-ASCII");
-        assertEquals("One\r\nTwo\r\nThree\r\nFour\r\n", s);
+        Assert.assertEquals("One\r\nTwo\r\nThree\r\nFour\r\n", s);
     }
 
+    @Test
     public void testBasicReadWriteLine() throws Exception {
 
         String[] teststrs = new String[5];
@@ -207,12 +200,13 @@ public class TestSessionInOutBuffers ext
         inbuf.fill(channel);
 
         for (int i = 0; i < teststrs.length; i++) {
-            assertEquals(teststrs[i], inbuf.readLine(true));
+            Assert.assertEquals(teststrs[i], inbuf.readLine(true));
         }
-        assertNull(inbuf.readLine(true));
-        assertNull(inbuf.readLine(true));
+        Assert.assertNull(inbuf.readLine(true));
+        Assert.assertNull(inbuf.readLine(true));
     }
 
+    @Test
     public void testComplexReadWriteLine() throws Exception {
         HttpParams params = new BasicHttpParams();
 
@@ -257,18 +251,19 @@ public class TestSessionInOutBuffers ext
         SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, params);
         inbuf.fill(channel);
 
-        assertEquals("a", inbuf.readLine(true));
-        assertEquals("", inbuf.readLine(true));
-        assertEquals("\r", inbuf.readLine(true));
-        assertEquals("", inbuf.readLine(true));
-        assertEquals(s1, inbuf.readLine(true));
-        assertEquals(s2, inbuf.readLine(true));
-        assertEquals(s3, inbuf.readLine(true));
-        assertEquals("a", inbuf.readLine(true));
-        assertNull(inbuf.readLine(true));
-        assertNull(inbuf.readLine(true));
+        Assert.assertEquals("a", inbuf.readLine(true));
+        Assert.assertEquals("", inbuf.readLine(true));
+        Assert.assertEquals("\r", inbuf.readLine(true));
+        Assert.assertEquals("", inbuf.readLine(true));
+        Assert.assertEquals(s1, inbuf.readLine(true));
+        Assert.assertEquals(s2, inbuf.readLine(true));
+        Assert.assertEquals(s3, inbuf.readLine(true));
+        Assert.assertEquals("a", inbuf.readLine(true));
+        Assert.assertNull(inbuf.readLine(true));
+        Assert.assertNull(inbuf.readLine(true));
     }
 
+    @Test
     public void testReadOneByte() throws Exception {
         // make the buffer larger than that of transmitter
         byte[] out = new byte[40];
@@ -286,10 +281,11 @@ public class TestSessionInOutBuffers ext
             in[i] = (byte)inbuf.read();
         }
         for (int i = 0; i < out.length; i++) {
-            assertEquals(out[i], in[i]);
+            Assert.assertEquals(out[i], in[i]);
         }
     }
 
+    @Test
     public void testReadByteBuffer() throws Exception {
         byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
         ReadableByteChannel channel = newChannel(pattern);
@@ -298,15 +294,16 @@ public class TestSessionInOutBuffers ext
         while (inbuf.fill(channel) > 0) {
         }
         ByteBuffer dst = ByteBuffer.allocate(10);
-        assertEquals(10, inbuf.read(dst));
+        Assert.assertEquals(10, inbuf.read(dst));
         dst.flip();
-        assertEquals(dst, ByteBuffer.wrap(pattern, 0, 10));
+        Assert.assertEquals(dst, ByteBuffer.wrap(pattern, 0, 10));
         dst.clear();
-        assertEquals(6, inbuf.read(dst));
+        Assert.assertEquals(6, inbuf.read(dst));
         dst.flip();
-        assertEquals(dst, ByteBuffer.wrap(pattern, 10, 6));
+        Assert.assertEquals(dst, ByteBuffer.wrap(pattern, 10, 6));
     }
 
+    @Test
     public void testReadByteBufferWithMaxLen() throws Exception {
         byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
         ReadableByteChannel channel = newChannel(pattern);
@@ -315,18 +312,19 @@ public class TestSessionInOutBuffers ext
         while (inbuf.fill(channel) > 0) {
         }
         ByteBuffer dst = ByteBuffer.allocate(16);
-        assertEquals(10, inbuf.read(dst, 10));
+        Assert.assertEquals(10, inbuf.read(dst, 10));
         dst.flip();
-        assertEquals(dst, ByteBuffer.wrap(pattern, 0, 10));
+        Assert.assertEquals(dst, ByteBuffer.wrap(pattern, 0, 10));
         dst.clear();
-        assertEquals(3, inbuf.read(dst, 3));
+        Assert.assertEquals(3, inbuf.read(dst, 3));
         dst.flip();
-        assertEquals(dst, ByteBuffer.wrap(pattern, 10, 3));
-        assertEquals(3, inbuf.read(dst, 20));
+        Assert.assertEquals(dst, ByteBuffer.wrap(pattern, 10, 3));
+        Assert.assertEquals(3, inbuf.read(dst, 20));
         dst.flip();
-        assertEquals(dst, ByteBuffer.wrap(pattern, 13, 3));
+        Assert.assertEquals(dst, ByteBuffer.wrap(pattern, 13, 3));
     }
 
+    @Test
     public void testReadToChannel() throws Exception {
         byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
         ReadableByteChannel channel = newChannel(pattern);
@@ -338,10 +336,11 @@ public class TestSessionInOutBuffers ext
         ByteArrayOutputStream outstream = new ByteArrayOutputStream();
         WritableByteChannel dst = newChannel(outstream);
 
-        assertEquals(16, inbuf.read(dst));
-        assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
+        Assert.assertEquals(16, inbuf.read(dst));
+        Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
     }
 
+    @Test
     public void testReadToChannelWithMaxLen() throws Exception {
         byte[] pattern = "0123456789ABCDEF".getBytes("US-ASCII");
         ReadableByteChannel channel = newChannel(pattern);
@@ -353,12 +352,13 @@ public class TestSessionInOutBuffers ext
         ByteArrayOutputStream outstream = new ByteArrayOutputStream();
         WritableByteChannel dst = newChannel(outstream);
 
-        assertEquals(10, inbuf.read(dst, 10));
-        assertEquals(3, inbuf.read(dst, 3));
-        assertEquals(3, inbuf.read(dst, 10));
-        assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
+        Assert.assertEquals(10, inbuf.read(dst, 10));
+        Assert.assertEquals(3, inbuf.read(dst, 3));
+        Assert.assertEquals(3, inbuf.read(dst, 10));
+        Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
     }
 
+    @Test
     public void testWriteByteBuffer() throws Exception {
         byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes("US-ASCII");
 
@@ -371,9 +371,10 @@ public class TestSessionInOutBuffers ext
         WritableByteChannel channel = newChannel(outstream);
         while (outbuf.flush(channel) > 0) {
         }
-        assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
+        Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
     }
 
+    @Test
     public void testWriteFromChannel() throws Exception {
         byte[] pattern = "0123456789ABCDEF0123456789ABCDEF".getBytes("US-ASCII");
 
@@ -387,7 +388,7 @@ public class TestSessionInOutBuffers ext
         WritableByteChannel channel = newChannel(outstream);
         while (outbuf.flush(channel) > 0) {
         }
-        assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
+        Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
     }
 
     static final int SWISS_GERMAN_HELLO [] = {
@@ -409,6 +410,7 @@ public class TestSessionInOutBuffers ext
         return buffer.toString();
     }
 
+    @Test
     public void testMultibyteCodedReadWriteLine() throws Exception {
         String s1 = constructString(SWISS_GERMAN_HELLO);
         String s2 = constructString(RUSSIAN_HELLO);
@@ -438,19 +440,20 @@ public class TestSessionInOutBuffers ext
         }
 
         for (int i = 0; i < 10; i++) {
-            assertEquals(s1, inbuf.readLine(true));
-            assertEquals(s2, inbuf.readLine(true));
-            assertEquals(s3, inbuf.readLine(true));
+            Assert.assertEquals(s1, inbuf.readLine(true));
+            Assert.assertEquals(s2, inbuf.readLine(true));
+            Assert.assertEquals(s3, inbuf.readLine(true));
         }
     }
 
+    @Test
     public void testMalformedCharacters() throws Exception {
         HttpParams params = new BasicHttpParams();
         String s1 = constructString(SWISS_GERMAN_HELLO);
         SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, params);
         try {
             outbuf.writeLine(s1);
-            fail("Expected CharacterCodingException");
+            Assert.fail("Expected CharacterCodingException");
         } catch (CharacterCodingException expected) {
         }
 
@@ -462,11 +465,12 @@ public class TestSessionInOutBuffers ext
 
         try {
             String s = inbuf.readLine(true);
-            fail("Expected CharacterCodingException, got '" + s + "'");
+            Assert.fail("Expected CharacterCodingException, got '" + s + "'");
         } catch (CharacterCodingException expected) {
         }
     }
 
+    @Test
     public void testInputMatchesBufferLength() throws Exception {
         HttpParams params = new BasicHttpParams();
         String s1 = "abcde";

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java Mon May  9 11:26:57 2011
@@ -70,19 +70,14 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
 import org.apache.http.util.EncodingUtils;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * HttpCore NIO integration tests for async handlers.
  */
 public class TestAsyncNHttpHandlers extends HttpCoreNIOTestBase {
 
-    // ------------------------------------------------------------ Constructor
-    public TestAsyncNHttpHandlers(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
     private void executeStandardTest(
             final NHttpRequestHandler requestHandler,
             final NHttpRequestExecutionHandler requestExecutionHandler) throws Exception {
@@ -138,7 +133,7 @@ public class TestAsyncNHttpHandlers exte
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -154,19 +149,19 @@ public class TestAsyncNHttpHandlers exte
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         for (int i = 0; i < jobs.length; i++) {
             Job testjob = jobs[i];
             testjob.waitFor();
             if (testjob.isSuccessful()) {
-                assertEquals(HttpStatus.SC_OK, testjob.getStatusCode());
-                assertEquals(testjob.getExpected(), testjob.getResult());
+                Assert.assertEquals(HttpStatus.SC_OK, testjob.getStatusCode());
+                Assert.assertEquals(testjob.getExpected(), testjob.getResult());
             } else {
-                fail(testjob.getFailureMessage());
+                Assert.fail(testjob.getFailureMessage());
             }
         }
     }
@@ -175,6 +170,7 @@ public class TestAsyncNHttpHandlers exte
      * This test case executes a series of simple (non-pipelined) GET requests
      * over multiple connections. This uses non-blocking output entities.
      */
+    @Test
     public void testHttpGets() throws Exception {
         NHttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -193,6 +189,7 @@ public class TestAsyncNHttpHandlers exte
      * with content length delimited content over multiple connections.
      * It uses purely asynchronous handlers.
      */
+    @Test
     public void testHttpPostsWithContentLength() throws Exception {
         NHttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -219,6 +216,7 @@ public class TestAsyncNHttpHandlers exte
      * with chunk coded content content over multiple connections.  This tests
      * with nonblocking handlers & nonblocking entities.
      */
+    @Test
     public void testHttpPostsChunked() throws Exception {
         NHttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -245,6 +243,7 @@ public class TestAsyncNHttpHandlers exte
      * POST requests over multiple persistent connections. This tests with nonblocking
      * handlers & entities.
      */
+    @Test
     public void testHttpPostsHTTP10() throws Exception {
         NHttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -271,6 +270,7 @@ public class TestAsyncNHttpHandlers exte
      * over multiple connections using the 'expect: continue' handshake.  This test
      * uses nonblocking handlers & entities.
      */
+    @Test
     public void testHttpPostsWithExpectContinue() throws Exception {
         NHttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -297,6 +297,7 @@ public class TestAsyncNHttpHandlers exte
      * one of which does not meet the target server expectations.
      * This test uses nonblocking entities.
      */
+    @Test
     public void testHttpPostsWithExpectationVerification() throws Exception {
         Job[] jobs = new Job[3];
         jobs[0] = new Job("AAAAA", 10);
@@ -384,7 +385,7 @@ public class TestAsyncNHttpHandlers exte
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         SessionRequest sessionRequest = this.client.openConnection(
                 new InetSocketAddress("localhost", serverAddress.getPort()),
@@ -394,28 +395,29 @@ public class TestAsyncNHttpHandlers exte
         if (sessionRequest.getException() != null) {
             throw sessionRequest.getException();
         }
-        assertNotNull(sessionRequest.getSession());
+        Assert.assertNotNull(sessionRequest.getSession());
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         for (int i = 0; i < 2; i++) {
             Job testjob = jobs[i];
             testjob.waitFor();
             if (testjob.isSuccessful()) {
-                assertEquals(testjob.getExpected(), testjob.getResult());
+                Assert.assertEquals(testjob.getExpected(), testjob.getResult());
             } else {
-                fail(testjob.getFailureMessage());
+                Assert.fail(testjob.getFailureMessage());
             }
         }
         Job failedExpectation = jobs[2];
         failedExpectation.waitFor();
-        assertEquals(HttpStatus.SC_EXPECTATION_FAILED, failedExpectation.getStatusCode());
+        Assert.assertEquals(HttpStatus.SC_EXPECTATION_FAILED, failedExpectation.getStatusCode());
     }
 
     /**
      * This test case executes a series of simple (non-pipelined) HEAD requests
      * over multiple connections. This test uses nonblocking entities.
      */
+    @Test
     public void testHttpHeads() throws Exception {
         int connNo = 3;
         int reqNo = 20;
@@ -478,7 +480,7 @@ public class TestAsyncNHttpHandlers exte
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -494,19 +496,19 @@ public class TestAsyncNHttpHandlers exte
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         for (int i = 0; i < jobs.length; i++) {
             Job testjob = jobs[i];
             testjob.waitFor();
             if (testjob.getFailureMessage() != null) {
-                fail(testjob.getFailureMessage());
+                Assert.fail(testjob.getFailureMessage());
             }
-            assertEquals(HttpStatus.SC_OK, testjob.getStatusCode());
-            assertNull(testjob.getResult());
+            Assert.assertEquals(HttpStatus.SC_OK, testjob.getStatusCode());
+            Assert.assertNull(testjob.getResult());
         }
     }
 
@@ -514,6 +516,7 @@ public class TestAsyncNHttpHandlers exte
      * This test executes a series of delayed GETs, ensuring the
      * {@link NHttpResponseTrigger} works correctly.
      */
+    @Test
     public void testDelayedHttpGets() throws Exception {
 
         NHttpRequestHandler requestHandler = new NHttpRequestHandler() {
@@ -576,6 +579,7 @@ public class TestAsyncNHttpHandlers exte
     /**
      * This test ensures that HttpExceptions work correctly when immediate.
      */
+    @Test
     public void testHttpException() throws Exception {
 
         NHttpRequestHandler requestHandler = new SimpleNHttpRequestHandler() {
@@ -657,7 +661,7 @@ public class TestAsyncNHttpHandlers exte
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -673,19 +677,19 @@ public class TestAsyncNHttpHandlers exte
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         for (int i = 0; i < jobs.length; i++) {
             Job testjob = jobs[i];
             testjob.waitFor();
             if (testjob.isSuccessful()) {
-                assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, testjob.getStatusCode());
-                assertEquals(testjob.getPattern() + "x" + testjob.getCount(), testjob.getResult());
+                Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, testjob.getStatusCode());
+                Assert.assertEquals(testjob.getPattern() + "x" + testjob.getCount(), testjob.getResult());
             } else {
-                fail(testjob.getFailureMessage());
+                Assert.fail(testjob.getFailureMessage());
             }
         }
     }
@@ -693,6 +697,7 @@ public class TestAsyncNHttpHandlers exte
     /**
      * This test ensures that HttpExceptions work correctly when they are delayed by a trigger.
      */
+    @Test
     public void testDelayedHttpException() throws Exception {
 
         NHttpRequestHandler requestHandler = new NHttpRequestHandler() {
@@ -778,7 +783,7 @@ public class TestAsyncNHttpHandlers exte
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -794,19 +799,19 @@ public class TestAsyncNHttpHandlers exte
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         for (int i = 0; i < jobs.length; i++) {
             Job testjob = jobs[i];
             testjob.waitFor();
             if (testjob.isSuccessful()) {
-                assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, testjob.getStatusCode());
-                assertEquals(testjob.getPattern() + "x" + testjob.getCount(), testjob.getResult());
+                Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, testjob.getStatusCode());
+                Assert.assertEquals(testjob.getPattern() + "x" + testjob.getCount(), testjob.getResult());
             } else {
-                fail(testjob.getFailureMessage());
+                Assert.fail(testjob.getFailureMessage());
             }
         }
     }
@@ -814,6 +819,7 @@ public class TestAsyncNHttpHandlers exte
     /**
      * This test makes sure that if no service handler is installed, things still work.
      */
+    @Test
     public void testNoServiceHandler() throws Exception {
         NHttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -873,7 +879,7 @@ public class TestAsyncNHttpHandlers exte
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -889,20 +895,20 @@ public class TestAsyncNHttpHandlers exte
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         for (int i = 0; i < jobs.length; i++) {
             Job testjob = jobs[i];
 
             testjob.waitFor();
             if (testjob.isSuccessful()) {
-                assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, testjob.getStatusCode());
-                assertEquals("", testjob.getResult());
+                Assert.assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, testjob.getStatusCode());
+                Assert.assertEquals("", testjob.getResult());
             } else {
-                fail(testjob.getFailureMessage());
+                Assert.fail(testjob.getFailureMessage());
             }
         }
     }
@@ -912,6 +918,7 @@ public class TestAsyncNHttpHandlers exte
      * with no entities on the client side, to ensure they are sent properly,
      * and the server can read them.
      */
+    @Test
     public void testHttpPostWithNoEntities() throws Exception {
         NHttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -976,7 +983,7 @@ public class TestAsyncNHttpHandlers exte
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -992,23 +999,24 @@ public class TestAsyncNHttpHandlers exte
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         for (int i = 0; i < jobs.length; i++) {
             Job testjob = jobs[i];
             testjob.waitFor();
             if (testjob.isSuccessful()) {
-                assertEquals(HttpStatus.SC_OK, testjob.getStatusCode());
-                assertEquals("", testjob.getResult());
+                Assert.assertEquals(HttpStatus.SC_OK, testjob.getStatusCode());
+                Assert.assertEquals("", testjob.getResult());
             } else {
-                fail(testjob.getFailureMessage());
+                Assert.fail(testjob.getFailureMessage());
             }
         }
     }
 
+    @Test
     public void testNoRequestHandler() throws Exception {
         NHttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -1074,7 +1082,7 @@ public class TestAsyncNHttpHandlers exte
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -1090,18 +1098,18 @@ public class TestAsyncNHttpHandlers exte
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         for (int i = 0; i < jobs.length; i++) {
             Job testjob = jobs[i];
             testjob.waitFor();
             if (testjob.isSuccessful()) {
-                assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, testjob.getStatusCode());
+                Assert.assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, testjob.getStatusCode());
             } else {
-                fail(testjob.getFailureMessage());
+                Assert.fail(testjob.getFailureMessage());
             }
         }
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java?rev=1100965&r1=1100964&r2=1100965&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java Mon May  9 11:26:57 2011
@@ -63,6 +63,8 @@ import org.apache.http.protocol.Response
 import org.apache.http.protocol.ResponseContent;
 import org.apache.http.protocol.ResponseDate;
 import org.apache.http.protocol.ResponseServer;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * HttpCore NIO integration tests using buffering versions of the
@@ -70,13 +72,6 @@ import org.apache.http.protocol.Response
  */
 public class TestBufferingNHttpHandlers extends HttpCoreNIOTestBase {
 
-    // ------------------------------------------------------------ Constructor
-    public TestBufferingNHttpHandlers(String testName) {
-        super(testName);
-    }
-
-    // ------------------------------------------------------- TestCase Methods
-
     private void executeStandardTest(
             final HttpRequestHandler requestHandler,
             final HttpRequestExecutionHandler requestExecutionHandler) throws Exception {
@@ -132,7 +127,7 @@ public class TestBufferingNHttpHandlers 
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
 
-        assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
+        Assert.assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
 
         Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
         for (int i = 0; i < connNo; i++) {
@@ -148,19 +143,19 @@ public class TestBufferingNHttpHandlers 
             if (sessionRequest.getException() != null) {
                 throw sessionRequest.getException();
             }
-            assertNotNull(sessionRequest.getSession());
+            Assert.assertNotNull(sessionRequest.getSession());
         }
 
-        assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
+        Assert.assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
 
         for (int i = 0; i < jobs.length; i++) {
             Job testjob = jobs[i];
             testjob.waitFor();
             if (testjob.isSuccessful()) {
-                assertEquals(HttpStatus.SC_OK, testjob.getStatusCode());
-                assertEquals(testjob.getExpected(), testjob.getResult());
+                Assert.assertEquals(HttpStatus.SC_OK, testjob.getStatusCode());
+                Assert.assertEquals(testjob.getExpected(), testjob.getResult());
             } else {
-                fail(testjob.getFailureMessage());
+                Assert.fail(testjob.getFailureMessage());
             }
         }
     }
@@ -169,6 +164,7 @@ public class TestBufferingNHttpHandlers 
      * This test case executes a series of simple (non-pipelined) GET requests
      * over multiple connections.
      */
+    @Test
     public void testHttpGets() throws Exception {
         HttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -186,6 +182,7 @@ public class TestBufferingNHttpHandlers 
      * This test case executes a series of simple (non-pipelined) POST requests
      * with content length delimited content over multiple connections.
      */
+    @Test
     public void testHttpPostsWithContentLength() throws Exception {
         HttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -211,6 +208,7 @@ public class TestBufferingNHttpHandlers 
      * This test case executes a series of simple (non-pipelined) POST requests
      * with chunk coded content content over multiple connections.
      */
+    @Test
     public void testHttpPostsChunked() throws Exception {
         HttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -236,6 +234,7 @@ public class TestBufferingNHttpHandlers 
      * This test case executes a series of simple (non-pipelined) HTTP/1.0
      * POST requests over multiple persistent connections.
      */
+    @Test
     public void testHttpPostsHTTP10() throws Exception {
         HttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 
@@ -261,6 +260,7 @@ public class TestBufferingNHttpHandlers 
      * This test case executes a series of simple (non-pipelined) POST requests
      * over multiple connections using the 'expect: continue' handshake.
      */
+    @Test
     public void testHttpPostsWithExpectContinue() throws Exception {
         HttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
 



Mime
View raw message