Skip to content

Commit d411cff

Browse files
committed
Set awt headless = true
1 parent 758a93e commit d411cff

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

fx-onscreen-keyboard/src/test/java/org/comtel2000/keyboard/control/KeyButtonTest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import java.util.concurrent.TimeUnit;
88
import java.util.concurrent.atomic.AtomicReference;
99

10-
import org.junit.jupiter.api.AfterAll;
1110
import org.junit.jupiter.api.AssertionFailureBuilder;
1211
import org.junit.jupiter.api.BeforeAll;
1312
import org.junit.jupiter.api.Test;
13+
import org.junit.jupiter.api.Timeout;
1414

1515
import javafx.animation.Animation;
1616
import javafx.application.Platform;
@@ -21,20 +21,21 @@ class KeyButtonTest {
2121

2222
@BeforeAll
2323
static void initToolkit() throws Exception {
24-
// Initialize JavaFX toolkit
25-
var latch = new CountDownLatch(1);
26-
Platform.startup(latch::countDown);
27-
if (!latch.await(3, TimeUnit.SECONDS)) {
28-
throw new IllegalStateException("JavaFX toolkit failed to initialize");
24+
// Ensure headless property is set early in CI via JAVA_TOOL_OPTIONS; this is
25+
// just in case.
26+
System.setProperty("java.awt.headless", System.getProperty("java.awt.headless", "true"));
27+
28+
// Initialize JavaFX toolkit (safe if already started)
29+
try {
30+
Platform.startup(() -> {
31+
/* no-op */ });
32+
} catch (IllegalStateException ex) {
33+
// toolkit already started
2934
}
3035
}
3136

32-
@AfterAll
33-
static void exitToolkit() throws Exception {
34-
Platform.exit();
35-
}
36-
3737
@Test
38+
@Timeout(value = 20, unit = TimeUnit.SECONDS)
3839
void previousTimelineStoppedWhenNewPressed() throws Exception {
3940
var latch = new CountDownLatch(1);
4041
var exception = new AtomicReference<Throwable>();

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@
142142
<waitUntil>uploaded</waitUntil>
143143
</configuration>
144144
</plugin>
145+
<plugin>
146+
<groupId>org.apache.maven.plugins</groupId>
147+
<artifactId>maven-surefire-plugin</artifactId>
148+
<version>3.5.4</version>
149+
<configuration>
150+
<systemPropertyVariables>
151+
<java.awt.headless>true</java.awt.headless>
152+
</systemPropertyVariables>
153+
</configuration>
154+
</plugin>
145155
</plugins>
146156

147157
<pluginManagement>

0 commit comments

Comments
 (0)