io.restassured.builder.ResponseBuilder Java Examples

The following examples show how to use io.restassured.builder.ResponseBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YamlToJsonFilter.java    From microprofile-open-api with Apache License 2.0 6 votes vote down vote up
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
    try {
        Response response = ctx.next(requestSpec, responseSpec);

        ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
        Object obj = yamlReader.readValue(response.getBody().asString(), Object.class);

        ObjectMapper jsonWriter = new ObjectMapper();
        String json = jsonWriter.writeValueAsString(obj);

        ResponseBuilder builder = new ResponseBuilder();
        builder.clone(response);
        builder.setBody(json);
        builder.setContentType(ContentType.JSON);

        return builder.build();
    }
    catch (Exception e) {
        throw new IllegalStateException("Failed to convert the request: " + ExceptionUtils.getMessage(e), e);
    }
}
 
Example #2
Source File: PlaceholderHandlerTest.java    From heat with Apache License 2.0 6 votes vote down vote up
private Response buildResponse() {
    ResponseBuilder rspBuilder = new ResponseBuilder();
    rspBuilder.setStatusCode(200);
    rspBuilder.setBody("{\"field_path\":\"field_value\",\"array1\":[{\"array_field1\":\"array_field_value1\"}]}");

    List<Header> headerList = new ArrayList();
    Header header1 = new Header("test_header", "test_value");
    Header header2 = new Header("test_header2", "test_value2");
    headerList.add(header1);
    headerList.add(header2);
    Headers headers = new Headers(headerList);
    rspBuilder.setHeaders(headers);

    List<Cookie> cookieList = new ArrayList();
    Cookie cookie1 = new Cookie.Builder("test_cookie", "test_value").build();
    Cookie cookie2 = new Cookie.Builder("test_cookie2", "test_value2").build();
    cookieList.add(cookie1);
    cookieList.add(cookie2);
    Cookies cookies = new Cookies(cookieList);
    rspBuilder.setCookies(cookies);

    return rspBuilder.build();
}
 
Example #3
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(48)
public void testApplicationSimpleTimerUnitOpenMetrics() {

    String prefix = "org_eclipse_microprofile_metrics_test_MetricAppBean_simpleTimeMeA_";
    
    Response resp = given().header("Accept", TEXT_PLAIN).
            get("/metrics/application/org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA");
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
            
    resp.then().statusCode(200)
        .and()
        .body(containsString("# TYPE application_" + prefix + "total counter"))
        .body(containsString(prefix + "total"))
        .body(containsString(prefix + "elapsedTime_seconds"))
        .body(containsString(prefix + "maxTimeDuration_seconds"))
        .body(containsString(prefix + "minTimeDuration_seconds"))
    ;
}
 
Example #4
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
/**
 * Test that semicolons `;` in tag values are translated to underscores `_`
 * in the JSON output
 */
@Test
@RunAsClient
@InSequence(46)
public void testTranslateSemiColonToUnderScoreJSON() {
    Header wantJson = new Header("Accept", APPLICATION_JSON);
    Response resp = given().header(wantJson).get("/metrics/application");
    JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify()));
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filteredJSONPath.prettify());
    resp = responseBuilder.build();
    
    resp.then().statusCode(200)
        .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.semiColonTaggedCounter;"
                + "scTag=semi_colons_are_bad;tier=integration'", equalTo(0));
}
 
Example #5
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(7)
public void testBaseAttributeJson() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantJson = new Header("Accept", APPLICATION_JSON);
    
    Response resp = given().header(wantJson).get("/metrics/base/thread.max.count");
    JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify()));
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filteredJSONPath.prettify());
    resp = responseBuilder.build();
    resp.then().statusCode(200).and()
            .contentType(MpMetricTest.APPLICATION_JSON).and().body(containsString("thread.max.count;tier=integration"));
}
 
Example #6
Source File: ReusedMetricsTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(4)
public void testSharedCounterAgain() {

  Header acceptJson = new Header("Accept", APPLICATION_JSON);

  Response resp = given().header(acceptJson).get("/metrics/application");
  JsonPath filteredJSONPath = new JsonPath(resp.jsonPath().prettify().replaceAll(JSON_APP_LABEL_REGEX, JSON_APP_LABEL_REGEXS_SUB));
  ResponseBuilder responseBuilder = new ResponseBuilder();
  responseBuilder.clone(resp);
  responseBuilder.setBody(filteredJSONPath.prettify());
  resp = responseBuilder.build();

  resp.then()
  .assertThat().body("'countMe2;tier=integration'", equalTo(2))
  .assertThat().body("'org.eclipse.microprofile.metrics.test.MetricAppBean2.meterMe2'.'count;tier=integration'", equalTo(2))
  .assertThat().body("'timeMe2'.'count;tier=integration'", equalTo(2))
  .assertThat().body("'simplyTimeMe2'.'count;tier=integration'", equalTo(2));


}
 
