Skip to content

Commit 0e6f725

Browse files
authored
Add a test for InProc dependency (#2905)
based on [#7760](open-telemetry/opentelemetry-java-instrumentation#7760)
1 parent 8d34a55 commit 0e6f725

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

smoke-tests/apps/SpringScheduling/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33

44
package com.microsoft.applicationinsights.smoketestapp;
55

6+
import java.time.Instant;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.scheduling.TaskScheduler;
69
import org.springframework.web.bind.annotation.GetMapping;
710
import org.springframework.web.bind.annotation.RestController;
811

912
@RestController
1013
public class TestController {
1114

15+
@Autowired private TaskScheduler taskScheduler;
16+
1217
@GetMapping("/")
1318
public String root() {
1419
return "OK";
@@ -18,4 +23,10 @@ public String root() {
1823
public String scheduler() {
1924
return "OK!";
2025
}
26+
27+
@GetMapping("/should-ignore")
28+
public String shouldIgnoreTest() throws Exception {
29+
taskScheduler.schedule(() -> System.out.println("here i am"), Instant.now());
30+
return "OK!";
31+
}
2132
}

smoke-tests/apps/SpringScheduling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SpringSchedulingTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9;
1313
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8;
1414
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9;
15+
import static org.assertj.core.api.Assertions.assertThat;
1516

1617
import com.microsoft.applicationinsights.smoketest.schemav2.Data;
1718
import com.microsoft.applicationinsights.smoketest.schemav2.Envelope;
@@ -24,7 +25,19 @@
2425
@UseAgent
2526
abstract class SpringSchedulingTest {
2627

27-
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create();
28+
@RegisterExtension
29+
static final SmokeTestExtension testing =
30+
SmokeTestExtension.builder()
31+
.setSelfDiagnosticsLevel("debug")
32+
.build(); // SmokeTestExtension.create();
33+
34+
@Test
35+
@TargetUri("/should-ignore")
36+
void shouldIgnoreTest() throws Exception {
37+
// sleep a bit to make sure no dependencies are reported
38+
Thread.sleep(5000);
39+
assertThat(testing.mockedIngestion.getCountForType("RemoteDependencyData")).isZero();
40+
}
2841

2942
@Test
3043
@TargetUri("/scheduler")

0 commit comments

Comments
 (0)