modules/base/src/test/java/test/javafx/beans/property/ReadOnlySetPropertyBaseTest.java

Print this page
rev 9235 : 8134760: Refactor Javafx base module tests for clear separation of tests
Reviewed-by:


   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 javafx.beans.property;
  27 
  28 import javafx.beans.InvalidationListenerMock;
  29 import javafx.beans.value.ChangeListenerMock;




  30 import javafx.collections.FXCollections;
  31 import javafx.collections.ObservableSet;
  32 import org.junit.Before;
  33 import org.junit.Test;
  34 
  35 import static org.junit.Assert.fail;
  36 
  37 public class ReadOnlySetPropertyBaseTest {
  38     
  39     private static final Object UNDEFINED = null;
  40     private static final Object DEFAULT = null;
  41     private static final ObservableSet<Object> VALUE_1 = FXCollections.observableSet();
  42     private static final ObservableSet<Object> VALUE_2 = FXCollections.observableSet(new Object());
  43     
  44     private ReadOnlyPropertyMock property;
  45     private InvalidationListenerMock invalidationListener;
  46     private ChangeListenerMock<Object> changeListener;
  47 
  48     @Before
  49     public void setUp() throws Exception {


  79     }
  80     
  81     private static class ReadOnlyPropertyMock extends ReadOnlySetPropertyBase<Object> {
  82 
  83         private ObservableSet<Object> value;
  84         
  85         @Override
  86         public Object getBean() {
  87             // not used
  88             return null;
  89         }
  90 
  91         @Override
  92         public String getName() {
  93             // not used
  94             return null;
  95         }
  96         
  97         private void set(ObservableSet<Object> value) {
  98             this.value = value;
  99             fireValueChangedEvent();
 100         }
 101 
 102         @Override
 103         public ObservableSet<Object> get() {
 104             return value;
 105         }
 106 
 107         @Override
 108         public ReadOnlyIntegerProperty sizeProperty() {
 109             fail("Not in use");
 110             return null;
 111         }
 112 
 113         @Override
 114         public ReadOnlyBooleanProperty emptyProperty() {
 115             fail("Not in use");
 116             return null;
 117         }
 118     }
 119 


   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.beans.property;
  27 
  28 import javafx.beans.property.ReadOnlyBooleanProperty;
  29 import javafx.beans.property.ReadOnlyIntegerProperty;
  30 import javafx.beans.property.ReadOnlySetPropertyBase;
  31 import javafx.beans.property.ReadOnlySetPropertyBaseShim;
  32 import test.javafx.beans.InvalidationListenerMock;
  33 import test.javafx.beans.value.ChangeListenerMock;
  34 import javafx.collections.FXCollections;
  35 import javafx.collections.ObservableSet;
  36 import org.junit.Before;
  37 import org.junit.Test;
  38 
  39 import static org.junit.Assert.fail;
  40 
  41 public class ReadOnlySetPropertyBaseTest {
  42     
  43     private static final Object UNDEFINED = null;
  44     private static final Object DEFAULT = null;
  45     private static final ObservableSet<Object> VALUE_1 = FXCollections.observableSet();
  46     private static final ObservableSet<Object> VALUE_2 = FXCollections.observableSet(new Object());
  47     
  48     private ReadOnlyPropertyMock property;
  49     private InvalidationListenerMock invalidationListener;
  50     private ChangeListenerMock<Object> changeListener;
  51 
  52     @Before
  53     public void setUp() throws Exception {


  83     }
  84     
  85     private static class ReadOnlyPropertyMock extends ReadOnlySetPropertyBase<Object> {
  86 
  87         private ObservableSet<Object> value;
  88         
  89         @Override
  90         public Object getBean() {
  91             // not used
  92             return null;
  93         }
  94 
  95         @Override
  96         public String getName() {
  97             // not used
  98             return null;
  99         }
 100         
 101         private void set(ObservableSet<Object> value) {
 102             this.value = value;
 103             ReadOnlySetPropertyBaseShim.fireValueChangedEvent(this);
 104         }
 105 
 106         @Override
 107         public ObservableSet<Object> get() {
 108             return value;
 109         }
 110 
 111         @Override
 112         public ReadOnlyIntegerProperty sizeProperty() {
 113             fail("Not in use");
 114             return null;
 115         }
 116 
 117         @Override
 118         public ReadOnlyBooleanProperty emptyProperty() {
 119             fail("Not in use");
 120             return null;
 121         }
 122     }
 123