Skip to content

Commit c5256c8

Browse files
committed
ensure all tests can be run together (avoid IllegalStateException from one set of tests killing JavaFX)
1 parent ca9487f commit c5256c8

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

app/ux-analytics/monitor/src/test/java/org/phoebus/applications/uxanalytics/monitor/backend/database/ServiceLayerConnectionTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,12 @@ public class ServiceLayerConnectionTest {
5252

5353
@BeforeAll
5454
public static void initJFX(){
55-
Platform.startup(()->{});
56-
57-
}
58-
59-
@AfterAll
60-
public static void tearDownJFX(){
61-
Platform.exit();
55+
try {
56+
Platform.startup(() -> {});
57+
}
58+
catch (IllegalStateException e) {
59+
// JFX already started
60+
}
6261
}
6362

6463
public void setupUI(){

app/ux-analytics/monitor/src/test/java/org/phoebus/applications/uxanalytics/monitor/representation/ActiveTabTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ public class ActiveTabTest {
4646
@BeforeAll
4747
public static void startJFX()
4848
{
49-
Platform.startup(()->{});
50-
}
51-
52-
@AfterAll
53-
public static void stopJFX()
54-
{
55-
Platform.exit();
49+
try {
50+
Platform.startup(() -> {});
51+
}
52+
catch (IllegalStateException e) {
53+
// JFX already started
54+
}
5655
}
5756

5857
@BeforeEach

app/ux-analytics/monitor/src/test/java/org/phoebus/applications/uxanalytics/monitor/representation/ActiveWindowsServiceTest.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ public class ActiveWindowsServiceTest {
3737

3838
@BeforeAll
3939
static void setUp() {
40-
Platform.startup(() -> {});
40+
try {
41+
Platform.startup(() -> {});
42+
}
43+
catch (IllegalStateException e) {
44+
// JFX already started
45+
}
4146
Platform.runLater(()->{
4247
app = new DisplayRuntimeApplication();
4348
stage = new Stage();
@@ -63,15 +68,6 @@ void reset() {
6368
activeWindowsService.clear();
6469
}
6570

66-
@AfterAll
67-
static void tearDown() {
68-
Platform.runLater(() ->{
69-
if(stage!=null)
70-
stage.close();
71-
});
72-
Platform.exit();
73-
}
74-
7571
@Test
7672
synchronized void testWindowIsPresentInActiveWindowsServiceWhenActive(){
7773
try {

0 commit comments

Comments
 (0)