Example #7
Source File: ReusedMetricsTest.java    From microprofile-metrics with Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(2)
  public void testSharedCounter() {

      Header acceptJson = new Header("Accept", APPLICATION_JSON);

      Response resp = given().header(acceptJson).get("/metrics/application");
      JsonPath filteredJSONPath = new JsonPath(resp.jsonPath().prettify().replaceAll(JSON_APP_LABEL_REGEX, JSON_APP_LABEL_REGEXS_SUB));
      ResponseBuilder responseBuilder = new ResponseBuilder();
      responseBuilder.clone(resp);
      responseBuilder.setBody(filteredJSONPath.prettify());
      resp = responseBuilder.build();

      resp.then()
              .assertThat().body("'countMe2;tier=integration'", equalTo(1))
              .assertThat().body("'org.eclipse.microprofile.metrics.test.MetricAppBean2.meterMe2'.'count;tier=integration'", equalTo(1))
              .assertThat().body("'timeMe2'.'count;tier=integration'", equalTo(1))
              .assertThat().body("'simplyTimeMe2'.'count;tier=integration'", equalTo(1));

}
 
Example #8
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(1)
public void testSimpleRESTGet() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
    when().
    get(contextRoot+"/get-noparam").
    then().
        statusCode(200);

   Response resp = given().header(acceptHeader).when().get(METRICS_ENDPOINT);
   ResponseBuilder responseBuilder = new ResponseBuilder();
   responseBuilder.clone(resp);
   responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
   resp = responseBuilder.build();
   resp.then().
       statusCode(200).
       contentType(TEXT_PLAIN).
       body(containsString(OM_BASE_REQUEST_COUNT_START + "getNoParam" + OM_BASE_REQUEST_END)
               , containsString(OM_BASE_REQUEST_TIME_START + "getNoParam" + OM_BASE_REQUEST_END)
               , containsString(OM_BASE_MAX_TIME_START + "getNoParam" + OM_BASE_REQUEST_END)
               , containsString(OM_BASE_MIN_TIME_START + "getNoParam" + OM_BASE_REQUEST_END));
}
 
Example #9
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(30)
public void testNonStandardUnitsOpenMetrics() {

    String prefix = "jellybeanHistogram_";
    Header wantOpenMetricsFormat = new Header("Accept", TEXT_PLAIN);
    
    Response resp = given().header(wantOpenMetricsFormat).get("/metrics/application/jellybeanHistogram");
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    
    
    resp.then().statusCode(200)
    .and()
    .body(containsString(prefix + "jellybeans_count"))
    .body(containsString("# TYPE application_" + prefix + "jellybeans summary"))
    .body(containsString(prefix + "mean_jellybeans"))
    .body(containsString(prefix + "min_jellybeans"))
    .body(containsString(prefix + "max_jellybeans"))
    .body(containsString(prefix + "stddev_jellybeans"))
    .body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.5\"}"))
    .body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.75\"}"))
    .body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.95\"}"))
    .body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.98\"}"))
    .body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.99\"}"))
    .body(containsString(prefix + "jellybeans{tier=\"integration\",quantile=\"0.999\"}"));
}
 
Example #10
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(26)
public void testApplicationHistogramUnitNoneOpenMetrics() {

    String prefix = "metricTest_test1_histogram2";

    Response resp = given().header("Accept", TEXT_PLAIN).get("/metrics/application/metricTest.test1.histogram2");
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    
    resp.then().statusCode(200)
        .and()
        .body(containsString(prefix + "_count"))
        .body(containsString("# TYPE application_" + prefix + " summary"))
        .body(containsString(prefix + "_mean"))
        .body(containsString(prefix + "_min"))
        .body(containsString(prefix + "_max"))
        .body(containsString(prefix + "_stddev"))
        .body(containsString(prefix + "{tier=\"integration\",quantile=\"0.5\"}"))
        .body(containsString(prefix + "{tier=\"integration\",quantile=\"0.75\"}"))
        .body(containsString(prefix + "{tier=\"integration\",quantile=\"0.95\"}"))
        .body(containsString(prefix + "{tier=\"integration\",quantile=\"0.98\"}"))
        .body(containsString(prefix + "{tier=\"integration\",quantile=\"0.99\"}"))
        .body(containsString(prefix + "{tier=\"integration\",quantile=\"0.999\"}"))
    ;
}
 
