Skip to content

Commit

Permalink
Add test annotations to Java async test
Browse files Browse the repository at this point in the history
  • Loading branch information
yasmin-aumeeruddy committed Jun 26, 2024
1 parent e128bc3 commit a240d24
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import io.opentelemetry.api.baggage.Baggage;
import io.opentelemetry.api.trace.SpanKind;
Expand Down Expand Up @@ -93,22 +94,27 @@ void setUp() {
}
}

@Test
public void testJaxRsServerAsyncCompletionStage() {
doAsyncTest((client) -> client.getCompletionStage(QUERY_VALUE));
}

@Test
public void testJaxRsServerAsyncCompletionStageError() {
doErrorAsyncTest((client) -> client.getCompletionStageError(QUERY_VALUE));
}

@Test
public void testJaxRsServerAsyncSuspend() {
doAsyncTest((client) -> client.getSuspend(QUERY_VALUE));
}

@Test
public void testJaxRsServerAsyncSuspendError() {
doErrorAsyncTest((client) -> client.getSuspendError(QUERY_VALUE));
}

@Test
private void doAsyncTest(Function<JaxRsServerAsyncTestEndpointClient, String> requestFunction) {
Baggage baggage = Baggage.builder()
.put(JaxRsServerAsyncTestEndpoint.BAGGAGE_KEY, TEST_VALUE)
Expand Down Expand Up @@ -153,6 +159,7 @@ private void doAsyncTest(Function<JaxRsServerAsyncTestEndpointClient, String> re
Assert.assertTrue(serverSpan.getEndEpochNanos() >= subtaskSpan.getEndEpochNanos());
}

@Test
private void doErrorAsyncTest(Function<JaxRsServerAsyncTestEndpointClient, String> requestFunction) {
Baggage baggage = Baggage.builder()
.put(JaxRsServerAsyncTestEndpoint.BAGGAGE_KEY, TEST_VALUE)
Expand Down

0 comments on commit a240d24

Please sign in to comment.