Made reads quicker to avoid that tests last forever.

This commit is contained in:
Simone Bordet 2012-02-24 11:56:40 +01:00
parent 2e66e54425
commit f87cd6d1ba
1 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,5 @@
package org.eclipse.jetty.servlets; package org.eclipse.jetty.servlets;
import static org.hamcrest.Matchers.*;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -17,6 +15,8 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.log.StdErrLog; import org.eclipse.jetty.util.log.StdErrLog;
import org.junit.Assert; import org.junit.Assert;
import static org.hamcrest.Matchers.not;
public class PipelineHelper public class PipelineHelper
{ {
private static final Logger LOG = Log.getLogger(PipelineHelper.class); private static final Logger LOG = Log.getLogger(PipelineHelper.class);
@ -38,7 +38,7 @@ public class PipelineHelper
/** /**
* Open the Socket to the destination endpoint and * Open the Socket to the destination endpoint and
* *
* @return the open java Socket. * @return the open java Socket.
* @throws IOException * @throws IOException
*/ */
@ -57,7 +57,7 @@ public class PipelineHelper
/** /**
* Issue a HTTP/1.1 GET request with Connection:keep-alive set. * Issue a HTTP/1.1 GET request with Connection:keep-alive set.
* *
* @param path * @param path
* the path to GET * the path to GET
* @param acceptGzipped * @param acceptGzipped
@ -87,7 +87,7 @@ public class PipelineHelper
{ {
req.append("Connection: keep-alive\r\n"); req.append("Connection: keep-alive\r\n");
} }
req.append("\r\n"); req.append("\r\n");
LOG.debug("Request:" + req); LOG.debug("Request:" + req);
@ -100,7 +100,7 @@ public class PipelineHelper
public String readResponseHeader() throws IOException public String readResponseHeader() throws IOException
{ {
// Read Response Header // Read Response Header
socket.setSoTimeout(10000); socket.setSoTimeout(10000);
LOG.debug("Reading http header"); LOG.debug("Reading http header");
@ -199,7 +199,8 @@ public class PipelineHelper
int val = inputStream.read(); int val = inputStream.read();
try try
{ {
Thread.sleep(10); if (left % 10 == 0)
Thread.sleep(1);
} }
catch (InterruptedException e) catch (InterruptedException e)
{ {