use of io.gravitee.reporter.api.http.Metrics in project gravitee-gateway by gravitee-io.
the class TransactionHandlerTest method shouldHaveTransactionIdWithCustomHeader.
@Test
public void shouldHaveTransactionIdWithCustomHeader() throws InterruptedException {
final CountDownLatch lock = new CountDownLatch(1);
when(request.id()).thenReturn(UUID.toString(UUID.random()));
new TransactionHandler(CUSTOM_TRANSACTION_ID_HEADER, request1 -> {
assertNotNull(request1.transactionId());
assertEquals(request1.transactionId(), request1.headers().getFirst(CUSTOM_TRANSACTION_ID_HEADER));
assertEquals(request1.transactionId(), request1.metrics().getTransactionId());
assertEquals(request1.transactionId(), response.headers().getFirst(CUSTOM_TRANSACTION_ID_HEADER));
lock.countDown();
}, response).handle(request);
assertEquals(true, lock.await(10000, TimeUnit.MILLISECONDS));
}
use of io.gravitee.reporter.api.http.Metrics in project gravitee-gateway by gravitee-io.
the class TransactionHandlerTest method shouldPropagateSameTransactionId.
@Test
public void shouldPropagateSameTransactionId() throws InterruptedException {
final CountDownLatch lock = new CountDownLatch(1);
String transactionId = UUID.toString(UUID.random());
request.headers().set(TransactionHandler.DEFAULT_TRANSACTIONAL_ID_HEADER, transactionId);
new TransactionHandler(request1 -> {
assertNotNull(request1.transactionId());
assertEquals(transactionId, request1.transactionId());
assertEquals(transactionId, request1.headers().getFirst(TransactionHandler.DEFAULT_TRANSACTIONAL_ID_HEADER));
assertEquals(transactionId, request1.metrics().getTransactionId());
assertEquals(request1.transactionId(), response.headers().getFirst(TransactionHandler.DEFAULT_TRANSACTIONAL_ID_HEADER));
lock.countDown();
}, response).handle(request);
assertEquals(true, lock.await(10000, TimeUnit.MILLISECONDS));
}
Aggregations