Extract assertions on the registry size into a method

This commit is contained in:
Guillaume Nodet
2020-12-10 09:48:38 +01:00
parent e8c39062ab
commit 4c310c5793
4 changed files with 38 additions and 13 deletions

View File

@@ -43,18 +43,24 @@ public class ExtensionsNativeIT {
@Test
void version() throws IOException, InterruptedException {
registry.killAll();
Assertions.assertThat(registry.getAll().size()).isEqualTo(0);
assertDaemonRegistrySize(0);
final TestClientOutput o = new TestClientOutput();
client.execute(o, "-v").assertSuccess();
Assertions.assertThat(registry.getAll().size()).isEqualTo(1);
assertDaemonRegistrySize(1);
DaemonInfo daemon = registry.getAll().iterator().next();
assertTrue(daemon.getOptions().contains("mvnd.coreExtensions=io.takari.aether:takari-local-repository:0.11.3"));
registry.awaitIdle(daemon.getUid());
client.execute(o, "-v").assertSuccess();
Assertions.assertThat(registry.getAll().size()).isEqualTo(1);
assertDaemonRegistrySize(1);
}
private void assertDaemonRegistrySize(int size) {
Assertions.assertThat(registry.getAll().size())
.as("Daemon registry size should be " + size)
.isEqualTo(size);
}
}

View File

@@ -45,7 +45,7 @@ public class NewManagedModuleNativeIT {
@Test
void upgrade() throws IOException, InterruptedException {
Assertions.assertThat(registry.getAll().size()).isEqualTo(0);
assertDaemonRegistrySize(0);
/* Build the initial state of the test project */
final Path parentDir = parameters.getTestDir().resolve("project/parent");
@@ -54,7 +54,7 @@ public class NewManagedModuleNativeIT {
final TestClientOutput output = new TestClientOutput();
cl.execute(output, "clean", "install", "-e", "-B", "-ntp").assertSuccess();
}
Assertions.assertThat(registry.getAll().size()).isEqualTo(1);
assertDaemonRegistrySize(1);
final DaemonInfo d = registry.getAll().get(0);
/* Wait, till the instance becomes idle */
@@ -85,7 +85,12 @@ public class NewManagedModuleNativeIT {
cl.execute(output, "clean", "install", "-e", "-B", "-ntp")
.assertSuccess();
}
Assertions.assertThat(registry.getAll().size()).isEqualTo(1);
assertDaemonRegistrySize(1);
}
private void assertDaemonRegistrySize(int size) {
Assertions.assertThat(registry.getAll().size())
.as("Daemon registry size should be " + size)
.isEqualTo(size);
}
}

View File

@@ -39,11 +39,11 @@ public class StopStatusTest {
void stopStatus() throws IOException, InterruptedException {
/* The registry should be empty before we run anything */
Assertions.assertThat(registry.getAll()).isEmpty();
assertDaemonRegistrySize(0);
client.execute(new TestClientOutput(), "clean").assertSuccess();
/* There should be exactly one item in the registry after the first build */
Assertions.assertThat(registry.getAll().size()).isEqualTo(1);
assertDaemonRegistrySize(1);
final DaemonInfo d = registry.getAll().get(0);
{
@@ -58,11 +58,11 @@ public class StopStatusTest {
client.execute(new TestClientOutput(), "clean").assertSuccess();
/* There should still be exactly one item in the registry after the second build */
Assertions.assertThat(registry.getAll().size()).isEqualTo(1);
assertDaemonRegistrySize(1);
client.execute(new TestClientOutput(), "--stop").assertSuccess();
/* No items in the registry after we have killed all daemons */
Assertions.assertThat(registry.getAll()).isEmpty();
assertDaemonRegistrySize(0);
{
/* After --stop, the output of --status may not contain the UID we have seen before */
@@ -77,4 +77,10 @@ public class StopStatusTest {
}
}
private void assertDaemonRegistrySize(int size) {
Assertions.assertThat(registry.getAll().size())
.as("Daemon registry size should be " + size)
.isEqualTo(size);
}
}

View File

@@ -44,18 +44,20 @@ public class UpgradesInBomNativeIT {
@Test
void upgrade() throws IOException, InterruptedException {
assertDaemonRegistrySize(0);
/* Install the dependencies */
for (String artifactDir : Arrays.asList("project/hello-0.0.1", "project/hello-0.0.2-SNAPSHOT")) {
final Client cl = clientFactory.newClient(parameters.cd(parameters.getTestDir().resolve(artifactDir)));
final TestClientOutput output = new TestClientOutput();
cl.execute(output, "clean", "install", "-e").assertSuccess();
assertDaemonRegistrySize(1);
final DaemonInfo d = registry.getAll().get(0);
/* Wait, till the instance becomes idle */
registry.awaitIdle(d.getUid());
registry.killAll();
}
Assertions.assertThat(registry.getAll().size()).isEqualTo(0);
assertDaemonRegistrySize(0);
/* Build the initial state of the test project */
final Path parentDir = parameters.getTestDir().resolve("project/parent");
@@ -64,7 +66,7 @@ public class UpgradesInBomNativeIT {
final TestClientOutput output = new TestClientOutput();
cl.execute(output, "clean", "install", "-e").assertSuccess();
}
Assertions.assertThat(registry.getAll().size()).isEqualTo(1);
assertDaemonRegistrySize(1);
final DaemonInfo d = registry.getAll().get(0);
/* Wait, till the instance becomes idle */
@@ -83,7 +85,13 @@ public class UpgradesInBomNativeIT {
cl.execute(output, "clean", "install", "-e")
.assertSuccess();
}
Assertions.assertThat(registry.getAll().size()).isEqualTo(1);
assertDaemonRegistrySize(1);
}
private void assertDaemonRegistrySize(int size) {
Assertions.assertThat(registry.getAll().size())
.as("Daemon registry size should be " + size)
.isEqualTo(size);
}
}