Search in sources :

Example 1 with RuntimeErrorContextMissingStrategy

use of com.amazonaws.xray.strategy.RuntimeErrorContextMissingStrategy in project aws-xray-sdk-java by aws.

the class LambdaSegmentContextTest method testEndSubsegmentUsesContextMissing.

@Test
@SetEnvironmentVariable(key = "_X_AMZN_TRACE_ID", value = TRACE_HEADER)
void testEndSubsegmentUsesContextMissing() {
    AWSXRay.getGlobalRecorder().setContextMissingStrategy(new LogErrorContextMissingStrategy());
    // No exception
    AWSXRay.endSubsegment();
    AWSXRay.getGlobalRecorder().setContextMissingStrategy(new RuntimeErrorContextMissingStrategy());
    assertThatThrownBy(AWSXRay::endSubsegment).isInstanceOf(SubsegmentNotFoundException.class);
}
Also used : LogErrorContextMissingStrategy(com.amazonaws.xray.strategy.LogErrorContextMissingStrategy) RuntimeErrorContextMissingStrategy(com.amazonaws.xray.strategy.RuntimeErrorContextMissingStrategy) SetEnvironmentVariable(org.junitpioneer.jupiter.SetEnvironmentVariable) Test(org.junit.jupiter.api.Test)

Aggregations

LogErrorContextMissingStrategy (com.amazonaws.xray.strategy.LogErrorContextMissingStrategy)1 RuntimeErrorContextMissingStrategy (com.amazonaws.xray.strategy.RuntimeErrorContextMissingStrategy)1 Test (org.junit.jupiter.api.Test)1 SetEnvironmentVariable (org.junitpioneer.jupiter.SetEnvironmentVariable)1