Skip to content

Commit

Permalink
test: Fix RemoteRegistryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
kohlschuetter committed Jul 27, 2023
1 parent 978b084 commit 73abb13
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,16 @@ protected int shutdownAfterSecs() {

assertThrows(ServerException.class, () -> sra.getRegistry().getNaming().shutdownRegistry());

sra.shutdownAndWait(true);
sra.shutdownAndWait(false);
if (!awaitNoRMIFiles(socketDir, 5)) {
sra.shutdownAndWait(true);
}
} catch (Exception e) {
throw e;
}

int count;
int loops = 10;
do {
count = countRMIFiles(socketDir);
if (count == 0) {
break;
}
Thread.sleep(100);
} while (loops-- > 0);

assertEquals(0, count, "There shouldn't be any RMI socket files in " + socketDir);
assertTrue(awaitNoRMIFiles(socketDir, 5), "There shouldn't be any RMI socket files in "
+ socketDir);
} finally {
for (File d : socketDir.listFiles()) {
d.delete();
Expand All @@ -150,6 +144,19 @@ protected int shutdownAfterSecs() {
}
}

private boolean awaitNoRMIFiles(File socketDir, int loops) {
int count;
do {
count = countRMIFiles(socketDir);
if (count == 0) {
return true;
}
Thread.sleep(100);
} while (loops-- > 0);

return count == 0;
}

private void tryToSayHello(SpawnedRegistryAccess sra) throws Exception {
AFRegistry registry = sra.getRegistry();
assertNotNull(registry, "Could not access the AFUNIXRegistry created by the forked VM");
Expand Down

0 comments on commit 73abb13

Please sign in to comment.