You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2024/12/02 13:30:22 UTC

(tomcat) branch main updated: Test improvement

This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new c5e5ec5b7f Test improvement
c5e5ec5b7f is described below

commit c5e5ec5b7fe0afe60125eb31387d0a1f5ee776fe
Author: remm <re...@apache.org>
AuthorDate: Mon Dec 2 14:29:42 2024 +0100

    Test improvement
---
 .../catalina/valves/TestJDBCAccessLogValve.java    | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/test/org/apache/catalina/valves/TestJDBCAccessLogValve.java b/test/org/apache/catalina/valves/TestJDBCAccessLogValve.java
index 518faa52e9..dc2597316f 100644
--- a/test/org/apache/catalina/valves/TestJDBCAccessLogValve.java
+++ b/test/org/apache/catalina/valves/TestJDBCAccessLogValve.java
@@ -71,9 +71,10 @@ public class TestJDBCAccessLogValve extends TomcatBaseTest {
     @Test
     public void testValve() throws Exception {
 
-       Tomcat tomcat = getTomcatInstance();
+        Tomcat tomcat = getTomcatInstance();
         // No file system docBase required
-        Context ctx = getProgrammaticRootContext();
+        getTomcatInstanceTestWebapp(false, false);
+        Context ctx = (Context) tomcat.getHost().findChildren()[0];
 
         CustomJDBCAccessLogValve accessLogValve = new CustomJDBCAccessLogValve();
         accessLogValve.setDriverName("org.apache.derby.jdbc.EmbeddedDriver");
@@ -85,12 +86,12 @@ public class TestJDBCAccessLogValve extends TomcatBaseTest {
         tomcat.start();
 
         ByteChunk result = new ByteChunk();
-        int rc = getUrl("http://localhost:" + getPort() + "/test1", result, null);
-        Assert.assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
+        int rc = getUrl("http://localhost:" + getPort() + "/test/index.html", result, null);
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
         result.recycle();
 
-        rc = getUrl("http://localhost:" + getPort() + "/test2?foo=bar", result, null);
-        Assert.assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
+        rc = getUrl("http://localhost:" + getPort() + "/test/404.html?foo=bar", result, null);
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
 
         accessLogValve.verify();
 
@@ -130,11 +131,12 @@ public class TestJDBCAccessLogValve extends TomcatBaseTest {
                 statement.execute("SELECT * FROM access");
                 ResultSet rs = statement.getResultSet();
                 Assert.assertTrue(rs.next());
-                Assert.assertEquals(HttpServletResponse.SC_NOT_FOUND, rs.getInt("status"));
-                Assert.assertEquals("/test1", rs.getString("query"));
+                Assert.assertEquals(HttpServletResponse.SC_OK, rs.getInt("status"));
+                Assert.assertEquals("/test/index.html", rs.getString("query"));
+                Assert.assertTrue(rs.getLong("bytes") == 934);
                 Assert.assertTrue(rs.next());
-                Assert.assertEquals(HttpServletResponse.SC_NOT_FOUND, rs.getInt("status"));
-                Assert.assertEquals("/test2", rs.getString("query"));
+                Assert.assertEquals(HttpServletResponse.SC_OK, rs.getInt("status"));
+                Assert.assertEquals("/test/404.html", rs.getString("query"));
             }
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org