hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r599808 - in /jakarta/httpcomponents/httpcore/trunk: ./ module-nio/ module-nio/src/main/java/org/apache/http/impl/nio/codecs/ module-nio/src/main/java/org/apache/http/impl/nio/reactor/ module-nio/src/test/java/org/apache/http/mockup/ module...
Date Fri, 30 Nov 2007 12:52:41 GMT
Author: olegk
Date: Fri Nov 30 04:52:38 2007
New Revision: 599808

URL: http://svn.apache.org/viewvc?rev=599808&view=rev
Log:
Initial port of HttpCore NIO to Java 1.5: use of generics

Added:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ByteSequence.java   (with props)
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ResponseSequence.java   (with props)
Removed:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/SimpleThreadPoolExecutor.java
Modified:
    jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    jakarta/httpcomponents/httpcore/trunk/module-nio/pom.xml
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.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/reactor/AbstractIOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelQueue.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointQueue.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionQueue.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestQueue.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionSet.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java

Modified: jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Fri Nov 30 04:52:38 2007
@@ -1,5 +1,8 @@
 Changes since 4.0 Alpha 6
 
+* HttpCore NIO ported to Java 1.5.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-130] Fixed over-synchronization bug leading to a thread deadlock 
   condition in SSL IOEventDispatch implementations.
   Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/pom.xml
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/pom.xml?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/pom.xml (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/pom.xml Fri Nov 30 04:52:38 2007
@@ -74,8 +74,8 @@
   </dependencies>
 
   <properties>
-    <maven.compile.source>1.4</maven.compile.source>
-    <maven.compile.target>1.4</maven.compile.target>
+    <maven.compile.source>1.5</maven.compile.source>
+    <maven.compile.target>1.5</maven.compile.target>
     <maven.compile.optimize>true</maven.compile.optimize>
     <maven.compile.deprecation>true</maven.compile.deprecation>
   </properties>

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java Fri Nov 30 04:52:38 2007
@@ -61,7 +61,7 @@
 
     private HttpMessage message;
     private CharArrayBuffer lineBuf;
-    private final List headerBufs;
+    private final List<CharArrayBuffer> headerBufs;
 
     private int maxLineLen = -1;
     private int maxHeaderCount = -1;
@@ -78,7 +78,7 @@
         this.sessionBuffer = buffer;
         this.state = READ_HEAD_LINE;
         this.endOfStream = false;
-        this.headerBufs = new ArrayList();        
+        this.headerBufs = new ArrayList<CharArrayBuffer>();        
         this.maxLineLen = params.getIntParameter(
                 CoreConnectionPNames.MAX_LINE_LENGTH, -1);
         this.maxHeaderCount = params.getIntParameter(

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java Fri Nov 30 04:52:38 2007
@@ -75,7 +75,7 @@
             throw new IllegalArgumentException("HTTP message may not be null");
         }
         writeHeadLine(message);
-        for (Iterator it = message.headerIterator(); it.hasNext(); ) {
+        for (Iterator<?> it = message.headerIterator(); it.hasNext(); ) {
             Header header = (Header) it.next();
             this.sessionBuffer.writeLine
                 (lineFormatter.formatHeader(this.lineBuf, header));

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?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- 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 Fri Nov 30 04:52:38 2007
@@ -60,7 +60,7 @@
     private int chunkSize;
     private int pos;
     
-    private final List trailerBufs;
+    private final List<CharArrayBuffer> trailerBufs;
     
     private Header[] footers;
     
@@ -74,7 +74,7 @@
         this.pos = 0;
         this.endOfChunk = false;
         this.endOfStream = false;
-        this.trailerBufs = new ArrayList();
+        this.trailerBufs = new ArrayList<CharArrayBuffer>();
     }
 
     private void readChunkHead() throws IOException {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java Fri Nov 30 04:52:38 2007
@@ -85,7 +85,7 @@
     
     protected abstract void timeoutCheck(SelectionKey key, long now);
 
-    protected abstract void validate(Set keys);
+    protected abstract void validate(Set<SelectionKey> keys);
     
     protected abstract void keyCreated(SelectionKey key, IOSession session);
     
@@ -167,10 +167,10 @@
         }
     }
     
-    private void processEvents(final Set selectedKeys) {
-        for (Iterator it = selectedKeys.iterator(); it.hasNext(); ) {
+    private void processEvents(final Set<SelectionKey> selectedKeys) {
+        for (Iterator<SelectionKey> it = selectedKeys.iterator(); it.hasNext(); ) {
             
-            SelectionKey key = (SelectionKey) it.next();
+            SelectionKey key = it.next();
             processEvent(key);
             
         }
@@ -261,8 +261,8 @@
 
     protected void closeSessions() {
         synchronized (this.sessions) {
-            for (Iterator it = this.sessions.iterator(); it.hasNext(); ) {
-                IOSession session = (IOSession) it.next();
+            for (Iterator<IOSession> it = this.sessions.iterator(); it.hasNext(); ) {
+                IOSession session = it.next();
                 session.close();
             }
         }
@@ -284,10 +284,10 @@
     }
     
     protected void closeActiveChannels() throws IOReactorException {
-        Set keys = this.selector.keys();
-        for (Iterator it = keys.iterator(); it.hasNext(); ) {
+        Set<SelectionKey> keys = this.selector.keys();
+        for (Iterator<SelectionKey> it = keys.iterator(); it.hasNext(); ) {
             try {
-                SelectionKey key = (SelectionKey) it.next();
+                SelectionKey key = it.next();
                 Channel channel = key.channel();
                 if (channel != null) {
                     channel.close();

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java Fri Nov 30 04:52:38 2007
@@ -194,10 +194,10 @@
         this.selector.wakeup();
         
         // Close out all channels
-        Set keys = this.selector.keys();
-        for (Iterator it = keys.iterator(); it.hasNext(); ) {
+        Set<SelectionKey> keys = this.selector.keys();
+        for (Iterator<SelectionKey> it = keys.iterator(); it.hasNext(); ) {
             try {
-                SelectionKey key = (SelectionKey) it.next();
+                SelectionKey key = it.next();
                 Channel channel = key.channel();
                 if (channel != null) {
                     channel.close();

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java Fri Nov 30 04:52:38 2007
@@ -112,20 +112,20 @@
         }
     }
     
-    protected void validate(final Set keys) {
+    protected void validate(final Set<SelectionKey> keys) {
         long currentTime = System.currentTimeMillis();
         if( (currentTime - this.lastTimeoutCheck) >= this.timeoutCheckInterval) {
             this.lastTimeoutCheck = currentTime;
             if (keys != null) {
-                for (Iterator it = keys.iterator(); it.hasNext();) {
-                    SelectionKey key = (SelectionKey) it.next();
+                for (Iterator<SelectionKey> it = keys.iterator(); it.hasNext();) {
+                    SelectionKey key = it.next();
                     timeoutCheck(key, currentTime);
                 }
             }
         }
         if (!this.bufferingSessions.isEmpty()) {
-            for (Iterator it = this.bufferingSessions.iterator(); it.hasNext(); ) {
-                IOSession session = (IOSession) it.next();
+            for (Iterator<IOSession> it = this.bufferingSessions.iterator(); it.hasNext(); ) {
+                IOSession session = it.next();
                 if (!session.hasBufferedInput()) {
                     it.remove();
                     continue;

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelQueue.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelQueue.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelQueue.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelQueue.java Fri Nov 30 04:52:38 2007
@@ -35,11 +35,11 @@
 
 public class ChannelQueue {
     
-    private final LinkedList list;
+    private final LinkedList<ChannelEntry> list;
     
     public ChannelQueue() {
         super();
-        this.list = new LinkedList();
+        this.list = new LinkedList<ChannelEntry>();
     }
 
     public synchronized void push(final ChannelEntry entry) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java Fri Nov 30 04:52:38 2007
@@ -75,10 +75,10 @@
         processSessionRequests();
         
         if (readyCount > 0) {
-            Set selectedKeys = this.selector.selectedKeys();
-            for (Iterator it = selectedKeys.iterator(); it.hasNext(); ) {
+            Set<SelectionKey> selectedKeys = this.selector.selectedKeys();
+            for (Iterator<SelectionKey> it = selectedKeys.iterator(); it.hasNext(); ) {
                 
-                SelectionKey key = (SelectionKey) it.next();
+                SelectionKey key = it.next();
                 processEvent(key);
                 
             }
@@ -88,7 +88,7 @@
         long currentTime = System.currentTimeMillis();
         if ((currentTime - this.lastTimeoutCheck) >= this.selectTimeout) {
             this.lastTimeoutCheck = currentTime;
-            Set keys = this.selector.keys();
+            Set<SelectionKey> keys = this.selector.keys();
             if (keys != null) {
                 processTimeouts(keys);
             }
@@ -134,10 +134,10 @@
         }
     }
 
-    private void processTimeouts(final Set keys) {
+    private void processTimeouts(final Set<SelectionKey> keys) {
         long now = System.currentTimeMillis();
-        for (Iterator it = keys.iterator(); it.hasNext();) {
-            SelectionKey key = (SelectionKey) it.next();
+        for (Iterator<SelectionKey> it = keys.iterator(); it.hasNext();) {
+            SelectionKey key = it.next();
             Object attachment = key.attachment();
             
             if (attachment instanceof SessionRequestHandle) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java Fri Nov 30 04:52:38 2007
@@ -69,10 +69,10 @@
         processSessionRequests();
 
         if (readyCount > 0) {
-            Set selectedKeys = this.selector.selectedKeys();
-            for (Iterator it = selectedKeys.iterator(); it.hasNext(); ) {
+            Set<SelectionKey> selectedKeys = this.selector.selectedKeys();
+            for (Iterator<SelectionKey> it = selectedKeys.iterator(); it.hasNext(); ) {
                 
-                SelectionKey key = (SelectionKey) it.next();
+                SelectionKey key = it.next();
                 processEvent(key);
                 
             }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java Fri Nov 30 04:52:38 2007
@@ -51,7 +51,7 @@
     private final SelectionKey key;
     private final ByteChannel channel;
     private final SessionClosedCallback callback;
-    private final Map attributes;
+    private final Map<String, Object> attributes;
     
     private SessionBufferStatus bufferStatus;
     private int socketTimeout;
@@ -64,7 +64,7 @@
         this.key = key;
         this.channel = (ByteChannel) this.key.channel();
         this.callback = callback;
-        this.attributes = Collections.synchronizedMap(new HashMap());
+        this.attributes = Collections.synchronizedMap(new HashMap<String, Object>());
         this.socketTimeout = 0;
         this.status = ACTIVE;
     }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointQueue.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointQueue.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointQueue.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointQueue.java Fri Nov 30 04:52:38 2007
@@ -35,11 +35,11 @@
 
 public class ListenerEndpointQueue {
     
-    private final LinkedList list;
+    private final LinkedList<ListenerEndpointImpl> list;
     
     public ListenerEndpointQueue() {
         super();
-        this.list = new LinkedList();
+        this.list = new LinkedList<ListenerEndpointImpl>();
     }
 
     public synchronized void push(final ListenerEndpointImpl entry) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionQueue.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionQueue.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionQueue.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionQueue.java Fri Nov 30 04:52:38 2007
@@ -37,11 +37,11 @@
 
 public class SessionQueue {
     
-    private final LinkedList list;
+    private final LinkedList<IOSession> list;
     
     public SessionQueue() {
         super();
-        this.list = new LinkedList();
+        this.list = new LinkedList<IOSession>();
     }
 
     public synchronized void push(final IOSession session) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestQueue.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestQueue.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestQueue.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestQueue.java Fri Nov 30 04:52:38 2007
@@ -35,11 +35,11 @@
 
 public class SessionRequestQueue {
     
-    private final LinkedList list;
+    private final LinkedList<SessionRequestImpl> list;
     
     public SessionRequestQueue() {
         super();
-        this.list = new LinkedList();
+        this.list = new LinkedList<SessionRequestImpl>();
     }
 
     public synchronized void push(final SessionRequestImpl entry) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionSet.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionSet.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionSet.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionSet.java Fri Nov 30 04:52:38 2007
@@ -39,11 +39,11 @@
 
 public class SessionSet {
     
-    private final Set set;
+    private final Set<IOSession> set;
     
     public SessionSet() {
         super();
-        this.set = new HashSet();
+        this.set = new HashSet<IOSession>();
     }
 
     public synchronized void add(final IOSession session) {
@@ -68,7 +68,7 @@
         return this.set.isEmpty();
     }
     
-    public Iterator iterator() {
+    public Iterator<IOSession> iterator() {
         return this.set.iterator();
     }
     

Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ByteSequence.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ByteSequence.java?rev=599808&view=auto
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ByteSequence.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ByteSequence.java Fri Nov 30 04:52:38 2007
@@ -0,0 +1,69 @@
+/*
+ * $HeadURL:$
+ * $Revision:$
+ * $Date:$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.mockup;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+public class ByteSequence {
+
+    private final List<byte []> data;
+    
+    public ByteSequence() {
+        super();
+        this.data = new ArrayList<byte []>();
+    }
+    
+    public void addBytes(byte[] bytes) {
+        this.data.add(bytes);
+    }
+    
+    public int size() {
+        return this.data.size();
+    }
+
+    public byte[] getBytes(int index) {
+        return this.data.get(index);
+    }
+    
+    public void rnd(int count) {
+        Random rnd = new Random();
+        for (int i = 0; i < count; i++) {
+            int size = rnd.nextInt(5000);
+            byte[] data = new byte[size];
+            rnd.nextBytes(data);
+            this.data.add(data);
+        }
+    }
+    
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ByteSequence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ByteSequence.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ByteSequence.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ResponseSequence.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ResponseSequence.java?rev=599808&view=auto
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ResponseSequence.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ResponseSequence.java Fri Nov 30 04:52:38 2007
@@ -0,0 +1,60 @@
+/*
+ * $HeadURL:$
+ * $Revision:$
+ * $Date:$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.mockup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.http.HttpResponse;
+
+public class ResponseSequence {
+
+    private final List<HttpResponse> data;
+    
+    public ResponseSequence() {
+        super();
+        this.data = new ArrayList<HttpResponse>();
+    }
+    
+    public void addResponse(final HttpResponse response) {
+        this.data.add(response);
+    }
+    
+    public int size() {
+        return this.data.size();
+    }
+
+    public HttpResponse getResponse(int index) {
+        return this.data.get(index);
+    }
+    
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ResponseSequence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ResponseSequence.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/mockup/ResponseSequence.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java?rev=599808&r1=599807&r2=599808&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestNIOHttp.java Fri Nov 30 04:52:38 2007
@@ -36,7 +36,6 @@
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Random;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -56,10 +55,11 @@
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.mockup.ByteSequence;
 import org.apache.http.mockup.RequestCount;
+import org.apache.http.mockup.ResponseSequence;
 import org.apache.http.mockup.SimpleEventListener;
 import org.apache.http.mockup.SimpleHttpRequestHandlerResolver;
-import org.apache.http.mockup.SimpleThreadPoolExecutor;
 import org.apache.http.mockup.TestHttpClient;
 import org.apache.http.mockup.TestHttpServer;
 import org.apache.http.nio.NHttpClientHandler;
@@ -115,7 +115,6 @@
 
     private TestHttpServer server;
     private TestHttpClient client;
-    private SimpleThreadPoolExecutor executor;
     
     protected void setUp() throws Exception {
         HttpParams serverParams = new BasicHttpParams();
@@ -138,13 +137,11 @@
             .setParameter(CoreProtocolPNames.USER_AGENT, "TEST-CLIENT/1.1");
         
         this.client = new TestHttpClient(clientParams);
-        this.executor = new SimpleThreadPoolExecutor();
     }
 
     protected void tearDown() throws Exception {
         this.server.shutdown();
         this.client.shutdown();
-        this.executor.shutdown();
     }
     
     private NHttpServiceHandler createHttpServiceHandler(
@@ -198,21 +195,12 @@
         final int connNo = 3;
         final int reqNo = 20;
         final RequestCount requestCount = new RequestCount(connNo * reqNo); 
+        final ByteSequence requestData = new ByteSequence();
+        requestData.rnd(reqNo);
         
-        Random rnd = new Random();
-        
-        // Prepare some random data
-        final List testData = new ArrayList(reqNo);
-        for (int i = 0; i < reqNo; i++) {
-            int size = rnd.nextInt(5000);
-            byte[] data = new byte[size];
-            rnd.nextBytes(data);
-            testData.add(data);
-        }
-        
-        List[] responseData = new List[connNo];
-        for (int i = 0; i < responseData.length; i++) {
-            responseData[i] = new ArrayList();
+        List<ByteSequence> responseData = new ArrayList<ByteSequence>(connNo);
+        for (int i = 0; i < connNo; i++) {
+            responseData.add(new ByteSequence());
         }
         
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
@@ -230,8 +218,8 @@
                     throw new HttpException("Invalid request URI: " + s);
                 }
                 int index = Integer.parseInt(uri.getQuery());
-                byte[] data = (byte []) testData.get(index);
-                ByteArrayEntity entity = new ByteArrayEntity(data); 
+                byte[] bytes = requestData.getBytes(index);
+                ByteArrayEntity entity = new ByteArrayEntity(bytes); 
                 response.setEntity(entity);
             }
             
@@ -240,7 +228,7 @@
         HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
 
             public void initalizeContext(final HttpContext context, final Object attachment) {
-                context.setAttribute("LIST", (List) attachment);
+                context.setAttribute("LIST", (ByteSequence) attachment);
                 context.setAttribute("REQ-COUNT", new Integer(0));
                 context.setAttribute("RES-COUNT", new Integer(0));
             }
@@ -262,7 +250,7 @@
                 NHttpConnection conn = (NHttpConnection) context.getAttribute(
                         ExecutionContext.HTTP_CONNECTION);
                 
-                List list = (List) context.getAttribute("LIST");
+                ByteSequence list = (ByteSequence) context.getAttribute("LIST");
                 int i = ((Integer) context.getAttribute("RES-COUNT")).intValue();
                 i++;
                 context.setAttribute("RES-COUNT", new Integer(i));
@@ -270,7 +258,7 @@
                 try {
                     HttpEntity entity = response.getEntity();
                     byte[] data = EntityUtils.toByteArray(entity);
-                    list.add(data);
+                    list.addBytes(data);
                     requestCount.decrement();
                 } catch (IOException ex) {
                     requestCount.abort();
@@ -298,10 +286,10 @@
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
         
-        for (int i = 0; i < responseData.length; i++) {
+        for (int i = 0; i < responseData.size(); i++) {
             this.client.openConnection(
                     new InetSocketAddress("localhost", serverAddress.getPort()), 
-                    responseData[i]);
+                    responseData.get(i));
         }
      
         requestCount.await(10000);
@@ -310,13 +298,13 @@
         this.client.shutdown();
         this.server.shutdown();
 
-        for (int c = 0; c < responseData.length; c++) {
-            List receivedPackets = responseData[c];
-            List expectedPackets = testData;
+        for (int c = 0; c < responseData.size(); c++) {
+            ByteSequence receivedPackets = responseData.get(c);
+            ByteSequence expectedPackets = requestData;
             assertEquals(expectedPackets.size(), receivedPackets.size());
-            for (int p = 0; p < testData.size(); p++) {
-                byte[] expected = (byte[]) testData.get(p);
-                byte[] received = (byte[]) receivedPackets.get(p);
+            for (int p = 0; p < requestData.size(); p++) {
+                byte[] expected = requestData.getBytes(p);
+                byte[] received = receivedPackets.getBytes(p);
                 
                 assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
@@ -336,21 +324,12 @@
         final int connNo = 3;
         final int reqNo = 20;
         final RequestCount requestCount = new RequestCount(connNo * reqNo); 
+        final ByteSequence requestData = new ByteSequence();
+        requestData.rnd(reqNo);
         
-        Random rnd = new Random();
-        
-        // Prepare some random data
-        final List testData = new ArrayList(reqNo);
-        for (int i = 0; i < reqNo; i++) {
-            int size = rnd.nextInt(5000);
-            byte[] data = new byte[size];
-            rnd.nextBytes(data);
-            testData.add(data);
-        }
-        
-        List[] responseData = new List[connNo];
-        for (int i = 0; i < responseData.length; i++) {
-            responseData[i] = new ArrayList();
+        List<ByteSequence> responseData = new ArrayList<ByteSequence>(connNo);
+        for (int i = 0; i < connNo; i++) {
+            responseData.add(new ByteSequence());
         }
         
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
@@ -378,7 +357,7 @@
         HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
 
             public void initalizeContext(final HttpContext context, final Object attachment) {
-                context.setAttribute("LIST", (List) attachment);
+                context.setAttribute("LIST", (ByteSequence) attachment);
                 context.setAttribute("REQ-COUNT", new Integer(0));
                 context.setAttribute("RES-COUNT", new Integer(0));
             }
@@ -391,7 +370,8 @@
                 BasicHttpEntityEnclosingRequest post = null;
                 if (i < reqNo) {
                     post = new BasicHttpEntityEnclosingRequest("POST", "/?" + i);
-                    byte[] data = (byte[]) testData.get(i);
+
+                    byte[] data = requestData.getBytes(i);
                     ByteArrayEntity outgoing = new ByteArrayEntity(data);
                     post.setEntity(outgoing);
                     
@@ -404,7 +384,7 @@
                 NHttpConnection conn = (NHttpConnection) context.getAttribute(
                         ExecutionContext.HTTP_CONNECTION);
                 
-                List list = (List) context.getAttribute("LIST");
+                ByteSequence list = (ByteSequence) context.getAttribute("LIST");
                 int i = ((Integer) context.getAttribute("RES-COUNT")).intValue();
                 i++;
                 context.setAttribute("RES-COUNT", new Integer(i));
@@ -412,7 +392,7 @@
                 try {
                     HttpEntity entity = response.getEntity();
                     byte[] data = EntityUtils.toByteArray(entity);
-                    list.add(data);
+                    list.addBytes(data);
                     requestCount.decrement();
                 } catch (IOException ex) {
                     requestCount.abort();
@@ -440,10 +420,10 @@
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
         
-        for (int i = 0; i < responseData.length; i++) {
+        for (int i = 0; i < responseData.size(); i++) {
             this.client.openConnection(
                     new InetSocketAddress("localhost", serverAddress.getPort()), 
-                    responseData[i]);
+                    responseData.get(i));
         }
      
         requestCount.await(10000);
@@ -452,13 +432,13 @@
         this.client.shutdown();
         this.server.shutdown();
 
-        for (int c = 0; c < responseData.length; c++) {
-            List receivedPackets = responseData[c];
-            List expectedPackets = testData;
+        for (int c = 0; c < responseData.size(); c++) {
+            ByteSequence receivedPackets = responseData.get(c);
+            ByteSequence expectedPackets = requestData;
             assertEquals(expectedPackets.size(), receivedPackets.size());
-            for (int p = 0; p < testData.size(); p++) {
-                byte[] expected = (byte[]) testData.get(p);
-                byte[] received = (byte[]) receivedPackets.get(p);
+            for (int p = 0; p < requestData.size(); p++) {
+                byte[] expected = requestData.getBytes(p);
+                byte[] received = receivedPackets.getBytes(p);
                 
                 assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
@@ -478,21 +458,12 @@
         final int connNo = 3;
         final int reqNo = 20;
         final RequestCount requestCount = new RequestCount(connNo * reqNo); 
+        final ByteSequence requestData = new ByteSequence();
+        requestData.rnd(reqNo);
         
-        Random rnd = new Random();
-        
-        // Prepare some random data
-        final List testData = new ArrayList(reqNo);
-        for (int i = 0; i < reqNo; i++) {
-            int size = rnd.nextInt(20000);
-            byte[] data = new byte[size];
-            rnd.nextBytes(data);
-            testData.add(data);
-        }
-        
-        List[] responseData = new List[connNo];
-        for (int i = 0; i < responseData.length; i++) {
-            responseData[i] = new ArrayList();
+        List<ByteSequence> responseData = new ArrayList<ByteSequence>(connNo);
+        for (int i = 0; i < connNo; i++) {
+            responseData.add(new ByteSequence());
         }
         
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
@@ -519,7 +490,7 @@
         HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
 
             public void initalizeContext(final HttpContext context, final Object attachment) {
-                context.setAttribute("LIST", (List) attachment);
+                context.setAttribute("LIST", (ByteSequence) attachment);
                 context.setAttribute("REQ-COUNT", new Integer(0));
                 context.setAttribute("RES-COUNT", new Integer(0));
             }
@@ -532,7 +503,7 @@
                 BasicHttpEntityEnclosingRequest post = null;
                 if (i < reqNo) {
                     post = new BasicHttpEntityEnclosingRequest("POST", "/?" + i);
-                    byte[] data = (byte[]) testData.get(i);
+                    byte[] data = requestData.getBytes(i);
                     ByteArrayEntity outgoing = new ByteArrayEntity(data);
                     outgoing.setChunked(true);
                     post.setEntity(outgoing);
@@ -546,7 +517,7 @@
                 NHttpConnection conn = (NHttpConnection) context.getAttribute(
                         ExecutionContext.HTTP_CONNECTION);
                 
-                List list = (List) context.getAttribute("LIST");
+                ByteSequence list = (ByteSequence) context.getAttribute("LIST");
                 int i = ((Integer) context.getAttribute("RES-COUNT")).intValue();
                 i++;
                 context.setAttribute("RES-COUNT", new Integer(i));
@@ -554,7 +525,7 @@
                 try {
                     HttpEntity entity = response.getEntity();
                     byte[] data = EntityUtils.toByteArray(entity);
-                    list.add(data);
+                    list.addBytes(data);
                     requestCount.decrement();
                 } catch (IOException ex) {
                     requestCount.abort();
@@ -582,10 +553,10 @@
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
         
-        for (int i = 0; i < responseData.length; i++) {
+        for (int i = 0; i < responseData.size(); i++) {
             this.client.openConnection(
                     new InetSocketAddress("localhost", serverAddress.getPort()), 
-                    responseData[i]);
+                    responseData.get(i));
         }
      
         requestCount.await(10000);
@@ -597,13 +568,13 @@
         this.client.shutdown();
         this.server.shutdown();
 
-        for (int c = 0; c < responseData.length; c++) {
-            List receivedPackets = responseData[c];
-            List expectedPackets = testData;
+        for (int c = 0; c < responseData.size(); c++) {
+            ByteSequence receivedPackets = responseData.get(c);
+            ByteSequence expectedPackets = requestData;
             assertEquals(expectedPackets.size(), receivedPackets.size());
-            for (int p = 0; p < testData.size(); p++) {
-                byte[] expected = (byte[]) testData.get(p);
-                byte[] received = (byte[]) receivedPackets.get(p);
+            for (int p = 0; p < requestData.size(); p++) {
+                byte[] expected = requestData.getBytes(p);
+                byte[] received = receivedPackets.getBytes(p);
                 
                 assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
@@ -623,21 +594,12 @@
         final int connNo = 3;
         final int reqNo = 20;
         final RequestCount requestCount = new RequestCount(connNo * reqNo); 
+        final ByteSequence requestData = new ByteSequence();
+        requestData.rnd(reqNo);
         
-        Random rnd = new Random();
-        
-        // Prepare some random data
-        final List testData = new ArrayList(reqNo);
-        for (int i = 0; i < reqNo; i++) {
-            int size = rnd.nextInt(5000);
-            byte[] data = new byte[size];
-            rnd.nextBytes(data);
-            testData.add(data);
-        }
-        
-        List[] responseData = new List[connNo];
-        for (int i = 0; i < responseData.length; i++) {
-            responseData[i] = new ArrayList();
+        List<ByteSequence> responseData = new ArrayList<ByteSequence>(connNo);
+        for (int i = 0; i < connNo; i++) {
+            responseData.add(new ByteSequence());
         }
         
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
@@ -670,7 +632,7 @@
         HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
 
             public void initalizeContext(final HttpContext context, final Object attachment) {
-                context.setAttribute("LIST", (List) attachment);
+                context.setAttribute("LIST", (ByteSequence) attachment);
                 context.setAttribute("REQ-COUNT", new Integer(0));
                 context.setAttribute("RES-COUNT", new Integer(0));
             }
@@ -683,7 +645,7 @@
                 BasicHttpEntityEnclosingRequest post = null;
                 if (i < reqNo) {
                     post = new BasicHttpEntityEnclosingRequest("POST", "/?" + i);
-                    byte[] data = (byte[]) testData.get(i);
+                    byte[] data = requestData.getBytes(i);
                     ByteArrayEntity outgoing = new ByteArrayEntity(data);
                     post.setEntity(outgoing);
                     
@@ -696,7 +658,7 @@
                 NHttpConnection conn = (NHttpConnection) context.getAttribute(
                         ExecutionContext.HTTP_CONNECTION);
 
-                List list = (List) context.getAttribute("LIST");
+                ByteSequence list = (ByteSequence) context.getAttribute("LIST");
                 int i = ((Integer) context.getAttribute("RES-COUNT")).intValue();
                 i++;
                 context.setAttribute("RES-COUNT", new Integer(i));
@@ -704,7 +666,7 @@
                 try {
                     HttpEntity entity = response.getEntity();
                     byte[] data = EntityUtils.toByteArray(entity);
-                    list.add(data);
+                    list.addBytes(data);
                     requestCount.decrement();
                 } catch (IOException ex) {
                     requestCount.abort();
@@ -732,10 +694,10 @@
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
         
-        for (int i = 0; i < responseData.length; i++) {
+        for (int i = 0; i < responseData.size(); i++) {
             this.client.openConnection(
                     new InetSocketAddress("localhost", serverAddress.getPort()), 
-                    responseData[i]);
+                    responseData.get(i));
         }
      
         requestCount.await(10000);
@@ -744,13 +706,13 @@
         this.client.shutdown();
         this.server.shutdown();
 
-        for (int c = 0; c < responseData.length; c++) {
-            List receivedPackets = responseData[c];
-            List expectedPackets = testData;
+        for (int c = 0; c < responseData.size(); c++) {
+            ByteSequence receivedPackets = responseData.get(c);
+            ByteSequence expectedPackets = requestData;
             assertEquals(expectedPackets.size(), receivedPackets.size());
-            for (int p = 0; p < testData.size(); p++) {
-                byte[] expected = (byte[]) testData.get(p);
-                byte[] received = (byte[]) receivedPackets.get(p);
+            for (int p = 0; p < requestData.size(); p++) {
+                byte[] expected = requestData.getBytes(p);
+                byte[] received = receivedPackets.getBytes(p);
                 
                 assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
@@ -770,21 +732,12 @@
         final int connNo = 3;
         final int reqNo = 20;
         final RequestCount requestCount = new RequestCount(connNo * reqNo); 
+        final ByteSequence requestData = new ByteSequence();
+        requestData.rnd(reqNo);
         
-        Random rnd = new Random();
-        
-        // Prepare some random data
-        final List testData = new ArrayList(reqNo);
-        for (int i = 0; i < reqNo; i++) {
-            int size = rnd.nextInt(20000);
-            byte[] data = new byte[size];
-            rnd.nextBytes(data);
-            testData.add(data);
-        }
-        
-        List[] responseData = new List[connNo];
-        for (int i = 0; i < responseData.length; i++) {
-            responseData[i] = new ArrayList();
+        List<ByteSequence> responseData = new ArrayList<ByteSequence>(connNo);
+        for (int i = 0; i < connNo; i++) {
+            responseData.add(new ByteSequence());
         }
         
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
@@ -814,7 +767,7 @@
         HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
 
             public void initalizeContext(final HttpContext context, final Object attachment) {
-                context.setAttribute("LIST", (List) attachment);
+                context.setAttribute("LIST", (ByteSequence) attachment);
                 context.setAttribute("REQ-COUNT", new Integer(0));
                 context.setAttribute("RES-COUNT", new Integer(0));
             }
@@ -827,7 +780,7 @@
                 BasicHttpEntityEnclosingRequest post = null;
                 if (i < reqNo) {
                     post = new BasicHttpEntityEnclosingRequest("POST", "/?" + i);
-                    byte[] data = (byte[]) testData.get(i);
+                    byte[] data = requestData.getBytes(i);
                     ByteArrayEntity outgoing = new ByteArrayEntity(data);
                     outgoing.setChunked(true);
                     post.setEntity(outgoing);
@@ -841,7 +794,7 @@
                 NHttpConnection conn = (NHttpConnection) context.getAttribute(
                         ExecutionContext.HTTP_CONNECTION);
                 
-                List list = (List) context.getAttribute("LIST");
+                ByteSequence list = (ByteSequence) context.getAttribute("LIST");
                 int i = ((Integer) context.getAttribute("RES-COUNT")).intValue();
                 i++;
                 context.setAttribute("RES-COUNT", new Integer(i));
@@ -849,7 +802,7 @@
                 try {
                     HttpEntity entity = response.getEntity();
                     byte[] data = EntityUtils.toByteArray(entity);
-                    list.add(data);
+                    list.addBytes(data);
                     requestCount.decrement();
                 } catch (IOException ex) {
                     requestCount.abort();
@@ -877,10 +830,10 @@
         endpoint.waitFor();
         InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
         
-        for (int i = 0; i < responseData.length; i++) {
+        for (int i = 0; i < responseData.size(); i++) {
             this.client.openConnection(
                     new InetSocketAddress("localhost", serverAddress.getPort()), 
-                    responseData[i]);
+                    responseData.get(i));
         }
      
         requestCount.await(10000);
@@ -889,13 +842,13 @@
         this.client.shutdown();
         this.server.shutdown();
 
-        for (int c = 0; c < responseData.length; c++) {
-            List receivedPackets = responseData[c];
-            List expectedPackets = testData;
+        for (int c = 0; c < responseData.size(); c++) {
+            ByteSequence receivedPackets = responseData.get(c);
+            ByteSequence expectedPackets = requestData;
             assertEquals(expectedPackets.size(), receivedPackets.size());
-            for (int p = 0; p < testData.size(); p++) {
-                byte[] expected = (byte[]) testData.get(p);
-                byte[] received = (byte[]) receivedPackets.get(p);
+            for (int p = 0; p < requestData.size(); p++) {
+                byte[] expected = requestData.getBytes(p);
+                byte[] received = receivedPackets.getBytes(p);
                 
                 assertEquals(expected.length, received.length);
                 for (int i = 0; i < expected.length; i++) {
@@ -914,7 +867,7 @@
         
         final int reqNo = 3;
         final RequestCount requestCount = new RequestCount(reqNo); 
-        final List responses = new ArrayList(reqNo);
+        final ResponseSequence responses = new ResponseSequence();
         
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
 
@@ -961,7 +914,7 @@
         HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
 
             public void initalizeContext(final HttpContext context, final Object attachment) {
-                context.setAttribute("LIST", (List) attachment);
+                context.setAttribute("LIST", (ResponseSequence) attachment);
                 context.setAttribute("REQ-COUNT", new Integer(0));
                 context.setAttribute("RES-COUNT", new Integer(0));
             }
@@ -988,7 +941,7 @@
                 NHttpConnection conn = (NHttpConnection) context.getAttribute(
                         ExecutionContext.HTTP_CONNECTION);
                 
-                List list = (List) context.getAttribute("LIST");
+                ResponseSequence list = (ResponseSequence) context.getAttribute("LIST");
                 int i = ((Integer) context.getAttribute("RES-COUNT")).intValue();
                 i++;
                 context.setAttribute("RES-COUNT", new Integer(i));
@@ -1003,7 +956,7 @@
                     }
                 }
                 
-                list.add(response);
+                list.addResponse(response);
                 requestCount.decrement();
 
                 if (i < reqNo) {
@@ -1037,11 +990,11 @@
         this.server.shutdown();
 
         assertEquals(reqNo, responses.size());
-        HttpResponse response = (HttpResponse) responses.get(0);
+        HttpResponse response = responses.getResponse(0);
         assertEquals(HttpStatus.SC_EXPECTATION_FAILED, response.getStatusLine().getStatusCode());
-        response = (HttpResponse) responses.get(1);
+        response = responses.getResponse(1);
         assertEquals(HttpStatus.SC_EXPECTATION_FAILED, response.getStatusLine().getStatusCode());
-        response = (HttpResponse) responses.get(2);
+        response = responses.getResponse(2);
         assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
     }
     
@@ -1055,23 +1008,19 @@
         final int reqNo = 20;
         final RequestCount requestCount = new RequestCount(connNo * reqNo * 2); 
         
-        final String[] method = new String[1];
-        
-        Random rnd = new Random();
+        final ByteSequence requestData = new ByteSequence();
+        requestData.rnd(reqNo);
         
-        // Prepare some random data
-        final List testData = new ArrayList(reqNo);
-        for (int i = 0; i < reqNo; i++) {
-            int size = rnd.nextInt(5000);
-            byte[] data = new byte[size];
-            rnd.nextBytes(data);
-            testData.add(data);
+        List<ResponseSequence> responseData1 = new ArrayList<ResponseSequence>(connNo);
+        for (int i = 0; i < connNo; i++) {
+            responseData1.add(new ResponseSequence());
+        }
+        List<ResponseSequence> responseData2 = new ArrayList<ResponseSequence>(connNo);
+        for (int i = 0; i < connNo; i++) {
+            responseData2.add(new ResponseSequence());
         }
         
-        List[] responseData = new List[connNo];
-        for (int i = 0; i < responseData.length; i++) {
-            responseData[i] = new ArrayList();
-        }
+        final String[] method = new String[1];
         
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
 
@@ -1089,7 +1038,7 @@
                 }
                 int index = Integer.parseInt(uri.getQuery());
 
-                byte[] data = (byte []) testData.get(index);
+                byte[] data = requestData.getBytes(index);
                 ByteArrayEntity entity = new ByteArrayEntity(data); 
                 response.setEntity(entity);
             }
@@ -1099,7 +1048,7 @@
         HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
 
             public void initalizeContext(final HttpContext context, final Object attachment) {
-                context.setAttribute("LIST", (List) attachment);
+                context.setAttribute("LIST", (ResponseSequence) attachment);
                 context.setAttribute("REQ-COUNT", new Integer(0));
                 context.setAttribute("RES-COUNT", new Integer(0));
             }
@@ -1121,12 +1070,12 @@
                 NHttpConnection conn = (NHttpConnection) context.getAttribute(
                         ExecutionContext.HTTP_CONNECTION);
                 
-                List list = (List) context.getAttribute("LIST");
+                ResponseSequence list = (ResponseSequence) context.getAttribute("LIST");
                 int i = ((Integer) context.getAttribute("RES-COUNT")).intValue();
                 i++;
                 context.setAttribute("RES-COUNT", new Integer(i));
 
-                list.add(response);
+                list.addResponse(response);
                 requestCount.decrement();
 
                 if (i < reqNo) {
@@ -1152,45 +1101,39 @@
 
         method[0] = "GET";
         
-        for (int i = 0; i < responseData.length; i++) {
+        for (int i = 0; i < responseData1.size(); i++) {
             this.client.openConnection(
                     new InetSocketAddress("localhost", serverAddress.getPort()), 
-                    responseData[i]);
+                    responseData1.get(i));
         }
      
         requestCount.await(connNo * reqNo, 10000);
         assertEquals(connNo * reqNo, requestCount.getValue());
 
-        List[] responseDataGET = responseData; 
-
         method[0] = "HEAD";
 
-        responseData = new List[connNo];
-        for (int i = 0; i < responseData.length; i++) {
-            responseData[i] = new ArrayList();
-        }
-        
-        for (int i = 0; i < responseData.length; i++) {
+        for (int i = 0; i < responseData2.size(); i++) {
             this.client.openConnection(
                     new InetSocketAddress("localhost", serverAddress.getPort()), 
-                    responseData[i]);
+                    responseData2.get(i));
         }
      
+     
         requestCount.await(10000);
         assertEquals(0, requestCount.getValue());
         
         this.client.shutdown();
         this.server.shutdown();
 
-        for (int c = 0; c < responseData.length; c++) {
-            List headResponses = responseData[c];
-            List getResponses = responseDataGET[c];
-            List expectedPackets = testData;
+        for (int c = 0; c < connNo; c++) {
+            ResponseSequence getResponses = responseData1.get(c);
+            ResponseSequence headResponses = responseData2.get(c);
+            ByteSequence expectedPackets = requestData;
             assertEquals(expectedPackets.size(), headResponses.size());
             assertEquals(expectedPackets.size(), getResponses.size());
-            for (int p = 0; p < testData.size(); p++) {
-                HttpResponse getResponse = (HttpResponse) getResponses.get(p);
-                HttpResponse headResponse = (HttpResponse) headResponses.get(p);
+            for (int p = 0; p < requestData.size(); p++) {
+                HttpResponse getResponse = getResponses.getResponse(p);
+                HttpResponse headResponse = headResponses.getResponse(p);
                 assertEquals(null, headResponse.getEntity());
                 
                 Header[] getHeaders = getResponse.getAllHeaders();



Mime
View raw message