AbstractSpringStarterSmokeTest.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright The OpenTelemetry Authors
  3. * SPDX-License-Identifier: Apache-2.0
  4. */
  5. package io.opentelemetry.spring.smoketest;
  6. import static org.assertj.core.api.Assertions.assertThat;
  7. import io.opentelemetry.api.OpenTelemetry;
  8. import org.junit.jupiter.api.AfterEach;
  9. import org.junit.jupiter.api.BeforeEach;
  10. import org.junit.jupiter.api.extension.ExtendWith;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.boot.test.system.CapturedOutput;
  13. import org.springframework.boot.test.system.OutputCaptureExtension;
  14. @ExtendWith(OutputCaptureExtension.class)
  15. public abstract class AbstractSpringStarterSmokeTest {
  16. @Autowired protected OpenTelemetry openTelemetry;
  17. protected SpringSmokeTestRunner testing;
  18. @BeforeEach
  19. void setUpTesting() {
  20. testing = new SpringSmokeTestRunner(openTelemetry);
  21. }
  22. @AfterEach
  23. void checkSpringLogs(CapturedOutput output) {
  24. // warnings are emitted if the auto-configuration have non-fatal problems
  25. assertThat(output)
  26. // not a warning in Spring Boot 2
  27. .doesNotContain("is not eligible for getting processed by all BeanPostProcessors")
  28. // only look for WARN and ERROR log level, e.g. [Test worker] WARN
  29. .doesNotContain("] WARN")
  30. .satisfies(
  31. s -> {
  32. if (!s.toString()
  33. .contains(
  34. "Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider")) {
  35. assertThat(s).doesNotContain("] ERROR");
  36. }
  37. });
  38. }
  39. }