1 /*
   2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package test.javafx.binding;
  27 
  28 import javafx.beans.binding.*;
  29 import javafx.beans.property.IntegerProperty;
  30 import javafx.beans.property.ListProperty;
  31 import javafx.beans.property.SimpleIntegerProperty;
  32 import javafx.beans.property.SimpleListProperty;
  33 import javafx.collections.FXCollections;
  34 import javafx.collections.ObservableList;
  35 import test.com.sun.javafx.binding.ErrorLoggingUtiltity;
  36 import org.junit.Before;
  37 import org.junit.BeforeClass;
  38 import org.junit.Test;
  39 
  40 import static org.junit.Assert.*;
  41 
  42 /**
  43  */
  44 public class BindingsListTest {
  45 
  46     private static final double EPSILON_DOUBLE = 1e-12;
  47     private static final float EPSILON_FLOAT = 1e-5f;
  48 
  49     private static final Object data1 = new Object();
  50     private static final Object data2 = new Object();
  51 
  52     private ListProperty<Object> property;
  53     private ObservableList<Object> list1;
  54     private ObservableList<Object> list2;
  55     private IntegerProperty index;
  56 
  57     @BeforeClass
  58     public static void setUpClass() {
  59         ErrorLoggingUtiltity.reset();
  60     }
  61 
  62     @Before
  63     public void setUp() {
  64         property = new SimpleListProperty<Object>();
  65         list1 = FXCollections.<Object>observableArrayList(data1, data2);
  66         list2 = FXCollections.<Object>observableArrayList();
  67         index = new SimpleIntegerProperty();
  68     }
  69 
  70     @Test
  71     public void testSize() {
  72         final IntegerBinding size = Bindings.size(property);
  73         DependencyUtils.checkDependencies(size.getDependencies(), property);
  74 
  75         assertEquals(0, size.get());
  76         property.set(list1);
  77         assertEquals(2, size.get());
  78         list1.remove(data2);
  79         assertEquals(1, size.get());
  80         property.set(list2);
  81         assertEquals(0, size.get());
  82         property.addAll(data2, data2);
  83         assertEquals(2, size.get());
  84         property.set(null);
  85         assertEquals(0, size.get());
  86     }
  87 
  88     @Test(expected = NullPointerException.class)
  89     public void testSize_Null() {
  90         Bindings.size((ObservableList<Object>) null);
  91     }
  92 
  93     @Test
  94     public void testIsEmpty() {
  95         final BooleanBinding empty = Bindings.isEmpty(property);
  96         DependencyUtils.checkDependencies(empty.getDependencies(), property);
  97 
  98         assertTrue(empty.get());
  99         property.set(list1);
 100         assertFalse(empty.get());
 101         list1.remove(data2);
 102         assertFalse(empty.get());
 103         property.set(list2);
 104         assertTrue(empty.get());
 105         property.addAll(data2, data2);
 106         assertFalse(empty.get());
 107         property.set(null);
 108         assertTrue(empty.get());
 109     }
 110 
 111     @Test(expected = NullPointerException.class)
 112     public void testIsEmpty_Null() {
 113         Bindings.isEmpty((ObservableList<Object>) null);
 114     }
 115 
 116     @Test
 117     public void testIsNotEmpty() {
 118         final BooleanBinding notEmpty = Bindings.isNotEmpty(property);
 119         DependencyUtils.checkDependencies(notEmpty.getDependencies(), property);
 120 
 121         assertFalse(notEmpty.get());
 122         property.set(list1);
 123         assertTrue(notEmpty.get());
 124         list1.remove(data2);
 125         assertTrue(notEmpty.get());
 126         property.set(list2);
 127         assertFalse(notEmpty.get());
 128         property.addAll(data2, data2);
 129         assertTrue(notEmpty.get());
 130         property.set(null);
 131         assertFalse(notEmpty.get());
 132     }
 133 
 134     @Test(expected = NullPointerException.class)
 135     public void testIsNotEmpty_Null() {
 136         Bindings.isNotEmpty((ObservableList<Object>) null);
 137     }
 138 
 139     @Test
 140     public void testValueAt_Constant() {
 141         final ObjectBinding<Object> binding0 = Bindings.valueAt(property, 0);
 142         final ObjectBinding<Object> binding1 = Bindings.valueAt(property, 1);
 143         final ObjectBinding<Object> binding2 = Bindings.valueAt(property, 2);
 144         DependencyUtils.checkDependencies(binding0.getDependencies(), property);
 145         DependencyUtils.checkDependencies(binding1.getDependencies(), property);
 146         DependencyUtils.checkDependencies(binding2.getDependencies(), property);
 147         assertNull(binding0.get());
 148         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 149         assertNull(binding1.get());
 150         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 151         assertNull(binding2.get());
 152         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 153 
 154         property.set(list1);
 155         assertEquals(data1, binding0.get());
 156         assertEquals(data2, binding1.get());
 157         assertNull(binding2.get());
 158         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 159 
 160         property.remove(data2);
 161         assertEquals(data1, binding0.get());
 162         assertNull(binding1.get());
 163         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 164         assertNull(binding2.get());
 165         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 166 
 167         property.set(list2);
 168         assertNull(binding0.get());
 169         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 170         assertNull(binding1.get());
 171         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 172         assertNull(binding2.get());
 173         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 174 
 175         property.addAll(data2, data2);
 176         assertEquals(data2, binding0.get());
 177         assertEquals(data2, binding1.get());
 178         assertNull(binding2.get());
 179         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 180 
 181         property.set(null);
 182         assertNull(binding0.get());
 183         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 184         assertNull(binding1.get());
 185         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 186         assertNull(binding2.get());
 187         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 188     }
 189 
 190     @Test(expected = NullPointerException.class)
 191     public void testValueAt_Constant_Null() {
 192         Bindings.valueAt(null, 0);
 193     }
 194 
 195     @Test(expected = IllegalArgumentException.class)
 196     public void testValueAt_Constant_NegativeIndex() {
 197         Bindings.valueAt(property, -1);
 198     }
 199 
 200     @Test
 201     public void testValueAt_Variable() {
 202         final ObjectBinding<Object> binding = Bindings.valueAt(property, index);
 203         DependencyUtils.checkDependencies(binding.getDependencies(), property, index);
 204 
 205         index.set(-1);
 206         assertNull(binding.get());
 207         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 208         index.set(0);
 209         assertNull(binding.get());
 210         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 211 
 212         property.set(list1);
 213         index.set(-1);
 214         assertNull(binding.get());
 215         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 216         index.set(0);
 217         assertEquals(data1, binding.get());
 218         index.set(1);
 219         assertEquals(data2, binding.get());
 220         index.set(2);
 221         assertNull(binding.get());
 222         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 223 
 224         property.remove(data2);
 225         index.set(-1);
 226         assertNull(binding.get());
 227         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 228         index.set(0);
 229         assertEquals(data1, binding.get());
 230         index.set(1);
 231         assertNull(binding.get());
 232         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 233 
 234         property.set(list2);
 235         index.set(-1);
 236         assertNull(binding.get());
 237         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 238         index.set(0);
 239         assertNull(binding.get());
 240         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 241 
 242         property.addAll(data2, data2);
 243         index.set(-1);
 244         assertNull(binding.get());
 245         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 246         index.set(0);
 247         assertEquals(data2, binding.get());
 248         index.set(1);
 249         assertEquals(data2, binding.get());
 250         index.set(2);
 251         assertNull(binding.get());
 252         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 253 
 254         property.set(null);
 255         index.set(-1);
 256         assertNull(binding.get());
 257         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 258         index.set(0);
 259         assertNull(binding.get());
 260         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 261     }
 262 
 263     @Test(expected = NullPointerException.class)
 264     public void testValueAt_Variable_Null() {
 265         Bindings.valueAt((ObservableList<Object>)null, index);
 266     }
 267 
 268     @Test(expected = NullPointerException.class)
 269     public void testValueAt_Variable_NullIndex() {
 270         Bindings.valueAt(property, null);
 271     }
 272 
 273     @Test
 274     public void testBooleanValueAt_Constant() {
 275         final boolean defaultData = false;
 276         final boolean localData1 = false;
 277         final boolean localData2 = true;
 278         final ListProperty<Boolean> localProperty = new SimpleListProperty<Boolean>();
 279         final ObservableList<Boolean> localList1 = FXCollections.observableArrayList(localData1, localData2);
 280         final ObservableList<Boolean> localList2 = FXCollections.observableArrayList();
 281 
 282         final BooleanBinding binding0 = Bindings.booleanValueAt(localProperty, 0);
 283         final BooleanBinding binding1 = Bindings.booleanValueAt(localProperty, 1);
 284         final BooleanBinding binding2 = Bindings.booleanValueAt(localProperty, 2);
 285         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 286         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 287         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 288         assertEquals(defaultData, binding0.get());
 289         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 290         assertEquals(defaultData, binding1.get());
 291         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 292         assertEquals(defaultData, binding2.get());
 293         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 294 
 295         localProperty.set(localList1);
 296         assertEquals(localData1, binding0.get());
 297         assertEquals(localData2, binding1.get());
 298         assertEquals(defaultData, binding2.get());
 299         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 300 
 301         localProperty.remove(1);
 302         assertEquals(localData1, binding0.get());
 303         assertEquals(defaultData, binding1.get());
 304         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 305         assertEquals(defaultData, binding2.get());
 306         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 307 
 308         localProperty.set(localList2);
 309         assertEquals(defaultData, binding0.get());
 310         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 311         assertEquals(defaultData, binding1.get());
 312         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 313         assertEquals(defaultData, binding2.get());
 314         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 315 
 316         localProperty.addAll(localData2, localData2);
 317         assertEquals(localData2, binding0.get());
 318         assertEquals(localData2, binding1.get());
 319         assertEquals(defaultData, binding2.get());
 320         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 321 
 322         localProperty.set(null);
 323         assertEquals(defaultData, binding0.get());
 324         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 325         assertEquals(defaultData, binding1.get());
 326         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 327         assertEquals(defaultData, binding2.get());
 328         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 329     }
 330 
 331     @Test(expected = NullPointerException.class)
 332     public void testBooleanValueAt_Constant_Null() {
 333         Bindings.booleanValueAt(null, 0);
 334     }
 335 
 336     @Test(expected = IllegalArgumentException.class)
 337     public void testBooleanValueAt_Constant_NegativeIndex() {
 338         final ListProperty<Boolean> localProperty = new SimpleListProperty<Boolean>();
 339         Bindings.booleanValueAt(localProperty, -1);
 340     }
 341 
 342     @Test
 343     public void testBooleanValueAt_Variable() {
 344         final boolean defaultData = false;
 345         final boolean localData1 = false;
 346         final boolean localData2 = true;
 347         final ListProperty<Boolean> localProperty = new SimpleListProperty<Boolean>();
 348         final ObservableList<Boolean> localList1 = FXCollections.observableArrayList(localData1, localData2);
 349         final ObservableList<Boolean> localList2 = FXCollections.observableArrayList();
 350 
 351         final BooleanBinding binding = Bindings.booleanValueAt(localProperty, index);
 352         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 353 
 354         index.set(-1);
 355         assertEquals(defaultData, binding.get());
 356         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 357         index.set(0);
 358         assertEquals(defaultData, binding.get());
 359         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 360 
 361         localProperty.set(localList1);
 362         index.set(-1);
 363         assertEquals(defaultData, binding.get());
 364         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 365         index.set(0);
 366         assertEquals(localData1, binding.get());
 367         index.set(1);
 368         assertEquals(localData2, binding.get());
 369         index.set(2);
 370         assertEquals(defaultData, binding.get());
 371         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 372 
 373         localProperty.remove(1);
 374         index.set(-1);
 375         assertEquals(defaultData, binding.get());
 376         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 377         index.set(0);
 378         assertEquals(localData1, binding.get());
 379         index.set(1);
 380         assertEquals(defaultData, binding.get());
 381         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 382 
 383         localProperty.set(0, null);
 384         index.set(-1);
 385         assertEquals(defaultData, binding.get());
 386         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 387         index.set(0);
 388         assertEquals(defaultData, binding.get());
 389         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 390         index.set(1);
 391         assertEquals(defaultData, binding.get());
 392         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 393 
 394         localProperty.set(localList2);
 395         index.set(-1);
 396         assertEquals(defaultData, binding.get());
 397         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 398         index.set(0);
 399         assertEquals(defaultData, binding.get());
 400         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 401 
 402         localProperty.addAll(localData2, localData2);
 403         index.set(-1);
 404         assertEquals(defaultData, binding.get());
 405         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 406         index.set(0);
 407         assertEquals(localData2, binding.get());
 408         index.set(1);
 409         assertEquals(localData2, binding.get());
 410         index.set(2);
 411         assertEquals(defaultData, binding.get());
 412         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 413 
 414         localProperty.set(null);
 415         index.set(-1);
 416         assertEquals(defaultData, binding.get());
 417         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 418         index.set(0);
 419         assertEquals(defaultData, binding.get());
 420         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 421     }
 422 
 423     @Test(expected = NullPointerException.class)
 424     public void testBooleanValueAt_Variable_Null() {
 425         Bindings.booleanValueAt((ObservableList<Boolean>)null, index);
 426     }
 427 
 428     @Test(expected = NullPointerException.class)
 429     public void testBooleanValueAt_Variable_NullIndex() {
 430         final ListProperty<Boolean> localProperty = new SimpleListProperty<Boolean>();
 431         Bindings.booleanValueAt(localProperty, null);
 432     }
 433 
 434     @Test
 435     public void testDoubleValueAt_Constant() {
 436         final double defaultData = 0.0;
 437         final double localData1 = Math.PI;
 438         final double localData2 = -Math.E;
 439         final ListProperty<Double> localProperty = new SimpleListProperty<Double>();
 440         final ObservableList<Double> localList1 = FXCollections.observableArrayList(localData1, localData2);
 441         final ObservableList<Double> localList2 = FXCollections.observableArrayList();
 442 
 443         final DoubleBinding binding0 = Bindings.doubleValueAt(localProperty, 0);
 444         final DoubleBinding binding1 = Bindings.doubleValueAt(localProperty, 1);
 445         final DoubleBinding binding2 = Bindings.doubleValueAt(localProperty, 2);
 446         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 447         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 448         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 449         assertEquals(defaultData, binding0.get(), EPSILON_DOUBLE);
 450         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 451         assertEquals(defaultData, binding1.get(), EPSILON_DOUBLE);
 452         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 453         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 454         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 455 
 456         localProperty.set(localList1);
 457         assertEquals(localData1, binding0.get(), EPSILON_DOUBLE);
 458         assertEquals(localData2, binding1.get(), EPSILON_DOUBLE);
 459         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 460         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 461 
 462         localProperty.remove(1);
 463         assertEquals(localData1, binding0.get(), EPSILON_DOUBLE);
 464         assertEquals(defaultData, binding1.get(), EPSILON_DOUBLE);
 465         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 466         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 467         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 468 
 469         localProperty.set(localList2);
 470         assertEquals(defaultData, binding0.get(), EPSILON_DOUBLE);
 471         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 472         assertEquals(defaultData, binding1.get(), EPSILON_DOUBLE);
 473         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 474         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 475         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 476 
 477         localProperty.addAll(localData2, localData2);
 478         assertEquals(localData2, binding0.get(), EPSILON_DOUBLE);
 479         assertEquals(localData2, binding1.get(), EPSILON_DOUBLE);
 480         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 481         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 482 
 483         localProperty.set(null);
 484         assertEquals(defaultData, binding0.get(), EPSILON_DOUBLE);
 485         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 486         assertEquals(defaultData, binding1.get(), EPSILON_DOUBLE);
 487         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 488         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 489         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 490     }
 491 
 492     @Test(expected = NullPointerException.class)
 493     public void testDoubleValueAt_Constant_Null() {
 494         Bindings.doubleValueAt(null, 0);
 495     }
 496 
 497     @Test(expected = IllegalArgumentException.class)
 498     public void testDoubleValueAt_Constant_NegativeIndex() {
 499         final ListProperty<Double> localProperty = new SimpleListProperty<Double>();
 500         Bindings.doubleValueAt(localProperty, -1);
 501     }
 502 
 503     @Test
 504     public void testDoubleValueAt_Variable() {
 505         final double defaultData = 0.0;
 506         final double localData1 = -Math.PI;
 507         final double localData2 = Math.E;
 508         final ListProperty<Double> localProperty = new SimpleListProperty<Double>();
 509         final ObservableList<Double> localList1 = FXCollections.observableArrayList(localData1, localData2);
 510         final ObservableList<Double> localList2 = FXCollections.observableArrayList();
 511 
 512         final DoubleBinding binding = Bindings.doubleValueAt(localProperty, index);
 513         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 514 
 515         index.set(-1);
 516         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 517         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 518         index.set(0);
 519         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 520         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 521 
 522         localProperty.set(localList1);
 523         index.set(-1);
 524         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 525         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 526         index.set(0);
 527         assertEquals(localData1, binding.get(), EPSILON_DOUBLE);
 528         index.set(1);
 529         assertEquals(localData2, binding.get(), EPSILON_DOUBLE);
 530         index.set(2);
 531         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 532         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 533 
 534         localProperty.remove(1);
 535         index.set(-1);
 536         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 537         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 538         index.set(0);
 539         assertEquals(localData1, binding.get(), EPSILON_DOUBLE);
 540         index.set(1);
 541         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 542         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 543 
 544         localProperty.set(0, null);
 545         index.set(-1);
 546         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 547         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 548         index.set(0);
 549         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 550         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 551         index.set(1);
 552         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 553         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 554 
 555         localProperty.set(localList2);
 556         index.set(-1);
 557         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 558         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 559         index.set(0);
 560         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 561         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 562 
 563         localProperty.addAll(localData2, localData2);
 564         index.set(-1);
 565         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 566         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 567         index.set(0);
 568         assertEquals(localData2, binding.get(), EPSILON_DOUBLE);
 569         index.set(1);
 570         assertEquals(localData2, binding.get(), EPSILON_DOUBLE);
 571         index.set(2);
 572         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 573         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 574 
 575         localProperty.set(null);
 576         index.set(-1);
 577         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 578         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 579         index.set(0);
 580         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 581         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 582     }
 583 
 584     @Test(expected = NullPointerException.class)
 585     public void testDoubleValueAt_Variable_Null() {
 586         Bindings.doubleValueAt((ObservableList<Double>)null, index);
 587     }
 588 
 589     @Test(expected = NullPointerException.class)
 590     public void testDoubleValueAt_Variable_NullIndex() {
 591         final ListProperty<Double> localProperty = new SimpleListProperty<Double>();
 592         Bindings.doubleValueAt(localProperty, null);
 593     }
 594 
 595     @Test
 596     public void testFloatValueAt_Constant() {
 597         final float defaultData = 0.0f;
 598         final float localData1 = (float)Math.PI;
 599         final float localData2 = (float)-Math.E;
 600         final ListProperty<Float> localProperty = new SimpleListProperty<Float>();
 601         final ObservableList<Float> localList1 = FXCollections.observableArrayList(localData1, localData2);
 602         final ObservableList<Float> localList2 = FXCollections.observableArrayList();
 603 
 604         final FloatBinding binding0 = Bindings.floatValueAt(localProperty, 0);
 605         final FloatBinding binding1 = Bindings.floatValueAt(localProperty, 1);
 606         final FloatBinding binding2 = Bindings.floatValueAt(localProperty, 2);
 607         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 608         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 609         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 610         assertEquals(defaultData, binding0.get(), EPSILON_FLOAT);
 611         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 612         assertEquals(defaultData, binding1.get(), EPSILON_FLOAT);
 613         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 614         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 615         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 616 
 617         localProperty.set(localList1);
 618         assertEquals(localData1, binding0.get(), EPSILON_FLOAT);
 619         assertEquals(localData2, binding1.get(), EPSILON_FLOAT);
 620         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 621         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 622 
 623         localProperty.remove(1);
 624         assertEquals(localData1, binding0.get(), EPSILON_FLOAT);
 625         assertEquals(defaultData, binding1.get(), EPSILON_FLOAT);
 626         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 627         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 628         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 629 
 630         localProperty.set(localList2);
 631         assertEquals(defaultData, binding0.get(), EPSILON_FLOAT);
 632         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 633         assertEquals(defaultData, binding1.get(), EPSILON_FLOAT);
 634         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 635         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 636         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 637 
 638         localProperty.addAll(localData2, localData2);
 639         assertEquals(localData2, binding0.get(), EPSILON_FLOAT);
 640         assertEquals(localData2, binding1.get(), EPSILON_FLOAT);
 641         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 642         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 643 
 644         localProperty.set(null);
 645         assertEquals(defaultData, binding0.get(), EPSILON_FLOAT);
 646         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 647         assertEquals(defaultData, binding1.get(), EPSILON_FLOAT);
 648         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 649         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 650         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 651     }
 652 
 653     @Test(expected = NullPointerException.class)
 654     public void testFloatValueAt_Constant_Null() {
 655         Bindings.floatValueAt((ObservableList) null, 0);
 656     }
 657 
 658     @Test(expected = IllegalArgumentException.class)
 659     public void testFloatValueAt_Constant_NegativeIndex() {
 660         final ListProperty<Float> localProperty = new SimpleListProperty<Float>();
 661         Bindings.floatValueAt(localProperty, -1);
 662     }
 663 
 664     @Test
 665     public void testFloatValueAt_Variable() {
 666         final float defaultData = 0.0f;
 667         final float localData1 = (float)-Math.PI;
 668         final float localData2 = (float)Math.E;
 669         final ListProperty<Float> localProperty = new SimpleListProperty<Float>();
 670         final ObservableList<Float> localList1 = FXCollections.observableArrayList(localData1, localData2);
 671         final ObservableList<Float> localList2 = FXCollections.observableArrayList();
 672 
 673         final FloatBinding binding = Bindings.floatValueAt(localProperty, index);
 674         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 675 
 676         index.set(-1);
 677         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 678         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 679         index.set(0);
 680         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 681         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 682 
 683         localProperty.set(localList1);
 684         index.set(-1);
 685         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 686         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 687         index.set(0);
 688         assertEquals(localData1, binding.get(), EPSILON_FLOAT);
 689         index.set(1);
 690         assertEquals(localData2, binding.get(), EPSILON_FLOAT);
 691         index.set(2);
 692         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 693         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 694 
 695         localProperty.remove(1);
 696         index.set(-1);
 697         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 698         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 699         index.set(0);
 700         assertEquals(localData1, binding.get(), EPSILON_FLOAT);
 701         index.set(1);
 702         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 703         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 704 
 705         localProperty.set(0, null);
 706         index.set(-1);
 707         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 708         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 709         index.set(0);
 710         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 711         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 712         index.set(1);
 713         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 714         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 715 
 716         localProperty.set(localList2);
 717         index.set(-1);
 718         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 719         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 720         index.set(0);
 721         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 722         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 723 
 724         localProperty.addAll(localData2, localData2);
 725         index.set(-1);
 726         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 727         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 728         index.set(0);
 729         assertEquals(localData2, binding.get(), EPSILON_FLOAT);
 730         index.set(1);
 731         assertEquals(localData2, binding.get(), EPSILON_FLOAT);
 732         index.set(2);
 733         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 734         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 735 
 736         localProperty.set(null);
 737         index.set(-1);
 738         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 739         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 740         index.set(0);
 741         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 742         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 743     }
 744 
 745     @Test(expected = NullPointerException.class)
 746     public void testFloatValueAt_Variable_Null() {
 747         Bindings.floatValueAt((ObservableList<Float>)null, index);
 748     }
 749 
 750     @Test(expected = NullPointerException.class)
 751     public void testFloatValueAt_Variable_NullIndex() {
 752         final ListProperty<Float> localProperty = new SimpleListProperty<Float>();
 753         Bindings.floatValueAt(localProperty, null);
 754     }
 755 
 756     @Test
 757     public void testIntegerValueAt_Constant() {
 758         final int defaultData = 0;
 759         final int localData1 = 42;
 760         final int localData2 = -7;
 761         final ListProperty<Integer> localProperty = new SimpleListProperty<Integer>();
 762         final ObservableList<Integer> localList1 = FXCollections.observableArrayList(localData1, localData2);
 763         final ObservableList<Integer> localList2 = FXCollections.observableArrayList();
 764 
 765         final IntegerBinding binding0 = Bindings.integerValueAt(localProperty, 0);
 766         final IntegerBinding binding1 = Bindings.integerValueAt(localProperty, 1);
 767         final IntegerBinding binding2 = Bindings.integerValueAt(localProperty, 2);
 768         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 769         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 770         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 771         assertEquals(defaultData, binding0.get());
 772         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 773         assertEquals(defaultData, binding1.get());
 774         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 775         assertEquals(defaultData, binding2.get());
 776         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 777 
 778         localProperty.set(localList1);
 779         assertEquals(localData1, binding0.get());
 780         assertEquals(localData2, binding1.get());
 781         assertEquals(defaultData, binding2.get());
 782         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 783 
 784         localProperty.remove(1);
 785         assertEquals(localData1, binding0.get());
 786         assertEquals(defaultData, binding1.get());
 787         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 788         assertEquals(defaultData, binding2.get());
 789         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 790 
 791         localProperty.set(localList2);
 792         assertEquals(defaultData, binding0.get());
 793         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 794         assertEquals(defaultData, binding1.get());
 795         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 796         assertEquals(defaultData, binding2.get());
 797         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 798 
 799         localProperty.addAll(localData2, localData2);
 800         assertEquals(localData2, binding0.get());
 801         assertEquals(localData2, binding1.get());
 802         assertEquals(defaultData, binding2.get());
 803         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 804 
 805         localProperty.set(null);
 806         assertEquals(defaultData, binding0.get());
 807         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 808         assertEquals(defaultData, binding1.get());
 809         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 810         assertEquals(defaultData, binding2.get());
 811         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 812     }
 813 
 814     @Test(expected = NullPointerException.class)
 815     public void testIntegerValueAt_Constant_Null() {
 816         Bindings.integerValueAt((ObservableList) null, 0);
 817     }
 818 
 819     @Test(expected = IllegalArgumentException.class)
 820     public void testIntegerValueAt_Constant_NegativeIndex() {
 821         final ListProperty<Integer> localProperty = new SimpleListProperty<Integer>();
 822         Bindings.integerValueAt(localProperty, -1);
 823     }
 824 
 825     @Test
 826     public void testIntegerValueAt_Variable() {
 827         final int defaultData = 0;
 828         final int localData1 = 42;
 829         final int localData2 = -7;
 830         final ListProperty<Integer> localProperty = new SimpleListProperty<Integer>();
 831         final ObservableList<Integer> localList1 = FXCollections.observableArrayList(localData1, localData2);
 832         final ObservableList<Integer> localList2 = FXCollections.observableArrayList();
 833 
 834         final IntegerBinding binding = Bindings.integerValueAt(localProperty, index);
 835         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 836 
 837         index.set(-1);
 838         assertEquals(defaultData, binding.get());
 839         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 840         index.set(0);
 841         assertEquals(defaultData, binding.get());
 842         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 843 
 844         localProperty.set(localList1);
 845         index.set(-1);
 846         assertEquals(defaultData, binding.get());
 847         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 848         index.set(0);
 849         assertEquals(localData1, binding.get());
 850         index.set(1);
 851         assertEquals(localData2, binding.get());
 852         index.set(2);
 853         assertEquals(defaultData, binding.get());
 854         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 855 
 856         localProperty.remove(1);
 857         index.set(-1);
 858         assertEquals(defaultData, binding.get());
 859         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 860         index.set(0);
 861         assertEquals(localData1, binding.get());
 862         index.set(1);
 863         assertEquals(defaultData, binding.get());
 864         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 865 
 866         localProperty.set(0, null);
 867         index.set(-1);
 868         assertEquals(defaultData, binding.get());
 869         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 870         index.set(0);
 871         assertEquals(defaultData, binding.get());
 872         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 873         index.set(1);
 874         assertEquals(defaultData, binding.get());
 875         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 876 
 877         localProperty.set(localList2);
 878         index.set(-1);
 879         assertEquals(defaultData, binding.get());
 880         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 881         index.set(0);
 882         assertEquals(defaultData, binding.get());
 883         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 884 
 885         localProperty.addAll(localData2, localData2);
 886         index.set(-1);
 887         assertEquals(defaultData, binding.get());
 888         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 889         index.set(0);
 890         assertEquals(localData2, binding.get());
 891         index.set(1);
 892         assertEquals(localData2, binding.get());
 893         index.set(2);
 894         assertEquals(defaultData, binding.get());
 895         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 896 
 897         localProperty.set(null);
 898         index.set(-1);
 899         assertEquals(defaultData, binding.get());
 900         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 901         index.set(0);
 902         assertEquals(defaultData, binding.get());
 903         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 904     }
 905 
 906     @Test(expected = NullPointerException.class)
 907     public void testIntegerValueAt_Variable_Null() {
 908         Bindings.integerValueAt((ObservableList<Integer>)null, index);
 909     }
 910 
 911     @Test(expected = NullPointerException.class)
 912     public void testIntegerValueAt_Variable_NullIndex() {
 913         final ListProperty<Integer> localProperty = new SimpleListProperty<Integer>();
 914         Bindings.integerValueAt(localProperty, null);
 915     }
 916 
 917     @Test
 918     public void testLongValueAt_Constant() {
 919         final long defaultData = 0L;
 920         final long localData1 = 1234567890987654321L;
 921         final long localData2 = -987654321987654321L;
 922         final ListProperty<Long> localProperty = new SimpleListProperty<Long>();
 923         final ObservableList<Long> localList1 = FXCollections.observableArrayList(localData1, localData2);
 924         final ObservableList<Long> localList2 = FXCollections.observableArrayList();
 925 
 926         final LongBinding binding0 = Bindings.longValueAt(localProperty, 0);
 927         final LongBinding binding1 = Bindings.longValueAt(localProperty, 1);
 928         final LongBinding binding2 = Bindings.longValueAt(localProperty, 2);
 929         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 930         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 931         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 932         assertEquals(defaultData, binding0.get());
 933         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 934         assertEquals(defaultData, binding1.get());
 935         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 936         assertEquals(defaultData, binding2.get());
 937         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 938 
 939         localProperty.set(localList1);
 940         assertEquals(localData1, binding0.get());
 941         assertEquals(localData2, binding1.get());
 942         assertEquals(defaultData, binding2.get());
 943         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 944 
 945         localProperty.remove(1);
 946         assertEquals(localData1, binding0.get());
 947         assertEquals(defaultData, binding1.get());
 948         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 949         assertEquals(defaultData, binding2.get());
 950         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 951 
 952         localProperty.set(localList2);
 953         assertEquals(defaultData, binding0.get());
 954         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 955         assertEquals(defaultData, binding1.get());
 956         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 957         assertEquals(defaultData, binding2.get());
 958         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 959 
 960         localProperty.addAll(localData2, localData2);
 961         assertEquals(localData2, binding0.get());
 962         assertEquals(localData2, binding1.get());
 963         assertEquals(defaultData, binding2.get());
 964         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 965 
 966         localProperty.set(null);
 967         assertEquals(defaultData, binding0.get());
 968         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 969         assertEquals(defaultData, binding1.get());
 970         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 971         assertEquals(defaultData, binding2.get());
 972         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
 973     }
 974 
 975     @Test(expected = NullPointerException.class)
 976     public void testLongValueAt_Constant_Null() {
 977         Bindings.longValueAt(null, 0);
 978     }
 979 
 980     @Test(expected = IllegalArgumentException.class)
 981     public void testLongValueAt_Constant_NegativeIndex() {
 982         final ListProperty<Long> localProperty = new SimpleListProperty<Long>();
 983         Bindings.longValueAt(localProperty, -1);
 984     }
 985 
 986     @Test
 987     public void testLongValueAt_Variable() {
 988         final long defaultData = 0;
 989         final long localData1 = 98765432123456789L;
 990         final long localData2 = -1234567890123456789L;
 991         final ListProperty<Long> localProperty = new SimpleListProperty<Long>();
 992         final ObservableList<Long> localList1 = FXCollections.observableArrayList(localData1, localData2);
 993         final ObservableList<Long> localList2 = FXCollections.observableArrayList();
 994 
 995         final LongBinding binding = Bindings.longValueAt(localProperty, index);
 996         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 997 
 998         index.set(-1);
 999         assertEquals(defaultData, binding.get());
1000         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1001         index.set(0);
1002         assertEquals(defaultData, binding.get());
1003         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1004 
1005         localProperty.set(localList1);
1006         index.set(-1);
1007         assertEquals(defaultData, binding.get());
1008         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1009         index.set(0);
1010         assertEquals(localData1, binding.get());
1011         index.set(1);
1012         assertEquals(localData2, binding.get());
1013         index.set(2);
1014         assertEquals(defaultData, binding.get());
1015         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1016 
1017         localProperty.remove(1);
1018         index.set(-1);
1019         assertEquals(defaultData, binding.get());
1020         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1021         index.set(0);
1022         assertEquals(localData1, binding.get());
1023         index.set(1);
1024         assertEquals(defaultData, binding.get());
1025         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1026 
1027         localProperty.set(0, null);
1028         index.set(-1);
1029         assertEquals(defaultData, binding.get());
1030         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1031         index.set(0);
1032         assertEquals(defaultData, binding.get());
1033         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
1034         index.set(1);
1035         assertEquals(defaultData, binding.get());
1036         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1037 
1038         localProperty.set(localList2);
1039         index.set(-1);
1040         assertEquals(defaultData, binding.get());
1041         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1042         index.set(0);
1043         assertEquals(defaultData, binding.get());
1044         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1045 
1046         localProperty.addAll(localData2, localData2);
1047         index.set(-1);
1048         assertEquals(defaultData, binding.get());
1049         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1050         index.set(0);
1051         assertEquals(localData2, binding.get());
1052         index.set(1);
1053         assertEquals(localData2, binding.get());
1054         index.set(2);
1055         assertEquals(defaultData, binding.get());
1056         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1057 
1058         localProperty.set(null);
1059         index.set(-1);
1060         assertEquals(defaultData, binding.get());
1061         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1062         index.set(0);
1063         assertEquals(defaultData, binding.get());
1064         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1065     }
1066 
1067     @Test(expected = NullPointerException.class)
1068     public void testLongValueAt_Variable_Null() {
1069         Bindings.longValueAt((ObservableList<Long>)null, index);
1070     }
1071 
1072     @Test(expected = NullPointerException.class)
1073     public void testLongValueAt_Variable_NullIndex() {
1074         final ListProperty<Long> localProperty = new SimpleListProperty<Long>();
1075         Bindings.longValueAt(localProperty, null);
1076     }
1077 
1078     @Test
1079     public void testStringValueAt_Constant() {
1080         final String defaultData = null;
1081         final String localData1 = "Hello World";
1082         final String localData2 = "Goodbye World";
1083         final ListProperty<String> localProperty = new SimpleListProperty<String>();
1084         final ObservableList<String> localList1 = FXCollections.observableArrayList(localData1, localData2);
1085         final ObservableList<String> localList2 = FXCollections.observableArrayList();
1086 
1087         final StringBinding binding0 = Bindings.stringValueAt(localProperty, 0);
1088         final StringBinding binding1 = Bindings.stringValueAt(localProperty, 1);
1089         final StringBinding binding2 = Bindings.stringValueAt(localProperty, 2);
1090         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
1091         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
1092         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
1093         assertEquals(defaultData, binding0.get());
1094         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1095         assertEquals(defaultData, binding1.get());
1096         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1097         assertEquals(defaultData, binding2.get());
1098         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1099 
1100         localProperty.set(localList1);
1101         assertEquals(localData1, binding0.get());
1102         assertEquals(localData2, binding1.get());
1103         assertEquals(defaultData, binding2.get());
1104         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1105 
1106         localProperty.remove(1);
1107         assertEquals(localData1, binding0.get());
1108         assertEquals(defaultData, binding1.get());
1109         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1110         assertEquals(defaultData, binding2.get());
1111         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1112 
1113         localProperty.set(localList2);
1114         assertEquals(defaultData, binding0.get());
1115         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1116         assertEquals(defaultData, binding1.get());
1117         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1118         assertEquals(defaultData, binding2.get());
1119         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1120 
1121         localProperty.addAll(localData2, localData2);
1122         assertEquals(localData2, binding0.get());
1123         assertEquals(localData2, binding1.get());
1124         assertEquals(defaultData, binding2.get());
1125         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1126 
1127         localProperty.set(null);
1128         assertEquals(defaultData, binding0.get());
1129         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1130         assertEquals(defaultData, binding1.get());
1131         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1132         assertEquals(defaultData, binding2.get());
1133         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1134     }
1135 
1136     @Test(expected = NullPointerException.class)
1137     public void testStringValueAt_Constant_Null() {
1138         Bindings.stringValueAt(null, 0);
1139     }
1140 
1141     @Test(expected = IllegalArgumentException.class)
1142     public void testStringValueAt_Constant_NegativeIndex() {
1143         final ListProperty<String> localProperty = new SimpleListProperty<String>();
1144         Bindings.stringValueAt(localProperty, -1);
1145     }
1146 
1147     @Test
1148     public void testStringValueAt_Variable() {
1149         final String defaultData = null;
1150         final String localData1 = "Goodbye";
1151         final String localData2 = "Hello";
1152         final ListProperty<String> localProperty = new SimpleListProperty<String>();
1153         final ObservableList<String> localList1 = FXCollections.observableArrayList(localData1, localData2);
1154         final ObservableList<String> localList2 = FXCollections.observableArrayList();
1155 
1156         final StringBinding binding = Bindings.stringValueAt(localProperty, index);
1157         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
1158 
1159         index.set(-1);
1160         assertEquals(defaultData, binding.get());
1161         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1162         index.set(0);
1163         assertEquals(defaultData, binding.get());
1164         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1165 
1166         localProperty.set(localList1);
1167         index.set(-1);
1168         assertEquals(defaultData, binding.get());
1169         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1170         index.set(0);
1171         assertEquals(localData1, binding.get());
1172         index.set(1);
1173         assertEquals(localData2, binding.get());
1174         index.set(2);
1175         assertEquals(defaultData, binding.get());
1176         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1177 
1178         localProperty.remove(1);
1179         index.set(-1);
1180         assertEquals(defaultData, binding.get());
1181         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1182         index.set(0);
1183         assertEquals(localData1, binding.get());
1184         index.set(1);
1185         assertEquals(defaultData, binding.get());
1186         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1187 
1188         localProperty.set(localList2);
1189         index.set(-1);
1190         assertEquals(defaultData, binding.get());
1191         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1192         index.set(0);
1193         assertEquals(defaultData, binding.get());
1194         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1195 
1196         localProperty.addAll(localData2, localData2);
1197         index.set(-1);
1198         assertEquals(defaultData, binding.get());
1199         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1200         index.set(0);
1201         assertEquals(localData2, binding.get());
1202         index.set(1);
1203         assertEquals(localData2, binding.get());
1204         index.set(2);
1205         assertEquals(defaultData, binding.get());
1206         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1207 
1208         localProperty.set(null);
1209         index.set(-1);
1210         assertEquals(defaultData, binding.get());
1211         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1212         index.set(0);
1213         assertEquals(defaultData, binding.get());
1214         ErrorLoggingUtiltity.checkFine(IndexOutOfBoundsException.class);
1215     }
1216 
1217     @Test(expected = NullPointerException.class)
1218     public void testStringValueAt_Variable_Null() {
1219         Bindings.stringValueAt((ObservableList<String>)null, index);
1220     }
1221 
1222     @Test(expected = NullPointerException.class)
1223     public void testStringValueAt_Variable_NullIndex() {
1224         final ListProperty<String> localProperty = new SimpleListProperty<String>();
1225         Bindings.stringValueAt(localProperty, null);
1226     }
1227 
1228 
1229 }