|
| 1 | +/* |
| 2 | + * Copyright The OpenTelemetry Authors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +package io.opentelemetry.instrumentation.resources; |
| 7 | + |
| 8 | +import static org.assertj.core.api.Assertions.assertThat; |
| 9 | + |
| 10 | +import io.opentelemetry.api.common.AttributeKey; |
| 11 | +import io.opentelemetry.api.common.Attributes; |
| 12 | +import io.opentelemetry.sdk.resources.Resource; |
| 13 | +import org.junit.jupiter.api.Test; |
| 14 | +import org.junit.jupiter.api.TestInstance; |
| 15 | +import org.junit.jupiter.api.condition.EnabledOnJre; |
| 16 | +import org.junit.jupiter.api.condition.JRE; |
| 17 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 18 | + |
| 19 | +@TestInstance(TestInstance.Lifecycle.PER_CLASS) |
| 20 | +@ExtendWith(SecurityManagerExtension.class) |
| 21 | +@EnabledOnJre( |
| 22 | + value = {JRE.JAVA_8, JRE.JAVA_11, JRE.JAVA_16}, |
| 23 | + disabledReason = "Java 17 deprecates security manager for removal") |
| 24 | +class SecurityManagerResourceTest { |
| 25 | + |
| 26 | + @Test |
| 27 | + void hostResourceTestEmpty() { |
| 28 | + Attributes attributes = HostResource.buildResource().getAttributes(); |
| 29 | + assertThat(attributes.asMap()).containsOnlyKeys(AttributeKey.stringKey("host.name")); |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + void osResourceEmpty() { |
| 34 | + assertThat(OsResource.buildResource()).isEqualTo(Resource.empty()); |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + void processResourceEmpty() { |
| 39 | + Attributes attributes = ProcessResource.buildResource().getAttributes(); |
| 40 | + assertThat(attributes.asMap()).containsOnlyKeys(AttributeKey.longKey("process.pid")); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + void processRuntimeResourceEmpty() { |
| 45 | + assertThat(ProcessRuntimeResource.buildResource()).isEqualTo(Resource.empty()); |
| 46 | + } |
| 47 | +} |
0 commit comments