Skip to content

Commit 1c463da

Browse files
authored
revert
1 parent a650a08 commit 1c463da

File tree

1 file changed

+3
-39
lines changed

1 file changed

+3
-39
lines changed

custom/src/test/java/co/elastic/otel/config/ConfigLoggingAgentListenerTest.java

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import java.util.ArrayList;
2929
import java.util.List;
3030
import java.util.concurrent.TimeUnit;
31-
import javax.tools.JavaCompiler;
32-
import javax.tools.ToolProvider;
3331
import org.junit.jupiter.api.AfterAll;
3432
import org.junit.jupiter.api.BeforeAll;
3533
import org.junit.jupiter.api.Test;
@@ -43,81 +41,47 @@ public class ConfigLoggingAgentListenerTest {
4341

4442
private static String agentJarFile;
4543
private static File testTargetClass;
46-
private static File testTargetCompiledClass;
4744

4845
@BeforeAll
4946
public static void setup() throws IOException {
5047
agentJarFile = getAgentJarFile();
5148
testTargetClass = createTestTarget();
52-
compileTestTarget(testTargetClass);
53-
testTargetCompiledClass = new File(testTargetClass.getParent(), TARGET_CLASS_NAME + ".class");
5449
}
5550

5651
@AfterAll
5752
public static void teardown() throws IOException {
5853
testTargetClass.delete();
59-
testTargetCompiledClass.delete();
6054
}
6155

6256
@Test
6357
public void checkLogConfigPresent() throws IOException {
64-
String output =
65-
filterOutUpstreamDebugConfigLine(executeCommand(createTestTargetCommand(true), 120));
58+
String output = executeCommand(createTestTargetCommand(true), 20);
6659
for (String identifyingString : identifyingStrings) {
6760
assertThat(output).contains(identifyingString);
6861
}
6962
}
7063

7164
@Test
7265
public void checkLogConfigAbsent() throws IOException {
73-
String output =
74-
filterOutUpstreamDebugConfigLine(executeCommand(createTestTargetCommand(false), 120));
66+
String output = executeCommand(createTestTargetCommand(false), 20);
7567
for (String identifyingString : identifyingStrings) {
7668
assertThat(output).doesNotContain(identifyingString);
7769
}
7870
}
7971

80-
static String filterOutUpstreamDebugConfigLine(String line) {
81-
// remove the debug level AutoConfiguredOpenTelemetrySdkBuilder output as this has the same
82-
// content apart from being from AutoConfiguredOpenTelemetrySdkBuilder
83-
if (line.contains(
84-
"AutoConfiguredOpenTelemetrySdkBuilder - Global OpenTelemetry set to OpenTelemetrySdk")) {
85-
return line.replaceFirst(
86-
"[\r\n].*?AutoConfiguredOpenTelemetrySdkBuilder - Global OpenTelemetry set to OpenTelemetrySdk.*?[\r\n]",
87-
"");
88-
}
89-
return line;
90-
}
91-
9272
static List<String> createTestTargetCommand(boolean logConfig) throws IOException {
9373
List<String> command = new ArrayList<>();
9474
command.add("java");
9575
command.add("-Xmx32m");
96-
command.add("-Dotel.javaagent.logging=application");
97-
command.add("-Dotel.javaagent.debug=false");
98-
command.add("-Dotel.service.name=ConfigLoggingAgentListenerTest:" + logConfig);
99-
command.add("-Dotel.traces.exporter=none");
100-
command.add("-Dotel.resource.providers.aws.enabled=false");
101-
command.add("-Dotel.resource.providers.gcp.enabled=false");
102-
command.add("-Dotel.resource.providers.azure.enabled=false");
10376
command.add("-javaagent:" + agentJarFile);
10477
// Only on false, ie test the 'true' default with no option
10578
if (!logConfig) {
10679
command.add("-D" + ConfigLoggingAgentListener.LOG_THE_CONFIG + "=false");
10780
}
108-
command.add("-cp");
109-
command.add(testTargetCompiledClass.getParentFile().getAbsolutePath());
110-
command.add(TARGET_CLASS_NAME);
81+
command.add(testTargetClass.getAbsolutePath());
11182
return command;
11283
}
11384

114-
static void compileTestTarget(File sourceFile) throws IOException {
115-
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
116-
if (compiler.run(null, null, null, sourceFile.getAbsolutePath()) != 0) {
117-
throw new IOException("Failed to compile test target");
118-
}
119-
}
120-
12185
static File createTestTarget() throws IOException {
12286
String targetClass =
12387
"public class "

0 commit comments

Comments
 (0)