maxConcurrentDownloads in ConcurrentDownloadsTest can also be 1 when the downloads are fast

This commit is contained in:
Peter Palaga
2021-01-22 13:56:24 +01:00
parent 69092513a6
commit 786430ebc0

View File

@@ -26,7 +26,7 @@ import org.mvndaemon.mvnd.common.Message;
import org.mvndaemon.mvnd.junit.MvndTest;
import org.mvndaemon.mvnd.junit.TestUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@MvndTest(projectDir = "src/test/projects/concurrent-downloads")
public class ConcurrentDownloadsTest {
@@ -45,7 +45,7 @@ public class ConcurrentDownloadsTest {
final TestClientOutput o = new TestClientOutput();
client.execute(o, "clean", "install", "-e", "-B").assertSuccess();
int maxCur = 0;
int maxConcurrentDownloads = 0;
int cur = 0;
for (Message m : o.getMessages()) {
if (m instanceof Message.TransferEvent) {
@@ -54,14 +54,16 @@ public class ConcurrentDownloadsTest {
if (resource.contains("apache-camel") || resource.contains("apache-activemq")) {
if (m.getType() == Message.TRANSFER_STARTED) {
cur++;
maxCur = Math.max(cur, maxCur);
maxConcurrentDownloads = Math.max(cur, maxConcurrentDownloads);
} else if (m.getType() == Message.TRANSFER_SUCCEEDED) {
cur--;
}
}
}
}
assertEquals(2, maxCur);
assertTrue(maxConcurrentDownloads >= 1 && maxConcurrentDownloads <= 2,
"The maximum number of concurrent downloads (actual: " + maxConcurrentDownloads
+ ") must fulfil the condition maxConcurrentDownloads >= 1 && maxConcurrentDownloads <= 2");
}
}