Java Code Examples for org.jboss.arquillian.junit.InSequence

The following examples show how to use org.jboss.arquillian.junit.InSequence. These examples are extracted from open source projects. 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 Project: microprofile-metrics   Source File: MpMetricTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(31)
public void testOptionalBaseMetrics() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath();

    Map<String, Object> elements = jsonPath.getMap(".");
    Map<String, MiniMeta> names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE);

    for (MiniMeta item : names.values()) {
        if (elements.containsKey(item.toJSONName()) && names.get(item.name).optional) {
            String prefix = names.get(item.name).name;
            String type = "'"+item.toJSONName()+"'"+".type";
            String unit= "'"+item.toJSONName()+"'"+".unit";

            given().header(wantJson).options("/metrics/base/"+prefix).then().statusCode(200)
            .body(type, equalTo(names.get(item.name).type))
            .body(unit, equalTo(names.get(item.name).unit));
        }
    }

}
 
Example 2
Source Project: microprofile-metrics   Source File: MpMetricTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(19)
public void testApplicationMetadataItems() {
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/application").jsonPath();

    Map<String, Object> elements = jsonPath.getMap(".");
    
    List<String> missing = new ArrayList<>();

    Map<String, MiniMeta> names = getExpectedMetadataFromXmlFile(MetricRegistry.Type.APPLICATION);
    for (String item : names.keySet()) {
        if (!elements.containsKey(item)) {
            missing.add(item);
        }
    }
    assertTrue("Following application items are missing: " + Arrays.toString(missing.toArray()), missing.isEmpty());
}
 
Example 3
Source Project: smallrye-graphql   Source File: MetricTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(101)
public void verifyMetricsAreUpdated() {
    SimpleTimer metricForGetQuery = metricRegistry.getSimpleTimers().get(new MetricID("mp_graphql_Query_get"));
    Assert.assertEquals("The 'get' query was called three times, this should be reflected in metric value",
            3, metricForGetQuery.getCount());
    Assert.assertTrue("Total elapsed time for query should be greater than zero",
            metricForGetQuery.getElapsedTime().toNanos() > 0);

    SimpleTimer metricForMutation = metricRegistry.getSimpleTimers().get(new MetricID("mp_graphql_Mutation_mutate"));
    Assert.assertEquals("The query was called twice, this should be reflected in metric value",
            2, metricForMutation.getCount());
    Assert.assertTrue("Total elapsed time for query should be greater than zero",
            metricForMutation.getElapsedTime().toNanos() > 0);

    SimpleTimer metricForSource = metricRegistry.getSimpleTimers().get(new MetricID("mp_graphql_Foo_description"));
    Assert.assertEquals("The get{description} query was called once, this should be reflected in metric value",
            1, metricForSource.getCount());
    Assert.assertTrue("Total elapsed time for query should be greater than zero",
            metricForSource.getElapsedTime().toNanos() > 0);
}
 
Example 4
Source Project: microprofile-metrics   Source File: TagsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(5)
public void timerTagsTest() {
    
    Tag tagEarth = new Tag("planet", "earth");
    Tag tagRed = new Tag("colour", "red");
    Tag tagBlue = new Tag("colour", "blue");
    
    String timerName = "org.eclipse.microprofile.metrics.tck.TagTest.timerColour";
    
    Timer timerColour = registry.timer(timerName);
    Timer timerRed = registry.timer(timerName,tagEarth,tagRed);
    Timer timerBlue = registry.timer(timerName,tagEarth,tagBlue);
    
    MetricID timerColourMID = new MetricID(timerName);
    MetricID timerRedMID = new MetricID(timerName, tagEarth,tagRed);
    MetricID timerBlueMID = new MetricID(timerName, tagEarth,tagBlue);
    
    //check multi-dimensional metrics are registered
    assertThat("Timer is not registered correctly", registry.getTimer(timerColourMID), notNullValue());
    assertThat("Timer is not registered correctly", registry.getTimer(timerRedMID), notNullValue());
    assertThat("Timer is not registered correctly", registry.getTimer(timerBlueMID), notNullValue());
}
 
