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.MapProperty;
  30 import javafx.beans.property.SimpleMapProperty;
  31 import javafx.beans.property.SimpleStringProperty;
  32 import javafx.beans.property.StringProperty;
  33 import javafx.beans.value.ObservableValue;
  34 import javafx.collections.FXCollections;
  35 import javafx.collections.ObservableMap;
  36 import test.com.sun.javafx.binding.ErrorLoggingUtiltity;
  37 import org.junit.Before;
  38 import org.junit.BeforeClass;
  39 import org.junit.Test;
  40 
  41 import static org.junit.Assert.*;
  42 
  43 public class BindingsMapTest {
  44 
  45     private static final double EPSILON_DOUBLE = 1e-12;
  46     private static final float EPSILON_FLOAT = 1e-5f;
  47 
  48     private static final String key1 = "Key1";
  49     private static final String key2 = "Key2";
  50     private static final String key3 = "Key3";
  51     private static final Object data1 = new Object();
  52     private static final Object data2 = new Object();
  53 
  54     private MapProperty<String, Object> property;
  55     private ObservableMap<String, Object> map1;
  56     private ObservableMap<String, Object> map2;
  57     private StringProperty index;
  58 
  59     @BeforeClass
  60     public static void setUpClass() {
  61         ErrorLoggingUtiltity.reset();
  62     }
  63 
  64     @Before
  65     public void setUp() {
  66         property = new SimpleMapProperty<String, Object>();
  67         map1 = FXCollections.observableHashMap();
  68         map1.put(key1, data1);
  69         map1.put(key2, data2);
  70         map2 = FXCollections.observableHashMap();
  71         index = new SimpleStringProperty();
  72     }
  73 
  74     @Test
  75     public void testSize() {
  76         final IntegerBinding size = Bindings.size(property);
  77         DependencyUtils.checkDependencies(size.getDependencies(), property);
  78 
  79         assertEquals(0, size.get());
  80         property.set(map1);
  81         assertEquals(2, size.get());
  82         map1.remove(key2);
  83         assertEquals(1, size.get());
  84         property.set(map2);
  85         assertEquals(0, size.get());
  86         property.put(key1, data1);
  87         property.put(key2, data2);
  88         assertEquals(2, size.get());
  89         property.set(null);
  90         assertEquals(0, size.get());
  91     }
  92 
  93     @Test(expected = NullPointerException.class)
  94     public void testSize_Null() {
  95         Bindings.size((ObservableMap<String, Object>) null);
  96     }
  97 
  98     @Test
  99     public void testIsEmpty() {
 100         final BooleanBinding empty = Bindings.isEmpty(property);
 101         DependencyUtils.checkDependencies(empty.getDependencies(), property);
 102 
 103         assertTrue(empty.get());
 104         property.set(map1);
 105         assertFalse(empty.get());
 106         map1.remove(key2);
 107         assertFalse(empty.get());
 108         property.set(map2);
 109         assertTrue(empty.get());
 110         property.put(key1, data1);
 111         property.put(key2, data2);
 112         assertFalse(empty.get());
 113         property.set(null);
 114         assertTrue(empty.get());
 115     }
 116 
 117     @Test(expected = NullPointerException.class)
 118     public void testIsEmpty_Null() {
 119         Bindings.isEmpty((ObservableMap<String, Object>) null);
 120     }
 121 
 122     @Test
 123     public void testIsNotEmpty() {
 124         final BooleanBinding notEmpty = Bindings.isNotEmpty(property);
 125         DependencyUtils.checkDependencies(notEmpty.getDependencies(), property);
 126 
 127         assertFalse(notEmpty.get());
 128         property.set(map1);
 129         assertTrue(notEmpty.get());
 130         map1.remove(key2);
 131         assertTrue(notEmpty.get());
 132         property.set(map2);
 133         assertFalse(notEmpty.get());
 134         property.put(key1, data1);
 135         property.put(key2, data2);
 136         assertTrue(notEmpty.get());
 137         property.set(null);
 138         assertFalse(notEmpty.get());
 139     }
 140 
 141     @Test(expected = NullPointerException.class)
 142     public void testIsNotEmpty_Null() {
 143         Bindings.isNotEmpty((ObservableMap<String, Object>) null);
 144     }
 145 
 146     @Test
 147     public void testValueAt_Constant() {
 148         final ObjectBinding<Object> binding0 = Bindings.valueAt(property, key1);
 149         final ObjectBinding<Object> binding1 = Bindings.valueAt(property, key2);
 150         final ObjectBinding<Object> binding2 = Bindings.valueAt(property, key3);
 151         DependencyUtils.checkDependencies(binding0.getDependencies(), property);
 152         DependencyUtils.checkDependencies(binding1.getDependencies(), property);
 153         DependencyUtils.checkDependencies(binding2.getDependencies(), property);
 154         assertNull(binding0.get());
 155         assertNull(binding1.get());
 156         assertNull(binding2.get());
 157 
 158         property.set(map1);
 159         assertEquals(data1, binding0.get());
 160         assertEquals(data2, binding1.get());
 161         assertNull(binding2.get());
 162 
 163         property.remove(key2);
 164         assertEquals(data1, binding0.get());
 165         assertNull(binding1.get());
 166         assertNull(binding2.get());
 167 
 168         property.set(map2);
 169         assertNull(binding0.get());
 170         assertNull(binding1.get());
 171         assertNull(binding2.get());
 172 
 173         property.put(key1, data2);
 174         property.put(key2, data2);
 175         assertEquals(data2, binding0.get());
 176         assertEquals(data2, binding1.get());
 177         assertNull(binding2.get());
 178 
 179         property.set(null);
 180         assertNull(binding0.get());
 181         assertNull(binding1.get());
 182         assertNull(binding2.get());
 183     }
 184 
 185     @Test(expected = NullPointerException.class)
 186     public void testValueAt_Constant_Null() {
 187         Bindings.valueAt(null, key1);
 188     }
 189 
 190     @Test
 191     public void testValueAt_Variable() {
 192         final ObjectBinding<Object> binding = Bindings.valueAt(property, index);
 193         DependencyUtils.checkDependencies(binding.getDependencies(), property, index);
 194 
 195         index.set(null);
 196         assertNull(binding.get());
 197         index.set(key1);
 198         assertNull(binding.get());
 199 
 200         property.set(map1);
 201         index.set(null);
 202         assertNull(binding.get());
 203         index.set(key1);
 204         assertEquals(data1, binding.get());
 205         index.set(key2);
 206         assertEquals(data2, binding.get());
 207         index.set(key3);
 208         assertNull(binding.get());
 209 
 210         property.remove(key2);
 211         index.set(null);
 212         assertNull(binding.get());
 213         index.set(key1);
 214         assertEquals(data1, binding.get());
 215         index.set(key2);
 216         assertNull(binding.get());
 217 
 218         property.set(map2);
 219         index.set(null);
 220         assertNull(binding.get());
 221         index.set(key1);
 222         assertNull(binding.get());
 223 
 224         property.put(key1, data2);
 225         property.put(key2, data2);
 226         index.set(null);
 227         assertNull(binding.get());
 228         index.set(key1);
 229         assertEquals(data2, binding.get());
 230         index.set(key2);
 231         assertEquals(data2, binding.get());
 232         index.set(key3);
 233         assertNull(binding.get());
 234 
 235         property.set(null);
 236         index.set(null);
 237         assertNull(binding.get());
 238         index.set(key1);
 239         assertNull(binding.get());
 240     }
 241 
 242     @Test(expected = NullPointerException.class)
 243     public void testValueAt_Variable_Null() {
 244         Bindings.valueAt((ObservableMap<String, Object>)null, index);
 245     }
 246 
 247     @Test(expected = NullPointerException.class)
 248     public void testValueAt_Variable_Null_2() {
 249         Bindings.valueAt(property, (ObservableValue<String>)null);
 250     }
 251 
 252     @Test
 253     public void testBooleanValueAt_Constant() {
 254         final boolean defaultData = false;
 255         final boolean localData1 = false;
 256         final boolean localData2 = true;
 257         final MapProperty<String, Boolean> localProperty = new SimpleMapProperty<String, Boolean>();
 258         final ObservableMap<String, Boolean> localMap1 = FXCollections.observableHashMap();
 259         localMap1.put(key1, localData1);
 260         localMap1.put(key2, localData2);
 261         final ObservableMap<String, Boolean> localMap2 = FXCollections.observableHashMap();
 262 
 263         final BooleanBinding binding0 = Bindings.booleanValueAt(localProperty, key1);
 264         final BooleanBinding binding1 = Bindings.booleanValueAt(localProperty, key2);
 265         final BooleanBinding binding2 = Bindings.booleanValueAt(localProperty, key3);
 266         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 267         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 268         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 269         assertEquals(defaultData, binding0.get());
 270         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 271         assertEquals(defaultData, binding1.get());
 272         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 273         assertEquals(defaultData, binding2.get());
 274         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 275 
 276         localProperty.set(localMap1);
 277         assertEquals(localData1, binding0.get());
 278         assertEquals(localData2, binding1.get());
 279         assertEquals(defaultData, binding2.get());
 280         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 281 
 282         localProperty.remove(key2);
 283         assertEquals(localData1, binding0.get());
 284         assertEquals(defaultData, binding1.get());
 285         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 286         assertEquals(defaultData, binding2.get());
 287         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 288 
 289         localProperty.set(localMap2);
 290         assertEquals(defaultData, binding0.get());
 291         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 292         assertEquals(defaultData, binding1.get());
 293         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 294         assertEquals(defaultData, binding2.get());
 295         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 296 
 297         localProperty.put(key1, localData2);
 298         localProperty.put(key2, localData2);
 299         assertEquals(localData2, binding0.get());
 300         assertEquals(localData2, binding1.get());
 301         assertEquals(defaultData, binding2.get());
 302         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 303 
 304         localProperty.set(null);
 305         assertEquals(defaultData, binding0.get());
 306         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 307         assertEquals(defaultData, binding1.get());
 308         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 309         assertEquals(defaultData, binding2.get());
 310         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 311     }
 312 
 313     @Test(expected = NullPointerException.class)
 314     public void testBooleanValueAt_Constant_Null() {
 315         Bindings.booleanValueAt(null, key1);
 316     }
 317 
 318     @Test
 319     public void testBooleanValueAt_Variable() {
 320         final boolean defaultData = false;
 321         final boolean localData1 = false;
 322         final boolean localData2 = true;
 323         final MapProperty<String, Boolean> localProperty = new SimpleMapProperty<String, Boolean>();
 324         final ObservableMap<String, Boolean> localMap1 = FXCollections.observableHashMap();
 325         localMap1.put(key1, localData1);
 326         localMap1.put(key2, localData2);
 327         final ObservableMap<String, Boolean> localMap2 = FXCollections.observableHashMap();
 328 
 329         final BooleanBinding binding = Bindings.booleanValueAt(localProperty, index);
 330         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 331 
 332         index.set(null);
 333         assertEquals(defaultData, binding.get());
 334         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 335         index.set(key1);
 336         assertEquals(defaultData, binding.get());
 337         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 338 
 339         localProperty.set(localMap1);
 340         index.set(null);
 341         assertEquals(defaultData, binding.get());
 342         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 343         index.set(key1);
 344         assertEquals(localData1, binding.get());
 345         index.set(key2);
 346         assertEquals(localData2, binding.get());
 347         index.set(key3);
 348         assertEquals(defaultData, binding.get());
 349         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 350 
 351         localProperty.remove(key2);
 352         index.set(null);
 353         assertEquals(defaultData, binding.get());
 354         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 355         index.set(key1);
 356         assertEquals(localData1, binding.get());
 357         index.set(key2);
 358         assertEquals(defaultData, binding.get());
 359         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 360 
 361         localProperty.set(localMap2);
 362         index.set(null);
 363         assertEquals(defaultData, binding.get());
 364         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 365         index.set(key1);
 366         assertEquals(defaultData, binding.get());
 367         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 368 
 369         localProperty.put(key1, localData2);
 370         localProperty.put(key2, localData2);
 371         index.set(null);
 372         assertEquals(defaultData, binding.get());
 373         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 374         index.set(key1);
 375         assertEquals(localData2, binding.get());
 376         index.set(key2);
 377         assertEquals(localData2, binding.get());
 378         index.set(key3);
 379         assertEquals(defaultData, binding.get());
 380         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 381 
 382         localProperty.set(null);
 383         index.set(null);
 384         assertEquals(defaultData, binding.get());
 385         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 386         index.set(key1);
 387         assertEquals(defaultData, binding.get());
 388         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 389     }
 390 
 391     @Test(expected = NullPointerException.class)
 392     public void testBooleanValueAt_Variable_Null() {
 393         Bindings.booleanValueAt((ObservableMap<String, Boolean>)null, index);
 394     }
 395 
 396     @Test(expected = NullPointerException.class)
 397     public void testBooleanValueAt_Variable_Null_2() {
 398         final MapProperty<String, Boolean> localProperty = new SimpleMapProperty<String, Boolean>();
 399         Bindings.booleanValueAt(localProperty, (ObservableValue<String>)null);
 400     }
 401 
 402     @Test
 403     public void testDoubleValueAt_Constant() {
 404         final double defaultData = 0.0;
 405         final double localData1 = Math.PI;
 406         final double localData2 = -Math.E;
 407         final MapProperty<String, Double> localProperty = new SimpleMapProperty<String, Double>();
 408         final ObservableMap<String, Double> localMap1 = FXCollections.observableHashMap();
 409         localMap1.put(key1, localData1);
 410         localMap1.put(key2, localData2);
 411         final ObservableMap<String, Double> localMap2 = FXCollections.observableHashMap();
 412 
 413         final DoubleBinding binding0 = Bindings.doubleValueAt(localProperty, key1);
 414         final DoubleBinding binding1 = Bindings.doubleValueAt(localProperty, key2);
 415         final DoubleBinding binding2 = Bindings.doubleValueAt(localProperty, key3);
 416         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 417         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 418         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 419         assertEquals(defaultData, binding0.get(), EPSILON_DOUBLE);
 420         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 421         assertEquals(defaultData, binding1.get(), EPSILON_DOUBLE);
 422         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 423         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 424         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 425 
 426         localProperty.set(localMap1);
 427         assertEquals(localData1, binding0.get(), EPSILON_DOUBLE);
 428         assertEquals(localData2, binding1.get(), EPSILON_DOUBLE);
 429         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 430         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 431 
 432         localProperty.remove(key2);
 433         assertEquals(localData1, binding0.get(), EPSILON_DOUBLE);
 434         assertEquals(defaultData, binding1.get(), EPSILON_DOUBLE);
 435         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 436         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 437         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 438 
 439         localProperty.set(localMap2);
 440         assertEquals(defaultData, binding0.get(), EPSILON_DOUBLE);
 441         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 442         assertEquals(defaultData, binding1.get(), EPSILON_DOUBLE);
 443         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 444         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 445         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 446 
 447         localProperty.put(key1, localData2);
 448         localProperty.put(key2, localData2);
 449         assertEquals(localData2, binding0.get(), EPSILON_DOUBLE);
 450         assertEquals(localData2, binding1.get(), EPSILON_DOUBLE);
 451         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 452         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 453 
 454         localProperty.set(null);
 455         assertEquals(defaultData, binding0.get(), EPSILON_DOUBLE);
 456         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 457         assertEquals(defaultData, binding1.get(), EPSILON_DOUBLE);
 458         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 459         assertEquals(defaultData, binding2.get(), EPSILON_DOUBLE);
 460         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 461     }
 462 
 463     @Test(expected = NullPointerException.class)
 464     public void testDoubleValueAt_Constant_Null() {
 465         Bindings.doubleValueAt(null, key1);
 466     }
 467 
 468     @Test
 469     public void testDoubleValueAt_Variable() {
 470         final double defaultData = 0.0;
 471         final double localData1 = -Math.PI;
 472         final double localData2 = Math.E;
 473         final MapProperty<String, Double> localProperty = new SimpleMapProperty<String, Double>();
 474         final ObservableMap<String, Double> localMap1 = FXCollections.observableHashMap();
 475         localMap1.put(key1, localData1);
 476         localMap1.put(key2, localData2);
 477         final ObservableMap<String, Double> localMap2 = FXCollections.observableHashMap();
 478 
 479         final DoubleBinding binding = Bindings.doubleValueAt(localProperty, index);
 480         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 481 
 482         index.set(null);
 483         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 484         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 485         index.set(key1);
 486         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 487         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 488 
 489         localProperty.set(localMap1);
 490         index.set(null);
 491         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 492         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 493         index.set(key1);
 494         assertEquals(localData1, binding.get(), EPSILON_DOUBLE);
 495         index.set(key2);
 496         assertEquals(localData2, binding.get(), EPSILON_DOUBLE);
 497         index.set(key3);
 498         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 499         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 500 
 501         localProperty.remove(key2);
 502         index.set(null);
 503         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 504         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 505         index.set(key1);
 506         assertEquals(localData1, binding.get(), EPSILON_DOUBLE);
 507         index.set(key2);
 508         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 509         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 510 
 511         localProperty.set(localMap2);
 512         index.set(null);
 513         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 514         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 515         index.set(key1);
 516         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 517         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 518 
 519         localProperty.put(key1, localData2);
 520         localProperty.put(key2, localData2);
 521         index.set(null);
 522         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 523         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 524         index.set(key1);
 525         assertEquals(localData2, binding.get(), EPSILON_DOUBLE);
 526         index.set(key2);
 527         assertEquals(localData2, binding.get(), EPSILON_DOUBLE);
 528         index.set(key3);
 529         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 530         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 531 
 532         localProperty.set(null);
 533         index.set(null);
 534         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 535         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 536         index.set(key1);
 537         assertEquals(defaultData, binding.get(), EPSILON_DOUBLE);
 538         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 539     }
 540 
 541     @Test(expected = NullPointerException.class)
 542     public void testDoubleValueAt_Variable_Null_1() {
 543         Bindings.doubleValueAt((ObservableMap<String, Double>)null, index);
 544     }
 545 
 546     @Test(expected = NullPointerException.class)
 547     public void testDoubleValueAt_Variable_Null_2() {
 548         final MapProperty<String, Double> localProperty = new SimpleMapProperty<String, Double>();
 549         Bindings.doubleValueAt(localProperty, (ObservableValue<String>)null);
 550     }
 551 
 552     @Test
 553     public void testFloatValueAt_Constant() {
 554         final float defaultData = 0.0f;
 555         final float localData1 = (float)Math.PI;
 556         final float localData2 = (float)-Math.E;
 557         final MapProperty<String, Float> localProperty = new SimpleMapProperty<String, Float>();
 558         final ObservableMap<String, Float> localMap1 = FXCollections.observableHashMap();
 559         localMap1.put(key1, localData1);
 560         localMap1.put(key2, localData2);
 561         final ObservableMap<String, Float> localMap2 = FXCollections.observableHashMap();
 562 
 563         final FloatBinding binding0 = Bindings.floatValueAt(localProperty, key1);
 564         final FloatBinding binding1 = Bindings.floatValueAt(localProperty, key2);
 565         final FloatBinding binding2 = Bindings.floatValueAt(localProperty, key3);
 566         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 567         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 568         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 569         assertEquals(defaultData, binding0.get(), EPSILON_FLOAT);
 570         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 571         assertEquals(defaultData, binding1.get(), EPSILON_FLOAT);
 572         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 573         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 574         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 575 
 576         localProperty.set(localMap1);
 577         assertEquals(localData1, binding0.get(), EPSILON_FLOAT);
 578         assertEquals(localData2, binding1.get(), EPSILON_FLOAT);
 579         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 580         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 581 
 582         localProperty.remove(key2);
 583         assertEquals(localData1, binding0.get(), EPSILON_FLOAT);
 584         assertEquals(defaultData, binding1.get(), EPSILON_FLOAT);
 585         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 586         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 587         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 588 
 589         localProperty.set(localMap2);
 590         assertEquals(defaultData, binding0.get(), EPSILON_FLOAT);
 591         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 592         assertEquals(defaultData, binding1.get(), EPSILON_FLOAT);
 593         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 594         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 595         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 596 
 597         localProperty.put(key1, localData2);
 598         localProperty.put(key2, localData2);
 599         assertEquals(localData2, binding0.get(), EPSILON_FLOAT);
 600         assertEquals(localData2, binding1.get(), EPSILON_FLOAT);
 601         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 602         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 603 
 604         localProperty.set(null);
 605         assertEquals(defaultData, binding0.get(), EPSILON_FLOAT);
 606         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 607         assertEquals(defaultData, binding1.get(), EPSILON_FLOAT);
 608         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 609         assertEquals(defaultData, binding2.get(), EPSILON_FLOAT);
 610         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 611     }
 612 
 613     @Test(expected = NullPointerException.class)
 614     public void testFloatValueAt_Constant_Null() {
 615         Bindings.floatValueAt(null, key1);
 616     }
 617 
 618     @Test
 619     public void testFloatValueAt_Variable() {
 620         final float defaultData = 0.0f;
 621         final float localData1 = (float)-Math.PI;
 622         final float localData2 = (float)Math.E;
 623         final MapProperty<String, Float> localProperty = new SimpleMapProperty<String, Float>();
 624         final ObservableMap<String, Float> localMap1 = FXCollections.observableHashMap();
 625         localMap1.put(key1, localData1);
 626         localMap1.put(key2, localData2);
 627         final ObservableMap<String, Float> localMap2 = FXCollections.observableHashMap();
 628 
 629         final FloatBinding binding = Bindings.floatValueAt(localProperty, index);
 630         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 631 
 632         index.set(null);
 633         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 634         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 635         index.set(key1);
 636         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 637         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 638 
 639         localProperty.set(localMap1);
 640         index.set(null);
 641         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 642         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 643         index.set(key1);
 644         assertEquals(localData1, binding.get(), EPSILON_FLOAT);
 645         index.set(key2);
 646         assertEquals(localData2, binding.get(), EPSILON_FLOAT);
 647         index.set(key3);
 648         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 649         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 650 
 651         localProperty.remove(key2);
 652         index.set(null);
 653         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 654         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 655         index.set(key1);
 656         assertEquals(localData1, binding.get(), EPSILON_FLOAT);
 657         index.set(key2);
 658         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 659         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 660 
 661         localProperty.set(localMap2);
 662         index.set(null);
 663         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 664         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 665         index.set(key1);
 666         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 667         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 668 
 669         localProperty.put(key1, localData2);
 670         localProperty.put(key2, localData2);
 671         index.set(null);
 672         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 673         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 674         index.set(key1);
 675         assertEquals(localData2, binding.get(), EPSILON_FLOAT);
 676         index.set(key2);
 677         assertEquals(localData2, binding.get(), EPSILON_FLOAT);
 678         index.set(key3);
 679         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 680         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 681 
 682         localProperty.set(null);
 683         index.set(null);
 684         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 685         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 686         index.set(key1);
 687         assertEquals(defaultData, binding.get(), EPSILON_FLOAT);
 688         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 689     }
 690 
 691     @Test(expected = NullPointerException.class)
 692     public void testFloatValueAt_Variable_Null_1() {
 693         Bindings.floatValueAt((ObservableMap<String, Float>)null, index);
 694     }
 695 
 696     @Test(expected = NullPointerException.class)
 697     public void testFloatValueAt_Variable_Null_2() {
 698         final MapProperty<String, Float> localProperty = new SimpleMapProperty<String, Float>();
 699         Bindings.floatValueAt(localProperty, (ObservableValue<String>)null);
 700     }
 701 
 702     @Test
 703     public void testIntegerValueAt_Constant() {
 704         final int defaultData = 0;
 705         final int localData1 = 42;
 706         final int localData2 = -7;
 707         final MapProperty<String, Integer> localProperty = new SimpleMapProperty<String, Integer>();
 708         final ObservableMap<String, Integer> localMap1 = FXCollections.observableHashMap();
 709         localMap1.put(key1, localData1);
 710         localMap1.put(key2, localData2);
 711         final ObservableMap<String, Integer> localMap2 = FXCollections.observableHashMap();
 712 
 713         final IntegerBinding binding0 = Bindings.integerValueAt(localProperty, key1);
 714         final IntegerBinding binding1 = Bindings.integerValueAt(localProperty, key2);
 715         final IntegerBinding binding2 = Bindings.integerValueAt(localProperty, key3);
 716         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 717         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 718         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 719         assertEquals(defaultData, binding0.get());
 720         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 721         assertEquals(defaultData, binding1.get());
 722         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 723         assertEquals(defaultData, binding2.get());
 724         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 725 
 726         localProperty.set(localMap1);
 727         assertEquals(localData1, binding0.get());
 728         assertEquals(localData2, binding1.get());
 729         assertEquals(defaultData, binding2.get());
 730         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 731 
 732         localProperty.remove(key2);
 733         assertEquals(localData1, binding0.get());
 734         assertEquals(defaultData, binding1.get());
 735         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 736         assertEquals(defaultData, binding2.get());
 737         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 738 
 739         localProperty.set(localMap2);
 740         assertEquals(defaultData, binding0.get());
 741         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 742         assertEquals(defaultData, binding1.get());
 743         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 744         assertEquals(defaultData, binding2.get());
 745         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 746 
 747         localProperty.put(key1, localData2);
 748         localProperty.put(key2, localData2);
 749         assertEquals(localData2, binding0.get());
 750         assertEquals(localData2, binding1.get());
 751         assertEquals(defaultData, binding2.get());
 752         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 753 
 754         localProperty.set(null);
 755         assertEquals(defaultData, binding0.get());
 756         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 757         assertEquals(defaultData, binding1.get());
 758         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 759         assertEquals(defaultData, binding2.get());
 760         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 761     }
 762 
 763     @Test(expected = NullPointerException.class)
 764     public void testIntegerValueAt_Constant_Null() {
 765         Bindings.integerValueAt(null, key1);
 766     }
 767 
 768     @Test
 769     public void testIntegerValueAt_Variable() {
 770         final int defaultData = 0;
 771         final int localData1 = 42;
 772         final int localData2 = -7;
 773         final MapProperty<String, Integer> localProperty = new SimpleMapProperty<String, Integer>();
 774         final ObservableMap<String, Integer> localMap1 = FXCollections.observableHashMap();
 775         localMap1.put(key1, localData1);
 776         localMap1.put(key2, localData2);
 777         final ObservableMap<String, Integer> localMap2 = FXCollections.observableHashMap();
 778 
 779         final IntegerBinding binding = Bindings.integerValueAt(localProperty, index);
 780         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 781 
 782         index.set(null);
 783         assertEquals(defaultData, binding.get());
 784         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 785         index.set(key1);
 786         assertEquals(defaultData, binding.get());
 787         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 788 
 789         localProperty.set(localMap1);
 790         index.set(null);
 791         assertEquals(defaultData, binding.get());
 792         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 793         index.set(key1);
 794         assertEquals(localData1, binding.get());
 795         index.set(key2);
 796         assertEquals(localData2, binding.get());
 797         index.set(key3);
 798         assertEquals(defaultData, binding.get());
 799         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 800 
 801         localProperty.remove(key2);
 802         index.set(null);
 803         assertEquals(defaultData, binding.get());
 804         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 805         index.set(key1);
 806         assertEquals(localData1, binding.get());
 807         index.set(key2);
 808         assertEquals(defaultData, binding.get());
 809         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 810 
 811         localProperty.set(localMap2);
 812         index.set(null);
 813         assertEquals(defaultData, binding.get());
 814         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 815         index.set(key1);
 816         assertEquals(defaultData, binding.get());
 817         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 818 
 819         localProperty.put(key1, localData2);
 820         localProperty.put(key2, localData2);
 821         index.set(null);
 822         assertEquals(defaultData, binding.get());
 823         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 824         index.set(key1);
 825         assertEquals(localData2, binding.get());
 826         index.set(key2);
 827         assertEquals(localData2, binding.get());
 828         index.set(key3);
 829         assertEquals(defaultData, binding.get());
 830         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 831 
 832         localProperty.set(null);
 833         index.set(null);
 834         assertEquals(defaultData, binding.get());
 835         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 836         index.set(key1);
 837         assertEquals(defaultData, binding.get());
 838         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 839     }
 840 
 841     @Test(expected = NullPointerException.class)
 842     public void testIntegerValueAt_Variable_Null_1() {
 843         Bindings.integerValueAt((ObservableMap<String, Integer>)null, index);
 844     }
 845 
 846     @Test(expected = NullPointerException.class)
 847     public void testIntegerValueAt_Variable_Null_2() {
 848         final MapProperty<String, Integer> localProperty = new SimpleMapProperty<String, Integer>();
 849         Bindings.integerValueAt(localProperty, (ObservableValue<String>)null);
 850     }
 851 
 852     @Test
 853     public void testLongValueAt_Constant() {
 854         final long defaultData = 0L;
 855         final long localData1 = 1234567890987654321L;
 856         final long localData2 = -987654321987654321L;
 857         final MapProperty<String, Long> localProperty = new SimpleMapProperty<String, Long>();
 858         final ObservableMap<String, Long> localMap1 = FXCollections.observableHashMap();
 859         localMap1.put(key1, localData1);
 860         localMap1.put(key2, localData2);
 861         final ObservableMap<String, Long> localMap2 = FXCollections.observableHashMap();
 862 
 863         final LongBinding binding0 = Bindings.longValueAt(localProperty, key1);
 864         final LongBinding binding1 = Bindings.longValueAt(localProperty, key2);
 865         final LongBinding binding2 = Bindings.longValueAt(localProperty, key3);
 866         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
 867         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
 868         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
 869         assertEquals(defaultData, binding0.get());
 870         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 871         assertEquals(defaultData, binding1.get());
 872         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 873         assertEquals(defaultData, binding2.get());
 874         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 875 
 876         localProperty.set(localMap1);
 877         assertEquals(localData1, binding0.get());
 878         assertEquals(localData2, binding1.get());
 879         assertEquals(defaultData, binding2.get());
 880         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 881 
 882         localProperty.remove(key2);
 883         assertEquals(localData1, binding0.get());
 884         assertEquals(defaultData, binding1.get());
 885         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 886         assertEquals(defaultData, binding2.get());
 887         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 888 
 889         localProperty.set(localMap2);
 890         assertEquals(defaultData, binding0.get());
 891         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 892         assertEquals(defaultData, binding1.get());
 893         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 894         assertEquals(defaultData, binding2.get());
 895         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 896 
 897         localProperty.put(key1, localData2);
 898         localProperty.put(key2, localData2);
 899         assertEquals(localData2, binding0.get());
 900         assertEquals(localData2, binding1.get());
 901         assertEquals(defaultData, binding2.get());
 902         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 903 
 904         localProperty.set(null);
 905         assertEquals(defaultData, binding0.get());
 906         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 907         assertEquals(defaultData, binding1.get());
 908         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 909         assertEquals(defaultData, binding2.get());
 910         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 911     }
 912 
 913     @Test(expected = NullPointerException.class)
 914     public void testLongValueAt_Constant_Null() {
 915         Bindings.longValueAt(null, key1);
 916     }
 917 
 918     @Test
 919     public void testLongValueAt_Variable() {
 920         final long defaultData = 0;
 921         final long localData1 = 98765432123456789L;
 922         final long localData2 = -1234567890123456789L;
 923         final MapProperty<String, Long> localProperty = new SimpleMapProperty<String, Long>();
 924         final ObservableMap<String, Long> localMap1 = FXCollections.observableHashMap();
 925         localMap1.put(key1, localData1);
 926         localMap1.put(key2, localData2);
 927         final ObservableMap<String, Long> localMap2 = FXCollections.observableHashMap();
 928 
 929         final LongBinding binding = Bindings.longValueAt(localProperty, index);
 930         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
 931 
 932         index.set(null);
 933         assertEquals(defaultData, binding.get());
 934         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 935         index.set(key1);
 936         assertEquals(defaultData, binding.get());
 937         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 938 
 939         localProperty.set(localMap1);
 940         index.set(null);
 941         assertEquals(defaultData, binding.get());
 942         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 943         index.set(key1);
 944         assertEquals(localData1, binding.get());
 945         index.set(key2);
 946         assertEquals(localData2, binding.get());
 947         index.set(key3);
 948         assertEquals(defaultData, binding.get());
 949         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 950 
 951         localProperty.remove(key2);
 952         index.set(null);
 953         assertEquals(defaultData, binding.get());
 954         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 955         index.set(key1);
 956         assertEquals(localData1, binding.get());
 957         index.set(key2);
 958         assertEquals(defaultData, binding.get());
 959         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 960 
 961         localProperty.set(localMap2);
 962         index.set(null);
 963         assertEquals(defaultData, binding.get());
 964         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 965         index.set(key1);
 966         assertEquals(defaultData, binding.get());
 967         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 968 
 969         localProperty.put(key1, localData2);
 970         localProperty.put(key2, localData2);
 971         index.set(null);
 972         assertEquals(defaultData, binding.get());
 973         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 974         index.set(key1);
 975         assertEquals(localData2, binding.get());
 976         index.set(key2);
 977         assertEquals(localData2, binding.get());
 978         index.set(key3);
 979         assertEquals(defaultData, binding.get());
 980         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 981 
 982         localProperty.set(null);
 983         index.set(null);
 984         assertEquals(defaultData, binding.get());
 985         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 986         index.set(key1);
 987         assertEquals(defaultData, binding.get());
 988         ErrorLoggingUtiltity.checkFine(NullPointerException.class);
 989     }
 990 
 991     @Test(expected = NullPointerException.class)
 992     public void testLongValueAt_Variable_Null() {
 993         Bindings.longValueAt((ObservableMap<String, Long>)null, index);
 994     }
 995 
 996     @Test(expected = NullPointerException.class)
 997     public void testLongValueAt_Variable_Null_2() {
 998         final MapProperty<String, Long> localProperty = new SimpleMapProperty<String, Long>();
 999         Bindings.longValueAt(localProperty, (ObservableValue<String>)null);
1000     }
1001 
1002     @Test
1003     public void testStringValueAt_Constant() {
1004         final String defaultData = null;
1005         final String localData1 = "Hello World";
1006         final String localData2 = "Goodbye World";
1007         final MapProperty<String, String> localProperty = new SimpleMapProperty<String, String>();
1008         final ObservableMap<String, String> localMap1 = FXCollections.observableHashMap();
1009         localMap1.put(key1, localData1);
1010         localMap1.put(key2, localData2);
1011         final ObservableMap<String, String> localMap2 = FXCollections.observableHashMap();
1012 
1013         final StringBinding binding0 = Bindings.stringValueAt(localProperty, key1);
1014         final StringBinding binding1 = Bindings.stringValueAt(localProperty, key2);
1015         final StringBinding binding2 = Bindings.stringValueAt(localProperty, key3);
1016         DependencyUtils.checkDependencies(binding0.getDependencies(), localProperty);
1017         DependencyUtils.checkDependencies(binding1.getDependencies(), localProperty);
1018         DependencyUtils.checkDependencies(binding2.getDependencies(), localProperty);
1019         assertEquals(defaultData, binding0.get());
1020         assertEquals(defaultData, binding1.get());
1021         assertEquals(defaultData, binding2.get());
1022 
1023         localProperty.set(localMap1);
1024         assertEquals(localData1, binding0.get());
1025         assertEquals(localData2, binding1.get());
1026         assertEquals(defaultData, binding2.get());
1027 
1028         localProperty.remove(key2);
1029         assertEquals(localData1, binding0.get());
1030         assertEquals(defaultData, binding1.get());
1031         assertEquals(defaultData, binding2.get());
1032 
1033         localProperty.set(localMap2);
1034         assertEquals(defaultData, binding0.get());
1035         assertEquals(defaultData, binding1.get());
1036         assertEquals(defaultData, binding2.get());
1037 
1038         localProperty.put(key1, localData2);
1039         localProperty.put(key2, localData2);
1040         assertEquals(localData2, binding0.get());
1041         assertEquals(localData2, binding1.get());
1042         assertEquals(defaultData, binding2.get());
1043 
1044         localProperty.set(null);
1045         assertEquals(defaultData, binding0.get());
1046         assertEquals(defaultData, binding1.get());
1047         assertEquals(defaultData, binding2.get());
1048     }
1049 
1050     @Test(expected = NullPointerException.class)
1051     public void testStringValueAt_Constant_Null() {
1052         Bindings.stringValueAt(null, key1);
1053     }
1054 
1055     @Test
1056     public void testStringValueAt_Variable() {
1057         final String defaultData = null;
1058         final String localData1 = "Goodbye";
1059         final String localData2 = "Hello";
1060         final MapProperty<String, String> localProperty = new SimpleMapProperty<String, String>();
1061         final ObservableMap<String, String> localMap1 = FXCollections.observableHashMap();
1062         localMap1.put(key1, localData1);
1063         localMap1.put(key2, localData2);
1064         final ObservableMap<String, String> localMap2 = FXCollections.observableHashMap();
1065 
1066         final StringBinding binding = Bindings.stringValueAt(localProperty, index);
1067         DependencyUtils.checkDependencies(binding.getDependencies(), localProperty, index);
1068 
1069         index.set(null);
1070         assertEquals(defaultData, binding.get());
1071         index.set(key1);
1072         assertEquals(defaultData, binding.get());
1073 
1074         localProperty.set(localMap1);
1075         index.set(null);
1076         assertEquals(defaultData, binding.get());
1077         index.set(key1);
1078         assertEquals(localData1, binding.get());
1079         index.set(key2);
1080         assertEquals(localData2, binding.get());
1081         index.set(key3);
1082         assertEquals(defaultData, binding.get());
1083 
1084         localProperty.remove(key2);
1085         index.set(null);
1086         assertEquals(defaultData, binding.get());
1087         index.set(key1);
1088         assertEquals(localData1, binding.get());
1089         index.set(key2);
1090         assertEquals(defaultData, binding.get());
1091 
1092         localProperty.set(localMap2);
1093         index.set(null);
1094         assertEquals(defaultData, binding.get());
1095         index.set(key1);
1096         assertEquals(defaultData, binding.get());
1097 
1098         localProperty.put(key1, localData2);
1099         localProperty.put(key2, localData2);
1100         index.set(null);
1101         assertEquals(defaultData, binding.get());
1102         index.set(key1);
1103         assertEquals(localData2, binding.get());
1104         index.set(key2);
1105         assertEquals(localData2, binding.get());
1106         index.set(key3);
1107         assertEquals(defaultData, binding.get());
1108 
1109         localProperty.set(null);
1110         index.set(null);
1111         assertEquals(defaultData, binding.get());
1112         index.set(key1);
1113         assertEquals(defaultData, binding.get());
1114     }
1115 
1116     @Test(expected = NullPointerException.class)
1117     public void testStringValueAt_Variable_Null() {
1118         Bindings.stringValueAt((ObservableMap<String, String>)null, index);
1119     }
1120 
1121     @Test(expected = NullPointerException.class)
1122     public void testStringValueAt_Variable_Null_2() {
1123         final MapProperty<String, String> localProperty = new SimpleMapProperty<String, String>();
1124         Bindings.stringValueAt(localProperty, (ObservableValue<String>)null);
1125     }
1126 
1127 
1128 }