This is an automated email from the ASF dual-hosted git repository.
rjung 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 7ae80d7554 Short sleep in unit test should suffice, but allow for
lonhger ones also
7ae80d7554 is described below
commit 7ae80d7554d8ec921f33a4bffe135fe7952c8974
Author: Rainer Jung <[email protected]>
AuthorDate: Fri Apr 28 13:00:18 2023 +0200
Short sleep in unit test should suffice, but allow for lonhger ones also
---
.../org/apache/catalina/valves/TestAccessLogValve.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/test/org/apache/catalina/valves/TestAccessLogValve.java
b/test/org/apache/catalina/valves/TestAccessLogValve.java
index 140b967596..824eab08eb 100644
--- a/test/org/apache/catalina/valves/TestAccessLogValve.java
+++ b/test/org/apache/catalina/valves/TestAccessLogValve.java
@@ -55,7 +55,8 @@ public class TestAccessLogValve extends TomcatBaseTest {
private static Log log = LogFactory.getLog(TestAccessLogValve.class);
// Requests can return in the client before log() has been called
- private static final long SLEEP = 10;
+ private static final long SLEEP = 2;
+ private static final long SLEEP_MAX = 100;
private static final String TEXT_TYPE = "text";
private static final String JSON_TYPE = "json";
@@ -309,12 +310,17 @@ public class TestAccessLogValve extends TomcatBaseTest {
reqHead.put(REQUEST_HEADER, testHeaders);
int status = getUrl(url, out, reqHead, resHead);
Assert.assertEquals(HttpServletResponse.SC_OK, status);
- try {
- Thread.currentThread().sleep(SLEEP);
- } catch (InterruptedException ex) {
- log.error("Exception during sleep", ex);
- }
+ long startWait = System.currentTimeMillis();
String result = writer.toString();
+ while ("".equals(result) && System.currentTimeMillis() - startWait <
SLEEP_MAX) {
+ try {
+ Thread.currentThread().sleep(SLEEP);
+ } catch (InterruptedException ex) {
+ log.error("Exception during sleep", ex);
+ }
+ result = writer.toString();
+ }
+ Assert.assertFalse("Access log line empty after " +
(System.currentTimeMillis() - startWait) + " milliseconds", "".equals(result));
boolean matches = Pattern.matches(resultMatch, result);
if (!matches) {
log.error("Resulting log line '" + result + "' does not match '" +
resultMatch + "'");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]