package com.tcs.isn.fame.cots.binding.javafx.tuto1; import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.Test; import javafx.beans.property.Property; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.scene.control.TextField; /** */ public class FXPropertyChangeTest { @Test public void not_wrong_intermediate_update_value() { TextField field = new TextField("tes"); Property property = field.textProperty(); property.addListener(new ChangeListener() { @Override public void changed(ObservableValue value, String oldVal, String newVal) { Assert.assertThat(oldVal, CoreMatchers.equalTo("tes")); Assert.assertThat(newVal, CoreMatchers.equalTo("test")); } }); field.insertText(field.getText().length(), "t"); } @Test public void wrong_intermediate_update_value() { TextField field = new TextField("old"); Property property = field.textProperty(); property.addListener(new ChangeListener() { @Override public void changed(ObservableValue value, String oldVal, String newVal) { Assert.assertThat(oldVal, CoreMatchers.equalTo("old")); Assert.assertThat(newVal, CoreMatchers.equalTo("new")); } }); field.setText("new"); } }