Fix a test case.

This commit is contained in:
wusheng 2017-06-08 22:12:16 +08:00
parent 673b975738
commit 6745e50f4e
1 changed files with 9 additions and 1 deletions

View File

@ -2,8 +2,10 @@ package org.skywalking.apm.trace;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import org.junit.Assert;
import org.junit.Test;
import org.skywalking.apm.trace.tag.StringTagReader;
import org.skywalking.apm.trace.tag.Tags;
/**
@ -116,6 +118,12 @@ public class TraceSegmentTestCase {
Assert.assertEquals(length, segmentJson.length());
System.out.println(segmentJson);
JsonObject jsonObject = gson.fromJson(segmentJson, JsonObject.class);
Assert.assertEquals(segment.getSpans().size(), jsonObject.get("ss").getAsJsonArray().size());
Assert.assertEquals(segment.getRefs().get(0).getTraceSegmentId(),
jsonObject.get("rs").getAsJsonArray().get(0).getAsJsonObject().get("ts").getAsString());
Assert.assertEquals(StringTagReader.get(segment.getSpans().get(1), Tags.SPAN_LAYER.SPAN_LAYER_TAG),
jsonObject.get("ss").getAsJsonArray().get(1).getAsJsonObject().get("ts").getAsJsonObject().get("span.layer").getAsString());
}
}