Example #11
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(25)
public void testApplicationHistogramUnitBytesOpenMetrics() {

    String prefix = "metricTest_test1_histogram_";

    Response resp = given().header("Accept", TEXT_PLAIN).get("/metrics/application/metricTest.test1.histogram");
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    
    resp.then().statusCode(200)
        .and()
        .body(containsString(prefix + "bytes_count"))
        .body(containsString("# TYPE application_" + prefix + "bytes summary"))
        .body(containsString(prefix + "mean_bytes"))
        .body(containsString(prefix + "min_bytes"))
        .body(containsString(prefix + "max_bytes"))
        .body(containsString(prefix + "stddev_bytes"))
        .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.5\"}"))
        .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.75\"}"))
        .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.95\"}"))
        .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.98\"}"))
        .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.99\"}"))
        .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.999\"}"))
    ;
}
 
Example #12
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(24)
public void testApplicationTimerUnitOpenMetrics() {

    String prefix = "org_eclipse_microprofile_metrics_test_MetricAppBean_timeMeA_";
    
    Response resp = given().header("Accept", TEXT_PLAIN).get("/metrics/application/org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA");
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
            
    resp.then().statusCode(200)
        .and()
        .body(containsString("# TYPE application_" + prefix + "seconds summary"))
        .body(containsString(prefix + "seconds_count"))
        .body(containsString(prefix + "rate_per_second"))
        .body(containsString(prefix + "one_min_rate_per_second"))
        .body(containsString(prefix + "five_min_rate_per_second"))
        .body(containsString(prefix + "fifteen_min_rate_per_second"))
        .body(containsString(prefix + "elapsedTime"))
        .body(containsString(prefix + "mean_seconds"))
        .body(containsString(prefix + "min_seconds"))
        .body(containsString(prefix + "max_seconds"))
        .body(containsString(prefix + "stddev_second"))
        .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.5\"}"))
        .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.75\"}"))
        .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.95\"}"))
        .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.98\"}"))
        .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.99\"}"))
        .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.999\"}"))
    ;
}
 
Example #13
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(9)
public void testBaseAttributeOpenMetrics() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Response resp = given().header("Accept", TEXT_PLAIN).get("/metrics/base/thread.max.count");
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().statusCode(200).and()
    .contentType(TEXT_PLAIN).and().body(containsString("# TYPE base_thread_max_count"),
            containsString("base_thread_max_count{tier=\"integration\"}"));
}
 
Example #14
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(6)
public void testBaseOpenMetrics() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Response resp = given().header("Accept", TEXT_PLAIN).get("/metrics/base");
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().statusCode(200).and().contentType(TEXT_PLAIN).and()
        .body(containsString("# TYPE base_thread_max_count"), containsString("base_thread_max_count{tier=\"integration\"}"));
}
 
Example #15
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(5)
public void testBase() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Response resp = given().header("Accept", APPLICATION_JSON).get("/metrics/base");
    JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify()));
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filteredJSONPath.prettify());
    resp = responseBuilder.build();
    
    resp.then().statusCode(200).and()
        .contentType(MpMetricTest.APPLICATION_JSON).and().body(containsString("thread.max.count;tier=integration"));        
}
 
Example #16
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(13)
public void testGetNameObject() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
    when().
         get(contextRoot+"/get-name-object").
    then().
        statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(TEXT_PLAIN).
        body(containsString(OM_BASE_REQUEST_COUNT_START + "getNameObject" + NAME_OBJECT_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "getNameObject" + NAME_OBJECT_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "getNameObject" + NAME_OBJECT_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "getNameObject" + NAME_OBJECT_PARAM + OM_BASE_REQUEST_END));

}
 
