Merge remote-tracking branch 'origin/fix/jetty-10-home-with-docs-awaitility' into fix/jetty-10-home-with-docs

# Conflicts:
#	tests/jetty-home-tester/src/main/java/org/eclipse/jetty/tests/hometester/JettyHomeTester.java
This commit is contained in:
Joakim Erdfelt 2022-11-16 08:30:16 -06:00
commit f9b8d50a2e
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
2 changed files with 21 additions and 17 deletions

View File

@ -23,6 +23,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-resolver-provider</artifactId>
@ -32,6 +33,10 @@
<artifactId>maven-resolver-util</artifactId>
<version>${maven.resolver.version}</version>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>

View File

@ -42,6 +42,8 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.awaitility.core.ConditionTimeoutException;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.AbstractRepositoryListener;
import org.eclipse.aether.DefaultRepositorySystemSession;
@ -68,6 +70,8 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.awaitility.Awaitility.await;
/**
* <p>Helper class to test the Jetty Distribution</p>.
* <p>API can change without any further notice.</p>
@ -569,16 +573,15 @@ public class JettyHomeTester
*/
public boolean awaitConsoleLogsFor(String txt, long time, TimeUnit unit) throws InterruptedException
{
long end = System.currentTimeMillis() + unit.toMillis(time);
while (System.currentTimeMillis() < end)
try
{
boolean result = logs.stream().anyMatch(s -> s.contains(txt));
if (result)
return true;
//noinspection BusyWait
Thread.sleep(250);
await().atMost(time, unit).until(() -> logs.stream().anyMatch(s -> s.contains(txt)));
return true;
}
catch (ConditionTimeoutException e)
{
return false;
}
return false;
}
/**
@ -598,15 +601,11 @@ public class JettyHomeTester
thread.start();
try
{
long end = System.currentTimeMillis() + unit.toMillis(time);
while (System.currentTimeMillis() < end)
{
boolean result = logs.stream().anyMatch(s -> s.contains(txt));
if (result)
return true;
//noinspection BusyWait
Thread.sleep(250);
}
await().atMost(time, unit).until(() -> logs.stream().anyMatch(s -> s.contains(txt)));
return true;
}
catch (ConditionTimeoutException e)
{
return false;
}
finally