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.ObservableMap;
32 import org.junit.Before;
33 import org.junit.Test;
34
35 import java.util.Collections;
36 import java.util.HashMap;
37
38 import static org.junit.Assert.fail;
39
40 public class ReadOnlyMapPropertyBaseTest {
41
42 private static final Object UNDEFINED = null;
43 private static final Object DEFAULT = null;
44 private static final ObservableMap<Object, Object> VALUE_1 = FXCollections.observableMap(Collections.emptyMap());
45 private static final ObservableMap<Object, Object> VALUE_2 = FXCollections.observableMap(Collections.singletonMap(new Object(), new Object()));
46
47 private ReadOnlyPropertyMock property;
48 private InvalidationListenerMock invalidationListener;
49 private ChangeListenerMock<Object> changeListener;
50
51 @Before
52 public void setUp() throws Exception {
53 property = new ReadOnlyPropertyMock();
54 invalidationListener = new InvalidationListenerMock();
55 changeListener = new ChangeListenerMock<Object>(UNDEFINED);
56 }
82 }
83
84 private static class ReadOnlyPropertyMock extends ReadOnlyMapPropertyBase<Object, Object> {
85
86 private ObservableMap<Object, Object> value;
87
88 @Override
89 public Object getBean() {
90 // not used
91 return null;
92 }
93
94 @Override
95 public String getName() {
96 // not used
97 return null;
98 }
99
100 private void set(ObservableMap<Object, Object> value) {
101 this.value = value;
102 fireValueChangedEvent();
103 }
104
105 @Override
106 public ObservableMap<Object, Object> get() {
107 return value;
108 }
109
110 @Override
111 public ReadOnlyIntegerProperty sizeProperty() {
112 fail("Not in use");
113 return null;
114 }
115
116 @Override
117 public ReadOnlyBooleanProperty emptyProperty() {
118 fail("Not in use");
119 return null;
120 }
121 }
122
|
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 test.javafx.beans.InvalidationListenerMock;
29 import test.javafx.beans.value.ChangeListenerMock;
30 import javafx.collections.FXCollections;
31 import javafx.collections.ObservableMap;
32 import org.junit.Before;
33 import org.junit.Test;
34
35 import java.util.Collections;
36 import java.util.HashMap;
37 import javafx.beans.property.ReadOnlyBooleanProperty;
38 import javafx.beans.property.ReadOnlyIntegerProperty;
39 import javafx.beans.property.ReadOnlyMapPropertyBase;
40 import javafx.beans.property.ReadOnlyMapPropertyBaseShim;
41
42 import static org.junit.Assert.fail;
43
44 public class ReadOnlyMapPropertyBaseTest {
45
46 private static final Object UNDEFINED = null;
47 private static final Object DEFAULT = null;
48 private static final ObservableMap<Object, Object> VALUE_1 = FXCollections.observableMap(Collections.emptyMap());
49 private static final ObservableMap<Object, Object> VALUE_2 = FXCollections.observableMap(Collections.singletonMap(new Object(), new Object()));
50
51 private ReadOnlyPropertyMock property;
52 private InvalidationListenerMock invalidationListener;
53 private ChangeListenerMock<Object> changeListener;
54
55 @Before
56 public void setUp() throws Exception {
57 property = new ReadOnlyPropertyMock();
58 invalidationListener = new InvalidationListenerMock();
59 changeListener = new ChangeListenerMock<Object>(UNDEFINED);
60 }
86 }
87
88 private static class ReadOnlyPropertyMock extends ReadOnlyMapPropertyBase<Object, Object> {
89
90 private ObservableMap<Object, Object> value;
91
92 @Override
93 public Object getBean() {
94 // not used
95 return null;
96 }
97
98 @Override
99 public String getName() {
100 // not used
101 return null;
102 }
103
104 private void set(ObservableMap<Object, Object> value) {
105 this.value = value;
106 ReadOnlyMapPropertyBaseShim.fireValueChangedEvent(this);
107 }
108
109 @Override
110 public ObservableMap<Object, Object> get() {
111 return value;
112 }
113
114 @Override
115 public ReadOnlyIntegerProperty sizeProperty() {
116 fail("Not in use");
117 return null;
118 }
119
120 @Override
121 public ReadOnlyBooleanProperty emptyProperty() {
122 fail("Not in use");
123 return null;
124 }
125 }
126
|