From 8aa3655c5525434f4360b6dc41030b1c2ae2c9b2 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 28 Nov 2018 09:26:55 +0100 Subject: [PATCH] Issue #113 - fix to failing tests removed tests for %B and %b which have been removed in favor of %O adjusted the NcsaRequestLogTest to only test ExtendedNCSA format Signed-off-by: Lachlan Roberts --- .../server/handler/CustomRequestLogTest.java | 28 ------------------- .../server/handler/NcsaRequestLogTest.java | 13 +++------ 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/CustomRequestLogTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/CustomRequestLogTest.java index 066d8fe890c..247fa7795ce 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/CustomRequestLogTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/CustomRequestLogTest.java @@ -188,34 +188,6 @@ public class CustomRequestLogTest } } - @Test - public void testLogResponseSize() throws Exception - { - testHandlerServerStart("ResponseSize: %B"); - - _connector.getResponse("GET / HTTP/1.0\n\n"); - String log = _entries.poll(5,TimeUnit.SECONDS); - assertThat(log, is("ResponseSize: 0")); - - _connector.getResponse("GET / HTTP/1.0\nEcho: hello world\n\n"); - log = _entries.poll(5,TimeUnit.SECONDS); - assertThat(log, is("ResponseSize: 11")); - } - - @Test - public void testLogResponseSizeCLF() throws Exception - { - testHandlerServerStart("ResponseSize: %b"); - - _connector.getResponse("GET / HTTP/1.0\n\n"); - String log = _entries.poll(5,TimeUnit.SECONDS); - assertThat(log, is("ResponseSize: -")); - - _connector.getResponse("GET / HTTP/1.0\nEcho: hello world\n\n"); - log = _entries.poll(5,TimeUnit.SECONDS); - assertThat(log, is("ResponseSize: 11")); - } - @Test public void testLogBytesSent() throws Exception { diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java index 71aa3e5fa93..2945a524e83 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; + import javax.servlet.AsyncContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -52,7 +53,6 @@ import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.ValueSource; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; public class NcsaRequestLogTest @@ -69,14 +69,12 @@ public class NcsaRequestLogTest switch (logType) { case "customNCSA": - _log = new CustomRequestLog(writer, CustomRequestLog.NCSA_FORMAT); + _log = new CustomRequestLog(writer, CustomRequestLog.EXTENDED_NCSA_FORMAT); break; case "NCSA": { AbstractNCSARequestLog logNCSA = new AbstractNCSARequestLog(writer); logNCSA.setExtended(true); - logNCSA.setLogLatency(true); - logNCSA.setLogCookies(true); _log = logNCSA; break; } @@ -354,7 +352,7 @@ public class NcsaRequestLogTest _connector.getResponse("GET http://[:1]/foo HTTP/1.1\nReferer: http://other.site\n\n"); String log = _entries.poll(5,TimeUnit.SECONDS); assertThat(log,containsString("GET http://[:1]/foo ")); - assertThat(log,containsString(" 400 50 \"http://other.site\" \"-\" - ")); + assertThat(log,containsString(" 400 50 \"http://other.site\" \"-\"")); } @ParameterizedTest() @@ -367,7 +365,7 @@ public class NcsaRequestLogTest _connector.getResponse("GET http://[:1]/foo HTTP/1.1\nReferer: http://other.site\nUser-Agent: Mozilla/5.0 (test)\n\n"); String log = _entries.poll(5,TimeUnit.SECONDS); assertThat(log,containsString("GET http://[:1]/foo ")); - assertThat(log,containsString(" 400 50 \"http://other.site\" \"Mozilla/5.0 (test)\" - ")); + assertThat(log,containsString(" 400 50 \"http://other.site\" \"Mozilla/5.0 (test)\"")); } @@ -490,9 +488,6 @@ public class NcsaRequestLogTest startServer(); makeRequest(requestPath); assertRequestLog(expectedLogEntry, _log); - - if (!(testHandler instanceof HelloHandler)) - assertThat(errors,contains(requestPath)); }