2929import io .opencensus .tags .Tagger ;
3030import io .opencensus .tags .TagsComponent ;
3131import io .opencensus .tags .propagation .TagContextBinarySerializer ;
32- import io .opencensus .tags .propagation .TagContextParseException ;
32+ import io .opencensus .tags .propagation .TagContextDeserializationException ;
3333import org .junit .Rule ;
3434import org .junit .Test ;
3535import org .junit .rules .ExpectedException ;
@@ -58,7 +58,7 @@ public void testVersionAndValueTypeConstants() {
5858 }
5959
6060 @ Test
61- public void testDeserializeNoTags () throws TagContextParseException {
61+ public void testDeserializeNoTags () throws TagContextDeserializationException {
6262 TagContext expected = tagger .empty ();
6363 TagContext actual =
6464 serializer .fromByteArray (
@@ -67,42 +67,43 @@ public void testDeserializeNoTags() throws TagContextParseException {
6767 }
6868
6969 @ Test
70- public void testDeserializeEmptyByteArrayThrowException () throws TagContextParseException {
71- thrown .expect (TagContextParseException .class );
70+ public void testDeserializeEmptyByteArrayThrowException ()
71+ throws TagContextDeserializationException {
72+ thrown .expect (TagContextDeserializationException .class );
7273 thrown .expectMessage ("Input byte[] can not be empty." );
7374 serializer .fromByteArray (new byte [0 ]);
7475 }
7576
7677 @ Test
77- public void testDeserializeInvalidTagKey () throws TagContextParseException {
78+ public void testDeserializeInvalidTagKey () throws TagContextDeserializationException {
7879 ByteArrayDataOutput output = ByteStreams .newDataOutput ();
7980 output .write (SerializationUtils .VERSION_ID );
8081
8182 // Encode an invalid tag key and a valid tag value:
8283 encodeTagToOutput ("\2 key" , "value" , output );
8384 final byte [] bytes = output .toByteArray ();
8485
85- thrown .expect (TagContextParseException .class );
86+ thrown .expect (TagContextDeserializationException .class );
8687 thrown .expectMessage ("Invalid tag key: \2 key" );
8788 serializer .fromByteArray (bytes );
8889 }
8990
9091 @ Test
91- public void testDeserializeInvalidTagValue () throws TagContextParseException {
92+ public void testDeserializeInvalidTagValue () throws TagContextDeserializationException {
9293 ByteArrayDataOutput output = ByteStreams .newDataOutput ();
9394 output .write (SerializationUtils .VERSION_ID );
9495
9596 // Encode a valid tag key and an invalid tag value:
9697 encodeTagToOutput ("my key" , "val\3 " , output );
9798 final byte [] bytes = output .toByteArray ();
9899
99- thrown .expect (TagContextParseException .class );
100+ thrown .expect (TagContextDeserializationException .class );
100101 thrown .expectMessage ("Invalid tag value for key TagKey{name=my key}: val\3 " );
101102 serializer .fromByteArray (bytes );
102103 }
103104
104105 @ Test
105- public void testDeserializeOneTag () throws TagContextParseException {
106+ public void testDeserializeOneTag () throws TagContextDeserializationException {
106107 ByteArrayDataOutput output = ByteStreams .newDataOutput ();
107108 output .write (SerializationUtils .VERSION_ID );
108109 encodeTagToOutput ("Key" , "Value" , output );
@@ -115,7 +116,7 @@ public void testDeserializeOneTag() throws TagContextParseException {
115116 }
116117
117118 @ Test
118- public void testDeserializeMultipleTags () throws TagContextParseException {
119+ public void testDeserializeMultipleTags () throws TagContextDeserializationException {
119120 ByteArrayDataOutput output = ByteStreams .newDataOutput ();
120121 output .write (SerializationUtils .VERSION_ID );
121122 encodeTagToOutput ("Key1" , "Value1" , output );
@@ -130,7 +131,7 @@ public void testDeserializeMultipleTags() throws TagContextParseException {
130131 }
131132
132133 @ Test
133- public void stopParsingAtUnknownField () throws TagContextParseException {
134+ public void stopParsingAtUnknownField () throws TagContextDeserializationException {
134135 ByteArrayDataOutput output = ByteStreams .newDataOutput ();
135136 output .write (SerializationUtils .VERSION_ID );
136137 encodeTagToOutput ("Key1" , "Value1" , output );
@@ -153,7 +154,7 @@ public void stopParsingAtUnknownField() throws TagContextParseException {
153154 }
154155
155156 @ Test
156- public void stopParsingAtUnknownTagAtStart () throws TagContextParseException {
157+ public void stopParsingAtUnknownTagAtStart () throws TagContextDeserializationException {
157158 ByteArrayDataOutput output = ByteStreams .newDataOutput ();
158159 output .write (SerializationUtils .VERSION_ID );
159160
@@ -166,15 +167,15 @@ public void stopParsingAtUnknownTagAtStart() throws TagContextParseException {
166167 }
167168
168169 @ Test
169- public void testDeserializeWrongFormat () throws TagContextParseException {
170+ public void testDeserializeWrongFormat () throws TagContextDeserializationException {
170171 // encoded tags should follow the format <version_id>(<tag_field_id><tag_encoding>)*
171- thrown .expect (TagContextParseException .class );
172+ thrown .expect (TagContextDeserializationException .class );
172173 serializer .fromByteArray (new byte [3 ]);
173174 }
174175
175176 @ Test
176- public void testDeserializeWrongVersionId () throws TagContextParseException {
177- thrown .expect (TagContextParseException .class );
177+ public void testDeserializeWrongVersionId () throws TagContextDeserializationException {
178+ thrown .expect (TagContextDeserializationException .class );
178179 thrown .expectMessage ("Wrong Version ID: 1. Currently supported version is: 0" );
179180 serializer .fromByteArray (new byte [] {(byte ) (SerializationUtils .VERSION_ID + 1 )});
180181 }
0 commit comments