public static ExitCode fromCode(final int code) { for (final ExitCode each : values()) { if (each.getCode() == code) { return each; } } return UNKNOWN_ERROR; }
public synchronized void end(final ExitCode exitCode) { this.dos.writeByte(Id.DONE); this.dos.writeInt(exitCode.getCode()); this.dos.flush(); }
@Override public synchronized void done(final ExitCode exitCode) { this.w.writeByte(Id.DONE); this.w.writeInt(exitCode.getCode()); this.w.flush(); }
System.exit(exitCode.getCode());
private void mockClientSocketToSendExitCode(final ExitCode timeout) throws IOException { final SafeDataOutputStream dos = new SafeDataOutputStream(this.o); dos.writeByte(Id.DONE); dos.writeInt(timeout.getCode()); mockClientSocketInputStream(); }
@Test public void shouldPassCommandsToReceiver() throws Exception { final SafeDataOutputStream dos = new SafeDataOutputStream(this.o); dos.writeByte(Id.DESCRIBE); dos.writeByte(Id.DONE); dos.writeInt(ExitCode.OK.getCode()); mockClientSocketInputStream(); this.testee.call(); verify(this.receiveStrategy, times(1)).apply(anyByte(), any(SafeDataInputStream.class)); }
@Test public void shouldSendExitCode() { this.testee.done(ExitCode.TIMEOUT); final SafeDataInputStream is = resultToStream(); assertEquals(Id.DONE, is.readByte()); assertEquals(is.readInt(), ExitCode.TIMEOUT.getCode()); }
public static ExitCode fromCode(final int code) { for (final ExitCode each : values()) { if (each.getCode() == code) { return each; } } return UNKNOWN_ERROR; }
public synchronized void end(final ExitCode exitCode) { this.dos.writeByte(Id.DONE); this.dos.writeInt(exitCode.getCode()); this.dos.flush(); }
@Override public synchronized void done(final ExitCode exitCode) { this.w.writeByte(Id.DONE); this.w.writeInt(exitCode.getCode()); this.w.flush(); }
System.exit(exitCode.getCode());