Example 5
Source Project: microprofile-metrics   Source File: TagsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(3)
public void counterTagsTest() {
    
    Tag tagEarth = new Tag("planet", "earth");
    Tag tagRed = new Tag("colour", "red");
    Tag tagBlue = new Tag("colour", "blue");
    
    String counterName = "org.eclipse.microprofile.metrics.tck.TagTest.counterColour";
    
    Counter counterColour = registry.counter(counterName);
    Counter counterRed = registry.counter(counterName,tagEarth,tagRed);
    Counter counterBlue = registry.counter(counterName,tagEarth,tagBlue);
    
    MetricID counterColourMID = new MetricID(counterName);
    MetricID counterRedMID = new MetricID(counterName, tagEarth,tagRed);
    MetricID counterBlueMID = new MetricID(counterName, tagEarth,tagBlue);
    
    //check multi-dimensional metrics are registered
    assertThat("Counter is not registered correctly", registry.getCounter(counterColourMID), notNullValue());
    assertThat("Counter is not registered correctly", registry.getCounter(counterRedMID), notNullValue());
    assertThat("Counter is not registered correctly", registry.getCounter(counterBlueMID), notNullValue());
}
 
Example 6
@Test
@InSequence(2)
public void incrementCounterTagFields() {
    Counter counterOne = registry.getCounter(counterMID);
    assertThat("Counter is not registered correctly", counterOne, notNullValue());

    Counter counterTwo = registry.getCounter(counterTwoMID);
    assertThat("Counter is not registered correctly", counterTwo, notNullValue());

    Counter counterThree = registry.getCounter(counterThreeMID);
    assertThat("Counter is not registered correctly", counterThree, notNullValue());

    // Call the increment method and assert the counter is up-to-date
    long value = Math.round(Math.random() * Long.MAX_VALUE);
    bean.incrementOne(value);

    long valueTwo = Math.round(Math.random() * Long.MAX_VALUE);
    bean.incrementTwo(valueTwo);

    long valueThree = Math.round(Math.random() * Long.MAX_VALUE);
    bean.incrementThree(valueThree);

    assertThat("Counter value is incorrect", counterOne.getCount(), is(equalTo(value)));
    assertThat("Counter value is incorrect", counterTwo.getCount(), is(equalTo(valueTwo)));
    assertThat("Counter value is incorrect", counterThree.getCount(), is(equalTo(valueThree)));
}
 
Example 7
Source Project: microprofile-metrics   Source File: TagsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(2)
public void lastTagValueTest() {
    
    Tag tagColour = new Tag("colour","red");
    Tag tagColourTwo = new Tag("colour","blue");
    
    String counterName = "org.eclipse.microprofile.metrics.tck.TagTest.counter";
    Counter counter = registry.counter(counterName, tagColour, tagColourTwo);
    
    //MetricID that only has colour=blue... the last tag value to be passed in
    MetricID counterMID = new MetricID(counterName, tagColourTwo);
    
    //check the metric is registered
    assertThat("Counter is not registered correctly", registry.getCounter(counterMID), notNullValue());
}
 
Example 8
@Test
@InSequence(3)
public void removeTimerFromRegistry() throws InterruptedException {
    // Get a contextual instance of the bean
    TimedMethodBean1 bean = instance.get();

    Timer timer = registry.getTimer(timerMID);
    assertThat("Timer is not registered correctly", timer, notNullValue());

    // Remove the timer from metrics registry
    registry.remove(timerMID);

    try {
        // Call the timed method and assert an exception is thrown
        bean.timedMethod();
    }
    catch (RuntimeException cause) {
        assertThat(cause, is(instanceOf(IllegalStateException.class)));
        // Make sure that the timer hasn't been called
        assertThat("Timer count is incorrect", timer.getCount(), is(equalTo(TIMER_COUNT.get())));
        return;
    }

    fail("No exception has been re-thrown!");
}
 
Example 9
@Test
@InSequence(2)
public void callMetricsMethodOnce() {
    assertThat("Metrics are not registered correctly", registry.getMetricIDs(),
        is(equalTo(MetricsUtil.createMetricIDs(absoluteMetricNames()))));

    // Call the monitored method and assert it's been instrumented
    bean.metricsMethod();

    // Make sure that the metrics have been called
    assertThat("Counter count is incorrect", registry.getCounter(
            new MetricID(absoluteMetricName("counter"))).getCount(), is(equalTo(1L)));
    assertThat("Meter count is incorrect", registry.getMeter(
            new MetricID(absoluteMetricName("meter"))).getCount(), is(equalTo(1L)));
    assertThat("Timer count is incorrect", registry.getTimer(
            new MetricID(absoluteMetricName("timer"))).getCount(), is(equalTo(1L)));
    // Let's call the gauge at the end as Weld is intercepting the gauge
    // invocation while OWB not
    assertThat("Gauge value is incorrect", registry.getGauge(
            new MetricID(absoluteMetricName("gauge"))).getValue(), is(equalTo(1234L)));
}
 
