Add tags test case.

This commit is contained in:
wusheng 2017-03-16 20:22:24 +08:00
parent 76fd789d74
commit dfa0eead31
1 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package com.a.eye.skywalking.trace.tag;
import com.a.eye.skywalking.trace.Span;
import org.junit.Assert;
import org.junit.Test;
/**
* @author wusheng
*/
public class TagsTest {
@Test
public void testLayer(){
Span span = new Span(1, "/test");
Tags.SPAN_LAYER.asDB(span);
Assert.assertEquals("db", span.getTag("span.layer"));
Tags.SPAN_LAYER.asRPCFramework(span);
Assert.assertEquals("rpc", span.getTag("span.layer"));
Tags.SPAN_LAYER.asHttp(span);
Assert.assertEquals("http", span.getTag("span.layer"));
}
@Test
public void testBooleanTag(){
BooleanTag tag = new BooleanTag("test.key", false);
Span span = new Span(1, "/test");
Assert.assertFalse(tag.get(span));
tag.set(span, true);
Assert.assertTrue(tag.get(span));
}
@Test
public void testIntTag(){
IntTag tag = new IntTag("test.key");
Span span = new Span(1, "/test");
Assert.assertNull(tag.get(span));
tag.set(span, 123);
Assert.assertEquals(123, tag.get(span).intValue());
}
@Test
public void testShortTag(){
ShortTag tag = new ShortTag("test.key");
Span span = new Span(1, "/test");
Assert.assertNull(tag.get(span));
short value = 123;
tag.set(span, value);
Assert.assertEquals(value, tag.get(span).intValue());
}
}