@Override
  public void cleanup() {
    for ( ServerSocket serverSocket : serverSockets ) {
      try {

        socketRepository.releaseSocket( serverSocket.getLocalPort() );
        logDetailed(
          BaseMessages.getString( PKG, "BaseStep.Log.ReleasedServerSocketOnPort", serverSocket.getLocalPort() ) );
      } catch ( IOException e ) {
        logError( "Cleanup: Unable to release server socket (" + serverSocket.getLocalPort() + ")", e );
      }
    }

    List<RemoteStep> remoteInputSteps = getRemoteInputSteps();
    if ( remoteInputSteps != null ) {
      cleanupRemoteSteps( remoteInputSteps );
    }

    List<RemoteStep> remoteOutputSteps = getRemoteOutputSteps();
    if ( remoteOutputSteps != null ) {
      cleanupRemoteSteps( remoteOutputSteps );
    }
  }
@Test
  public void testCleanup() throws IOException {
    BaseStep baseStep =
      new BaseStep( mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans );
    ServerSocket serverSocketMock = mock( ServerSocket.class );
    doReturn( 0 ).when( serverSocketMock ).getLocalPort();
    baseStep.setServerSockets( Collections.singletonList( serverSocketMock ) );
    SocketRepository socketRepositoryMock = mock( SocketRepository.class );
    baseStep.setSocketRepository( socketRepositoryMock );

    baseStep.cleanup();

    verify( socketRepositoryMock ).releaseSocket( 0 );
  }