Skip to content

Commit 6ae5cf9

Browse files
committed
add test
1 parent b00bf82 commit 6ae5cf9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import org.junit.jupiter.api.Test;
7474
import org.junit.jupiter.api.extension.ExtendWith;
7575
import org.junit.jupiter.api.extension.RegisterExtension;
76+
import org.junitpioneer.jupiter.SetSystemProperty;
7677
import org.mockito.Mock;
7778
import org.mockito.Mockito;
7879
import org.mockito.junit.jupiter.MockitoExtension;
@@ -431,6 +432,20 @@ void builder_callAutoConfigureListeners() {
431432
verify(listener).afterAutoConfigure(sdk);
432433
}
433434

435+
@Test
436+
@SetSystemProperty(key = "maven.home", value = "temp")
437+
void builder_catchesException() throws InterruptedException {
438+
OpenTelemetrySdk sdk = mock(OpenTelemetrySdk.class);
439+
doThrow(NoClassDefFoundError.class).when(sdk).close();
440+
441+
Thread thread = builder.shutdownHook(sdk);
442+
thread.start();
443+
thread.join();
444+
445+
verify(sdk).close();
446+
logs.assertContains("Flush failed during shutdown");
447+
}
448+
434449
private static Supplier<Map<String, String>> disableExportPropertySupplier() {
435450
Map<String, String> props = new HashMap<>();
436451
props.put("otel.metrics.exporter", "none");

0 commit comments

Comments
 (0)