Example #17
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(7)
public void testDeleteNoParam() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
    when().
         delete(contextRoot+"/delete-noparam").
    then().
        statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(TEXT_PLAIN).
        body(containsString(OM_BASE_REQUEST_COUNT_START + "deleteNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "deleteNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "deleteNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "deleteNoParam" + OM_BASE_REQUEST_END));

}
 
Example #18
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(6)
public void testSimpleRESTPost() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
    when().
         post(contextRoot+"/post-noparam").
    then().
        statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(TEXT_PLAIN).
        body(containsString(OM_BASE_REQUEST_COUNT_START + "postNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "postNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "postNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "postNoParam" + OM_BASE_REQUEST_END));

}
 
Example #19
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(5)
public void testSimpleRESTPut() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
    when().
         put(contextRoot+"/put-noparam").
    then().
        statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(TEXT_PLAIN).
        body(containsString(OM_BASE_REQUEST_COUNT_START + "putNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "putNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "putNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "putNoParam" + OM_BASE_REQUEST_END));
}
 
Example #20
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(4)
public void testSimpleRESTHead() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
    when().
         head(contextRoot+"/head-noparam").
    then().
        statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(TEXT_PLAIN).
        body(containsString(OM_BASE_REQUEST_COUNT_START + "headNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "headNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "headNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "headNoParam" + OM_BASE_REQUEST_END));

}
 
Example #21
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(3)
public void testSimpleRESTOptions() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
    when().
         options(contextRoot+"/options-noparam").
    then().
        statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(TEXT_PLAIN).
        body(containsString(OM_BASE_REQUEST_COUNT_START + "optionsNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "optionsNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "optionsNoParam" + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "optionsNoParam" + OM_BASE_REQUEST_END));

}
 
Example #22
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 5 votes vote down vote up
@Test
   @RunAsClient
   @InSequence(2)
   public void testSimpleRESTGetExplicit() throws InterruptedException {
       Header acceptHeader = new Header("Accept", TEXT_PLAIN);


       given().
            header(acceptHeader).
            port(applicationPort).
       when().
       get(contextRoot+"/get-noparam").
       then().
           statusCode(200);
      /*
       * Explicitly hitting /metrics/base/REST.request from now on
       */
       Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
       ResponseBuilder responseBuilder = new ResponseBuilder();
       responseBuilder.clone(resp);
       responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
       resp = responseBuilder.build();
       resp.then().
       statusCode(200).
       contentType(TEXT_PLAIN).
       body(containsString(OM_BASE_REQUEST_COUNT_START + "getNoParam" + OM_BASE_REQUEST_END +" 2")
               , containsString(OM_BASE_REQUEST_TIME_START + "getNoParam" + OM_BASE_REQUEST_END)
               , containsString(OM_BASE_MAX_TIME_START + "getNoParam" + OM_BASE_REQUEST_END)
               , containsString(OM_BASE_MIN_TIME_START + "getNoParam" + OM_BASE_REQUEST_END));
}
 
Example #23
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 4 votes vote down vote up
@Test
@RunAsClient
@InSequence(16)
public void testValidateGetJSONnoParam() throws InterruptedException {
    Header acceptHeader = new Header("Accept", APPLICATION_JSON);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify()));
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filteredJSONPath.prettify());
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(APPLICATION_JSON)
        .body(JSON_BASE_REQUEST_COUNT_START +"getNoParam"+JSON_BASE_REQUEST_END, equalTo(2))  //end-point was hit twice
        .body(JSON_BASE_REQUEST_TIME_START +"getNoParam"+JSON_BASE_REQUEST_END, not(0))
        .body(JSON_BASE_MAX_TIME_START +"getNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())
        .body(JSON_BASE_MIN_TIME_START +"getNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())

        .body(JSON_BASE_REQUEST_COUNT_START +"optionsNoParam"+JSON_BASE_REQUEST_END, equalTo(1))
        .body(JSON_BASE_REQUEST_TIME_START +"optionsNoParam"+JSON_BASE_REQUEST_END, not(0))
        .body(JSON_BASE_MAX_TIME_START +"optionsNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())
        .body(JSON_BASE_MIN_TIME_START +"optionsNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())

        .body(JSON_BASE_REQUEST_COUNT_START +"headNoParam"+JSON_BASE_REQUEST_END, equalTo(1))
        .body(JSON_BASE_REQUEST_TIME_START +"headNoParam"+JSON_BASE_REQUEST_END, not(0))
        .body(JSON_BASE_MAX_TIME_START +"headNoParam"+JSON_BASE_REQUEST_END,nullOrGreaterThanZero())
        .body(JSON_BASE_MIN_TIME_START +"headNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())

        .body(JSON_BASE_REQUEST_COUNT_START +"putNoParam"+JSON_BASE_REQUEST_END, equalTo(1))
        .body(JSON_BASE_REQUEST_TIME_START +"putNoParam"+JSON_BASE_REQUEST_END, not(0))
        .body(JSON_BASE_MAX_TIME_START +"putNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())
        .body(JSON_BASE_MIN_TIME_START +"putNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())

        .body(JSON_BASE_REQUEST_COUNT_START +"postNoParam"+JSON_BASE_REQUEST_END, equalTo(1))
        .body(JSON_BASE_REQUEST_TIME_START +"postNoParam"+JSON_BASE_REQUEST_END, not(0))
        .body(JSON_BASE_MAX_TIME_START +"postNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())
        .body(JSON_BASE_MIN_TIME_START +"postNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())

        .body(JSON_BASE_REQUEST_COUNT_START +"deleteNoParam"+JSON_BASE_REQUEST_END, equalTo(1))
        .body(JSON_BASE_REQUEST_TIME_START +"deleteNoParam"+JSON_BASE_REQUEST_END, not(0))
        .body(JSON_BASE_MAX_TIME_START +"deleteNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero())
        .body(JSON_BASE_MIN_TIME_START +"deleteNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero());

}
 
Example #24
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 4 votes vote down vote up
@Test
@RunAsClient
@InSequence(12)
public void testGetMultiParam() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
         queryParam("qp1", true).
         queryParam("qp2", 1).
         queryParam("qp3", 1.0).
         queryParam("qp4", "a").
         queryParam("qp5", 1L).
    when().
         get(contextRoot+"/get-multiple-param1").
    then().
        statusCode(200);

    given().
        header(acceptHeader).
        port(applicationPort).
        queryParam("qp1", "a").
        queryParam("qp2", Arrays.asList("b", "c"))
    .when()
        .get(contextRoot + "/get-multiple-param2")
    .then()
        .statusCode(200);

    given()
        .header(acceptHeader).
        port(applicationPort).
        queryParam("qp1", true).
        queryParam("qp2", false).
        queryParam("qp3", 1.0).
        queryParam("qp4", Arrays.asList("a","b", "c"))
    .when()
            .get(contextRoot + "/get-multiple-param3")
    .then()
        .statusCode(200);

    given().
        header(acceptHeader).
        port(applicationPort).
        queryParam("qp1", Arrays.asList("a","b", "c")).
        queryParam("qp1", Arrays.asList("x","y", "z")).
        queryParam("qp3", Arrays.asList(1.0,2.0,3.0)).
   when()
        .get(contextRoot + "/get-multiple-param4")
   .then()
       .statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(TEXT_PLAIN).
        body(containsString(OM_BASE_REQUEST_COUNT_START + "getMultipleParam1"
                    + BOOLEAN_PARAM + INT_PARAM + DOUBLE_PARAM + STRING_PARAM + LONG_PARAM + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getMultipleParam1"
                    + BOOLEAN_PARAM + INT_PARAM + DOUBLE_PARAM + STRING_PARAM + LONG_PARAM + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getMultipleParam1"
                    + BOOLEAN_PARAM + INT_PARAM + DOUBLE_PARAM + STRING_PARAM + LONG_PARAM + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getMultipleParam1"
                    + BOOLEAN_PARAM + INT_PARAM + DOUBLE_PARAM + STRING_PARAM + LONG_PARAM + OM_BASE_REQUEST_END)

            , containsString(OM_BASE_REQUEST_COUNT_START + "getMultipleParam2"
                    + STRING_PARAM + LIST_PARAM +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getMultipleParam2"
                    + STRING_PARAM + LIST_PARAM +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getMultipleParam2"
                    + STRING_PARAM + LIST_PARAM +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getMultipleParam2"
                    + STRING_PARAM + LIST_PARAM +  OM_BASE_REQUEST_END)

            , containsString(OM_BASE_REQUEST_COUNT_START + "getMultipleParam3"
                    + BOOLEAN_PARAM + BOOLEANW_PARAM + DOUBLE_PARAM + STRING_PARAM +ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getMultipleParam3"
                    + BOOLEAN_PARAM + BOOLEANW_PARAM + DOUBLE_PARAM + STRING_PARAM +ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getMultipleParam3"
                    + BOOLEAN_PARAM + BOOLEANW_PARAM + DOUBLE_PARAM + STRING_PARAM +ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getMultipleParam3"
                    + BOOLEAN_PARAM + BOOLEANW_PARAM + DOUBLE_PARAM + STRING_PARAM +ARRAY_BRACKETS + OM_BASE_REQUEST_END)

            , containsString(OM_BASE_REQUEST_COUNT_START + "getMultipleParam4"
                    + SET_PARAM + SORTED_SET_PARAM + DOUBLE_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getMultipleParam4"
                    + SET_PARAM + SORTED_SET_PARAM + DOUBLE_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getMultipleParam4"
                    + SET_PARAM + SORTED_SET_PARAM + DOUBLE_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getMultipleParam4"
                    + SET_PARAM + SORTED_SET_PARAM + DOUBLE_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END));

}
 
Example #25
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 4 votes vote down vote up
@Test
@RunAsClient
@InSequence(11)
public void testGetArrayVarargParams() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
         queryParam("qp1", Arrays.asList(true, false)).
    when().
         get(contextRoot+"/get-vararg-param1").
    then().
        statusCode(200);

    given().
        header(acceptHeader).
        port(applicationPort).
        queryParam("qp1", Arrays.asList(1, 2)).
        queryParam("qp2", Arrays.asList("a", "b"))
    .when()
        .get(contextRoot + "/get-vararg-param2")
    .then()
        .statusCode(200);

    given().
        header(acceptHeader).
        port(applicationPort).
        queryParam("qp1", Arrays.asList("a","b"))
    .when()
            .get(contextRoot + "/get-array-param1")
    .then()
        .statusCode(200);

    given().
        header(acceptHeader).
        port(applicationPort).
        queryParam("qp1", Arrays.asList(1, 2))
   .when()
        .get(contextRoot + "/get-array-param2")
   .then()
       .statusCode(200);

    given().
        header(acceptHeader).
        port(applicationPort).
        queryParam("qp1", Arrays.asList(1.0, 2.0))
    .when()
        .get(contextRoot + "/get-array-param3")
    .then()
       .statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(TEXT_PLAIN).
        body(containsString(OM_BASE_REQUEST_COUNT_START + "getVarargParam1" + BOOLEANW_PARAM + ARRAY_BRACKETS +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getVarargParam1" + BOOLEANW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getVarargParam1" + BOOLEANW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getVarargParam1" + BOOLEANW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)

            , containsString(OM_BASE_REQUEST_COUNT_START + "getVarargParam2"
                    + INT_PARAM + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getVarargParam2"
                    + INT_PARAM + STRING_PARAM + ARRAY_BRACKETS +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getVarargParam2"
                    + INT_PARAM + STRING_PARAM + ARRAY_BRACKETS +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getVarargParam2"
                    + INT_PARAM + STRING_PARAM + ARRAY_BRACKETS +  OM_BASE_REQUEST_END)

            , containsString(OM_BASE_REQUEST_COUNT_START + "getArrayParam1" + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getArrayParam1" + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getArrayParam1" + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getArrayParam1" + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)

            , containsString(OM_BASE_REQUEST_COUNT_START + "getArrayParam2" + INT_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getArrayParam2" + INT_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getArrayParam2" + INT_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getArrayParam2" + INT_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)

            , containsString(OM_BASE_REQUEST_COUNT_START + "getArrayParam3" + DOUBLEW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getArrayParam3" + DOUBLEW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getArrayParam3" + DOUBLEW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getArrayParam3" + DOUBLEW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END));

}
 
Example #26
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 4 votes vote down vote up
@Test
@RunAsClient
@InSequence(10)
public void testGetListParam() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
         queryParam("qp1", Arrays.asList("a","b","c")).
    when().
         get(contextRoot+"/get-list-param1").
    then().
        statusCode(200);

    given().
        header(acceptHeader).
        port(applicationPort).
        queryParam("qp1", Arrays.asList(1, 2))
    .when()
        .get(contextRoot + "/get-list-param2")
    .then()
        .statusCode(200);

    given().
        header(acceptHeader).
        port(applicationPort).
        queryParam("qp1", Arrays.asList(1.0, 2.0)).
        queryParam("qp2", Arrays.asList(1L, 2L))
    .when()
            .get(contextRoot + "/get-list-param3")
    .then()
        .statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
    statusCode(200).
    contentType(TEXT_PLAIN).
    body(containsString(OM_BASE_REQUEST_COUNT_START + "getListParam1" + LIST_PARAM +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getListParam1" + LIST_PARAM +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getListParam1" + LIST_PARAM +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getListParam1" + LIST_PARAM +  OM_BASE_REQUEST_END)

            , containsString(OM_BASE_REQUEST_COUNT_START + "getListParam2" + LIST_PARAM +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getListParam2" + LIST_PARAM +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getListParam2" + LIST_PARAM +  OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getListParam2" + LIST_PARAM +  OM_BASE_REQUEST_END)

            , containsString(OM_BASE_REQUEST_COUNT_START + "getListParam3" + LIST_PARAM + LIST_PARAM + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_REQUEST_TIME_START + "getListParam3" + LIST_PARAM + LIST_PARAM + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MAX_TIME_START + "getListParam3" + LIST_PARAM + LIST_PARAM + OM_BASE_REQUEST_END)
            , containsString(OM_BASE_MIN_TIME_START + "getListParam3" + LIST_PARAM + LIST_PARAM + OM_BASE_REQUEST_END)
            );

}
 
Example #27
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 4 votes vote down vote up
@Test
@RunAsClient
@InSequence(9)
public void testGetContextParams() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
    when().
         get(contextRoot+"/get-context-params").
    then().
        statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().statusCode(200).contentType(TEXT_PLAIN).body(
            containsString(
                    OM_BASE_REQUEST_COUNT_START
                    + "getContextParams"
                    + HTTP_HEADERS_PARAM
                    + REQUEST_PARAM
                    + URI_INFO_PARAM
                    + RESOURCE_CONTEXT_PARAM
                    + PROVIDERS_PARAM
                    + APPLICATION_PARAM
                    + SECURITY_CONTEXT_PARAM
                    + CONFIGURATION_PARAM
                    + OM_BASE_REQUEST_END),
            containsString(
                    OM_BASE_REQUEST_TIME_START
                    + "getContextParams"
                    + HTTP_HEADERS_PARAM
                    + REQUEST_PARAM
                    + URI_INFO_PARAM
                    + RESOURCE_CONTEXT_PARAM
                    + PROVIDERS_PARAM
                    + APPLICATION_PARAM
                    + SECURITY_CONTEXT_PARAM
                    + CONFIGURATION_PARAM
                    + OM_BASE_REQUEST_END),
            containsString(
                    OM_BASE_MAX_TIME_START
                    + "getContextParams"
                    + HTTP_HEADERS_PARAM
                    + REQUEST_PARAM
                    + URI_INFO_PARAM
                    + RESOURCE_CONTEXT_PARAM
                    + PROVIDERS_PARAM
                    + APPLICATION_PARAM
                    + SECURITY_CONTEXT_PARAM
                    + CONFIGURATION_PARAM
                    + OM_BASE_REQUEST_END),
            containsString(
                    OM_BASE_MIN_TIME_START
                    + "getContextParams"
                    + HTTP_HEADERS_PARAM
                    + REQUEST_PARAM
                    + URI_INFO_PARAM
                    + RESOURCE_CONTEXT_PARAM
                    + PROVIDERS_PARAM
                    + APPLICATION_PARAM
                    + SECURITY_CONTEXT_PARAM
                    + CONFIGURATION_PARAM
                    + OM_BASE_REQUEST_END));

}
 
Example #28
Source File: MpMetricTest.java    From microprofile-metrics with Apache License 2.0 4 votes vote down vote up
@Test
@RunAsClient
@InSequence(18)
public void testApplicationMetricsJSON() {
    Header wantJson = new Header("Accept", APPLICATION_JSON);
    
    Response resp = given().header(wantJson).get("/metrics/application");
    JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify()));
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filteredJSONPath.prettify());
    resp = responseBuilder.build();

    resp.then().statusCode(200)

            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.redCount;tier=integration'", equalTo(0))

            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.blue;tier=integration'", equalTo(0))

            .body("'greenCount;tier=integration'", equalTo(0))

            .body("'purple;app=myShop;tier=integration'", equalTo(0))

            .body("'metricTest.test1.count;tier=integration'", equalTo(1))

            .body("'metricTest.test1.countMeA;tier=integration'", equalTo(1))
            .body("'metricTest.test1.countMeB;tier=integration'", equalTo(1))

            .body("'metricTest.test1.gauge;tier=integration'", equalTo(19))

            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.gaugeMeA;tier=integration'", equalTo(1000))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.gaugeMeB;tier=integration'", equalTo(7777777))

            .body("'metricTest.test1.histogram'.'count;tier=integration'", equalTo(1000))
            .body("'metricTest.test1.histogram'.'max;tier=integration'", equalTo(999))
            .body("'metricTest.test1.histogram'.'mean;tier=integration'", closeTo(499.5))
            .body("'metricTest.test1.histogram'.'min;tier=integration'", equalTo(0))
            .body("'metricTest.test1.histogram'.'p50;tier=integration'", closeTo(499.0))
            .body("'metricTest.test1.histogram'.'p75;tier=integration'", closeTo(749))
            .body("'metricTest.test1.histogram'.'p95;tier=integration'", closeTo(949))
            .body("'metricTest.test1.histogram'.'p98;tier=integration'", closeTo(979))
            .body("'metricTest.test1.histogram'.'p99;tier=integration'", closeTo(989))
            .body("'metricTest.test1.histogram'.'p999;tier=integration'", closeTo(998))
            .body("'metricTest.test1.histogram'", hasKey("stddev;tier=integration"))

            .body("'metricTest.test1.meter'.'count;tier=integration'", equalTo(1))
            .body("'metricTest.test1.meter'", hasKey("fifteenMinRate;tier=integration"))
            .body("'metricTest.test1.meter'", hasKey("fiveMinRate;tier=integration"))
            .body("'metricTest.test1.meter'", hasKey("meanRate;tier=integration"))
            .body("'metricTest.test1.meter'", hasKey("oneMinRate;tier=integration"))

            .body("'meterMeA'.'count;tier=integration'", equalTo(1))
            .body("'meterMeA'", hasKey("fifteenMinRate;tier=integration"))
            .body("'meterMeA'", hasKey("fiveMinRate;tier=integration"))
            .body("'meterMeA'", hasKey("meanRate;tier=integration"))
            .body("'meterMeA'", hasKey("oneMinRate;tier=integration"))

            .body("'metricTest.test1.timer'.'count;tier=integration'", equalTo(1))
            .body("'metricTest.test1.timer'", hasKey("fifteenMinRate;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("fiveMinRate;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("meanRate;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("oneMinRate;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("elapsedTime;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("max;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("mean;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("min;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("p50;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("p75;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("p95;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("p98;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("p99;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("p999;tier=integration"))
            .body("'metricTest.test1.timer'", hasKey("stddev;tier=integration"))

            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'.'count;tier=integration'", equalTo(1))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("fifteenMinRate;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("fiveMinRate;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("meanRate;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("oneMinRate;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("elapsedTime;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("max;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("mean;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("min;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p50;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p75;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p95;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p98;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p99;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p999;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("stddev;tier=integration"))
            
            .body("'metricTest.test1.simpleTimer'.'count;tier=integration'", equalTo(1))
            .body("'metricTest.test1.simpleTimer'", hasKey("elapsedTime;tier=integration"))
            .body("'metricTest.test1.simpleTimer'", hasKey("minTimeDuration;tier=integration"))
            .body("'metricTest.test1.simpleTimer'", hasKey("maxTimeDuration;tier=integration"))
            
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA'.'count;tier=integration'", equalTo(1))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA'", hasKey("elapsedTime;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA'", hasKey("minTimeDuration;tier=integration"))
            .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA'", hasKey("maxTimeDuration;tier=integration"));
}
 
Example #29
Source File: MpMetricOptionalTest.java    From microprofile-metrics with Apache License 2.0 4 votes vote down vote up
@Test
@RunAsClient
@InSequence(8)
public void testGetSingleParams() throws InterruptedException {
    Header acceptHeader = new Header("Accept", TEXT_PLAIN);

    given().
         header(acceptHeader).
         port(applicationPort).
         queryParam("qp1", "s1").
    when().
         get(contextRoot+"/get-single-string-param").
    then().
        statusCode(200);

    given().
         header(acceptHeader).
         port(applicationPort).
         queryParam("qp1", 123).
    when().
         get(contextRoot+"/get-single-int-param").
    then().
        statusCode(200);

    given().
         header(acceptHeader).
         port(applicationPort).
         queryParam("qp1", 123.45).
    when().
         get(contextRoot+"/get-single-double-param").
    then().
        statusCode(200);

    given().
         header(acceptHeader).
         port(applicationPort).
         queryParam("qp1", 123L).
    when().
         get(contextRoot+"/get-single-long-param").
    then().
        statusCode(200);

    given().
         header(acceptHeader).
         port(applicationPort).
         queryParam("qp1", true).
    when().
         get(contextRoot+"/get-single-boolean-param").
    then().
        statusCode(200);

    Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT);
    ResponseBuilder responseBuilder = new ResponseBuilder();
    responseBuilder.clone(resp);
    responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString()));
    resp = responseBuilder.build();
    resp.then().
        statusCode(200).
        contentType(TEXT_PLAIN).
        body(containsString(OM_BASE_REQUEST_COUNT_START + "getSingleStringParam" + STRING_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "getSingleStringParam" + STRING_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "getSingleStringParam" + STRING_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "getSingleStringParam" + STRING_PARAM + OM_BASE_REQUEST_END)

                , containsString(OM_BASE_REQUEST_COUNT_START + "getSingleIntParam" + INT_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "getSingleIntParam" + INT_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "getSingleIntParam" + INT_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "getSingleIntParam" + INT_PARAM + OM_BASE_REQUEST_END)

                , containsString(OM_BASE_REQUEST_COUNT_START + "getSingleDoubleParam" + DOUBLE_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "getSingleDoubleParam" + DOUBLE_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "getSingleDoubleParam" + DOUBLE_PARAM+ OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "getSingleDoubleParam" + DOUBLE_PARAM+ OM_BASE_REQUEST_END)

                , containsString(OM_BASE_REQUEST_COUNT_START + "getSingleLongParam" + LONG_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "getSingleLongParam" + LONG_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "getSingleLongParam" + LONG_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "getSingleLongParam" + LONG_PARAM + OM_BASE_REQUEST_END)

                , containsString(OM_BASE_REQUEST_COUNT_START + "getSingleBooleanParam" + BOOLEAN_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_REQUEST_TIME_START + "getSingleBooleanParam" + BOOLEAN_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MAX_TIME_START + "getSingleBooleanParam" + BOOLEAN_PARAM + OM_BASE_REQUEST_END)
                , containsString(OM_BASE_MIN_TIME_START + "getSingleBooleanParam" + BOOLEAN_PARAM + OM_BASE_REQUEST_END));

}