Search in sources :

Example 6 with StringService

use of services.StringService in project helidon by oracle.

the class MetricsTest method shouldHaveTimerMetric.

/**
 * Verify that the StringService split method has the timer metric.
 */
@Test
public void shouldHaveTimerMetric() {
    JsonObject json = getMetrics();
    JsonObject timer = json.getJsonObject(StringService.class.getName() + ".split");
    assertThat(timer, is(notNullValue()));
    int count = timer.getInt("count");
    int min = timer.getInt("min");
    assertThat(count, is(0));
    assertThat(min, is(0));
    Iterator<StringMessage> iterator = stringStub.split(StringMessage.newBuilder().setText("A B C").build());
    while (iterator.hasNext()) {
        iterator.next();
    }
    json = getMetrics();
    timer = json.getJsonObject(StringService.class.getName() + ".split");
    assertThat(timer, is(notNullValue()));
    count = timer.getInt("count");
    min = timer.getInt("min");
    assertThat(count, is(1));
    assertThat(min, is(not(0)));
}
Also used : StringMessage(io.helidon.grpc.examples.common.Strings.StringMessage) JsonObject(jakarta.json.JsonObject) StringService(services.StringService) Test(org.junit.jupiter.api.Test)

Example 7 with StringService

use of services.StringService in project helidon by oracle.

the class MetricsTest method shouldHaveCounterMetric.

/**
 * Verify that the StringService upper method has the counter metric.
 */
@Test
public void shouldHaveCounterMetric() {
    JsonObject json = getMetrics();
    int count = json.getInt(StringService.class.getName() + ".upper");
    assertThat(count, is(0));
    stringStub.upper(StringMessage.newBuilder().setText("foo").build());
    json = getMetrics();
    count = json.getInt(StringService.class.getName() + ".upper");
    assertThat(count, is(1));
}
Also used : JsonObject(jakarta.json.JsonObject) StringService(services.StringService) Test(org.junit.jupiter.api.Test)

Aggregations

StringService (services.StringService)7 GrpcRouting (io.helidon.grpc.server.GrpcRouting)4 GrpcServerConfiguration (io.helidon.grpc.server.GrpcServerConfiguration)4 BeforeAll (org.junit.jupiter.api.BeforeAll)4 Channel (io.grpc.Channel)3 JsonObject (jakarta.json.JsonObject)3 Test (org.junit.jupiter.api.Test)3 LogConfig (io.helidon.common.LogConfig)2 Config (io.helidon.config.Config)2 EchoService (services.EchoService)2 TreeMapService (services.TreeMapService)2 StringMessage (io.helidon.grpc.examples.common.Strings.StringMessage)1 ServiceDescriptor (io.helidon.grpc.server.ServiceDescriptor)1 Security (io.helidon.security.Security)1 JsonNumber (jakarta.json.JsonNumber)1