@@ -627,6 +627,43 @@ public void testRebind() {
627
627
invalidationListener .check (null , 0 );
628
628
}
629
629
630
+ @ Test
631
+ public void testRebind_Identity () {
632
+ final ListProperty <Object > v1 = new SimpleListProperty <>(FXCollections .observableArrayList ());
633
+ final ListProperty <Object > v2 = new SimpleListProperty <>(FXCollections .observableArrayList ());
634
+ attachListChangeListener ();
635
+
636
+ // bind
637
+ property .bind (v1 );
638
+ property .check (1 );
639
+ listChangeListener .check1AddRemove (property , EMPTY_LIST , 0 , 0 );
640
+ listChangeListener .clear ();
641
+
642
+ // rebind to same
643
+ property .bind (v1 );
644
+ property .check (0 );
645
+ listChangeListener .check0 ();
646
+
647
+ // rebind to other, without explicitly unbinding
648
+ property .bind (v2 );
649
+ property .check (1 );
650
+ listChangeListener .check1AddRemove (property , EMPTY_LIST , 0 , 0 );
651
+ listChangeListener .clear ();
652
+
653
+ v2 .add ("One" );
654
+ listChangeListener .check1AddRemove (property , EMPTY_LIST , 0 , 1 );
655
+ listChangeListener .clear ();
656
+
657
+ v2 .add ("Two" );
658
+ listChangeListener .check1AddRemove (property , EMPTY_LIST , 1 , 2 );
659
+ listChangeListener .clear ();
660
+
661
+ property .check (4 );
662
+ assertTrue (property .isBound ());
663
+ assertEquals (2 , property .toArray ().length );
664
+ assertEquals ("ListProperty [bound, value: [One, Two]]" , property .toString ());
665
+ }
666
+
630
667
@ Test
631
668
public void testUnbind () {
632
669
attachInvalidationListener ();
0 commit comments