Example 10
@Test
@InSequence(2)
public void incrementCountersFromRegistry() {
    assertThat("Counters are not registered correctly", registry.getCounters(),
        allOf(
            hasKey(counter1MID),
            hasKey(counter2MID),
            not(hasKey(notRegMID))
        )
    );
    Counter counter1 = registry.getCounter(counter1MID);
    Counter counter2 = registry.getCounter(counter2MID);

    @SuppressWarnings("unchecked")
    Gauge<Double> gauge = (Gauge<Double>) registry.getGauge(ratioGaugeMID);
    assertThat("Gauge is not registered correctly", gauge, notNullValue());

    counter1.inc(Math.round(Math.random() * Integer.MAX_VALUE));
    counter2.inc(Math.round(Math.random() * Integer.MAX_VALUE));

    assertThat("Gauge value is incorrect", gauge.getValue(), is(equalTo(((double) counter1.getCount()) / ((double) counter2.getCount()))));
}
 
Example 11
Source Project: microprofile-metrics   Source File: MpMetricTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(11)
public void testBaseMetadataSingluarItems() {
    Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests"));
    Header wantJson = new Header("Accept", APPLICATION_JSON);

    JsonPath jsonPath = given().header(wantJson).options("/metrics/base").jsonPath();

    Map<String, Object> elements = jsonPath.getMap(".");
    List<String> missing = new ArrayList<>();

    Map<String, MiniMeta> baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.Type.BASE);
    for (String item : baseNames.keySet()) {
        if (item.startsWith("gc.") || baseNames.get(item).optional) {
            continue;
        }
        if (!elements.containsKey(item)) {
            missing.add(item);
        }
    }

    assertTrue("Following base items are missing: " + Arrays.toString(missing.toArray()), missing.isEmpty());
}
 
Example 12
@Test
@InSequence(2)
public void callGaugeTagAfterSetterCall() {
    @SuppressWarnings("unchecked")
    Gauge<Long> gaugeOne = (Gauge<Long>) registry.getGauge(gaugeOneMID);
    @SuppressWarnings("unchecked")
    Gauge<Long> gaugeTwo = (Gauge<Long>) registry.getGauge(gaugeTwoMID);
    assertThat("Gauge is not registered correctly", gaugeOne, notNullValue());
    assertThat("Gauge is not registered correctly", gaugeTwo, notNullValue());

    // Call the setter method and assert the gauge is up-to-date
    long value = Math.round(Math.random() * Long.MAX_VALUE);
    bean.setGaugeOne(value);
    
    long secondValue = Math.round(Math.random() * Long.MAX_VALUE);
    bean.setGaugeTwo(secondValue);
    
    assertThat("Gauge value is incorrect", gaugeOne.getValue(), is(equalTo(value)));
    assertThat("Gauge value is incorrect", gaugeTwo.getValue(), is(equalTo(secondValue)));
}
 
Example 13
Source Project: microprofile-metrics   Source File: MpMetricTest.java    License: 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 14
Source Project: monolith   Source File: BookingServiceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(10)
public void testPagination() {

    // Test pagination logic
    MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<String, String>();

    queryParameters.add("first", "2");
    queryParameters.add("maxResults", "1");

    List<Booking> bookings = bookingService.getAll(queryParameters);
    assertNotNull(bookings);
    assertEquals(1, bookings.size());
    assertEquals("Sydney Opera House", bookings.get(0).getPerformance().getShow().getVenue().getName());
    assertEquals("Rock concert of the decade", bookings.get(0).getPerformance().getShow().getEvent().getName());
}
 
Example 15
Source Project: microprofile-metrics   Source File: TagsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(1)
public void simpleTagTest() {
    Tag one = new Tag("hello", "world");
    Tag two = new Tag("goodbye", "friend");
    MetricID metricID = new MetricID("metricName", one, two);
    
    assertThat(metricID.getTags(), hasKey("hello"));
    assertThat(metricID.getTags(), hasValue("world"));
    
    assertThat(metricID.getTags(), hasKey("goodbye"));
    assertThat(metricID.getTags(), hasValue("friend"));
    
    //MP_METRICS_TAGS=tier=integration
    assertThat("Counter's Global Tag not set properly", metricID.getTags(), hasKey("tier"));
    assertThat("Counter's Global Tag not set properly", metricID.getTags(), hasValue("integration"));
}
 
