aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/test')
-rw-r--r--api/src/test/java/io/opencensus/tags/TagsTest.java20
1 files changed, 9 insertions, 11 deletions
diff --git a/api/src/test/java/io/opencensus/tags/TagsTest.java b/api/src/test/java/io/opencensus/tags/TagsTest.java
index 5cab5b45..dee517b6 100644
--- a/api/src/test/java/io/opencensus/tags/TagsTest.java
+++ b/api/src/test/java/io/opencensus/tags/TagsTest.java
@@ -56,22 +56,20 @@ public class TagsTest {
.isEqualTo("io.opencensus.tags.NoopTags$NoopTagsComponent");
}
- @Test
- public void getState() {
- assertThat(Tags.getState()).isEqualTo(TaggingState.DISABLED);
- }
-
+ // There is only one test that modifies tagging state in the Tags class, since the state is
+ // global, and it could affect other tests. NoopTagsTest has more thorough tests for tagging
+ // state.
@Test
@SuppressWarnings("deprecation")
- public void setState_IgnoresInput() {
+ public void testState() {
+ // Test that setState ignores its input.
Tags.setState(TaggingState.ENABLED);
assertThat(Tags.getState()).isEqualTo(TaggingState.DISABLED);
- }
- @Test(expected = NullPointerException.class)
- @SuppressWarnings("deprecation")
- public void setState_DisallowsNull() {
- Tags.setState(null);
+ // Test that setState cannot be called after getState.
+ thrown.expect(IllegalStateException.class);
+ thrown.expectMessage("State was already read, cannot set state.");
+ Tags.setState(TaggingState.ENABLED);
}
@Test