コード例 #1
0
 @Before
 public void replaceServers() throws Exception {
   final int proxyPort = proxyServer.getPort();
   proxyServer.stop();
   proxyServer = null;
   server =
       Server.withPort(proxyPort)
           .serve("/")
           .withBehaviours(Behaviours.pause(Time.days(1)))
           .start();
 }
コード例 #2
0
  @Override
  public void waitForAllTasksToStop(final Time timeout, final Time window) {
    try {
      Time actualTimeout = timeout;
      if (actualTimeout == null) {
        actualTimeout = Time.minutes(1);
      }

      Time actualWindow = window;
      if (actualWindow == null) {
        actualWindow = Time.seconds(10);
      }

      LOG.info(
          "Waiting for Nexus to not execute any task for {} (timeouts in {})",
          actualWindow.toString(),
          actualTimeout.toString());

      final MultivaluedMap<String, String> params = new MultivaluedMapImpl();
      params.add("timeout", String.valueOf(actualTimeout.toMillis()));
      params.add("window", String.valueOf(actualWindow.toMillis()));

      final ClientResponse response =
          getNexusClient().serviceResource("tasks/waitFor", params).get(ClientResponse.class);

      response.close();

      if (Response.Status.ACCEPTED.getStatusCode() == response.getStatus()) {
        throw new TasksAreStillRunningException(actualTimeout);
      } else if (!response
          .getClientResponseStatus()
          .getFamily()
          .equals(Response.Status.Family.SUCCESSFUL)) {
        throw getNexusClient().convert(new UniformInterfaceException(response));
      }
    } catch (ClientHandlerException e) {
      throw getNexusClient().convert(e);
    } catch (UniformInterfaceException e) {
      throw getNexusClient().convert(e);
    }
  }