Example 16
Source Project: microprofile-metrics   Source File: TimerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(3)
public void testTimerRegistry() throws Exception {
    String timerLongName = "test.longData.timer";
    String timerTimeName = "testTime";

    MetricID timerLongNameMetricID = new MetricID(timerLongName);
    MetricID timerTimeNameMetricID = new MetricID(timerTimeName);

    Timer timerLong = registry.getTimer(timerLongNameMetricID);
    Timer timerTime = registry.getTimer(timerTimeNameMetricID);

    assertNotNull(timerLong);
    assertNotNull(timerTime);

    TestUtils.assertEqualsWithTolerance(480, timerLong.getSnapshot().getValue(0.5));
}
 
Example 17
@Test
@InSequence(2)
public void callSimplyTimedMethodOnce() throws InterruptedException {
    // Get a contextual instance of the bean
    SimplyTimedMethodBean1 bean = instance.get();

    SimpleTimer simpleTimer = registry.getSimpleTimer(simpleTimerMID);
    assertThat("SimplyTimed is not registered correctly", simpleTimer, notNullValue());

    // Call the simplyTimed method and assert it's been simplyTimed
    bean.simplyTimedMethod();

    // Make sure that the simpleTimer has been called
    assertThat("SimplyTimed count is incorrect", simpleTimer.getCount(), is(equalTo(SIMPLE_TIMER_COUNT.incrementAndGet())));
    TestUtils.assertEqualsWithTolerance(2000000000L,  simpleTimer.getElapsedTime().toNanos());
}
 
Example 18
Source Project: microprofile-metrics   Source File: ReusedMetricsTest.java    License: 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 19
Source Project: microprofile-metrics   Source File: MpMetricTest.java    License: 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 20
Source Project: monolith   Source File: BookingServiceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(10)
public void testPagination() {

    // Test pagination logic
    MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<String, String>();

    queryParameters.add("first", "2");
    queryParameters.add("maxResults", "1");

    List<Booking> bookings = bookingService.getAll(queryParameters);
    assertNotNull(bookings);
    assertEquals(1, bookings.size());
    assertEquals("Sydney Opera House", bookings.get(0).getPerformance().getShow().getVenue().getName());
    assertEquals("Rock concert of the decade", bookings.get(0).getPerformance().getShow().getEvent().getName());
}
 
Example 21
@Test
@InSequence(2)
public void callCachedMethodMultipleTimes() {
    assertThat("Metrics are not registered correctly", registry.getMetricIDs(),
        contains(cacheHitsMID, callsMID, hitsMID));
    Timer calls = registry.getTimer(callsMID);
    Meter hits = registry.getMeter(hitsMID);
    @SuppressWarnings("unchecked")
    Gauge<Double> gauge = (Gauge<Double>) registry.getGauge(cacheHitsMID);

    long count = 10 + Math.round(Math.random() * 10);
    for (int i = 0; i < count; i++) {
        bean.cachedMethod((Math.random() < 0.5));
    }

    assertThat("Gauge value is incorrect", gauge.getValue(), is(equalTo((double) hits.getCount() / (double) calls.getCount())));
}
 
Example 22
Source Project: microprofile-metrics   Source File: MpMetricTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@RunAsClient
@InSequence(34)
public void testPromNoBadCharsInNames() {
    given().header("Accept", TEXT_PLAIN).when().get("/metrics/application")
        .then().statusCode(200)
        .and()
            // metrics.counter("pm_counter-with-dashes");
        .body(containsString("pm_counter_with_dashes"))
            // metrics.counter("pm_counter#hash_x'y_");
        .body(containsString("pm_counter_hash_x_y_"))
            // metrics.counter("pm_counter-umlaut-äöü");
        .body(containsString("pm_counter_umlaut_"))
            // metrics.counter("pm_counter+accent_ê_");
        .body(containsString("pm_counter_accent_"));
}
 
