return new DefaultProcessCommands(directory, processNumber, false);
}
+ /**
+ * Clears the shared memory space of the specified process number.
+ */
+ public static void reset(File directory, int processNumber) {
+ try (DefaultProcessCommands processCommands = new DefaultProcessCommands(directory, processNumber, true)) {
+ // nothing else to do than open file and reset the space of specified process
+ }
+ }
+
@Override
public boolean isUp() {
return delegate.isUp();
DefaultProcessCommands.main(temp.newFolder(), processNumber);
}
-
@Test
public void main_fails_if_processNumber_is_MAX_PROCESSES() throws Exception {
int processNumber = MAX_PROCESSES;
DefaultProcessCommands.secondary(temp.newFolder(), processNumber);
}
+ @Test
+ public void reset_fails_if_processNumber_is_less_than_0() throws Exception {
+ int processNumber = -2;
+
+ expectProcessNumberNoValidIAE(processNumber);
+
+ DefaultProcessCommands.reset(temp.newFolder(), processNumber);
+ }
+
+ @Test
+ public void reset_fails_if_processNumber_is_higher_than_MAX_PROCESSES() throws Exception {
+ int processNumber = MAX_PROCESSES + 1;
+
+ expectProcessNumberNoValidIAE(processNumber);
+
+ DefaultProcessCommands.reset(temp.newFolder(), processNumber);
+ }
+
private void expectProcessNumberNoValidIAE(int processNumber) {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Process number " + processNumber + " is not valid");