jetty-9 some test clean ups

This commit is contained in:
Greg Wilkins 2012-06-06 13:27:56 +02:00
parent c1f3545d7c
commit 98a7f19ff9
3 changed files with 30 additions and 27 deletions

View File

@ -13,6 +13,7 @@
package org.eclipse.jetty.http;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@ -113,9 +114,9 @@ public class HttpFieldsTest
header.putTo(buffer);
buffer.flip();
String out = BufferUtil.toString(buffer);
assertTrue(out.contains("name0: value??0"));
assertTrue(out.contains("name??1: value1"));
assertTrue(out.contains("name?2: value???2"));
assertThat(out,containsString("name0: value??0"));
assertThat(out,containsString("name??1: value1"));
assertThat(out,containsString("name?2: value:??2"));
}
@Test

View File

@ -388,7 +388,7 @@ public class HttpGeneratorServerTest
assertEquals(0,gen.getContentPrepared());
assertThat(head,containsString("HTTP/1.1 200 OK"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00?00?00 GMT"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT"));
assertThat(head,containsString("Content-Length: 0"));
}
@ -492,7 +492,7 @@ public class HttpGeneratorServerTest
// System.err.println(head+body);
assertThat(head,containsString("HTTP/1.1 200 OK"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00?00?00 GMT"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT"));
assertThat(head,not(containsString("Content-Length")));
assertThat(head,containsString("Transfer-Encoding: chunked"));
assertTrue(head.endsWith("\r\n\r\n10\r\n"));
@ -579,7 +579,7 @@ public class HttpGeneratorServerTest
// System.err.println(head+body);
assertThat(head,containsString("HTTP/1.1 200 OK"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00?00?00 GMT"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT"));
assertThat(head,containsString("Content-Length: 59"));
assertThat(head,not(containsString("chunked")));
assertTrue(head.endsWith("\r\n\r\n"));
@ -633,7 +633,7 @@ public class HttpGeneratorServerTest
// System.err.println(head+body);
assertThat(head,containsString("HTTP/1.1 200 OK"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00?00?00 GMT"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT"));
assertThat(head,containsString("Content-Length: 59"));
assertThat(head,not(containsString("chunked")));
assertTrue(head.endsWith("\r\n\r\n"));
@ -698,7 +698,7 @@ public class HttpGeneratorServerTest
// System.err.println(head+body);
assertThat(head,containsString("HTTP/1.1 200 OK"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00?00?00 GMT"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT"));
assertThat(head,not(containsString("Content-Length")));
assertThat(head,containsString("Transfer-Encoding: chunked"));
assertTrue(head.endsWith("\r\n\r\n13\r\n"));
@ -752,7 +752,7 @@ public class HttpGeneratorServerTest
assertEquals(HttpGenerator.State.END,gen.getState());
assertThat(head,containsString("HTTP/1.1 200 OK"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00?00?00 GMT"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT"));
assertThat(head,containsString("Content-Length: 58"));
assertTrue(head.endsWith("\r\n\r\n"));
@ -823,7 +823,7 @@ public class HttpGeneratorServerTest
assertEquals(HttpGenerator.State.END,gen.getState());
assertThat(head,containsString("HTTP/1.1 200 OK"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00?00?00 GMT"));
assertThat(head,containsString("Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT"));
assertThat(head,containsString("Content-Length: 58"));
assertTrue(head.endsWith("\r\n\r\n"));

View File

@ -20,6 +20,7 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@ -54,7 +55,7 @@ public class SslConnectionTest
@Override
protected void endPointOpened(AsyncEndPoint endpoint)
{
System.err.println("endPointOpened");
// System.err.println("endPointOpened");
endpoint.getAsyncConnection().onOpen();
}
@ -73,7 +74,7 @@ public class SslConnectionTest
AsyncConnection appConnection = new TestConnection(sslConnection.getSslEndPoint());
sslConnection.getSslEndPoint().setAsyncConnection(appConnection);
System.err.println("New Connection "+sslConnection);
// System.err.println("New Connection "+sslConnection);
return sslConnection;
}
@ -84,7 +85,7 @@ public class SslConnectionTest
SelectChannelEndPoint endp = new SelectChannelEndPoint(channel,selectSet,key,getMaxIdleTime());
endp.setAsyncConnection(selectSet.getManager().newConnection(channel,endp, key.attachment()));
_lastEndp=endp;
System.err.println("newEndPoint "+endp);
// System.err.println("newEndPoint "+endp);
return endp;
}
};
@ -137,21 +138,21 @@ public class SslConnectionTest
@Override
public void onOpen()
{
System.err.println("onOpen");
// System.err.println("onOpen");
scheduleOnReadable();
}
@Override
public void onClose()
{
System.err.println("onClose");
// System.err.println("onClose");
}
@Override
public synchronized void onReadable()
{
AsyncEndPoint endp = getEndPoint();
System.err.println("onReadable "+endp);
// System.err.println("onReadable "+endp);
try
{
boolean progress=true;
@ -161,12 +162,12 @@ public class SslConnectionTest
// Fill the input buffer with everything available
int filled=endp.fill(_in);
System.err.println("filled="+filled);
// System.err.println("filled="+filled);
while (filled>0)
{
progress=true;
filled=endp.fill(_in);
System.err.println("filled="+filled);
// System.err.println("filled="+filled);
}
// System.err.println(BufferUtil.toDetailString(_in));
@ -178,13 +179,13 @@ public class SslConnectionTest
FutureCallback<Void> blockingWrite= new FutureCallback<>();
endp.write(null,blockingWrite,_in);
blockingWrite.get();
System.err.println("wrote "+l);
// System.err.println("wrote "+l);
}
// are we done?
if (endp.isInputShutdown())
{
System.err.println("shutdown");
// System.err.println("shutdown");
endp.shutdownOutput();
}
}
@ -218,7 +219,7 @@ public class SslConnectionTest
// Log.getRootLogger().setDebugEnabled(true);
Socket client = newClient();
System.err.println("client="+client);
// System.err.println("client="+client);
client.setSoTimeout(600000); // TODO: restore to smaller value
SocketChannel server = _connector.accept();
@ -226,10 +227,10 @@ public class SslConnectionTest
_manager.accept(server);
client.getOutputStream().write("HelloWorld".getBytes("UTF-8"));
System.err.println("wrote");
// System.err.println("wrote");
byte[] buffer = new byte[1024];
int len = client.getInputStream().read(buffer);
System.err.println(new String(buffer,0,len,"UTF-8"));
// System.err.println(new String(buffer,0,len,"UTF-8"));
client.close();
@ -237,13 +238,14 @@ public class SslConnectionTest
@Test
@Ignore
public void testNasty() throws Exception
{
//Log.getRootLogger().setDebugEnabled(true);
// Log.getRootLogger().setDebugEnabled(true);
final Socket client = newClient();
System.err.println("client="+client);
// System.err.println("client="+client);
client.setSoTimeout(600000); // TODO: restore to smaller value
SocketChannel server = _connector.accept();
@ -265,7 +267,7 @@ public class SslConnectionTest
System.err.println("===");
return;
}
System.err.println(new String(buffer,0,len,"UTF-8"));
// System.err.println(new String(buffer,0,len,"UTF-8"));
}
}
@ -276,10 +278,10 @@ public class SslConnectionTest
}
}.start();
for (int i=0;i<1000000;i++)
for (int i=0;i<100000;i++)
{
client.getOutputStream().write(("HelloWorld "+i+"\n").getBytes("UTF-8"));
System.err.println("wrote");
// System.err.println("wrote");
if (i%1000==0)
Thread.sleep(10);
}