diff --git a/smoke-tests/apps/SpringScheduling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java b/smoke-tests/apps/SpringScheduling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java index 62bd220c782..902c473c6bc 100644 --- a/smoke-tests/apps/SpringScheduling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java +++ b/smoke-tests/apps/SpringScheduling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java @@ -3,12 +3,17 @@ package com.microsoft.applicationinsights.smoketestapp; +import java.time.Instant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.TaskScheduler; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { + @Autowired private TaskScheduler taskScheduler; + @GetMapping("/") public String root() { return "OK"; @@ -18,4 +23,10 @@ public String root() { public String scheduler() { return "OK!"; } + + @GetMapping("/should-ignore") + public String shouldIgnoreTest() throws Exception { + taskScheduler.schedule(() -> System.out.println("here i am"), Instant.now()); + return "OK!"; + } } diff --git a/smoke-tests/apps/SpringScheduling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SpringSchedulingTest.java b/smoke-tests/apps/SpringScheduling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SpringSchedulingTest.java index 9b028e42bdc..267b80aff75 100644 --- a/smoke-tests/apps/SpringScheduling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SpringSchedulingTest.java +++ b/smoke-tests/apps/SpringScheduling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SpringSchedulingTest.java @@ -12,6 +12,7 @@ import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9; import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8; import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9; +import static org.assertj.core.api.Assertions.assertThat; import com.microsoft.applicationinsights.smoketest.schemav2.Data; import com.microsoft.applicationinsights.smoketest.schemav2.Envelope; @@ -24,7 +25,19 @@ @UseAgent abstract class SpringSchedulingTest { - @RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); + @RegisterExtension + static final SmokeTestExtension testing = + SmokeTestExtension.builder() + .setSelfDiagnosticsLevel("debug") + .build(); // SmokeTestExtension.create(); + + @Test + @TargetUri("/should-ignore") + void shouldIgnoreTest() throws Exception { + // sleep a bit to make sure no dependencies are reported + Thread.sleep(5000); + assertThat(testing.mockedIngestion.getCountForType("RemoteDependencyData")).isZero(); + } @Test @TargetUri("/scheduler")