Bug 184817 [DataBinding] WritableMap.put(...) fires an incorrect event
The event for WritableMap.put(...) when the key already exists reverses the new and old values in the change event. The following test will fail on the old value as it will be the new value. public void testPutWithExistingKeyMapChangeEvent() throws Exception { WritableMap map = new WritableMap(); String key = "key"; String value = "value"; map.put(key, value); MapChangeEventTracker listener = new MapChangeEventTracker(); map.addMapChangeListener(listener); assertEquals(0, listener.count); String newValue = "new value"; map.put(key, newValue); assertEquals(1, listener.count); MapChangeEvent event = listener.event; Set changedKeys = event.diff.getChangedKeys(); assertEquals(1, changedKeys.size()); assertTrue(changedKeys.contains(key)); assertEquals(value, event.diff.getOldValue(key)); //<<<FAILS assertEquals(newValue, event.diff.getNewValue(key)); }
tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/map/WritableMapTest.java
protected void setUp() throws Exception {
		RealmTester.setDefault(new CurrentRealm(true));
	}
	protected void tearDown() throws Exception {
		RealmTester.setDefault(null);
	}
	public void testPutRealmChecks() throws Exception {
		RealmTester.exerciseCurrent(new Runnable() {
			public void run() {
				WritableMap map = new WritableMap();
				map.put("", "");
			}
		});
	}
	public void testRemoveRealmChecks() throws Exception {