Skip to content

Commit 927fee2

Browse files
committed
prepare moving TestApp to separate sourceSet
1 parent 20354af commit 927fee2

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/JmxConnectorBuilderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private static void testConnector(ConnectorSupplier connectorSupplier) {
7676
.satisfies(
7777
connection -> {
7878
try {
79-
ObjectName name = new ObjectName(TestApp.OBJECT_NAME);
79+
ObjectName name = new ObjectName("io.opentelemetry.test:name=TestApp");
8080
Object value = connection.getAttribute(name, "IntValue");
8181
assertThat(value).isEqualTo(42);
8282
} catch (Exception e) {

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/TestApp.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
import javax.management.MBeanServer;
1010
import javax.management.ObjectName;
1111

12-
@SuppressWarnings("all")
1312
public class TestApp implements TestAppMXBean {
1413

15-
public static final String APP_STARTED_MSG = "app started";
16-
public static final String OBJECT_NAME = "io.opentelemetry.test:name=TestApp";
17-
1814
private volatile boolean running;
1915

16+
@SuppressWarnings("BusyWait")
2017
public static void main(String[] args) {
2118
TestApp app = TestApp.start();
2219
while (app.isRunning()) {
@@ -34,13 +31,13 @@ static TestApp start() {
3431
TestApp app = new TestApp();
3532
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
3633
try {
37-
ObjectName objectName = new ObjectName(OBJECT_NAME);
34+
ObjectName objectName = new ObjectName("io.opentelemetry.test:name=TestApp");
3835
mbs.registerMBean(app, objectName);
3936
} catch (Exception e) {
4037
throw new RuntimeException(e);
4138
}
4239
app.running = true;
43-
System.out.println(APP_STARTED_MSG);
40+
System.out.println("app started");
4441
return app;
4542
}
4643

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/TestAppContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.testcontainers.shaded.com.google.errorprone.annotations.CanIgnoreReturnValue;
2222
import org.testcontainers.utility.MountableFile;
2323

24-
/** Test container that allows to execute {@link TestApp} in an isolated container */
24+
/** Test container that allows to execute TestApp in an isolated container */
2525
public class TestAppContainer extends GenericContainer<TestAppContainer> {
2626

2727
private final Map<String, String> properties;
@@ -38,7 +38,7 @@ public TestAppContainer() {
3838

3939
this.withCopyFileToContainer(MountableFile.forHostPath(appJar), "/app.jar")
4040
.waitingFor(
41-
Wait.forLogMessage(TestApp.APP_STARTED_MSG + "\\n", 1)
41+
Wait.forLogMessage("app started\\n", 1)
4242
.withStartupTimeout(Duration.ofSeconds(5)))
4343
.withCommand("java", "-jar", "/app.jar");
4444
}

0 commit comments

Comments
 (0)