Skip to content
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1b4efaf
suppress stderr
andy-goryachev-oracle Sep 11, 2025
923f1b4
fixed utility class name
andy-goryachev-oracle Sep 11, 2025
16638a4
2025
andy-goryachev-oracle Sep 11, 2025
a669287
revert intentionally failing test
andy-goryachev-oracle Sep 11, 2025
dd43ce9
whitespace
andy-goryachev-oracle Sep 11, 2025
7b228d4
Merge remote-tracking branch 'origin/master' into 8336332.failed
andy-goryachev-oracle Sep 15, 2025
cd1b946
cleanup
andy-goryachev-oracle Sep 15, 2025
12e0f6a
moved utility
andy-goryachev-oracle Sep 15, 2025
1a60d2e
fxml
andy-goryachev-oracle Sep 15, 2025
2b435a8
add exports
andy-goryachev-oracle Sep 15, 2025
fb1fd24
whitespace
andy-goryachev-oracle Sep 15, 2025
bbcc412
test.javafx.util
andy-goryachev-oracle Sep 15, 2025
14e972e
decouple logging
andy-goryachev-oracle Sep 16, 2025
b29b402
revert add exports
andy-goryachev-oracle Sep 16, 2025
49a1c66
launcher test
andy-goryachev-oracle Sep 16, 2025
7eb04ae
whitespace
andy-goryachev-oracle Sep 16, 2025
f7bb2e8
message
andy-goryachev-oracle Sep 16, 2025
a6dc4f1
single exit common
andy-goryachev-oracle Sep 17, 2025
d8c1910
expected
andy-goryachev-oracle Sep 17, 2025
09a3ec2
Merge remote-tracking branch 'origin/master' into 8367567.expected
andy-goryachev-oracle Sep 17, 2025
98f6099
snapshot 1 test
andy-goryachev-oracle Sep 17, 2025
4954914
reverted renaming
andy-goryachev-oracle Sep 18, 2025
447b96d
cleanup
andy-goryachev-oracle Sep 18, 2025
3afa270
review comments
andy-goryachev-oracle Sep 18, 2025
4399362
static
andy-goryachev-oracle Sep 18, 2025
3ed8135
review comments
andy-goryachev-oracle Sep 18, 2025
734c261
run and wait
andy-goryachev-oracle Sep 18, 2025
25695f5
revert snapshot 1 test
andy-goryachev-oracle Sep 18, 2025
a9abd5a
Merge remote-tracking branch 'origin/master' into 8336332.failed
andy-goryachev-oracle Sep 19, 2025
3d90049
throws
andy-goryachev-oracle Sep 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,35 @@

package test.com.sun.javafx.binding;

import com.sun.javafx.binding.BidirectionalBinding;
import javafx.beans.binding.Bindings;
import javafx.beans.property.*;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

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;
import java.util.Arrays;
import java.util.Collection;
import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.property.ReadOnlyBooleanWrapper;
import javafx.beans.property.ReadOnlyDoubleWrapper;
import javafx.beans.property.ReadOnlyFloatWrapper;
import javafx.beans.property.ReadOnlyIntegerWrapper;
import javafx.beans.property.ReadOnlyLongWrapper;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import com.sun.javafx.binding.BidirectionalBinding;
import test.javafx.util.OutputRedirect;

