hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r321512 - in /jakarta/httpclient/trunk/http-common/src: java/org/apache/http/impl/io/AbstractHttpDataReceiver.java test/org/apache/http/impl/TestHttpDataReceiverAndTransmitter.java
Date Sat, 15 Oct 2005 23:32:24 GMT
Author: olegk
Date: Sat Oct 15 16:32:16 2005
New Revision: 321512

URL: http://svn.apache.org/viewcvs?rev=321512&view=rev
Log:
* More test coverage
* Removed unnecessary code from the AbstractHttpDataReceiver class

Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/AbstractHttpDataReceiver.java
    jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestHttpDataReceiverAndTransmitter.java

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/AbstractHttpDataReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/AbstractHttpDataReceiver.java?rev=321512&r1=321511&r2=321512&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/AbstractHttpDataReceiver.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/AbstractHttpDataReceiver.java
Sat Oct 15 16:32:16 2005
@@ -98,10 +98,6 @@
         return this.bufferpos < this.bufferlen;
     }
     
-    public boolean isDataAvailable(int timeout) throws IOException {
-        return hasBufferedData();
-    }
-    
     public int read() throws IOException {
         int noRead = 0;
     	while (!hasBufferedData()) {
@@ -180,11 +176,6 @@
                 noRead = fillBuffer();
                 if (noRead == -1) {
                     retry = false;
-                    if (hasBufferedData()) {
-                        int len = this.bufferlen - this.bufferpos;
-                        this.linebuffer.append(this.buffer, this.bufferpos, len);
-                        this.bufferpos = this.bufferlen;
-                    }
                 }
             }
         }

Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestHttpDataReceiverAndTransmitter.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestHttpDataReceiverAndTransmitter.java?rev=321512&r1=321511&r2=321512&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestHttpDataReceiverAndTransmitter.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/impl/TestHttpDataReceiverAndTransmitter.java
Sat Oct 15 16:32:16 2005
@@ -78,6 +78,12 @@
             //expected
         }
         try {
+            new HttpDataTransmitterMockup(out, -10); 
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            //expected
+        }
+        try {
             new HttpDataReceiverMockup((InputStream)null, 1024); 
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
@@ -100,8 +106,7 @@
         teststrs[3] = "";
         teststrs[4] = "And goodbye";
         
-        HttpDataTransmitterMockup transmitter = 
-            new HttpDataTransmitterMockup(); 
+        HttpDataTransmitterMockup transmitter = new HttpDataTransmitterMockup(); 
         for (int i = 0; i < teststrs.length; i++) {
             transmitter.writeLine(teststrs[i]);
         }
@@ -109,8 +114,8 @@
         transmitter.writeLine(null);
         transmitter.flush();
         
-        HttpDataReceiverMockup receiver = 
-            new HttpDataReceiverMockup(transmitter.getData());
+        HttpDataReceiverMockup receiver = new HttpDataReceiverMockup(
+        		transmitter.getData());
 
         for (int i = 0; i < teststrs.length; i++) {
             assertEquals(teststrs[i], receiver.readLine());
@@ -120,8 +125,7 @@
     }
 
     public void testComplexReadWriteLine() throws Exception {
-        HttpDataTransmitterMockup transmitter = 
-            new HttpDataTransmitterMockup(); 
+        HttpDataTransmitterMockup transmitter = new HttpDataTransmitterMockup(); 
         transmitter.write(new byte[] {'a', '\n'});
         transmitter.write(new byte[] {'\r', '\n'});
         transmitter.write(new byte[] {'\r', '\r', '\n'});
@@ -162,8 +166,8 @@
         transmitter.write(new byte[] {'a'});
         transmitter.flush();
         
-        HttpDataReceiverMockup receiver = 
-            new HttpDataReceiverMockup(transmitter.getData());
+        HttpDataReceiverMockup receiver = new HttpDataReceiverMockup(
+        		transmitter.getData());
 
         assertEquals("a", receiver.readLine());
         assertEquals("", receiver.readLine());
@@ -192,8 +196,7 @@
         teststrs[3] = "";
         teststrs[4] = "And goodbye";
         
-        HttpDataTransmitterMockup transmitter = 
-            new HttpDataTransmitterMockup(); 
+        HttpDataTransmitterMockup transmitter = new HttpDataTransmitterMockup(); 
         for (int i = 0; i < teststrs.length; i++) {
             transmitter.writeLine(teststrs[i]);
         }
@@ -201,8 +204,8 @@
         transmitter.writeLine(null);
         transmitter.flush();
         
-        HttpDataReceiverMockup receiver = 
-            new HttpDataReceiverMockup(transmitter.getData(), 1024);
+        HttpDataReceiverMockup receiver = new HttpDataReceiverMockup(
+        		transmitter.getData(), 1024);
 
         for (int i = 0; i < teststrs.length; i++) {
             assertEquals(teststrs[i], receiver.readLine());
@@ -217,8 +220,7 @@
         for (int i = 0; i < out.length; i++) {
             out[i] = (byte)('0' + i);
         }
-        HttpDataTransmitterMockup transmitter = 
-            new HttpDataTransmitterMockup();
+        HttpDataTransmitterMockup transmitter = new HttpDataTransmitterMockup();
         int off = 0;
         int remaining = out.length;
         while (remaining > 0) {
@@ -238,8 +240,7 @@
             assertEquals(out[i], tmp[i]);
         }
         
-        HttpDataReceiverMockup receiver = 
-            new HttpDataReceiverMockup(tmp);
+        HttpDataReceiverMockup receiver = new HttpDataReceiverMockup(tmp);
 
         // these read operations will have no effect
         assertEquals(0, receiver.read(null, 0, 10));
@@ -271,10 +272,9 @@
         // make the buffer larger than that of transmitter
         byte[] out = new byte[40];
         for (int i = 0; i < out.length; i++) {
-            out[i] = (byte)('0' + i);
+            out[i] = (byte)(120 + i);
         }
-        HttpDataTransmitterMockup transmitter = 
-            new HttpDataTransmitterMockup();
+        HttpDataTransmitterMockup transmitter = new HttpDataTransmitterMockup();
         for (int i = 0; i < out.length; i++) {
             transmitter.write(out[i]);
         }
@@ -286,9 +286,7 @@
             assertEquals(out[i], tmp[i]);
         }
         
-        HttpDataReceiverMockup receiver = 
-            new HttpDataReceiverMockup(tmp);
-
+        HttpDataReceiverMockup receiver = new HttpDataReceiverMockup(tmp);
         byte[] in = new byte[40];
         for (int i = 0; i < in.length; i++) {
             in[i] = (byte)receiver.read();
@@ -327,8 +325,7 @@
         HttpParams params = new DefaultHttpParams(null);
         HttpProtocolParams.setHttpElementCharset(params, "UTF-8");
         
-        HttpDataTransmitterMockup transmitter = 
-            new HttpDataTransmitterMockup();
+        HttpDataTransmitterMockup transmitter = new HttpDataTransmitterMockup();
         transmitter.reset(params);
 
         for (int i = 0; i < 10; i++) {
@@ -338,8 +335,8 @@
         }
         transmitter.flush();
         
-        HttpDataReceiverMockup receiver = 
-            new HttpDataReceiverMockup(transmitter.getData());
+        HttpDataReceiverMockup receiver = new HttpDataReceiverMockup(
+        		transmitter.getData());
         receiver.reset(params);
 
         for (int i = 0; i < 10; i++) {



Mime
View raw message