Skip to content

Commit 5993c09

Browse files
committed
8339513: [TestBug] Convert fxml tests to JUnit 5
Reviewed-by: kcr, angorya, mhanl
1 parent 3e6a272 commit 5993c09

31 files changed

+165
-124
lines changed

modules/javafx.fxml/src/test/java/test/com/sun/javafx/fxml/builder/ProxyBuilderTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,9 +31,14 @@
3131
import javafx.scene.paint.Color;
3232
import javafx.scene.paint.Paint;
3333
import javafx.stage.StageStyle;
34-
import org.junit.Test;
35-
import static org.junit.Assert.*;
36-
import org.junit.Ignore;
34+
35+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
36+
import static org.junit.jupiter.api.Assertions.assertEquals;
37+
import static org.junit.jupiter.api.Assertions.assertTrue;
38+
import static org.junit.jupiter.api.Assertions.fail;
39+
40+
import org.junit.jupiter.api.Test;
41+
import org.junit.jupiter.api.Disabled;
3742

3843
public class ProxyBuilderTest {
3944

@@ -97,7 +102,7 @@ public void testImmutableWithList() {
97102
}
98103

99104
@Test
100-
@Ignore
105+
@Disabled
101106
public void testImmutableTwoConstructorsWithSameArgNames() {
102107
ProxyBuilder pb = new ProxyBuilder(ImmutableClass.class);
103108
pb.put("a", 123);

modules/javafx.fxml/src/test/java/test/javafx/fxml/AlertTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024 Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,8 @@
2828
import javafx.fxml.FXMLLoader;
2929
import javafx.scene.control.Alert;
3030
import javafx.scene.control.ButtonType;
31-
import static org.junit.Assert.assertArrayEquals;
32-
import org.junit.Test;
31+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
32+
import org.junit.jupiter.api.Test;
3333

3434
public class AlertTest {
3535

modules/javafx.fxml/src/test/java/test/javafx/fxml/CompareVersionsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,9 +26,9 @@
2626
package test.javafx.fxml;
2727

2828
import javafx.fxml.FXMLLoaderShim;
29-
import org.junit.Test;
29+
import org.junit.jupiter.api.Test;
3030

31-
import static org.junit.Assert.*;
31+
import static org.junit.jupiter.api.Assertions.assertTrue;
3232

3333
public class CompareVersionsTest {
3434
@Test

modules/javafx.fxml/src/test/java/test/javafx/fxml/FXMLLoaderTest_FieldInjectionTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
package test.javafx.fxml;
21
/*
3-
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
43
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
54
*
65
* This code is free software; you can redistribute it and/or modify it
@@ -24,17 +23,19 @@
2423
* questions.
2524
*/
2625

26+
package test.javafx.fxml;
27+
2728
import javafx.scene.Node;
2829
import javafx.scene.Parent;
2930
import javafx.scene.shape.Rectangle;
30-
import org.junit.Test;
31+
import org.junit.jupiter.api.Test;
3132

3233
import java.io.IOException;
3334
import javafx.fxml.FXML;
3435
import javafx.fxml.FXMLLoader;
3536

36-
import static org.junit.Assert.assertEquals;
37-
import static org.junit.Assert.assertNotNull;
37+
import static org.junit.jupiter.api.Assertions.assertEquals;
38+
import static org.junit.jupiter.api.Assertions.assertNotNull;
3839

3940
public class FXMLLoaderTest_FieldInjectionTest {
4041

modules/javafx.fxml/src/test/java/test/javafx/fxml/FXMLLoader_BuilderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
package test.javafx.fxml;
21
/*
3-
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
43
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
54
*
65
* This code is free software; you can redistribute it and/or modify it
@@ -23,11 +22,12 @@
2322
* or visit www.oracle.com if you need additional information or have any
2423
* questions.
2524
*/
25+
package test.javafx.fxml;
2626

2727
import javafx.scene.shape.TriangleMesh;
28-
import org.junit.Test;
28+
import org.junit.jupiter.api.Test;
2929

30-
import static org.junit.Assert.*;
30+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
3131

3232
import java.io.IOException;
3333
import javafx.fxml.FXMLLoader;

modules/javafx.fxml/src/test/java/test/javafx/fxml/FXMLLoader_EventsTest.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
package test.javafx.fxml;
2-
3-
import javafx.beans.value.ChangeListener;
4-
import javafx.beans.value.ObservableValue;
5-
import javafx.util.Callback;
6-
import org.junit.Test;
7-
8-
import java.io.IOException;
9-
import javafx.fxml.FXMLLoader;
10-
import javafx.fxml.LoadException;
11-
12-
import static org.junit.Assert.*;
13-
141
/*
15-
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
163
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
174
*
185
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +22,23 @@
3522
* or visit www.oracle.com if you need additional information or have any
3623
* questions.
3724
*/
25+
26+
package test.javafx.fxml;
27+
28+
import javafx.beans.value.ChangeListener;
29+
import javafx.beans.value.ObservableValue;
30+
import javafx.util.Callback;
31+
import org.junit.jupiter.api.Test;
32+
33+
import java.io.IOException;
34+
import javafx.fxml.FXMLLoader;
35+
import javafx.fxml.LoadException;
36+
37+
import static org.junit.jupiter.api.Assertions.assertEquals;
38+
import static org.junit.jupiter.api.Assertions.assertFalse;
39+
import static org.junit.jupiter.api.Assertions.assertThrows;
40+
import static org.junit.jupiter.api.Assertions.assertTrue;
41+
3842
public class FXMLLoader_EventsTest {
3943
@Test
4044
public void testListEvents() throws Exception {
@@ -201,10 +205,12 @@ public void changed(ObservableValue<? extends Object> ov, Object o, Object n) {
201205
}
202206

203207

204-
@Test(expected = LoadException.class)
208+
@Test
205209
public void testPropertyEvents_testExpressionHandler_NA() throws IOException {
206-
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("property_events_test_expression_na.fxml"));
207-
fxmlLoader.load();
210+
assertThrows(LoadException.class, () -> {
211+
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("property_events_test_expression_na.fxml"));
212+
fxmlLoader.load();
213+
});
208214
}
209215

210216
@Test

modules/javafx.fxml/src/test/java/test/javafx/fxml/FXMLLoader_ExpressionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,7 @@
2828
import com.sun.javafx.fxml.expression.Expression;
2929
import com.sun.javafx.fxml.expression.KeyPath;
3030
import javafx.collections.ObservableList;
31-
import org.junit.Test;
31+
import org.junit.jupiter.api.Test;
3232

3333
import java.io.IOException;
3434
import java.util.HashMap;
@@ -37,7 +37,7 @@
3737
import static com.sun.javafx.fxml.expression.Expression.*;
3838
import static com.sun.javafx.fxml.expression.Expression.set;
3939
import static com.sun.javafx.fxml.expression.Expression.valueOf;
40-
import static org.junit.Assert.assertEquals;
40+
import static org.junit.jupiter.api.Assertions.assertEquals;
4141

4242
public class FXMLLoader_ExpressionTest {
4343

modules/javafx.fxml/src/test/java/test/javafx/fxml/FXMLLoader_ScriptTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
package test.javafx.fxml;
21
/*
3-
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
43
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
54
*
65
* This code is free software; you can redistribute it and/or modify it
@@ -23,9 +22,10 @@
2322
* or visit www.oracle.com if you need additional information or have any
2423
* questions.
2524
*/
25+
package test.javafx.fxml;
2626

2727
import com.sun.javafx.fxml.FXMLLoaderHelper;
28-
import org.junit.Test;
28+
import org.junit.jupiter.api.Test;
2929

3030
import java.io.IOException;
3131
import java.util.concurrent.atomic.AtomicBoolean;
@@ -34,8 +34,11 @@
3434
import javax.script.ScriptEngineManager;
3535
import javax.script.ScriptEngine;
3636

37-
import static org.junit.Assert.*;
38-
import static org.junit.Assume.assumeTrue;
37+
import static org.junit.jupiter.api.Assertions.assertFalse;
38+
import static org.junit.jupiter.api.Assertions.assertTrue;
39+
import static org.junit.jupiter.api.Assertions.assertNotNull;
40+
41+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
3942

4043
public class FXMLLoader_ScriptTest {
4144
@Test

modules/javafx.fxml/src/test/java/test/javafx/fxml/RT_15524Test.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,9 +28,10 @@
2828
import java.io.IOException;
2929
import java.util.Arrays;
3030
import javafx.fxml.FXMLLoader;
31-
import org.junit.Test;
31+
import org.junit.jupiter.api.Test;
3232

33-
import static org.junit.Assert.*;
33+
import static org.junit.jupiter.api.Assertions.assertEquals;
34+
import static org.junit.jupiter.api.Assertions.assertTrue;
3435

3536
public class RT_15524Test {
3637
@Test

modules/javafx.fxml/src/test/java/test/javafx/fxml/RT_16724Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
2727

2828
import java.io.IOException;
2929
import javafx.fxml.FXMLLoader;
30-
import org.junit.Test;
30+
import org.junit.jupiter.api.Test;
3131

3232
public class RT_16724Test {
3333
@Test

0 commit comments

Comments
 (0)