Package org.sonar.wsclient.system

Examples of org.sonar.wsclient.system.Migration


  @Override
  public Migration migrate(long timeoutInMs, long rateInMs) {
    if (rateInMs >= timeoutInMs) {
      throw new IllegalArgumentException("Timeout must be greater than rate");
    }
    Migration migration = null;
    boolean running = true;
    long endAt = System.currentTimeMillis() + timeoutInMs;
    while (running && System.currentTimeMillis() < endAt) {
      migration = migrate();
      if (migration.status() == Migration.Status.MIGRATION_NEEDED ||
        migration.status() == Migration.Status.MIGRATION_RUNNING) {
        sleepQuietly(rateInMs);
      } else {
        running = false;
      }
    }
View Full Code Here


  public void start_migration_asynchronously() {
    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
    httpServer.stubResponseBody(RUNNING_JSON);

    DefaultSystemClient client = new DefaultSystemClient(requestFactory);
    Migration migration = client.migrate();

    assertThat(httpServer.requestedPath()).isEqualTo("/api/server/setup");
    assertThat(migration.status()).isEqualTo(Migration.Status.MIGRATION_RUNNING);
    assertThat(migration.operationalWebapp()).isFalse();
    assertThat(migration.startedAt().getYear()).isEqualTo(113);//2013 = nb of years since 1900
  }
View Full Code Here

  public void stop_synchronous_migration_on_timeout() {
    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
    httpServer.stubResponseBody(RUNNING_JSON);

    DefaultSystemClient client = new DefaultSystemClient(requestFactory);
    Migration migration = client.migrate(50L, 5L);

    assertThat(migration.status()).isEqualTo(Migration.Status.MIGRATION_RUNNING);
    assertThat(migration.operationalWebapp()).isFalse();
  }
View Full Code Here

    when(requestFactory.post(eq("/api/server/setup"), anyMap())).thenReturn(
      RUNNING_JSON, DONE_JSON
    );

    DefaultSystemClient client = new DefaultSystemClient(requestFactory);
    Migration migration = client.migrate(500L, 5L);

    assertThat(migration.status()).isEqualTo(Migration.Status.MIGRATION_SUCCEEDED);
    assertThat(migration.operationalWebapp()).isTrue();
    assertThat(migration.message()).isEqualTo("done");
    assertThat(migration.startedAt()).isNull();
  }
View Full Code Here

TOP

Related Classes of org.sonar.wsclient.system.Migration

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.