예제 #1
0
  static void testStop(TestParams testParams) {
    BaseResult result =
        testParams
            .setEndpoint(StopResource.ENDPOINT)
            .newWebResource()
            .accept(MediaType.APPLICATION_JSON)
            .post(BaseResult.class);

    assertEquals(result.getEndpoint(), StopResource.ENDPOINT);
  }
예제 #2
0
  static void testGet(TestParams testParams) {
    String result =
        testParams
            .setEndpoint(TestGetResource.ENDPOINT_URL)
            .newWebResource()
            .accept(MediaType.TEXT_PLAIN)
            .get(String.class);

    assertEquals(TestGetResource.TEST_MESSAGE, result);
  }
예제 #3
0
  static void testRunnerRegistrySequence(TestParams testParams) {
    /*
     * ------------------------------------------------------------
     * Let's register a runner first before we query for it
     * ------------------------------------------------------------
     */

    String commitId = UUID.randomUUID().toString();
    String hostname = RandomStringUtils.randomAlphabetic(8);

    RunnerBuilder builder = new RunnerBuilder();
    builder
        .setTempDir(".")
        .setServerPort(19023)
        .setUrl("https://localhost:19023")
        .setHostname(hostname)
        .setIpv4Address("127.0.0.1");

    Boolean result =
        testParams
            .addQueryParameters(QUERY_PARAMS)
            .setEndpoint(RunnerRegistryResource.ENDPOINT)
            .newWebResource(null)
            .queryParam(RestParams.COMMIT_ID, commitId)
            .path("/register")
            .type(MediaType.APPLICATION_JSON_TYPE)
            .accept(MediaType.APPLICATION_JSON_TYPE)
            .post(Boolean.class, builder.getRunner());

    assertTrue(result);

    /*
     * ------------------------------------------------------------
     * Let's see if we can get the runner back from the registry
     * ------------------------------------------------------------
     */
    List<Runner> runnerList =
        testParams
            .setEndpoint(RunnerRegistryResource.ENDPOINT)
            .newWebResource(null)
            .queryParam(RestParams.COMMIT_ID, commitId)
            .path("/list")
            .type(MediaType.APPLICATION_JSON_TYPE)
            .accept(MediaType.APPLICATION_JSON_TYPE)
            .get(new GenericType<List<Runner>>() {});

    assertNotNull(runnerList);
    assertEquals(1, runnerList.size());

    Runner runner = runnerList.get(0);
    assertEquals(19023, runner.getServerPort());
    assertEquals("https://localhost:19023", runner.getUrl());
    assertEquals(hostname, runner.getHostname());
    assertEquals("127.0.0.1", runner.getIpv4Address());
    assertEquals(".", runner.getTempDir());

    /*
     * ------------------------------------------------------------
     * Let's unregister the runner from the registry and check
     * ------------------------------------------------------------
     */
    result =
        testParams
            .newWebResource(null)
            .queryParam(RestParams.RUNNER_URL, runner.getUrl())
            .path("/unregister")
            .type(MediaType.APPLICATION_JSON_TYPE)
            .accept(MediaType.APPLICATION_JSON_TYPE)
            .post(Boolean.class);

    assertTrue(result);

    /*
     * ------------------------------------------------------------
     * Let's make sure we do NOT get the runner from the registry
     * ------------------------------------------------------------
     */
    runnerList.clear();
    runnerList =
        testParams
            .setEndpoint(RunnerRegistryResource.ENDPOINT)
            .newWebResource(null)
            .queryParam(RestParams.COMMIT_ID, commitId)
            .path("/list")
            .type(MediaType.APPLICATION_JSON_TYPE)
            .accept(MediaType.APPLICATION_JSON_TYPE)
            .get(new GenericType<List<Runner>>() {});

    assertNotNull(runnerList);
    assertEquals(0, runnerList.size());
  }