public class BidirectionalBindingTest<T> {

Expand Down Expand Up @@ -69,6 +85,16 @@ public T[] getValues() {
private Property<T> op4;
private T[] v;

@BeforeEach
public void beforeEach() {
OutputRedirect.suppressStderr();
}

@AfterEach
public void afterEach() {
OutputRedirect.checkAndRestoreStderr();
}

private void setUp(Factory<T> factory) {
this.factory = factory;
op1 = factory.createProperty();
Expand Down Expand Up @@ -305,6 +331,8 @@ public void testBrokenBind(Factory<T> factory) {
op2.setValue(v[2]);
assertEquals(op3.getValue(), op1.getValue());
assertEquals(op2.getValue(), op1.getValue());

OutputRedirect.checkAndRestoreStderr(RuntimeException.class);
}

@ParameterizedTest
Expand All @@ -325,6 +353,8 @@ public void testDoubleBrokenBind(Factory<T> factory) {
assertEquals(op3.getValue(), op1.getValue());
assertEquals(v[0], op1.getValue());
assertEquals(v[1], op2.getValue());

OutputRedirect.checkAndRestoreStderr(RuntimeException.class);
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2025, 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,22 +27,13 @@

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


import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.BitSet;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

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

import com.sun.javafx.binding.ExpressionHelper;
import com.sun.javafx.binding.ExpressionHelperShim;

import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.ObjectProperty;
Expand All @@ -52,10 +43,15 @@
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.beans.value.ObservableValueStub;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.sun.javafx.binding.ExpressionHelper;
import com.sun.javafx.binding.ExpressionHelperShim;
import test.javafx.beans.InvalidationListenerMock;
import test.javafx.beans.WeakInvalidationListenerMock;
import test.javafx.beans.value.ChangeListenerMock;
import test.javafx.beans.value.WeakChangeListenerMock;
import test.javafx.util.OutputRedirect;
import test.util.memory.JMemoryBuddy;

public class ExpressionHelperTest {
Expand Down Expand Up @@ -566,7 +562,13 @@ public void testExceptionNotPropagatedFromMultipleInvalidation() {
public void testExceptionNotPropagatedFromSingleChange() {
helper = ExpressionHelper.addListener(helper, observable, (value, o1, o2) -> {throw new RuntimeException();});
observable.set(null);
ExpressionHelperShim.fireValueChangedEvent(helper);

OutputRedirect.suppressStderr();
try {
ExpressionHelperShim.fireValueChangedEvent(helper);
} finally {
OutputRedirect.checkAndRestoreStderr(RuntimeException.class);
}
}

@Test
Expand All @@ -576,7 +578,13 @@ public void testExceptionNotPropagatedFromMultipleChange() {
helper = ExpressionHelper.addListener(helper, observable, (value, o1, o2) -> {called.set(0); throw new RuntimeException();});
helper = ExpressionHelper.addListener(helper, observable, (value, o1, o2) -> {called.set(1); throw new RuntimeException();});
observable.set(null);
ExpressionHelperShim.fireValueChangedEvent(helper);

OutputRedirect.suppressStderr();
try {
ExpressionHelperShim.fireValueChangedEvent(helper);
} finally {
OutputRedirect.checkAndRestoreStderr(RuntimeException.class, RuntimeException.class);
}

assertTrue(called.get(0));
assertTrue(called.get(1));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2025, 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,13 +24,17 @@
*/
package test.com.sun.javafx.binding;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import test.javafx.beans.Person;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.binding.DoubleBinding;
Expand All @@ -39,13 +43,14 @@
import javafx.beans.binding.LongBinding;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.binding.StringBinding;
import test.javafx.binding.Variable;
import javafx.collections.ObservableList;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import test.javafx.beans.Person;
import test.javafx.binding.Variable;
import test.javafx.util.OutputRedirect;

public class SelectBindingTest {

Expand Down Expand Up @@ -102,13 +107,14 @@ public void removePropertyChangeListener(String property, PropertyChangeListener
private ObservableList<?> dependencies;

@BeforeAll
public static void setUpClass() {
System.err.println("SelectBindingTest : log messages are expected from these tests.");
public void setUpClass() throws Exception {
ErrorLoggingUtiltity.reset();
}

@BeforeEach
public void setUp() throws Exception {
OutputRedirect.suppressStderr();

a = new Variable("a");
b = new Variable("b");
c = new Variable("c");
Expand All @@ -119,6 +125,11 @@ public void setUp() throws Exception {
dependencies = select.getDependencies();
}

@AfterEach
public void afterEach() {
OutputRedirect.checkAndRestoreStderr();
}

@Test
public void testObject() {
final Person person1 = new Person();
Expand Down Expand Up @@ -397,6 +408,7 @@ public void createWithNoSteps() {
a.setName(null);
assertNull(select.get());
ErrorLoggingUtiltity.checkWarning(NullPointerException.class);
OutputRedirect.checkAndRestoreStderr(NullPointerException.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package test.javafx.binding;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.Callable;
Expand All @@ -39,14 +41,13 @@
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import test.com.sun.javafx.binding.ErrorLoggingUtiltity;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import static org.junit.jupiter.api.Assertions.*;
import test.com.sun.javafx.binding.ErrorLoggingUtiltity;
import test.javafx.util.OutputRedirect;

/**
*/
Expand All @@ -72,6 +73,16 @@ public static void setUpClass() {
ErrorLoggingUtiltity.reset();
}

@BeforeEach
public void beforeEach() {
OutputRedirect.suppressStderr();
}

@AfterEach
public void afterEach() {
OutputRedirect.checkAndRestoreStderr();
}

private void setup(Property<T> p0, Property<T> p1, Functions<T> f, T value0, T value1, T defaultValue) {
this.p0 = p0;
this.p1 = p1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2025, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.javafx.util;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;

/**
* PrintStream that accumulates output in memory.
*/
public class AccumulatingPrintStream extends PrintStream {

private final ByteArrayOutputStream out;

private AccumulatingPrintStream(ByteArrayOutputStream out) {
super(out);
this.out = out;
}

public static AccumulatingPrintStream create() {
ByteArrayOutputStream out = new ByteArrayOutputStream();
return new AccumulatingPrintStream(out);
}

public String getAccumulatedOutput() {
byte[] b = out.toByteArray();
return new String(b, charset());
}
}
Loading