Search in sources :

Example 6 with SegmentImpl

use of com.amazonaws.xray.entities.SegmentImpl in project aws-xray-sdk-java by aws.

the class EntityTest method testAllSubsegmentImplMutationMethodsThrowAlreadyEmittedExceptions.

@Test
public void testAllSubsegmentImplMutationMethodsThrowAlreadyEmittedExceptions() {
    SegmentImpl segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test");
    segment.getName();
    SubsegmentImpl subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment);
    MutatingMethodCount mutationResults = numberOfMutatingMethodsThatThrewException(subsegment, SubsegmentImpl.class);
    Assert.assertEquals(0, mutationResults.getMutatingMethodsThrowingExceptions());
    // the mutating methods set this to null...
    subsegment.setParentSegment(segment);
    segment.end();
    subsegment.end();
    mutationResults = numberOfMutatingMethodsThatThrewException(subsegment, SubsegmentImpl.class);
    Assert.assertEquals(mutationResults.getMutatingMethods(), mutationResults.getMutatingMethodsThrowingExceptions());
}
Also used : SubsegmentImpl(com.amazonaws.xray.entities.SubsegmentImpl) SegmentImpl(com.amazonaws.xray.entities.SegmentImpl) Test(org.junit.Test)

Example 7 with SegmentImpl

use of com.amazonaws.xray.entities.SegmentImpl in project aws-xray-sdk-java by aws.

the class EntityTest method testInProgressSegment.

@Test
public void testInProgressSegment() throws JSONException {
    String segmentId = Entity.generateId();
    TraceID traceId = new TraceID();
    Segment segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test", traceId);
    segment.setId(segmentId);
    segment.setStartTime(1.0);
    String expected = expectedInProgressSegment(traceId, segmentId, segment.getStartTime()).toString();
    JSONAssert.assertEquals(expected, segment.serialize(), JSONCompareMode.NON_EXTENSIBLE);
}
Also used : TraceID(com.amazonaws.xray.entities.TraceID) SegmentImpl(com.amazonaws.xray.entities.SegmentImpl) Segment(com.amazonaws.xray.entities.Segment) Test(org.junit.Test)

Example 8 with SegmentImpl

use of com.amazonaws.xray.entities.SegmentImpl in project aws-xray-sdk-java by aws.

the class EntityTest method testEndingSubsegmentImplTwiceThrowsAlreadyEmittedException.

@Test(expected = AlreadyEmittedException.class)
public void testEndingSubsegmentImplTwiceThrowsAlreadyEmittedException() {
    SegmentImpl segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test");
    segment.getName();
    SubsegmentImpl subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment);
    segment.end();
    subsegment.end();
    subsegment.end();
}
Also used : SubsegmentImpl(com.amazonaws.xray.entities.SubsegmentImpl) SegmentImpl(com.amazonaws.xray.entities.SegmentImpl) Test(org.junit.Test)

Example 9 with SegmentImpl

use of com.amazonaws.xray.entities.SegmentImpl in project aws-xray-sdk-java by aws.

the class EntityTest method testModifyingSegmentAfterEndingThrowsAlreadyEmittedException.

@SuppressWarnings("resource")
@Test(expected = AlreadyEmittedException.class)
public void testModifyingSegmentAfterEndingThrowsAlreadyEmittedException() {
    TraceID traceId = new TraceID();
    Segment segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test", traceId);
    segment.end();
    segment.setStartTime(1.0);
}
Also used : TraceID(com.amazonaws.xray.entities.TraceID) SegmentImpl(com.amazonaws.xray.entities.SegmentImpl) Segment(com.amazonaws.xray.entities.Segment) Test(org.junit.Test)

Aggregations

SegmentImpl (com.amazonaws.xray.entities.SegmentImpl)9 Test (org.junit.Test)9 SubsegmentImpl (com.amazonaws.xray.entities.SubsegmentImpl)5 Segment (com.amazonaws.xray.entities.Segment)4 TraceID (com.amazonaws.xray.entities.TraceID)3 Subsegment (com.amazonaws.xray.entities.Subsegment)1