gt:         assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
context: /*
   * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this
   * particular file as subject to the "Classpath" exception as provided
   * by Oracle in the LICENSE file that accompanied this code.
   *
   * This code is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   * version 2 for more details (a copy is included in the LICENSE file that
   * accompanied this code).
   *
   * You should have received a copy of the GNU General Public License version
   * 2 along with this work; if not, write to the Free Software Foundation,
   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   *
   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  
  package javafx.beans.property;
  
  
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertFalse;
  import static org.junit.Assert.assertTrue;
  
  import javafx.beans.InvalidationListenerMock;
  import javafx.beans.value.ChangeListenerMock;
  import javafx.beans.value.ObservableDoubleValueStub;
  import javafx.beans.value.ObservableObjectValueStub;
  
  import org.junit.Before;
  import org.junit.Test;
  
  public class ReadOnlyDoubleWrapperTest {
  
      private static final Double UNDEFINED = null;
      private static final double DEFAULT = 0.0;
      private static final double VALUE_1 = Math.PI;
      private static final double VALUE_2 = Math.E;
      private static final double EPSILON = 1e-12;
  
      private ReadOnlyDoubleWrapperMock property;
      private ReadOnlyDoubleProperty readOnlyProperty;
      private InvalidationListenerMock internalInvalidationListener;
      private InvalidationListenerMock publicInvalidationListener;
      private ChangeListenerMock<Number> internalChangeListener;
      private ChangeListenerMock<Number> publicChangeListener;
  
      @Before
      public void setUp() throws Exception {
          property = new ReadOnlyDoubleWrapperMock();
          readOnlyProperty = property.getReadOnlyProperty();
          internalInvalidationListener = new InvalidationListenerMock();
          publicInvalidationListener = new InvalidationListenerMock();
          internalChangeListener = new ChangeListenerMock<Number>(UNDEFINED);
          publicChangeListener = new ChangeListenerMock<Number>(UNDEFINED);
      }
  
      private void attachInvalidationListeners() {
          property.addListener(internalInvalidationListener);
          readOnlyProperty.addListener(publicInvalidationListener);
          property.get();
          readOnlyProperty.get();
          internalInvalidationListener.reset();
          publicInvalidationListener.reset();
      }
  
      private void attachInternalChangeListener() {
          property.addListener(internalChangeListener);
          property.get();
          internalChangeListener.reset();
      }
  
      private void attachPublicChangeListener() {
          readOnlyProperty.addListener(publicChangeListener);
          readOnlyProperty.get();
          publicChangeListener.reset();
      }
  
      @Test
      public void testConstructor_NoArguments() {
          final ReadOnlyDoubleWrapper p1 = new ReadOnlyDoubleWrapper();
          assertEquals(DEFAULT, p1.get(), EPSILON);
          assertEquals((Double)DEFAULT, p1.getValue(), EPSILON);
          assertFalse(property.isBound());
          assertEquals(null, p1.getBean());
          assertEquals("", p1.getName());
          final ReadOnlyDoubleProperty r1 = p1.getReadOnlyProperty();
          assertEquals(DEFAULT, r1.get(), EPSILON);
          assertEquals((Double)DEFAULT, r1.getValue(), EPSILON);
          assertEquals(null, r1.getBean());
          assertEquals("", r1.getName());
      }
  
      @Test
      public void testConstructor_InitialValue() {
          final ReadOnlyDoubleWrapper p1 = new ReadOnlyDoubleWrapper(VALUE_1);
          assertEquals(VALUE_1, p1.get(), EPSILON);
          assertEquals((Double)VALUE_1, p1.getValue(), EPSILON);
          assertFalse(property.isBound());
          assertEquals(null, p1.getBean());
          assertEquals("", p1.getName());
          final ReadOnlyDoubleProperty r1 = p1.getReadOnlyProperty();
          assertEquals(VALUE_1, r1.get(), EPSILON);
          assertEquals((Double)VALUE_1, r1.getValue(), EPSILON);
          assertEquals(null, r1.getBean());
          assertEquals("", r1.getName());
      }
  
      @Test
      public void testConstructor_Bean_Name() {
          final Object bean = new Object();
          final String name = "My name";
          final ReadOnlyDoubleWrapper p1 = new ReadOnlyDoubleWrapper(bean, name);
          assertEquals(DEFAULT, p1.get(), EPSILON);
          assertEquals((Double)DEFAULT, p1.getValue(), EPSILON);
          assertFalse(property.isBound());
          assertEquals(bean, p1.getBean());
          assertEquals(name, p1.getName());
          final ReadOnlyDoubleProperty r1 = p1.getReadOnlyProperty();
          assertEquals(DEFAULT, r1.get(), EPSILON);
          assertEquals((Double)DEFAULT, r1.getValue(), EPSILON);
          assertEquals(bean, r1.getBean());
          assertEquals(name, r1.getName());
      }
  
      @Test
      public void testConstructor_Bean_Name_InitialValue() {
          final Object bean = new Object();
          final String name = "My name";
          final ReadOnlyDoubleWrapper p1 = new ReadOnlyDoubleWrapper(bean, name, VALUE_1);
          assertEquals(VALUE_1, p1.get(), EPSILON);
          assertEquals((Double)VALUE_1, p1.getValue(), EPSILON);
          assertFalse(property.isBound());
          assertEquals(bean, p1.getBean());
          assertEquals(name, p1.getName());
          final ReadOnlyDoubleProperty r1 = p1.getReadOnlyProperty();
          assertEquals(VALUE_1, r1.get(), EPSILON);
          assertEquals((Double)VALUE_1, r1.getValue(), EPSILON);
          assertEquals(bean, r1.getBean());
          assertEquals(name, r1.getName());
      }
  
      @Test
      public void testLazySet() {
          attachInvalidationListeners();
  
          // set value once
          property.set(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(1);
          internalInvalidationListener.check(property, 1);
          assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
          publicInvalidationListener.check(readOnlyProperty, 1);
  
          // set same value again
          property.set(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(0);
          internalInvalidationListener.check(null, 0);
          assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
          publicInvalidationListener.check(null, 0);
  
          // set value twice without reading
          property.set(VALUE_2);
          property.set(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(1);
          internalInvalidationListener.check(property, 1);
          assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
          publicInvalidationListener.check(readOnlyProperty, 1);
      }
  
      @Test
      public void testInternalEagerSet() {
          attachInternalChangeListener();
  
          // set value once
          property.set(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(1);
          internalChangeListener.check(property, DEFAULT, VALUE_1, 1);
          assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
  
          // set same value again
          property.set(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(0);
          internalChangeListener.check(null, UNDEFINED, UNDEFINED, 0);
          assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
  
          // set value twice without reading
          property.set(VALUE_2);
          property.set(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(2);
          internalChangeListener.check(property, VALUE_2, VALUE_1, 2);
          assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
      }
  
      @Test
      public void testPublicEagerSet() {
          attachPublicChangeListener();
  
          // set value once
          property.set(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(1);
          assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
          publicChangeListener.check(readOnlyProperty, DEFAULT, VALUE_1, 1);
  
          // set same value again
          property.set(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(0);
          assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
          publicChangeListener.check(null, UNDEFINED, UNDEFINED, 0);
  
          // set value twice without reading
          property.set(VALUE_2);
          property.set(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(2);
          assertEquals(VALUE_1, readOnlyProperty.get(), EPSILON);
          publicChangeListener.check(readOnlyProperty, VALUE_2, VALUE_1, 2);
      }
  
      @Test
      public void testLazySetValue() {
          attachInvalidationListeners();
  
          // set value once
          property.setValue(VALUE_1);
          assertEquals(VALUE_1, property.get(), EPSILON);
          property.check(1);
          internalInvalidationListener.check(property, 1);
  