From 0c8bdb650c13ae2d43adccf78f1b318a2f709873 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 10 Mar 2014 12:31:44 -0700 Subject: [PATCH] cleaning up test --- .../jetty/servlet/AsyncServletIOTest.java | 44 +++++++++++-------- .../test/resources/jetty-logging.properties | 1 + 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java index 6a1257ea01a..d67d23d5a76 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java @@ -49,17 +49,20 @@ import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; -import org.hamcrest.Matchers; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertEquals; // TODO need these on SPDY as well! public class AsyncServletIOTest { + private static final Logger LOG = Log.getLogger(AsyncServletIOTest.class); protected AsyncIOServlet _servlet0=new AsyncIOServlet(); protected AsyncIOServlet2 _servlet2=new AsyncIOServlet2(); protected int _port; @@ -137,7 +140,7 @@ public class AsyncServletIOTest public void testBigWrites() throws Exception { process(102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400); - Assert.assertThat(_owp.get(),Matchers.greaterThan(1)); + Assert.assertThat("On Write Possible",_owp.get(),greaterThan(1)); } @Test @@ -179,14 +182,14 @@ public class AsyncServletIOTest // response line String line = in.readLine(); - // System.err.println("resp: "+line); - Assert.assertThat(line,Matchers.startsWith("HTTP/1.1 200 OK")); + LOG.debug("response-line: "+line); + Assert.assertThat(line,startsWith("HTTP/1.1 200 OK")); // Skip headers while (line!=null) { line = in.readLine(); - // System.err.println("line: "+line); + LOG.debug("header-line: "+line); if (line.length()==0) break; } @@ -195,7 +198,7 @@ public class AsyncServletIOTest while (true) { line = in.readLine(); - // System.err.println("body: "+line); + LOG.debug("body: "+line); if (line==null) break; list.add(line); @@ -256,19 +259,18 @@ public class AsyncServletIOTest out.write(content,1+half,content.length-half-1); } - BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()),102400); // response line String line = in.readLine(); - //System.err.println("line: "+line); - Assert.assertThat(line,Matchers.startsWith("HTTP/1.1 200 OK")); + LOG.debug("response-line: "+line); + Assert.assertThat(line,startsWith("HTTP/1.1 200 OK")); // Skip headers while (line!=null) { line = in.readLine(); - //System.err.println("line: "+line); + LOG.debug("header-line: "+line); if (line.length()==0) break; } @@ -279,9 +281,9 @@ public class AsyncServletIOTest line = in.readLine(); if (line==null) break; - //System.err.println("line: "+line.length()+"\t"+(line.length()>40?(line.substring(0,40)+"..."):line)); + LOG.debug("body: "+brief(line)); list.add(line); - Thread.sleep(50); + Thread.sleep(150); } } @@ -289,11 +291,11 @@ public class AsyncServletIOTest int w=0; for (String line : list) { - // System.err.println(line); + LOG.debug("line: "+brief(line)); if ("-".equals(line)) continue; - assertEquals(writes[w],line.length()); - assertEquals(line.charAt(0),'0'+(w%10)); + assertEquals("Line Length",writes[w],line.length()); + assertEquals("Line Contents",line.charAt(0),'0'+(w%10)); w++; if (w40?(line.substring(0,40)+"..."):line); + } static AtomicInteger _owp = new AtomicInteger(); static AtomicInteger _oda = new AtomicInteger(); @@ -366,7 +373,7 @@ public class AsyncServletIOTest { if (onDataAvailable.get()) { - System.err.println("OADR too early!"); + LOG.warn("OADR too early!"); _read.set(-1); } @@ -390,7 +397,7 @@ public class AsyncServletIOTest @Override public void onWritePossible() throws IOException { - //System.err.println("OWP"); + LOG.debug("OWP"); _owp.incrementAndGet(); while (writes!=null && _w< writes.length) @@ -424,6 +431,7 @@ public class AsyncServletIOTest } } + @SuppressWarnings("serial") public class AsyncIOServlet2 extends HttpServlet { public CountDownLatch completed = new CountDownLatch(1); diff --git a/jetty-servlet/src/test/resources/jetty-logging.properties b/jetty-servlet/src/test/resources/jetty-logging.properties index 3e0d7b71f47..50696d67ec0 100644 --- a/jetty-servlet/src/test/resources/jetty-logging.properties +++ b/jetty-servlet/src/test/resources/jetty-logging.properties @@ -2,3 +2,4 @@ org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog #org.eclipse.jetty.LEVEL=DEBUG #org.eclipse.jetty.server.LEVEL=DEBUG #org.eclipse.jetty.servlet.LEVEL=DEBUG +#org.eclipse.jetty.io.ChannelEndPoint.LEVEL=DEBUG