Skip to content

Commit

Permalink
8339513: [TestBug] Convert fxml tests to JUnit 5
Browse files Browse the repository at this point in the history
Reviewed-by: kcr, angorya, mhanl
  • Loading branch information
aghaisas committed Sep 16, 2024
1 parent 3e6a272 commit 5993c09
Show file tree
Hide file tree
Showing 31 changed files with 165 additions and 124 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,9 +31,14 @@
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.stage.StageStyle;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Ignore;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Disabled;

public class ProxyBuilderTest {

Expand Down Expand Up @@ -97,7 +102,7 @@ public void testImmutableWithList() {
}

@Test
@Ignore
@Disabled
public void testImmutableTwoConstructorsWithSameArgNames() {
ProxyBuilder pb = new ProxyBuilder(ImmutableClass.class);
pb.put("a", 123);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,8 +28,8 @@
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.api.Test;

public class AlertTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,9 +26,9 @@
package test.javafx.fxml;

import javafx.fxml.FXMLLoaderShim;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class CompareVersionsTest {
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package test.javafx.fxml;
/*
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,17 +23,19 @@
* questions.
*/

package test.javafx.fxml;

import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.shape.Rectangle;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class FXMLLoaderTest_FieldInjectionTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package test.javafx.fxml;
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,11 +22,12 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.javafx.fxml;

import javafx.scene.shape.TriangleMesh;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import java.io.IOException;
import javafx.fxml.FXMLLoader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
package test.javafx.fxml;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.util.Callback;
import org.junit.Test;

import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.fxml.LoadException;

import static org.junit.Assert.*;

/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -35,6 +22,23 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package test.javafx.fxml;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.util.Callback;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.fxml.LoadException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class FXMLLoader_EventsTest {
@Test
public void testListEvents() throws Exception {
Expand Down Expand Up @@ -201,10 +205,12 @@ public void changed(ObservableValue<? extends Object> ov, Object o, Object n) {
}


@Test(expected = LoadException.class)
@Test
public void testPropertyEvents_testExpressionHandler_NA() throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("property_events_test_expression_na.fxml"));
fxmlLoader.load();
assertThrows(LoadException.class, () -> {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("property_events_test_expression_na.fxml"));
fxmlLoader.load();
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,7 +28,7 @@
import com.sun.javafx.fxml.expression.Expression;
import com.sun.javafx.fxml.expression.KeyPath;
import javafx.collections.ObservableList;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.HashMap;
Expand All @@ -37,7 +37,7 @@
import static com.sun.javafx.fxml.expression.Expression.*;
import static com.sun.javafx.fxml.expression.Expression.set;
import static com.sun.javafx.fxml.expression.Expression.valueOf;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class FXMLLoader_ExpressionTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package test.javafx.fxml;
/*
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,9 +22,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.javafx.fxml;

import com.sun.javafx.fxml.FXMLLoaderHelper;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -34,8 +34,11 @@
import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;

import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import static org.junit.jupiter.api.Assumptions.assumeTrue;

public class FXMLLoader_ScriptTest {
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,9 +28,10 @@
import java.io.IOException;
import java.util.Arrays;
import javafx.fxml.FXMLLoader;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class RT_15524Test {
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,7 +27,7 @@

import java.io.IOException;
import javafx.fxml.FXMLLoader;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class RT_16724Test {
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,9 +28,9 @@
import java.io.IOException;
import java.util.ResourceBundle;
import javafx.fxml.FXMLLoader;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class RT_16815Test {
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,9 +26,9 @@
package test.javafx.fxml;

import javafx.fxml.FXMLLoader;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class RT_16977Test {
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -30,9 +30,10 @@
import java.util.Map;
import javafx.fxml.FXMLLoader;
import javafx.fxml.LoadListener;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class RT_18218Test {
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,12 +28,16 @@
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.fxml.LoadException;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertThrows;

public class RT_18933Test {
@Test(expected=LoadException.class)
@Test
public void testDefaultListProperty() throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("rt_18933.fxml"));
fxmlLoader.load();
assertThrows(LoadException.class, () -> {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("rt_18933.fxml"));
fxmlLoader.load();
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,11 +27,15 @@

import java.io.IOException;
import javafx.fxml.FXMLLoader;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertThrows;

public class RT_19008Test {
@Test(expected=NullPointerException.class)
@Test
public void testMissingResource() throws IOException {
FXMLLoader.load(getClass().getResource("rt_19008.fxml"));
assertThrows(NullPointerException.class, () -> {
FXMLLoader.load(getClass().getResource("rt_19008.fxml"));
});
}
}
Loading

1 comment on commit 5993c09

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.