Package org.sonar.process.test

Examples of org.sonar.process.test.StandardProcess


  public void launch_then_request_graceful_stop() throws Exception {
    Props props = new Props(new Properties());
    props.set(ProcessEntryPoint.PROPERTY_PROCESS_KEY, "test");
    props.set(ProcessEntryPoint.PROPERTY_TERMINATION_TIMEOUT, "30000");
    final ProcessEntryPoint entryPoint = new ProcessEntryPoint(props, exit, mock(ProcessCommands.class));
    final StandardProcess process = new StandardProcess();

    Thread runner = new Thread() {
      @Override
      public void run() {
        // starts and waits until terminated
        entryPoint.launch(process);
      }
    };
    runner.start();

    while (process.getState() != State.STARTED) {
      Thread.sleep(10L);
    }

    // requests for graceful stop -> waits until down
    // Should terminate before the timeout of 30s
    entryPoint.stop();

    assertThat(process.getState()).isEqualTo(State.STOPPED);
  }
View Full Code Here


  public void terminate_if_unexpected_shutdown() throws Exception {
    Props props = new Props(new Properties());
    props.set(ProcessEntryPoint.PROPERTY_PROCESS_KEY, "foo");
    props.set(ProcessEntryPoint.PROPERTY_TERMINATION_TIMEOUT, "30000");
    final ProcessEntryPoint entryPoint = new ProcessEntryPoint(props, exit, mock(ProcessCommands.class));
    final StandardProcess process = new StandardProcess();

    Thread runner = new Thread() {
      @Override
      public void run() {
        // starts and waits until terminated
        entryPoint.launch(process);
      }
    };
    runner.start();
    while (process.getState() != State.STARTED) {
      Thread.sleep(10L);
    }

    // emulate signal to shutdown process
    entryPoint.getShutdownHook().start();
    while (process.getState() != State.STOPPED) {
      Thread.sleep(10L);
    }
    // exit before test timeout, ok !
  }
View Full Code Here

TOP

Related Classes of org.sonar.process.test.StandardProcess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.