Example 23
Source Project: microprofile-metrics   Source File: TimedClassBeanTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(2)
public void callTimedMethodsOnce() {
    assertThat("Timers are not registered correctly", registry.getTimers().keySet(), is(equalTo(timerMIDsIncludingToString)));
    
    assertThat("Constructor timer count is incorrect", registry.getTimer(constructorMID).getCount(), is(equalTo(1L)));

    // Call the timed methods and assert they've been timed
    bean.timedMethodOne();
    bean.timedMethodTwo();
    // Let's call the non-public methods as well
    bean.timedMethodProtected();
    bean.timedMethodPackagedPrivate();

    // Make sure that the method timers have been timed
    assertThat("Method timer counts are incorrect", registry.getTimers(METHOD_TIMERS).values(),
            everyItem(Matchers.<Timer> hasProperty("count", equalTo(METHOD_COUNT.incrementAndGet()))));
}
 
Example 24
@Test
@InSequence(2)
public void callTimedMethodsOnce() { 
    assertThat("Timers are not registered correctly", registry.getTimers().keySet(),
        is(equalTo(MetricsUtil.createMetricIDs(absoluteMetricNames()))));

    // Call the timed methods and assert they've all been timed once
    bean.publicTimedMethod();
    bean.protectedTimedMethod();
    bean.packagePrivateTimedMethod();

    // Call the methods of the parent and assert they've also been timed once
    bean.timedMethodOne();
    bean.timedMethodTwo();
    bean.timedMethodProtected();
    bean.timedMethodPackagedPrivate();

    assertThat("Timer counts are incorrect", registry.getTimers().values(), everyItem(Matchers.<Timer>hasProperty("count", equalTo(1L))));
}
 
Example 25
Source Project: microprofile-metrics   Source File: TimedMethodBeanTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@InSequence(3)
public void removeTimerFromRegistry() throws InterruptedException {
    Timer timer = registry.getTimer(timerMID);
    assertThat("Timer is not registered correctly", timer, notNullValue());

    // Remove the timer from metrics registry
    registry.remove(timerMID);

    try {
        // Call the timed method and assert an exception is thrown
        bean.timedMethod();
    }
    catch (RuntimeException cause) {
        assertThat(cause, is(instanceOf(IllegalStateException.class)));
        // Make sure that the timer hasn't been called
        assertThat("Timer count is incorrect", timer.getCount(), is(equalTo(TIMER_COUNT.get())));
        return;
    }

    fail("No exception has been re-thrown!");
}
 
Example 26
@Test
@InSequence(1)
public void countersNotIncrementedYet() {
    assertThat("Counters are not registered correctly", registry.getCounters(),
        allOf(
            hasKey(counter1MID),
            hasKey(counter2MID),
            not(hasKey(notRegMID))
        )
    );
    Counter counter1 = registry.getCounter(counter1MID);
    Counter counter2 = registry.getCounter(counter2MID);

    @SuppressWarnings("unchecked")
    Gauge<Double> gauge = (Gauge<Double>) registry.getGauge(ratioGaugeMID);
    assertThat("Gauge is not registered correctly", gauge, notNullValue());

    assertThat("Gauge value is incorrect", gauge.getValue(), is(equalTo(((double) counter1.getCount()) / ((double) counter2.getCount()))));
}
 
Example 27
Source Project: microprofile-starter   Source File: TestMatrixTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(0)
public void apiAccessibleSanity() {
    Response response = target.request().get();
    assertEquals("MicroProfile Starter REST API should be available", Response.Status.OK.getStatusCode(), response.getStatus());
}
 
Example 28
@Test
@InSequence(2)
public void metricInjectionIntoTest(@Metric(name = "countedMethod", absolute = true) Counter instance) {
    Counter counter = registry.getCounter(counterMetricID);
    assertThat("Counter is not registered correctly", counter, notNullValue());

    // Make sure that the counter registered and the bean instance are the same
    assertThat("Counter and bean instance are not equal", instance, is(equalTo(counter)));
}
 
Example 29
Source Project: microprofile-metrics   Source File: MpMetricTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@RunAsClient
@InSequence(39)
public void testAccept5() {
    given().header("Accept","image/png;q=1,*/*;q=0.1")
        .when().get("/metrics/application")
        .then().statusCode(200)
        .and()
        .contentType(TEXT_PLAIN);
}
 
Example 30
@Test
@InSequence(1)
public void timedConstructorCalled() {
    long count = 1L + Math.round(Math.random() * 10);
    for (int i = 0; i < count; i++) {
        instance.get();
    }

    Timer timer = registry.getTimer(timerMID);
    assertThat("Timer is not registered correctly", timer, notNullValue());

    // Make sure that the timer has been called
    assertThat("Timer count is incorrect", timer.getCount(), is(equalTo(count)));
}