hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r556266 - in /jakarta/httpcomponents/httpcore/trunk: ./ module-nio/src/main/java/org/apache/http/impl/nio/ module-nio/src/main/java/org/apache/http/impl/nio/codecs/ module-nio/src/test/java/org/apache/http/impl/nio/codecs/ module-nio/src/te...
Date Sat, 14 Jul 2007 11:29:50 GMT
Author: olegk
Date: Sat Jul 14 04:29:48 2007
New Revision: 556266

URL: http://svn.apache.org/viewvc?view=rev&rev=556266
Log:
HTTPCORE-21: Transport and connection metrics

Contributed by Andrea Selva <selva.andre at gmail.com> and Oleg Kalnichevski


Modified:
    jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/MockupEncoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java

Modified: jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Sat Jul 14 04:29:48 2007
@@ -1,5 +1,9 @@
 Changes since release 4.0 Alpha 5
 
+* [HTTPCORE-21] Transport and connection metrics
+  Contributed by Andrea Selva <selva.andre at gmail.com> and 
+  Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-91] new interceptor RequestDate, renamed constants in protocol.HTTP
   Contributed by Roland Weber <rolandw at apache.org>
 

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java Sat Jul 14 04:29:48 2007
@@ -91,12 +91,15 @@
         try {
             if (this.response == null) {
                 int bytesRead = this.responseParser.fillBuffer(this.session.channel());
+                if (bytesRead > 0) {
+                    this.inTransportMetrics.incrementBytesTransferred(bytesRead);
+                }
                 this.response = (HttpResponse) this.responseParser.parse(); 
                 if (this.response != null) {
                     if (this.response.getStatusLine().getStatusCode() >= 200) {
                         HttpEntity entity = prepareDecoder(this.response);
                         this.response.setEntity(entity);
-                        this.metrics.incrementRequestCount();
+                        this.connMetrics.incrementRequestCount();
                     }
                     handler.responseReceived(this);
                     if (this.contentDecoder == null) {
@@ -129,7 +132,10 @@
 
         try {
             if (this.outbuf.hasData()) {
-                this.outbuf.flush(this.session.channel());
+                int bytesWritten = this.outbuf.flush(this.session.channel());
+                if (bytesWritten > 0) {
+                    this.outTransportMetrics.incrementBytesTransferred(bytesWritten);
+                }
             }
             if (!this.outbuf.hasData()) {
                 if (this.closed) {
@@ -193,7 +199,7 @@
             prepareEncoder(request);
             this.request = request;
         }
-        this.metrics.incrementRequestCount();
+        this.connMetrics.incrementRequestCount();
         this.session.setEvent(EventMask.WRITE);
     }
 

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java Sat Jul 14 04:29:48 2007
@@ -88,6 +88,9 @@
         try {
             if (this.request == null) {
                 int bytesRead = this.requestParser.fillBuffer(this.session.channel());
+                if (bytesRead > 0) {
+                    this.inTransportMetrics.incrementBytesTransferred(bytesRead);
+                }
                 this.request = (HttpRequest) this.requestParser.parse(); 
                 if (this.request != null) {
                     if (this.request instanceof HttpEntityEnclosingRequest) {
@@ -95,7 +98,7 @@
                         HttpEntity entity = prepareDecoder(this.request);
                         ((HttpEntityEnclosingRequest)this.request).setEntity(entity);
                     }
-                    this.metrics.incrementRequestCount();
+                    this.connMetrics.incrementRequestCount();
                     handler.requestReceived(this);
                     if (this.contentDecoder == null) {
                         // No request entity is expected
@@ -128,7 +131,10 @@
     public void produceOutput(final NHttpServiceHandler handler) {
         try {
             if (this.outbuf.hasData()) {
-                this.outbuf.flush(this.session.channel());
+                int bytesWritten = this.outbuf.flush(this.session.channel());
+                if (bytesWritten > 0) {
+                    this.outTransportMetrics.incrementBytesTransferred(bytesWritten);
+                }
             }
             if (!this.outbuf.hasData()) {
                 if (this.closed) {
@@ -189,7 +195,7 @@
         this.outbuf.writeLine(this.lineBuffer);
 
         if (response.getStatusLine().getStatusCode() >= 200) {
-            this.metrics.incrementRequestCount();
+            this.connMetrics.incrementRequestCount();
             if (response.getEntity() != null) {
                 this.response = response;
                 prepareEncoder(response);

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java Sat Jul 14 04:29:48 2007
@@ -50,6 +50,7 @@
 import org.apache.http.impl.HttpConnectionMetricsImpl;
 import org.apache.http.impl.entity.LaxContentLengthStrategy;
 import org.apache.http.impl.entity.StrictContentLengthStrategy;
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.NHttpConnection;
@@ -84,7 +85,10 @@
     protected final SessionInputBuffer inbuf;
     protected final SessionOutputBuffer outbuf;
     protected final CharArrayBuffer lineBuffer;
-    protected final HttpConnectionMetricsImpl metrics;
+    
+    protected final HttpTransportMetricsImpl inTransportMetrics;
+    protected final HttpTransportMetricsImpl outTransportMetrics;
+    protected final HttpConnectionMetricsImpl connMetrics;
     
     protected volatile ContentDecoder contentDecoder;
     protected volatile boolean hasBufferedInput;
@@ -124,7 +128,11 @@
         this.incomingContentStrategy = new LaxContentLengthStrategy();
         this.outgoingContentStrategy = new StrictContentLengthStrategy();
         
-        this.metrics = new HttpConnectionMetricsImpl(null, null);
+        this.inTransportMetrics = new HttpTransportMetricsImpl();
+        this.outTransportMetrics = new HttpTransportMetricsImpl();
+        this.connMetrics = new HttpConnectionMetricsImpl(
+                this.inTransportMetrics, 
+                this.outTransportMetrics);
         
         this.closed = false;
         this.session.setBufferStatus(this);
@@ -163,15 +171,25 @@
         BasicHttpEntity entity = new BasicHttpEntity();
         long len = this.incomingContentStrategy.determineLength(message);
         if (len == ContentLengthStrategy.CHUNKED) {
-            this.contentDecoder = new ChunkDecoder(this.session.channel(), this.inbuf);
+            this.contentDecoder = new ChunkDecoder(
+                    this.session.channel(), 
+                    this.inbuf, 
+                    this.inTransportMetrics);
             entity.setChunked(true);
             entity.setContentLength(-1);
         } else if (len == ContentLengthStrategy.IDENTITY) {
-            this.contentDecoder = new IdentityDecoder(this.session.channel(), this.inbuf);
+            this.contentDecoder = new IdentityDecoder(
+                    this.session.channel(), 
+                    this.inbuf, 
+                    this.inTransportMetrics);
             entity.setChunked(false);
             entity.setContentLength(-1);
         } else {
-            this.contentDecoder = new LengthDelimitedDecoder(this.session.channel(), this.inbuf, len);
+            this.contentDecoder = new LengthDelimitedDecoder(
+                    this.session.channel(), 
+                    this.inbuf, 
+                    this.inTransportMetrics,
+                    len);
             entity.setChunked(false);
             entity.setContentLength(len);
         }
@@ -190,11 +208,21 @@
     protected void prepareEncoder(final HttpMessage message) throws HttpException {
         long len = this.outgoingContentStrategy.determineLength(message);
         if (len == ContentLengthStrategy.CHUNKED) {
-            this.contentEncoder = new ChunkEncoder(this.outbuf);
+            this.contentEncoder = new ChunkEncoder(
+                    this.session.channel(),
+                    this.outbuf,
+                    this.outTransportMetrics);
         } else if (len == ContentLengthStrategy.IDENTITY) {
-            this.contentEncoder = new IdentityEncoder(this.session.channel());
+            this.contentEncoder = new IdentityEncoder(
+                    this.session.channel(),
+                    this.outbuf,
+                    this.outTransportMetrics);
         } else {
-            this.contentEncoder = new LengthDelimitedEncoder(this.session.channel(), len);
+            this.contentEncoder = new LengthDelimitedEncoder(
+                    this.session.channel(),
+                    this.outbuf,
+                    this.outTransportMetrics,
+                    len);
         }
     }
 
@@ -279,7 +307,7 @@
     }
 
     public HttpConnectionMetrics getMetrics() {
-        return this.metrics;
+        return this.connMetrics;
     }
     
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java Sat Jul 14 04:29:48 2007
@@ -34,25 +34,34 @@
 import java.nio.channels.ReadableByteChannel;
 
 import org.apache.http.nio.ContentDecoder;
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionInputBuffer;
 
 public abstract class AbstractContentDecoder implements ContentDecoder {
     
     protected final ReadableByteChannel channel;
     protected final SessionInputBuffer buffer;
+    protected final HttpTransportMetricsImpl metrics;
     
     protected boolean completed;
     
-    public AbstractContentDecoder(final ReadableByteChannel channel, final SessionInputBuffer buffer) {
+    public AbstractContentDecoder(
+            final ReadableByteChannel channel, 
+            final SessionInputBuffer buffer,
+            final HttpTransportMetricsImpl metrics) {
         super();
         if (channel == null) {
             throw new IllegalArgumentException("Channel may not be null");
         }
         if (buffer == null) {
             throw new IllegalArgumentException("Session input buffer may not be null");
-        }
+        }        
+        if (metrics == null) {
+            throw new IllegalArgumentException("Transport metrics may not be null");
+        }        
         this.buffer = buffer;
         this.channel = channel;
+        this.metrics = metrics;
     }
 
     public boolean isCompleted() {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java Sat Jul 14 04:29:48 2007
@@ -32,13 +32,39 @@
 package org.apache.http.impl.nio.codecs;
 
 import java.io.IOException;
+import java.nio.channels.WritableByteChannel;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
+import org.apache.http.impl.nio.reactor.SessionOutputBuffer;
 import org.apache.http.nio.ContentEncoder;
 
 public abstract class AbstractContentEncoder implements ContentEncoder {
+
+    protected final WritableByteChannel channel;
+    protected final SessionOutputBuffer buffer;
+    protected final HttpTransportMetricsImpl metrics;
     
     protected boolean completed;
     
+    public AbstractContentEncoder(
+            final WritableByteChannel channel, 
+            final SessionOutputBuffer buffer,
+            final HttpTransportMetricsImpl metrics) {
+        super();
+        if (channel == null) {
+            throw new IllegalArgumentException("Channel may not be null");
+        }
+        if (buffer == null) {
+            throw new IllegalArgumentException("Session input buffer may not be null");
+        }        
+        if (metrics == null) {
+            throw new IllegalArgumentException("Transport metrics may not be null");
+        }        
+        this.buffer = buffer;
+        this.channel = channel;
+        this.metrics = metrics;
+    }
+
     public boolean isCompleted() {
         return this.completed;
     }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java Sat Jul 14 04:29:48 2007
@@ -40,6 +40,7 @@
 import org.apache.http.Header;
 import org.apache.http.MalformedChunkCodingException;
 import org.apache.http.message.BufferedHeader;
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionInputBuffer;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
@@ -62,8 +63,11 @@
     
     private Header[] footers;
     
-    public ChunkDecoder(final ReadableByteChannel channel, final SessionInputBuffer buffer) {
-        super(channel, buffer);
+    public ChunkDecoder(            
+            final ReadableByteChannel channel, 
+            final SessionInputBuffer buffer,
+            final HttpTransportMetricsImpl metrics) {
+        super(channel, buffer, metrics);
         this.state = READ_CONTENT;
         this.chunkSize = -1;
         this.pos = 0;
@@ -155,6 +159,9 @@
 
             if (!this.buffer.hasData() || this.chunkSize == -1) {
                 int bytesRead = this.buffer.fill(this.channel);
+                if (bytesRead > 0) {
+                    this.metrics.incrementBytesTransferred(bytesRead);
+                }
                 if (bytesRead == -1) {
                     this.endOfStream = true;
                 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java Sat Jul 14 04:29:48 2007
@@ -33,21 +33,21 @@
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionOutputBuffer;
 import org.apache.http.util.CharArrayBuffer;
 
 public class ChunkEncoder extends AbstractContentEncoder {
     
-    private final SessionOutputBuffer outbuf;
     private final CharArrayBuffer lineBuffer;
     
-    public ChunkEncoder(final SessionOutputBuffer outbuf) {
-        super();
-        if (outbuf == null) {
-            throw new IllegalArgumentException("Session output buffer may not be null");
-        }
-        this.outbuf = outbuf;
+    public ChunkEncoder(
+            final WritableByteChannel channel, 
+            final SessionOutputBuffer buffer,
+            final HttpTransportMetricsImpl metrics) {
+        super(channel, buffer, metrics);
         this.lineBuffer = new CharArrayBuffer(16);
     }
 
@@ -62,10 +62,10 @@
         }
         this.lineBuffer.clear();
         this.lineBuffer.append(Integer.toHexString(chunk));
-        this.outbuf.writeLine(this.lineBuffer);
-        this.outbuf.write(src);
+        this.buffer.writeLine(this.lineBuffer);
+        this.buffer.write(src);
         this.lineBuffer.clear();
-        this.outbuf.writeLine(this.lineBuffer);
+        this.buffer.writeLine(this.lineBuffer);
         return chunk;
     }
 
@@ -73,9 +73,9 @@
         assertNotCompleted();
         this.lineBuffer.clear();
         this.lineBuffer.append("0");
-        this.outbuf.writeLine(this.lineBuffer);
+        this.buffer.writeLine(this.lineBuffer);
         this.lineBuffer.clear();
-        this.outbuf.writeLine(this.lineBuffer);
+        this.buffer.writeLine(this.lineBuffer);
         this.completed = true;
     }
     

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java Sat Jul 14 04:29:48 2007
@@ -36,6 +36,7 @@
 import java.nio.channels.FileChannel;
 import java.nio.channels.ReadableByteChannel;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionInputBuffer;
 import org.apache.http.nio.FileContentDecoder;
 
@@ -52,8 +53,11 @@
 public class IdentityDecoder extends AbstractContentDecoder 
         implements FileContentDecoder {
     
-    public IdentityDecoder(final ReadableByteChannel channel, final SessionInputBuffer buffer) {
-        super(channel, buffer);
+    public IdentityDecoder(
+            final ReadableByteChannel channel, 
+            final SessionInputBuffer buffer,
+            final HttpTransportMetricsImpl metrics) {
+        super(channel, buffer, metrics);
     }
 
     public int read(final ByteBuffer dst) throws IOException {
@@ -69,6 +73,9 @@
             bytesRead = this.buffer.read(dst);
         } else {
             bytesRead = this.channel.read(dst);
+            if (bytesRead > 0) {
+                this.metrics.incrementBytesTransferred(bytesRead);
+            }
         }
         if (bytesRead == -1) {
             this.completed = true;
@@ -76,7 +83,10 @@
         return bytesRead;
     }
     
-    public long read(final FileChannel fileChannel, long position, long count) throws IOException {
+    public long read(
+            final FileChannel fileChannel, 
+            long position, 
+            long count) throws IOException {
         if (fileChannel == null) {
             return 0;
         }
@@ -92,6 +102,9 @@
             bytesRead = fileChannel.write(tmpDst);
         } else {
             bytesRead = fileChannel.transferFrom(this.channel, position, count);
+            if (bytesRead > 0) {
+                this.metrics.incrementBytesTransferred(bytesRead);
+            }
         }
         if (bytesRead == 0) {
             this.completed = true;

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java Sat Jul 14 04:29:48 2007
@@ -35,6 +35,9 @@
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.channels.WritableByteChannel;
+
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
+import org.apache.http.impl.nio.reactor.SessionOutputBuffer;
 import org.apache.http.nio.FileContentEncoder;
 
 /**
@@ -50,14 +53,11 @@
 public class IdentityEncoder extends AbstractContentEncoder 
         implements FileContentEncoder {
     
-    private final WritableByteChannel channel;
-    
-    public IdentityEncoder(final WritableByteChannel channel) {
-        super();
-        if (channel == null) {
-            throw new IllegalArgumentException("Channel may not be null");
-        }
-        this.channel = channel;
+    public IdentityEncoder(
+            final WritableByteChannel channel, 
+            final SessionOutputBuffer buffer,
+            final HttpTransportMetricsImpl metrics) {
+        super(channel, buffer, metrics);
     }
 
     public int write(final ByteBuffer src) throws IOException {
@@ -65,15 +65,26 @@
             return 0;
         }
         assertNotCompleted();
-        return this.channel.write(src);
+        int bytesWritten = this.channel.write(src);
+        if (bytesWritten > 0) {
+            this.metrics.incrementBytesTransferred(bytesWritten);
+        }
+        return bytesWritten;
     }
  
-    public long write(final FileChannel filechannel, long position, long count) throws IOException {
-        if (channel == null) {
+    public long write(
+            final FileChannel filechannel, 
+            long position, 
+            long count) throws IOException {
+        if (filechannel == null) {
             return 0;
         }
         assertNotCompleted();
-        return filechannel.transferTo(position, count, this.channel);
+        long bytesWritten = filechannel.transferTo(position, count, this.channel);
+        if (bytesWritten > 0) {
+            this.metrics.incrementBytesTransferred(bytesWritten);
+        }
+        return bytesWritten;
     } 
     
     public String toString() {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java Sat Jul 14 04:29:48 2007
@@ -36,6 +36,7 @@
 import java.nio.channels.FileChannel;
 import java.nio.channels.ReadableByteChannel;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionInputBuffer;
 import org.apache.http.nio.FileContentDecoder;
 
@@ -59,8 +60,9 @@
     public LengthDelimitedDecoder(
             final ReadableByteChannel channel, 
             final SessionInputBuffer buffer,
+            final HttpTransportMetricsImpl metrics,
             long contentLength) {
-        super(channel, buffer);
+        super(channel, buffer, metrics);
         if (contentLength < 0) {
             throw new IllegalArgumentException("Content length may not be negative");
         }
@@ -90,6 +92,9 @@
             } else {
                 bytesRead = this.channel.read(dst);
             }
+            if (bytesRead > 0) {
+                this.metrics.incrementBytesTransferred(bytesRead);
+            }
         }
         if (bytesRead == -1) {
             this.completed = true;
@@ -123,6 +128,9 @@
                 bytesRead = fileChannel.transferFrom(this.channel, position, lenRemaining);
             } else {
                 bytesRead = fileChannel.transferFrom(this.channel, position, count);
+            }
+            if (bytesRead > 0) {
+                this.metrics.incrementBytesTransferred(bytesRead);
             }
         }
         if (bytesRead == 0) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java Sat Jul 14 04:29:48 2007
@@ -35,6 +35,9 @@
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.channels.WritableByteChannel;
+
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
+import org.apache.http.impl.nio.reactor.SessionOutputBuffer;
 import org.apache.http.nio.FileContentEncoder;
 
 /**
@@ -50,20 +53,19 @@
 public class LengthDelimitedEncoder extends AbstractContentEncoder 
         implements FileContentEncoder {
     
-    private final WritableByteChannel channel;
     private final long contentLength;
     
     private long len;
 
-    public LengthDelimitedEncoder(final WritableByteChannel channel, long contentLength) {
-        super();
-        if (channel == null) {
-            throw new IllegalArgumentException("Channel may not be null");
-        }
+    public LengthDelimitedEncoder(
+            final WritableByteChannel channel, 
+            final SessionOutputBuffer buffer,
+            final HttpTransportMetricsImpl metrics,
+            long contentLength) {
+        super(channel, buffer, metrics);
         if (contentLength < 0) {
             throw new IllegalArgumentException("Content length may not be negative");
-        }
-        this.channel = channel;
+        }        
         this.contentLength = contentLength;
         this.len = 0;
     }
@@ -85,6 +87,9 @@
         } else {
             bytesWritten = this.channel.write(src);
         }
+        if (bytesWritten > 0) {
+            this.metrics.incrementBytesTransferred(bytesWritten);
+        }
         this.len += bytesWritten;
         if (this.len >= this.contentLength) {
             this.completed = true;
@@ -104,6 +109,9 @@
             bytesWritten = fileChannel.transferTo(position, lenRemaining, this.channel);
         } else {
             bytesWritten = fileChannel.transferTo(position, count, this.channel);
+        }
+        if (bytesWritten > 0) {
+            this.metrics.incrementBytesTransferred(bytesWritten);
         }
         this.len += bytesWritten;
         if (this.len >= this.contentLength) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkDecoder.java Sat Jul 14 04:29:48 2007
@@ -40,6 +40,7 @@
 
 import org.apache.http.Header;
 import org.apache.http.MalformedChunkCodingException;
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionInputBuffer;
 import org.apache.http.nio.mockup.ReadableByteChannelMockup;
 
@@ -83,8 +84,9 @@
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {s}, "US-ASCII"); 
         
-        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -107,7 +109,8 @@
                 new String[] {s}, "US-ASCII"); 
     
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
 
@@ -142,7 +145,8 @@
                 new String[] {s1, s2}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         ByteBuffer tmp = ByteBuffer.allocate(4); 
@@ -184,9 +188,10 @@
                 chunks, "US-ASCII"); 
     
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         int bytesRead = 0;
         while (dst.hasRemaining() && !decoder.isCompleted()) {
@@ -219,7 +224,8 @@
                 new String[] {s}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -237,7 +243,8 @@
                 new String[] {s}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -256,7 +263,8 @@
                 new String[] {s}, "US-ASCII"); 
     
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -277,7 +285,8 @@
                 new String[] {s}, "US-ASCII"); 
     
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -296,7 +305,8 @@
                 new String[] {s}, "US-ASCII"); 
     
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
 
@@ -320,7 +330,8 @@
                 new String[] {s}, "US-ASCII"); 
     
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
 
@@ -337,6 +348,31 @@
         assertTrue(decoder.isCompleted());
     }
 
+    public void testInvalidConstructor() {
+        ReadableByteChannel channel = new ReadableByteChannelMockup(
+                new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
+        
+        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
+        try {
+            new ChunkDecoder(null, null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new ChunkDecoder(channel, null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new ChunkDecoder(channel, inbuf, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+    }
+    
     public void testInvalidInput() throws Exception {
         String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
                 "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1 abcde\r\n\r\n";
@@ -344,7 +380,8 @@
                 new String[] {s}, "US-ASCII"); 
     
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
         
         try {
             decoder.read(null);
@@ -353,5 +390,5 @@
             // expected
         }
     }
-    
+
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java Sat Jul 14 04:29:48 2007
@@ -39,6 +39,7 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionOutputBuffer;
 import org.apache.http.util.EncodingUtils;
 
@@ -77,16 +78,18 @@
     }
     
     public void testBasicCoding() throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
+        WritableByteChannel channel = newChannel(baos);
         SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
-        ChunkEncoder encoder = new ChunkEncoder(outbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
         
         encoder.write(wrap("12345"));
         encoder.write(wrap("678"));
         encoder.write(wrap("90"));
         encoder.complete();
         
-        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        outbuf.flush(newChannel(baos));
+        outbuf.flush(channel);
         
         String s = baos.toString("US-ASCII");
         
@@ -95,8 +98,11 @@
     }
 
     public void testCodingEmptyBuffer() throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
+        WritableByteChannel channel = newChannel(baos);
         SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
-        ChunkEncoder encoder = new ChunkEncoder(outbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
         
         encoder.write(wrap("12345"));
         encoder.write(wrap("678"));
@@ -109,8 +115,7 @@
         
         encoder.complete();
         
-        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        outbuf.flush(newChannel(baos));
+        outbuf.flush(channel);
         
         String s = baos.toString("US-ASCII");
         
@@ -119,8 +124,11 @@
     }
 
     public void testCodingCompleted() throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
+        WritableByteChannel channel = newChannel(baos);
         SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
-        ChunkEncoder encoder = new ChunkEncoder(outbuf);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
         
         encoder.write(wrap("12345"));
         encoder.write(wrap("678"));
@@ -142,8 +150,24 @@
     }
 
     public void testInvalidConstructor() {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+
+        try {
+            new ChunkEncoder(null, null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new ChunkEncoder(channel, null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
         try {
-            new ChunkEncoder(null);
+            new ChunkEncoder(channel, outbuf, null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java Sat Jul 14 04:29:48 2007
@@ -43,6 +43,7 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionInputBuffer;
 import org.apache.http.nio.mockup.ReadableByteChannelMockup;
 
@@ -97,7 +98,8 @@
                 new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics); 
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -128,11 +130,13 @@
                 new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        
         inbuf.fill(channel);
         
         assertEquals(6, inbuf.length());
         
-        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf); 
+        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics); 
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -158,30 +162,13 @@
         assertTrue(decoder.isCompleted());
     }
 
-    public void testInvalidInput() throws Exception {
-        String s = "stuff";
-        ReadableByteChannel channel = new ReadableByteChannelMockup(
-                new String[] {s}, "US-ASCII"); 
-    
-        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf);
-        
-        try {
-            decoder.read(null);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }
-    }
-    
-    
-    
     public void testBasicDecodingFile() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics); 
         
         File tmpFile = File.createTempFile("testFile", ".txt");
         FileChannel fchannel = new FileOutputStream(tmpFile).getChannel();
@@ -212,11 +199,13 @@
                 new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
         inbuf.fill(channel);
         
         assertEquals(6, inbuf.length());
         
-        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf); 
+        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics); 
         
         File tmpFile = File.createTempFile("testFile", ".txt");
         FileChannel fchannel = new FileOutputStream(tmpFile).getChannel();
@@ -240,6 +229,48 @@
         assertTrue(decoder.isCompleted());
         
         tmpFile.delete();
+    }
+
+    public void testInvalidConstructor() {
+        ReadableByteChannel channel = new ReadableByteChannelMockup(
+                new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
+        
+        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
+        try {
+            new IdentityDecoder(null, null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new IdentityDecoder(channel, null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new IdentityDecoder(channel, inbuf, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+    }
+    
+    public void testInvalidInput() throws Exception {
+        String s = "stuff";
+        ReadableByteChannel channel = new ReadableByteChannelMockup(
+                new String[] {s}, "US-ASCII"); 
+    
+        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics);
+        
+        try {
+            decoder.read(null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
     }
     
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityEncoder.java Sat Jul 14 04:29:48 2007
@@ -39,6 +39,8 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
+import org.apache.http.impl.nio.reactor.SessionOutputBuffer;
 import org.apache.http.util.EncodingUtils;
 
 /**
@@ -76,8 +78,12 @@
     }
     
     public void testBasicCoding() throws Exception {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        IdentityEncoder encoder = new IdentityEncoder(newChannel(baos));
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics);
         encoder.write(wrap("stuff"));
         encoder.complete();
         
@@ -89,7 +95,11 @@
     
     public void testCodingEmptyBuffer() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        IdentityEncoder encoder = new IdentityEncoder(newChannel(baos));
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics);
         encoder.write(wrap("stuff"));
         
         ByteBuffer empty = ByteBuffer.allocate(100);
@@ -107,7 +117,11 @@
 
     public void testCodingCompleted() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        IdentityEncoder encoder = new IdentityEncoder(newChannel(baos));
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics);
         encoder.write(wrap("stuff"));
         encoder.complete();
 
@@ -120,12 +134,28 @@
     }
 
     public void testInvalidConstructor() {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+
+        try {
+            new IdentityEncoder(null, null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
         try {
-            new IdentityEncoder(null);
+            new IdentityEncoder(channel, null, null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new IdentityEncoder(channel, outbuf, null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // ignore
         }
     }
-
+    
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedDecoder.java Sat Jul 14 04:29:48 2007
@@ -43,6 +43,7 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.reactor.SessionInputBuffer;
 import org.apache.http.nio.mockup.ReadableByteChannelMockup;
 
@@ -97,7 +98,9 @@
                 new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 16); 
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -125,7 +128,9 @@
                         "more stuff; and a lot more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 16); 
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -151,7 +156,9 @@
                 new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 16); 
         
         ByteBuffer dst = ByteBuffer.allocate(4); 
         
@@ -195,11 +202,14 @@
                 new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
         inbuf.fill(channel);
         
         assertEquals(6, inbuf.length());
         
-        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16); 
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 16); 
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -227,12 +237,15 @@
                         "more stuff; and a lot more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
         inbuf.fill(channel);
         inbuf.fill(channel);
         
         assertEquals(38, inbuf.length());
         
-        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16); 
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 16); 
         
         ByteBuffer dst = ByteBuffer.allocate(1024); 
         
@@ -247,55 +260,15 @@
         assertTrue(decoder.isCompleted());
     }
 
-    public void testInvalidConstructor() {
-        ReadableByteChannel channel = new ReadableByteChannelMockup(
-                new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
-        
-        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        try {
-            new LengthDelimitedDecoder(null, null, 10);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // ignore
-        }
-        try {
-            new LengthDelimitedDecoder(channel, null, 10);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // ignore
-        }
-        try {
-            new LengthDelimitedDecoder(channel, inbuf, -10);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // ignore
-        }
-    }
-
-    public void testInvalidInput() throws Exception {
-        String s = "stuff";
-        ReadableByteChannel channel = new ReadableByteChannelMockup(
-                new String[] {s}, "US-ASCII"); 
-    
-        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 3);
-        
-        try {
-            decoder.read(null);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }
-    }
-    
-    
     // ----------------------------------------------------- Test read
     public void testBasicDecodingFile() throws Exception {
         ReadableByteChannel channel = new ReadableByteChannelMockup(
                 new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 16); 
         
         File tmpFile = File.createTempFile("testFile", ".txt");
         FileChannel fchannel = new FileOutputStream(tmpFile).getChannel();
@@ -324,7 +297,9 @@
                         "more stuff; and a lot more stuff"}, "US-ASCII"); 
         
         SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
-        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 16); 
         
         File tmpFile = File.createTempFile("testFile", ".txt");
         FileChannel fchannel = new FileOutputStream(tmpFile).getChannel();
@@ -346,5 +321,54 @@
         tmpFile.delete();
     }
     
+    public void testInvalidConstructor() {
+        ReadableByteChannel channel = new ReadableByteChannelMockup(
+                new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
+        
+        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        try {
+            new LengthDelimitedDecoder(null, null, null, 10);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new LengthDelimitedDecoder(channel, null, null, 10);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new LengthDelimitedDecoder(channel, inbuf, null, 10);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new LengthDelimitedDecoder(channel, inbuf, metrics, -10);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+    }
+
+    public void testInvalidInput() throws Exception {
+        String s = "stuff";
+        ReadableByteChannel channel = new ReadableByteChannelMockup(
+                new String[] {s}, "US-ASCII"); 
+    
+        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256); 
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
+                channel, inbuf, metrics, 3);
+        
+        try {
+            decoder.read(null);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
     
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/impl/nio/codecs/TestLengthDelimitedEncoder.java Sat Jul 14 04:29:48 2007
@@ -44,6 +44,8 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
+import org.apache.http.impl.nio.reactor.SessionOutputBuffer;
 import org.apache.http.util.EncodingUtils;
 
 /**
@@ -82,7 +84,12 @@
     
     public void testBasicCoding() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(newChannel(baos), 16);
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
+                channel, outbuf, metrics, 16);
         encoder.write(wrap("stuff;"));
         encoder.write(wrap("more stuff"));
         
@@ -94,7 +101,12 @@
     
     public void testCodingBeyondContentLimit() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(newChannel(baos), 16);
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
+                channel, outbuf, metrics, 16);
         encoder.write(wrap("stuff;"));
         encoder.write(wrap("more stuff; and a lot more stuff"));
         
@@ -106,7 +118,12 @@
     
     public void testCodingEmptyBuffer() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(newChannel(baos), 16);
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
+                channel, outbuf, metrics, 16);
         encoder.write(wrap("stuff;"));
 
         ByteBuffer empty = ByteBuffer.allocate(100);
@@ -124,7 +141,12 @@
 
     public void testCodingCompleted() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(newChannel(baos), 5);
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
+                channel, outbuf, metrics, 5);
         encoder.write(wrap("stuff"));
 
         try {
@@ -135,26 +157,15 @@
         }
     }
 
-    public void testInvalidConstructor() {
-        try {
-            new LengthDelimitedEncoder(null, 10);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // ignore
-        }
-        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        try {
-            new LengthDelimitedEncoder(newChannel(baos), -10);
-            fail("IllegalArgumentException should have been thrown");
-        } catch (IllegalArgumentException ex) {
-            // ignore
-        }
-    }
-    
     /* ----------------- FileChannel Part testing --------------------------- */
     public void testCodingBeyondContentLimitFromFile() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(newChannel(baos), 16);
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
+                channel, outbuf, metrics, 16);
                
         File tmpFile = File.createTempFile("testFile", "txt");
         FileOutputStream fout = new FileOutputStream(tmpFile);
@@ -181,7 +192,12 @@
     
     public void testCodingEmptyFile() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(newChannel(baos), 16);
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
+                channel, outbuf, metrics, 16);
         encoder.write(wrap("stuff;"));
 
         //Create an empty file
@@ -208,7 +224,12 @@
 
     public void testCodingCompletedFromFile() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(newChannel(baos), 5);
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
+                channel, outbuf, metrics, 5);
         encoder.write(wrap("stuff"));
 
         File tmpFile = File.createTempFile("testFile", "txt");
@@ -233,7 +254,12 @@
     
     public void testCodingFromFileSmaller() throws Exception {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(newChannel(baos), 16);
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
+                channel, outbuf, metrics, 16);
                
         File tmpFile = File.createTempFile("testFile", "txt");
         FileOutputStream fout = new FileOutputStream(tmpFile);
@@ -256,4 +282,37 @@
         
         tmpFile.delete();
     }
+    
+    public void testInvalidConstructor() {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
+        WritableByteChannel channel = newChannel(baos);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
+
+        try {
+            new LengthDelimitedEncoder(null, null, null, 10);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new LengthDelimitedEncoder(channel, null, null, 10);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new LengthDelimitedEncoder(channel, outbuf, null, 10);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        try {
+            new LengthDelimitedEncoder(channel, outbuf, metrics, -10);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+    }
+
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/MockupEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/MockupEncoder.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/MockupEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/mockup/MockupEncoder.java Sat Jul 14 04:29:48 2007
@@ -35,19 +35,19 @@
 import java.nio.ByteBuffer;
 import java.nio.channels.WritableByteChannel;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.nio.codecs.AbstractContentEncoder;
+import org.apache.http.impl.nio.reactor.SessionOutputBuffer;
 
 public class MockupEncoder extends AbstractContentEncoder {
     
-    private final WritableByteChannel channel;
     private boolean completed;
     
-    public MockupEncoder(final WritableByteChannel channel) {
-        super();
-        if (channel == null) {
-            throw new IllegalArgumentException("Channel may not be null");
-        }
-        this.channel = channel;
+    public MockupEncoder(
+            final WritableByteChannel channel, 
+            final SessionOutputBuffer buffer,
+            final HttpTransportMetricsImpl metrics) {
+        super(channel, buffer, metrics);
     }
 
     public boolean isCompleted() {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java?view=diff&rev=556266&r1=556265&r2=556266
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java Sat Jul 14 04:29:48 2007
@@ -41,6 +41,8 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.http.impl.io.HttpTransportMetricsImpl;
+import org.apache.http.impl.nio.reactor.SessionOutputBuffer;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.mockup.MockupDecoder;
@@ -110,8 +112,10 @@
     public void testOutputBufferOperations() throws IOException {
         ByteArrayOutputStream outstream = new ByteArrayOutputStream();
         WritableByteChannel channel = Channels.newChannel(outstream);
+        SessionOutputBuffer outbuf = new SessionOutputBuffer(1024, 128);
+        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
         
-        ContentEncoder encoder = new MockupEncoder(channel);
+        ContentEncoder encoder = new MockupEncoder(channel, outbuf, metrics);
         
         SimpleOutputBuffer buffer = new SimpleOutputBuffer(4, new DirectByteBufferAllocator()); 
         



Mime
View raw message